molde 0.1.0__py3-none-any.whl

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 (62) hide show
  1. molde/__init__.py +5 -0
  2. molde/__main__.py +63 -0
  3. molde/actors/__init__.py +4 -0
  4. molde/actors/ghost_actor.py +12 -0
  5. molde/actors/lines_actor.py +31 -0
  6. molde/actors/round_points_actor.py +7 -0
  7. molde/actors/square_points_actor.py +32 -0
  8. molde/colors/__init__.py +2 -0
  9. molde/colors/color.py +120 -0
  10. molde/colors/color_names.py +125 -0
  11. molde/fonts/IBMPlexMono-Bold.ttf +0 -0
  12. molde/fonts/IBMPlexMono-Regular.ttf +0 -0
  13. molde/icons/arrow_down_dark_theme.svg +1 -0
  14. molde/icons/arrow_down_disabled_dark_theme.svg +1 -0
  15. molde/icons/arrow_down_disabled_light_theme.svg +1 -0
  16. molde/icons/arrow_down_light_theme.svg +1 -0
  17. molde/icons/arrow_left_dark_theme.svg +1 -0
  18. molde/icons/arrow_left_light_theme.svg +1 -0
  19. molde/icons/arrow_right_dark_theme.svg +1 -0
  20. molde/icons/arrow_right_light_theme.svg +1 -0
  21. molde/icons/arrow_up_dark_theme.svg +1 -0
  22. molde/icons/arrow_up_disabled_dark_theme.svg +1 -0
  23. molde/icons/arrow_up_disabled_light_theme.svg +1 -0
  24. molde/icons/arrow_up_light_theme.svg +1 -0
  25. molde/icons/check_box_image.svg +1 -0
  26. molde/interactor_styles/__init__.py +2 -0
  27. molde/interactor_styles/arcball_camera_style.py +272 -0
  28. molde/interactor_styles/box_selection_style.py +70 -0
  29. molde/pickers/__init__.py +2 -0
  30. molde/pickers/cell_area_picker.py +61 -0
  31. molde/pickers/cell_property_area_picker.py +84 -0
  32. molde/poly_data/__init__.py +2 -0
  33. molde/poly_data/lines_data.py +23 -0
  34. molde/poly_data/vertices_data.py +24 -0
  35. molde/render_widgets/__init__.py +2 -0
  36. molde/render_widgets/animated_render_widget.py +164 -0
  37. molde/render_widgets/common_render_widget.py +433 -0
  38. molde/stylesheets/__init__.py +119 -0
  39. molde/stylesheets/common.qss +16 -0
  40. molde/stylesheets/create_color_page.py +61 -0
  41. molde/stylesheets/mainwindow.ui +611 -0
  42. molde/stylesheets/qcheckbox.qss +19 -0
  43. molde/stylesheets/qinputs.qss +79 -0
  44. molde/stylesheets/qlayouts.qss +22 -0
  45. molde/stylesheets/qmenubar.qss +12 -0
  46. molde/stylesheets/qprogressbar.qss +12 -0
  47. molde/stylesheets/qpushbutton.qss +91 -0
  48. molde/stylesheets/qradiobutton.qss +31 -0
  49. molde/stylesheets/qscrollbar.qss +30 -0
  50. molde/stylesheets/qslider.qss +61 -0
  51. molde/stylesheets/qtablewidget.qss +27 -0
  52. molde/stylesheets/qtabwidget.qss +30 -0
  53. molde/stylesheets/qtoolbar.qss +62 -0
  54. molde/stylesheets/qtoolbuttons.qss +14 -0
  55. molde/stylesheets/qtreewidget.qss +25 -0
  56. molde/utils/__init__.py +8 -0
  57. molde/utils/format_sequences.py +44 -0
  58. molde/utils/poly_data_utils.py +25 -0
  59. molde/utils/tree_info.py +52 -0
  60. molde-0.1.0.dist-info/METADATA +44 -0
  61. molde-0.1.0.dist-info/RECORD +62 -0
  62. molde-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,119 @@
1
+ from typing import Literal
2
+ from PyQt5.QtWidgets import QApplication, QWidget
3
+ from molde import MOLDE_DIR
4
+ from molde.colors import color_names
5
+
6
+
7
+ def set_qproperty(widget: QWidget, **kwargs):
8
+ for key, val in kwargs.items():
9
+ widget.setProperty(key, val)
10
+ widget.style().polish(widget)
11
+
12
+ def get_variables(theme:Literal["light", "dark"] = "light") -> dict:
13
+ variables = {
14
+ "@border-radius": "5px",
15
+ }
16
+
17
+ if theme == "light":
18
+ variables.update({
19
+ "@primary-lighter": color_names.BLUE_7.to_hex(),
20
+ "@primary": color_names.BLUE_4.to_hex(),
21
+ "@primary-darker": color_names.BLUE_3.to_hex(),
22
+
23
+ "@danger-color-lighter": color_names.RED_7.to_hex(),
24
+ "@danger-color": color_names.RED_4.to_hex(),
25
+ "@danger-color-darker": color_names.RED_3.to_hex(),
26
+
27
+ "@warning-color-lighter": color_names.YELLOW_7.to_hex(),
28
+ "@warning-color": color_names.YELLOW_4.to_hex(),
29
+ "@warning-color-darker": color_names.YELLOW_3.to_hex(),
30
+
31
+ "@background": color_names.GRAY_9.to_hex(),
32
+ "@background-variant": color_names.GRAY_8.to_hex(),
33
+
34
+ "@input-color": "#F0F0F5",
35
+ "@on-primary": color_names.WHITE.to_hex(),
36
+ "@on-background": color_names.BLACK.to_hex(),
37
+
38
+ "@border-color": color_names.GRAY_7.to_hex(),
39
+ "@input-color": color_names.GRAY_9.to_hex(),
40
+
41
+ "@disabled-background": color_names.GRAY_8.to_hex(),
42
+ "@disabled-color": color_names.GRAY_7.to_hex(),
43
+
44
+ "@hover-arrow-color": color_names.GRAY_8.to_hex(),
45
+ "@arrow-up-image-icon": str(MOLDE_DIR / "icons/arrow_up_light_theme.svg").replace("\\", "/"),
46
+ "@arrow-down-image-icon": str(MOLDE_DIR/ "icons/arrow_down_light_theme.svg").replace("\\", "/"),
47
+ "@arrow-left-image-icon": str(MOLDE_DIR/ "icons/arrow_left_light_theme.svg").replace("\\", "/"),
48
+ "@arrow-right-image-icon": str(MOLDE_DIR/ "icons/arrow_right_light_theme.svg").replace("\\", "/"),
49
+ "@check-box-image-icon": str(MOLDE_DIR / "icons/check_box_image.svg").replace("\\", "/"),
50
+ "@arrow-up-disabled-image-icon" : str(MOLDE_DIR / "icons/arrow_up_disabled_light_theme.svg").replace("\\", "/"),
51
+ "@arrow-down-disabled-image-icon" : str(MOLDE_DIR / "icons/arrow_down_disabled_light_theme.svg").replace("\\", "/"),
52
+ })
53
+
54
+ elif theme == "dark":
55
+ variables.update({
56
+ "@primary-lighter": color_names.BLUE_7.to_hex(),
57
+ "@primary": color_names.BLUE_6.to_hex(),
58
+ "@primary-darker": color_names.BLUE_5.to_hex(),
59
+
60
+ "@danger-color-lighter": color_names.RED_7.to_hex(),
61
+ "@danger-color": color_names.RED_4.to_hex(),
62
+ "@danger-color-darker": color_names.RED_3.to_hex(),
63
+
64
+ "@warning-color-lighter": color_names.YELLOW_7.to_hex(),
65
+ "@warning-color": color_names.YELLOW_4.to_hex(),
66
+ "@warning-color-darker": color_names.YELLOW_3.to_hex(),
67
+
68
+ "@background": color_names.GRAY_1.to_hex(),
69
+ "@background-variant": color_names.GRAY_3.to_hex(),
70
+
71
+ "@on-background": color_names.WHITE.to_hex(),
72
+ "@on-primary": color_names.WHITE.to_hex(),
73
+
74
+ "@border-color": color_names.GRAY_2.to_hex(),
75
+ "@input-color": color_names.GRAY_3.to_hex(),
76
+
77
+ "@disabled-background": color_names.GRAY_0.to_hex(),
78
+ "@disabled-color": color_names.GRAY_4.to_hex(),
79
+
80
+ "@hover-arrow-color": color_names.GRAY_1.to_hex(),
81
+ "@arrow-up-image-icon": str(MOLDE_DIR / "icons/arrow_up_dark_theme.svg").replace("\\", "/"),
82
+ "@arrow-down-image-icon": str(MOLDE_DIR / "icons/arrow_down_dark_theme.svg").replace("\\", "/"),
83
+ "@arrow-left-image-icon": str(MOLDE_DIR/ "icons/arrow_left_dark_theme.svg").replace("\\", "/"),
84
+ "@arrow-right-image-icon": str(MOLDE_DIR/ "icons/arrow_right_dark_theme.svg").replace("\\", "/"),
85
+ "@check-box-image-icon": str(MOLDE_DIR / "icons/check_box_image.svg").replace("\\", "/"),
86
+ "@arrow-up-disabled-image-icon" : str(MOLDE_DIR / "icons/arrow_up_disabled_light_theme.svg").replace("\\", "/"),
87
+ "@arrow-down-disabled-image-icon" : str(MOLDE_DIR / "icons/arrow_down_disabled_light_theme.svg").replace("\\", "/"),
88
+
89
+ })
90
+
91
+ return variables
92
+
93
+ def get_stylesheet(theme:Literal["light", "dark"] = "light", *, extra_style=""):
94
+ qss_dir = MOLDE_DIR / "stylesheets/"
95
+
96
+ all_stylesheets = []
97
+ for path in qss_dir.glob("*.qss"):
98
+ all_stylesheets.append(path.read_text())
99
+ all_stylesheets.append(extra_style)
100
+ stylesheet = "\n\n".join(all_stylesheets)
101
+
102
+ # Replace variables by correspondent data
103
+ variable_size = lambda x: len(x[0])
104
+ variables_mapping = sorted(get_variables(theme).items(),
105
+ key=variable_size, reverse=True)
106
+ for name, data in variables_mapping:
107
+ stylesheet = stylesheet.replace(name, data)
108
+
109
+ return stylesheet
110
+
111
+ def set_theme(theme=Literal["light", "dark"], *, extra_style=""):
112
+
113
+ app: QApplication | None = QApplication.instance()
114
+ if app is None:
115
+ print("Ops")
116
+ return
117
+
118
+ stylesheet = get_stylesheet(theme)
119
+ app.setStyleSheet(stylesheet)
@@ -0,0 +1,16 @@
1
+ QWidget {
2
+ font-family: sans-serif;
3
+ background-color: @background;
4
+ color: @on-background;
5
+ border-color: @border-color;
6
+ }
7
+
8
+ QWidget::disabled {
9
+ background-color: @disabled-background;
10
+ color: @disabled-color;
11
+ }
12
+
13
+ QWidget:focus {
14
+ outline: none;
15
+ border-color: @primary-darker;
16
+ }
@@ -0,0 +1,61 @@
1
+ from molde import MOLDE_DIR
2
+ from molde.utils import nested_dict
3
+ from molde.colors import color_names
4
+
5
+
6
+ colors_by_name = nested_dict()
7
+ for full_name, color in color_names.__dict__.items():
8
+ try:
9
+ name, level = full_name.split("_")
10
+ level = int(level)
11
+ colors_by_name[name][level] = color.to_hex()
12
+ except:
13
+ continue
14
+
15
+ page_body_list = []
16
+ for color_name, color_data in colors_by_name.items():
17
+ color_data: dict
18
+ palette_header = ""
19
+ html_palette_list = []
20
+ for color_level, color_code in sorted(color_data.items(), reverse=True):
21
+ if color_level == 4:
22
+ palette_header = (
23
+ f'<div class="colorblock" style="color:#ffffff; background:{color_code}">'
24
+ f'<b>{color_name.title()}</b>'
25
+ f'<b>{color_code}</b>'
26
+ '</div>'
27
+ )
28
+ txt_color = "#000000" if color_level >= 5 else "#FFFFFF"
29
+ block = (
30
+ f'<div class="colorblock" style="color:{txt_color}; background:{color_code}">'
31
+ f'<b>{color_level}</b>'
32
+ f'<b>{color_code}</b>'
33
+ '</div>'
34
+ )
35
+ html_palette_list.append(block)
36
+
37
+ html_palette_list = [palette_header] + html_palette_list
38
+ page_body_list.append("\n".join(html_palette_list))
39
+
40
+ page_header = '''<html>
41
+ <title>Molde Colors</title>
42
+ <style>
43
+ body{
44
+ font-family: sans-serif;
45
+ background-color: #000000;
46
+ }
47
+ div.colorblock {
48
+ display:flex;
49
+ justify-content:space-between;
50
+ padding: 0.75rem 1.5rem;
51
+ }
52
+ </style>
53
+
54
+ '''
55
+
56
+ page_body = "\n\n&nbsp;\n\n".join(page_body_list)
57
+
58
+ page_footer = "\n\n</html>"
59
+
60
+ path = MOLDE_DIR.parent / "docs/index.html"
61
+ path.write_text(page_header + page_body + page_footer)