scramble_generator 1.19.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. scramble_generator-1.19.0/.gitignore +10 -0
  2. scramble_generator-1.19.0/.python-version +1 -0
  3. scramble_generator-1.19.0/CHANGELOG +31 -0
  4. scramble_generator-1.19.0/LICENSE +19 -0
  5. scramble_generator-1.19.0/PKG-INFO +28 -0
  6. scramble_generator-1.19.0/README.md +20 -0
  7. scramble_generator-1.19.0/bandit.yaml +16 -0
  8. scramble_generator-1.19.0/install.py +116 -0
  9. scramble_generator-1.19.0/pyproject.toml +23 -0
  10. scramble_generator-1.19.0/src/scramble_generator/__init__.py +2 -0
  11. scramble_generator-1.19.0/src/scramble_generator/app.py +189 -0
  12. scramble_generator-1.19.0/src/scramble_generator/resources/PYPI_README.md +14 -0
  13. scramble_generator-1.19.0/src/scramble_generator/resources/configs/config.yaml +38 -0
  14. scramble_generator-1.19.0/src/scramble_generator/resources/configs/themes.yaml +15 -0
  15. scramble_generator-1.19.0/src/scramble_generator/resources/gifs/app_showcase.gif +0 -0
  16. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator-128.png +0 -0
  17. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator-16.png +0 -0
  18. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator-256.png +0 -0
  19. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator-32.png +0 -0
  20. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator-512.png +0 -0
  21. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator-64.png +0 -0
  22. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator_with_text-128.png +0 -0
  23. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator_with_text-16.png +0 -0
  24. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator_with_text-256.png +0 -0
  25. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator_with_text-32.png +0 -0
  26. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator_with_text-512.png +0 -0
  27. scramble_generator-1.19.0/src/scramble_generator/resources/images/scramble_generator_with_text-64.png +0 -0
  28. scramble_generator-1.19.0/src/scramble_generator/scramble_generator.py +507 -0
  29. scramble_generator-1.19.0/src/scramble_generator/yaml_file_handler.py +18 -0
  30. scramble_generator-1.19.0/uninstall.py +42 -0
  31. scramble_generator-1.19.0/uv.lock +208 -0
@@ -0,0 +1,10 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,31 @@
1
+ # Scramble Generator Release Notes
2
+
3
+ ## 1.17.1 (30 Jan 2025)
4
+
5
+ ### Major Changes
6
+
7
+ ### Minor Changes
8
+
9
+ - [Issue #1](https://codeberg.org/melvinquick/scramble_generator/issues/1)
10
+ - [Issue #2](https://codeberg.org/melvinquick/scramble_generator/issues/2)
11
+
12
+ ### Patch Changes
13
+
14
+ - [Issue #4](https://codeberg.org/melvinquick/scramble_generator/issues/4)
15
+
16
+ ### Documentation Changes
17
+
18
+ - [Issue #3](https://codeberg.org/melvinquick/scramble_generator/issues/3)
19
+
20
+ ## 1.19.0 (24 Feb 2025)
21
+
22
+ ### Major Changes
23
+
24
+ ### Minor Changes
25
+
26
+ - [Remove save config option and user defaults](https://codeberg.org/melvinquick/scramble_generator/issues/5)
27
+ - [Overhaul UI to make more condensed and modern](https://codeberg.org/melvinquick/scramble_generator/issues/6)
28
+
29
+ ### Patch Changes
30
+
31
+ ### Documentation Changes
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2023, Melvin Quick
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: scramble_generator
3
+ Version: 1.19.0
4
+ Summary: Python app for generating scrambles for twisty puzzles.
5
+ Project-URL: repository, https://codeberg.org/melvinquick/scramble_generator
6
+ Project-URL: issues, https://codeberg.org/melvinquick/scramble_generator/issues
7
+ Author-email: Melvin Quick <melvinquick@proton.me>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.12
11
+ Requires-Dist: pyside6>=6.8.2.1
12
+ Requires-Dist: pyyaml>=6.0.2
13
+ Description-Content-Type: text/markdown
14
+
15
+ ## Donations
16
+
17
+ - [Buy Me A Coffee](https://www.buymeacoffee.com/KingKairos)
18
+ - [GitHub Sponsors](https://github.com/sponsors/melvinquick)
19
+
20
+ ## Purpose
21
+
22
+ The general purpose of this app is to give people an easy way to generate scrambles for standard twisty puzzles.
23
+
24
+ ## Useful Information
25
+
26
+ - [Project Goals](https://codeberg.org/melvinquick/scramble_generator/projects/11195)
27
+ - [Latest Release](https://codeberg.org/melvinquick/scramble_generator/releases/latest)
28
+ - [Releases](https://codeberg.org/melvinquick/scramble_generator/releases)
@@ -0,0 +1,20 @@
1
+ <p align="center"> <img src="src/scramble_generator/resources/images/scramble_generator_with_text-256.png" /> </p>
2
+
3
+ ## Donations
4
+
5
+ - [Buy Me A Coffee](https://www.buymeacoffee.com/KingKairos)
6
+ - [GitHub Sponsors](https://github.com/sponsors/melvinquick)
7
+
8
+ ## Purpose
9
+
10
+ The general purpose of this app is to give people an easy way to generate scrambles for standard twisty puzzles.
11
+
12
+ ## App Showcase
13
+
14
+ ![app_showcase.gif](scramblegenerator/src/scramblegenerator/resources/gifs/app_showcase.gif)
15
+
16
+ ## Useful Information
17
+
18
+ - [Project Goals](https://codeberg.org/melvinquick/scramble_generator/projects/11195)
19
+ - [Latest Release](https://codeberg.org/melvinquick/scramble_generator/releases/latest)
20
+ - [Releases](https://codeberg.org/melvinquick/scramble_generator/releases)
@@ -0,0 +1,16 @@
1
+ exclude_dirs:
2
+ [
3
+ "scramble_generator/.venv/",
4
+ "scramble_generator/dist/",
5
+ "scramble_generator/src/scramble_generator/__pycache__",
6
+ "scramble_generator/src/scramble_generator/resources/",
7
+ ".gitignore",
8
+ ".python-version",
9
+ "bandit.yaml",
10
+ "LICENSE",
11
+ "pyproject.toml",
12
+ "README.md",
13
+ "uv.lock",
14
+ ]
15
+ tests: []
16
+ skips: []
@@ -0,0 +1,116 @@
1
+ import os
2
+ import sys
3
+ import subprocess
4
+ from textwrap import dedent
5
+
6
+
7
+ def print_green(skk):
8
+ print("\033[92m {}\033[00m".format(skk))
9
+
10
+
11
+ def get_venv_path():
12
+ home_dir = os.path.expanduser("~")
13
+ venv_dir = os.path.join(home_dir, ".venvs")
14
+ if not os.path.exists(venv_dir):
15
+ os.makedirs(venv_dir)
16
+ return os.path.join(venv_dir, "scramble_generator_venv")
17
+
18
+
19
+ def create_venv(venv_path):
20
+ print("Creating the virtual environment...", end="")
21
+ sys.stdout.flush()
22
+ subprocess.run(
23
+ ["python3", "-m", "venv", venv_path],
24
+ check=True,
25
+ stdout=subprocess.DEVNULL,
26
+ stderr=subprocess.DEVNULL,
27
+ )
28
+ print_green("󰄬")
29
+
30
+ print("Ensuring pip is up to date...", end="")
31
+ sys.stdout.flush()
32
+ pip_path = os.path.join(venv_path, "bin", "pip")
33
+ subprocess.run(
34
+ [pip_path, "install", "--upgrade", "pip"],
35
+ check=True,
36
+ stdout=subprocess.DEVNULL,
37
+ stderr=subprocess.DEVNULL,
38
+ )
39
+ print_green("󰄬")
40
+
41
+
42
+ def install_app(venv_path):
43
+ print("Installing Scramble Generator into the virtual environment...", end="")
44
+ sys.stdout.flush()
45
+ pip_path = os.path.join(venv_path, "bin", "pip")
46
+ subprocess.run(
47
+ [pip_path, "install", "scramble_generator"],
48
+ check=True,
49
+ stdout=subprocess.DEVNULL,
50
+ stderr=subprocess.DEVNULL,
51
+ )
52
+ print_green("󰄬")
53
+
54
+
55
+ def get_icon(venv_path):
56
+ site_packages = os.path.join(venv_path, "lib")
57
+ for folder in os.listdir(site_packages):
58
+ if folder.startswith("python"):
59
+ site_packages = os.path.join(site_packages, folder, "site-packages")
60
+ break
61
+
62
+ icon_relative_path = (
63
+ "scramble_generator/resources/images/scramble_generator-128.png"
64
+ )
65
+ full_icon_path = os.path.join(site_packages, icon_relative_path)
66
+ return full_icon_path
67
+
68
+
69
+ def get_python_path(venv_path):
70
+ return os.path.join(venv_path, "bin", "python3")
71
+
72
+
73
+ def get_app_path(venv_path):
74
+ return os.path.join(venv_path, "bin", "psswd-box")
75
+
76
+
77
+ def create_desktop_file(icon, version, python, app):
78
+ print("Creating the .desktop entry...", end="")
79
+ sys.stdout.flush()
80
+ desktop_content = dedent(f"""
81
+ [Desktop Entry]
82
+ Version={version}
83
+ Type=Application
84
+ Name=Scramble Generator
85
+ Comment=Python app for generating scrambles for twisty puzzles.
86
+ Exec={python} {app}
87
+ Icon={icon}
88
+ Terminal=false
89
+ Categories=Utility;
90
+ """)
91
+ desktop_content = desktop_content.lstrip()
92
+ with open(
93
+ os.path.expanduser("~/.local/share/applications/scramble_generator.desktop"),
94
+ "w",
95
+ ) as f:
96
+ f.write(desktop_content)
97
+ print_green("󰄬")
98
+
99
+
100
+ def install():
101
+ venv_path = get_venv_path()
102
+ create_venv(venv_path)
103
+ install_app(venv_path)
104
+ version = "1.19.0"
105
+ icon = get_icon(venv_path)
106
+ python = get_python_path(venv_path)
107
+ app = get_app_path(venv_path)
108
+ create_desktop_file(icon, version, python, app)
109
+
110
+
111
+ def main():
112
+ install()
113
+
114
+
115
+ if __name__ == "__main__":
116
+ main()
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "scramble_generator"
3
+ version = "1.19.0"
4
+ description = "Python app for generating scrambles for twisty puzzles."
5
+ readme = "src/scramble_generator/resources/PYPI_README.md"
6
+ license = "MIT"
7
+ authors = [{ name = "Melvin Quick", email = "melvinquick@proton.me" }]
8
+ requires-python = ">=3.12"
9
+ dependencies = ["pyside6>=6.8.2.1", "pyyaml>=6.0.2"]
10
+
11
+ [project.urls]
12
+ repository = "https://codeberg.org/melvinquick/scramble_generator"
13
+ issues = "https://codeberg.org/melvinquick/scramble_generator/issues"
14
+
15
+ [project.gui-scripts]
16
+ scramble-generator = "scramble_generator.app:main"
17
+
18
+ [build-system]
19
+ requires = ["hatchling"]
20
+ build-backend = "hatchling.build"
21
+
22
+ [dependency-groups]
23
+ dev = ["bandit>=1.8.3"]
@@ -0,0 +1,2 @@
1
+ def main() -> None:
2
+ print("Hello from scramble-generator!")
@@ -0,0 +1,189 @@
1
+ """
2
+ Python app for generating scrambles for twisty puzzles.
3
+ """
4
+
5
+ import sys
6
+
7
+ from PySide6.QtCore import Qt, QTimer, QTime
8
+ from PySide6.QtWidgets import (
9
+ QApplication,
10
+ QMainWindow,
11
+ QWidget,
12
+ QPushButton,
13
+ QLabel,
14
+ QComboBox,
15
+ QSpinBox,
16
+ QGridLayout,
17
+ )
18
+
19
+ from scramble_generator.scramble_generator import ScrambleGenerator as SG
20
+ from scramble_generator.yaml_file_handler import YamlFileHandler
21
+
22
+ config_file = YamlFileHandler("resources/configs/config.yaml")
23
+ config = config_file.load_yaml_file()
24
+
25
+ themes_file = YamlFileHandler("resources/configs/themes.yaml")
26
+ themes = themes_file.load_yaml_file()
27
+
28
+
29
+ class ScrambleGenerator(QMainWindow):
30
+ def __init__(self):
31
+ super().__init__()
32
+ self.init_ui()
33
+
34
+ def init_ui(self):
35
+ self.show()
36
+
37
+ # * Set window default settings
38
+ self.setWindowTitle("Scramble Generator")
39
+ self.setFixedSize(
40
+ config["window_size"]["width"], config["window_size"]["height"]
41
+ )
42
+
43
+ # * Define normal variables
44
+ self.is_running = False
45
+ self.elapsed_time = QTime(0, 0)
46
+ self.puzzle_type_list = [puzzle for puzzle in config["puzzle_type_list"]]
47
+ self.theme_list = [theme for theme in list(themes)[:-1]]
48
+
49
+ # * Create end user widgets and apply settings to them
50
+ self.scramble_button = QPushButton("Generate Scramble")
51
+
52
+ self.puzzle_type = QComboBox()
53
+ self.puzzle_type.addItems(self.puzzle_type_list)
54
+ self.puzzle_type.setCurrentText(config["defaults"]["puzzle_type"])
55
+
56
+ self.num_moves = QSpinBox()
57
+ self.num_moves.setRange(
58
+ config["num_moves_range"]["min"], config["num_moves_range"]["max"]
59
+ )
60
+ self.num_moves.setValue(config["defaults"]["num_moves"])
61
+
62
+ self.theme_toggle = QPushButton(config["defaults"]["theme"])
63
+
64
+ self.scramble = QLabel(
65
+ " ", alignment=Qt.AlignmentFlag.AlignCenter, wordWrap=True
66
+ )
67
+ self.scramble.setFixedWidth(config["scramble_widget_width"])
68
+
69
+ self.timer_button = QPushButton("Start Timer")
70
+
71
+ self.timer_output = QLabel(
72
+ "00:00.0", alignment=Qt.AlignmentFlag.AlignCenter, maximumHeight=22
73
+ )
74
+
75
+ self.timer = QTimer()
76
+ self.timer.interval = 10 # * Milliseconds
77
+
78
+ # * Define button connections and/or actions
79
+ self.scramble_button.pressed.connect(self.get_moves)
80
+ self.puzzle_type.currentTextChanged.connect(self.set_default_num_moves)
81
+ self.theme_toggle.pressed.connect(self.toggle_theme)
82
+ self.timer_button.pressed.connect(self.toggle_timer)
83
+ self.timer.timeout.connect(self.update_time)
84
+
85
+ # * Create layouts
86
+ self.page = QGridLayout()
87
+ self.left_side = QGridLayout()
88
+ self.left_side.setVerticalSpacing(5)
89
+ self.right_side = QGridLayout()
90
+
91
+ # * Add widgets to layouts
92
+ self.left_side.addWidget(self.scramble_button, 0, 0, 1, 2)
93
+ self.left_side.addWidget(self.puzzle_type, 1, 0, 1, 1)
94
+ self.left_side.addWidget(self.num_moves, 1, 1, 1, 1)
95
+ self.left_side.addWidget(self.timer_button, 2, 0, 1, 2)
96
+ self.left_side.addWidget(self.timer_output, 3, 0, 1, 2)
97
+ self.left_side.addWidget(self.theme_toggle, 4, 0, 1, 2)
98
+
99
+ self.right_side.addWidget(self.scramble, 0, 0, 1, 2)
100
+
101
+ # * Setup overall page layout and set default window theme
102
+ self.page.addLayout(self.left_side, 0, 0)
103
+ self.page.addLayout(self.right_side, 0, 1)
104
+
105
+ self.gui = QWidget()
106
+ self.gui.setLayout(self.page)
107
+
108
+ self.setCentralWidget(self.gui)
109
+
110
+ self.apply_theme(self.theme_toggle.text().lower())
111
+
112
+ def toggle_theme(self):
113
+ if self.theme_toggle.text() == "Dark":
114
+ self.theme_toggle.setText("Light")
115
+ theme = self.theme_toggle.text()
116
+ else:
117
+ self.theme_toggle.setText("Dark")
118
+ theme = self.theme_toggle.text()
119
+
120
+ self.apply_theme(theme.lower())
121
+
122
+ def apply_theme(self, theme):
123
+ self.main_stylesheet = f"""
124
+ background-color: {themes[theme]["background-color"]};
125
+ color: {themes[theme]["color"]};
126
+ border: {themes[theme]["border"]};
127
+ border-radius: {themes["general"]["border-radius"]};
128
+ padding: {themes["general"]["padding"]};
129
+ """
130
+ self.widget_stylesheet = f"""
131
+ background-color: {themes[theme]["widget-background-color"]};
132
+ """
133
+ self.setStyleSheet(self.main_stylesheet)
134
+ self.scramble_button.setStyleSheet(self.widget_stylesheet)
135
+ self.puzzle_type.setStyleSheet(self.widget_stylesheet)
136
+ self.num_moves.setStyleSheet(self.widget_stylesheet)
137
+ self.theme_toggle.setStyleSheet(self.widget_stylesheet)
138
+ self.scramble.setStyleSheet(self.widget_stylesheet)
139
+ self.timer_button.setStyleSheet(self.widget_stylesheet)
140
+ self.timer_output.setStyleSheet(self.widget_stylesheet)
141
+
142
+ (
143
+ self.theme_toggle.setText("Dark")
144
+ if theme == "dark"
145
+ else self.theme_toggle.setText("Light")
146
+ )
147
+
148
+ def get_moves(self):
149
+ scramble = SG()
150
+ self.scramble.setText(
151
+ scramble.generate_scramble(
152
+ self.puzzle_type.currentText().lower(), self.num_moves.value()
153
+ )
154
+ )
155
+
156
+ def set_default_num_moves(self):
157
+ self.num_moves.setValue(
158
+ config["puzzle_default_moves"][self.puzzle_type.currentText().lower()]
159
+ )
160
+
161
+ def toggle_timer(self):
162
+ if not self.is_running:
163
+ self.timer.start(100) # * Update display every 100 milliseconds
164
+ self.timer_button.setText("Stop Timer")
165
+ self.is_running = True
166
+ else:
167
+ self.timer.stop()
168
+ self.timer_button.setText("Start Timer")
169
+ self.is_running = False
170
+ self.update_time()
171
+
172
+ def update_time(self):
173
+ self.elapsed_time = self.elapsed_time.addMSecs(
174
+ 100
175
+ ) # * Increment time by 100 milliseconds
176
+ self.timer_output.setText(self.elapsed_time.toString("mm:ss.z"))
177
+
178
+ if not self.is_running:
179
+ self.elapsed_time = QTime(0, 0)
180
+
181
+
182
+ def main():
183
+ app = QApplication(sys.argv)
184
+ main_window = ScrambleGenerator() # noqa: F841
185
+ sys.exit(app.exec())
186
+
187
+
188
+ if __name__ == "__main__":
189
+ main()
@@ -0,0 +1,14 @@
1
+ ## Donations
2
+
3
+ - [Buy Me A Coffee](https://www.buymeacoffee.com/KingKairos)
4
+ - [GitHub Sponsors](https://github.com/sponsors/melvinquick)
5
+
6
+ ## Purpose
7
+
8
+ The general purpose of this app is to give people an easy way to generate scrambles for standard twisty puzzles.
9
+
10
+ ## Useful Information
11
+
12
+ - [Project Goals](https://codeberg.org/melvinquick/scramble_generator/projects/11195)
13
+ - [Latest Release](https://codeberg.org/melvinquick/scramble_generator/releases/latest)
14
+ - [Releases](https://codeberg.org/melvinquick/scramble_generator/releases)
@@ -0,0 +1,38 @@
1
+ defaults:
2
+ num_moves: 25
3
+ puzzle_type: 3x3
4
+ theme: Dark
5
+ num_moves_range:
6
+ min: 10
7
+ max: 150
8
+ puzzle_default_moves:
9
+ 2x2: 10
10
+ 3x3: 25
11
+ 4x4: 40
12
+ 5x5: 60
13
+ 6x6: 80
14
+ 7x7: 90
15
+ 8x8: 100
16
+ 9x9: 110
17
+ 10x10: 120
18
+ 11x11: 130
19
+ pyraminx: 15
20
+ skewb: 25
21
+ puzzle_type_list:
22
+ - 2x2
23
+ - 3x3
24
+ - 4x4
25
+ - 5x5
26
+ - 6x6
27
+ - 7x7
28
+ - 8x8
29
+ - 9x9
30
+ - 10x10
31
+ - 11x11
32
+ - Pyraminx
33
+ - Skewb
34
+ window_title: "Scramble Generator"
35
+ window_size:
36
+ width: 660
37
+ height: 160
38
+ scramble_widget_width: 480
@@ -0,0 +1,15 @@
1
+ light:
2
+ background-color: "#d8dee9"
3
+ color: "#2e3440"
4
+ border: 1px solid '#e5e9f0'
5
+ widget-background-color: "#eceff4"
6
+
7
+ dark:
8
+ background-color: "#2e3440"
9
+ color: "#eceff4"
10
+ border: 1px solid '#434c5e'
11
+ widget-background-color: "#4c566a"
12
+
13
+ general:
14
+ border-radius: "4px"
15
+ padding: "2px 4px"