tkfluent 0.0.3__tar.gz → 0.0.5__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 (58) hide show
  1. {tkfluent-0.0.3 → tkfluent-0.0.5}/PKG-INFO +3 -1
  2. tkfluent-0.0.5/README.md +3 -0
  3. {tkfluent-0.0.3 → tkfluent-0.0.5}/pyproject.toml +1 -1
  4. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/__init__.py +6 -2
  5. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/__main__.py +20 -11
  6. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/badge.py +41 -32
  7. tkfluent-0.0.5/tkflu/button.py +265 -0
  8. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/bwm.py +50 -30
  9. tkfluent-0.0.5/tkflu/constants.py +15 -0
  10. tkfluent-0.0.5/tkflu/defs.py +16 -0
  11. tkfluent-0.0.5/tkflu/designs/__init__.py +2 -0
  12. tkfluent-0.0.5/tkflu/designs/__pycache__/__init__.cpython-311.pyc +0 -0
  13. tkfluent-0.0.5/tkflu/designs/__pycache__/badge.cpython-311.pyc +0 -0
  14. tkfluent-0.0.5/tkflu/designs/__pycache__/button.cpython-311.pyc +0 -0
  15. tkfluent-0.0.5/tkflu/designs/__pycache__/design.cpython-311.pyc +0 -0
  16. tkfluent-0.0.5/tkflu/designs/__pycache__/entry.cpython-311.pyc +0 -0
  17. tkfluent-0.0.5/tkflu/designs/__pycache__/frame.cpython-311.pyc +0 -0
  18. tkfluent-0.0.5/tkflu/designs/__pycache__/primary_color.cpython-311.pyc +0 -0
  19. tkfluent-0.0.5/tkflu/designs/__pycache__/text.cpython-311.pyc +0 -0
  20. tkfluent-0.0.5/tkflu/designs/__pycache__/window.cpython-311.pyc +0 -0
  21. tkfluent-0.0.5/tkflu/designs/badge.py +44 -0
  22. tkfluent-0.0.5/tkflu/designs/button.py +304 -0
  23. tkfluent-0.0.5/tkflu/designs/design.py +27 -0
  24. tkfluent-0.0.5/tkflu/designs/entry.py +164 -0
  25. tkfluent-0.0.5/tkflu/designs/fonts/__init__.py +20 -0
  26. tkfluent-0.0.5/tkflu/designs/fonts/__pycache__/__init__.cpython-311.pyc +0 -0
  27. tkfluent-0.0.5/tkflu/designs/fonts/segoeui.ttf +0 -0
  28. tkfluent-0.0.5/tkflu/designs/frame.py +37 -0
  29. tkfluent-0.0.5/tkflu/designs/primary_color.py +25 -0
  30. tkfluent-0.0.5/tkflu/designs/text.py +164 -0
  31. tkfluent-0.0.5/tkflu/designs/window.py +21 -0
  32. tkfluent-0.0.5/tkflu/entry.py +296 -0
  33. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/frame.py +84 -43
  34. tkfluent-0.0.5/tkflu/icons.py +47 -0
  35. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/label.py +2 -3
  36. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/menu.py +43 -4
  37. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/popupmenu.py +4 -29
  38. tkfluent-0.0.5/tkflu/popupwindow.py +31 -0
  39. tkfluent-0.0.5/tkflu/text.py +299 -0
  40. tkfluent-0.0.5/tkflu/togglebutton.py +384 -0
  41. tkfluent-0.0.5/tkflu/tooltip.py +8 -0
  42. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/toplevel.py +3 -4
  43. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/window.py +6 -3
  44. tkfluent-0.0.3/README.md +0 -1
  45. tkfluent-0.0.3/tkflu/button.py +0 -347
  46. tkfluent-0.0.3/tkflu/entry.py +0 -187
  47. tkfluent-0.0.3/tkflu/text.py +0 -190
  48. tkfluent-0.0.3/tkflu/togglebutton.py +0 -341
  49. tkfluent-0.0.3/tkflu/winico.py +0 -25
  50. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/checkbox.py +0 -0
  51. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/customwindow.py +0 -0
  52. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/customwindow2.py +0 -0
  53. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/image.py +0 -0
  54. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/listbox.py +0 -0
  55. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/litenav.py +0 -0
  56. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/menubar.py +0 -0
  57. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/scrollbar.py +0 -0
  58. {tkfluent-0.0.3 → tkfluent-0.0.5}/tkflu/thememanager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tkfluent
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Fluent Design for Tkinter
5
5
  Author: XiangQinxi
6
6
  Author-email: xiangqinxi@outlook.com
@@ -22,3 +22,5 @@ Project-URL: Documentation, https://tkfluent.netlify.app
22
22
  Description-Content-Type: text/markdown
23
23
 
24
24
  # tkfluent
25
+
26
+ `tkinter`现代化组件库。设计来于`Fluent` `WinUI3` 设计
@@ -0,0 +1,3 @@
1
+ # tkfluent
2
+
3
+ `tkinter`现代化组件库。设计来于`Fluent` `WinUI3` 设计
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tkfluent"
3
- version = "0.0.3"
3
+ version = "0.0.5"
4
4
  description = "Fluent Design for Tkinter"
5
5
  authors = ["XiangQinxi <xiangqinxi@outlook.com>"]
6
6
  readme = "README.md"
@@ -9,19 +9,23 @@ Fluent设计的tkinter组件库(模板)
9
9
 
10
10
  from .badge import FluBadge
11
11
  from .button import FluButton
12
+ from .constants import *
13
+ from .defs import *
12
14
  from .entry import FluEntry
13
15
  from .frame import FluFrame
14
16
  from .label import FluLabel
15
17
  from .menu import FluMenu
16
18
  from .menubar import FluMenuBar
17
- from .popupmenu import FluPopupMenu
19
+ from .popupmenu import FluPopupMenu, FluPopupMenuWindow
20
+ from .popupwindow import FluPopupWindow
18
21
  from .text import FluText
19
22
  from .thememanager import FluThemeManager
20
23
  from .togglebutton import FluToggleButton
24
+ from .tooltip import FluToolTip
21
25
  from .toplevel import FluToplevel
22
26
  from .window import FluWindow
23
- #from .winico import FluWinico
24
27
 
28
+ from .designs import *
25
29
 
26
30
  FluChip = FluBadge
27
31
  FluPushButton = FluButton
@@ -2,6 +2,8 @@ from tkflu import *
2
2
  from tkinter import *
3
3
  from tkinter.font import *
4
4
 
5
+ orange_primary_color()
6
+
5
7
  root = FluWindow()
6
8
  #root.wincustom(way=0)
7
9
  root.wm_geometry("360x500")
@@ -27,14 +29,20 @@ menu2 = FluMenu(height=93)
27
29
  menu2.add_command(
28
30
  label="FluMenu3-1", width=80, command=lambda: print("FluMenu3-1 -> Clicked")
29
31
  )
30
- menu2.add_command(
31
- label="FluMenu3-2", width=80, command=lambda: print("FluMenu3-2 -> Clicked")
32
+
33
+ menu3 = FluMenu(height=46, width=10)
34
+ menu3.add_command(
35
+ label="FluMenu3-2-1", width=80, command=lambda: print("FluMenu3-2-1 -> Clicked")
36
+ )
37
+
38
+ menu2.add_cascade(
39
+ label="FluMenu3-2", width=80, menu=menu3
32
40
  )
33
41
  menubar.add_cascade(
34
42
  label="FluMenu3", width=80, menu=menu2
35
43
  )
36
44
 
37
- menubar.pack(fill="x",)
45
+ menubar.pack(fill="x")
38
46
 
39
47
  frame = FluFrame(root)
40
48
 
@@ -54,21 +62,22 @@ button2 = FluButton(
54
62
  )
55
63
  button2.pack(fill="x", padx=5, pady=5)
56
64
 
57
- def toggle1():
58
- print(f"FluToggleButton -> Toggled -> Checked: {togglebutton1.dcget('checked')}")
59
- if togglebutton1.dcget('checked'):
60
- thememanager.mode("dark")
61
- else:
62
- thememanager.mode("light")
63
-
64
65
  togglebutton1 = FluToggleButton(
65
- frame, text="FluToggleButton", command=toggle1
66
+ frame, text="FluToggleButton", command=lambda: print(f"FluToggleButton -> Toggled -> Checked: {togglebutton1.dcget('checked')}")
66
67
  )
67
68
  togglebutton1.pack(fill="x", padx=5, pady=5)
68
69
 
70
+ togglebutton2 = FluToggleButton(
71
+ frame, text="Toggle Theme", command=lambda: toggle_theme(togglebutton2, thememanager)
72
+ )
73
+ togglebutton2.pack(fill="x", padx=5, pady=5)
74
+
69
75
  entry1 = FluEntry(frame)
70
76
  entry1.pack(fill="x", padx=5, pady=5)
71
77
 
78
+ entry2 = FluEntry(frame, height=50)
79
+ entry2.pack(fill="x", padx=5, pady=5)
80
+
72
81
  text1 = FluText(frame)
73
82
  text1.pack(fill="x", padx=5, pady=5)
74
83
 
@@ -2,18 +2,30 @@ from tkdeft.windows.draw import DSvgDraw
2
2
  from tkdeft.windows.canvas import DCanvas
3
3
  from tkdeft.windows.drawwidget import DDrawWidget
4
4
 
5
+ from .designs.badge import badge
6
+
5
7
 
6
8
  class FluBadgeDraw(DSvgDraw):
7
9
  def create_roundrect(self,
8
10
  x1, y1, x2, y2, temppath=None,
9
- fill="transparent", outline="black", width=1
11
+ fill="transparent", fill_opacity=1,
12
+ outline="black", outline_opacity=1, width=1
10
13
  ):
11
14
  drawing = self.create_drawing(x2 - x1, y2 - y1, temppath=temppath)
12
15
  drawing[1].add(
13
16
  drawing[1].rect(
14
17
  (x1, y1), (x2 - x1, y2 - y1), 20, 25,
15
- fill=fill, stroke_width=width,
16
- stroke=outline,
18
+ id=".Badge", transform="translate(0.500000 0.500000)",
19
+ fill=fill, fill_opacity=fill_opacity,
20
+ stroke=outline, stroke_opacity=outline_opacity, stroke_width=width,
21
+ )
22
+ )
23
+ drawing[1].add(
24
+ drawing[1].rect(
25
+ (x1, y1), (x2 - x1, y2 - y1), 20, 25,
26
+ id=".Badge", transform="translate(0.500000 0.500000)",
27
+ fill="white", fill_opacity=0,
28
+ stroke=outline, stroke_opacity=outline_opacity, stroke_width=width,
17
29
  )
18
30
  )
19
31
  drawing[1].save()
@@ -25,11 +37,13 @@ class FluBadgeCanvas(DCanvas):
25
37
 
26
38
  def create_round_rectangle(self,
27
39
  x1, y1, x2, y2, temppath=None,
28
- fill="transparent", outline="black", width=1
40
+ fill="transparent", fill_opacity=1,
41
+ outline="black", outline_opacity=1, width=1
29
42
  ):
30
43
  self._img = self.svgdraw.create_roundrect(
31
44
  x1, y1, x2, y2, temppath=temppath,
32
- fill=fill, outline=outline, width=width
45
+ fill=fill, fill_opacity=fill_opacity,
46
+ outline=outline, outline_opacity=outline_opacity, width=width
33
47
  )
34
48
  self._tkimg = self.svgdraw.create_tksvg_image(self._img)
35
49
  return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
@@ -72,9 +86,8 @@ class FluBadge(FluBadgeCanvas, DDrawWidget):
72
86
 
73
87
  self.bind("<<Clicked>>", lambda event=None: self.focus_set(), add="+")
74
88
 
75
- if font is None:
76
- from tkdeft.utility.fonts import SegoeFont
77
- self.attributes.font = SegoeFont()
89
+ from .defs import set_default_font
90
+ set_default_font(font, self.attributes)
78
91
 
79
92
  def _init(self, mode, style):
80
93
  from easydict import EasyDict
@@ -86,7 +99,9 @@ class FluBadge(FluBadgeCanvas, DDrawWidget):
86
99
  "font": None,
87
100
 
88
101
  "back_color": None,
102
+ "back_opacity": None,
89
103
  "border_color": None,
104
+ "border_color_opacity": None,
90
105
  "border_width": None,
91
106
  "text_color": None
92
107
  }
@@ -107,13 +122,16 @@ class FluBadge(FluBadgeCanvas, DDrawWidget):
107
122
  self.delete("all")
108
123
 
109
124
  _back_color = self.attributes.back_color
125
+ _back_opacity = self.attributes.back_opacity
110
126
  _border_color = self.attributes.border_color
127
+ _border_color_opacity = self.attributes.border_color_opacity
111
128
  _border_width = self.attributes.border_width
112
129
  _text_color = self.attributes.text_color
113
130
 
114
131
  self.element_border = self.create_round_rectangle(
115
132
  0, 0, self.winfo_width(), self.winfo_height(), temppath=self.temppath,
116
- fill=_back_color, outline=_border_color, width=_border_width
133
+ fill=_back_color, fill_opacity=_back_opacity,
134
+ outline=_border_color, outline_opacity=_border_color_opacity, width=_border_width
117
135
  )
118
136
 
119
137
  self.element_text = self.create_text(
@@ -137,34 +155,25 @@ class FluBadge(FluBadgeCanvas, DDrawWidget):
137
155
  else:
138
156
  self._light()
139
157
 
140
- def _light(self):
158
+ def _theme(self, mode, style):
159
+ n = badge(mode, style)
141
160
  self.dconfigure(
142
- back_color="#f9f9f9",
143
- border_color="#f0f0f0",
144
- border_width=1,
145
- text_color="#191919",
161
+ back_color=n["back_color"],
162
+ back_opacity=n["back_opacity"],
163
+ border_color=n["border_color"],
164
+ border_color_opacity=n["border_color_opacity"],
165
+ border_width=n["border_width"],
166
+ text_color=n["text_color"],
146
167
  )
147
168
 
169
+ def _light(self):
170
+ self._theme("light", "standard")
171
+
148
172
  def _light_accent(self):
149
- self.dconfigure(
150
- back_color="#005fb8",
151
- border_color="#005fb8",
152
- border_width=1,
153
- text_color="#ffffff",
154
- )
173
+ self._theme("light", "accent")
155
174
 
156
175
  def _dark(self):
157
- self.dconfigure(
158
- back_color="#242424",
159
- border_color="#242424",
160
- border_width=1,
161
- text_color="#ffffff",
162
- )
176
+ self._theme("dark", "standard")
163
177
 
164
178
  def _dark_accent(self):
165
- self.dconfigure(
166
- back_color="#60cdff",
167
- border_color="#60cdff",
168
- border_width=1,
169
- text_color="#000000",
170
- )
179
+ self._theme("dark", "accent")
@@ -0,0 +1,265 @@
1
+ from tkdeft.windows.draw import DSvgDraw
2
+ from tkdeft.windows.canvas import DCanvas
3
+ from tkdeft.windows.drawwidget import DDrawWidget
4
+
5
+ from .designs.button import button
6
+
7
+
8
+ class FluButtonDraw(DSvgDraw):
9
+ def create_roundrect(self,
10
+ x1, y1, x2, y2, radius, radiusy=None, temppath=None,
11
+ fill="transparent", fill_opacity=1,
12
+ outline="black", outline2=None, outline_opacity=1, outline2_opacity=1, width=1,
13
+ ):
14
+ if radiusy:
15
+ _rx = radius
16
+ _ry = radiusy
17
+ else:
18
+ _rx, _ry = radius, radius
19
+ drawing = self.create_drawing(x2 - x1, y2 - y1, temppath=temppath)
20
+ if outline2:
21
+ border = drawing[1].linearGradient(start=(x1, y1), end=(x1, y2), id="DButton.Border",
22
+ gradientUnits="userSpaceOnUse")
23
+ border.add_stop_color("0.9", outline, outline_opacity)
24
+ border.add_stop_color("1", outline2, outline2_opacity)
25
+ drawing[1].defs.add(border)
26
+ stroke = f"url(#{border.get_id()})"
27
+ stroke_opacity = 1
28
+ else:
29
+ stroke = outline
30
+ stroke_opacity = outline_opacity
31
+ drawing[1].add(
32
+ drawing[1].rect(
33
+ (x1, y1), (x2 - x1, y2 - y1), _rx, _ry,
34
+ fill=fill, fill_opacity=fill_opacity,
35
+ stroke=stroke, stroke_width=width, stroke_opacity=stroke_opacity,
36
+ transform="translate(0.500000 0.500000)"
37
+ )
38
+ )
39
+ drawing[1].save()
40
+ return drawing[0]
41
+
42
+
43
+ class FluButtonCanvas(DCanvas):
44
+ draw = FluButtonDraw
45
+
46
+ def create_round_rectangle(self,
47
+ x1, y1, x2, y2, r1, r2=None, temppath=None,
48
+ fill="transparent", fill_opacity=1,
49
+ outline="black", outline2="black", outline_opacity=1, outline2_opacity=1,
50
+ width=1,
51
+ ):
52
+ self._img = self.svgdraw.create_roundrect(
53
+ x1, y1, x2, y2, r1, r2, temppath=temppath,
54
+ fill=fill, fill_opacity=fill_opacity,
55
+ outline=outline, outline2=outline2, outline_opacity=outline_opacity, outline2_opacity=outline2_opacity,
56
+ width=width,
57
+ )
58
+ self._tkimg = self.svgdraw.create_tksvg_image(self._img)
59
+ return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
60
+
61
+ create_roundrect = create_round_rectangle
62
+
63
+
64
+ class FluButton(FluButtonCanvas, DDrawWidget):
65
+ def __init__(self, *args,
66
+ text="",
67
+ width=120,
68
+ height=32,
69
+ command=None,
70
+ font=None,
71
+ mode="light",
72
+ style="standard",
73
+ state="normal",
74
+ **kwargs):
75
+ self._init(mode, style)
76
+
77
+ super().__init__(*args, width=width, height=height, **kwargs)
78
+
79
+ if command is None:
80
+ def empty(): pass
81
+
82
+ command = empty
83
+
84
+ self.dconfigure(
85
+ text=text,
86
+ command=command,
87
+ state=state,
88
+ )
89
+
90
+ self.bind("<<Clicked>>", lambda event=None: self.focus_set(), add="+")
91
+ self.bind("<<Clicked>>", lambda event=None: self.attributes.command(), add="+")
92
+
93
+ self.bind("<Return>", lambda event=None: self.attributes.command(), add="+") # 可以使用回车键模拟点击
94
+
95
+ from .defs import set_default_font
96
+ set_default_font(font, self.attributes)
97
+
98
+ def _init(self, mode, style):
99
+
100
+ from easydict import EasyDict
101
+
102
+ self.attributes = EasyDict(
103
+ {
104
+ "text": "",
105
+ "command": None,
106
+ "font": None,
107
+ "state": "normal",
108
+
109
+ "rest": {},
110
+ "hover": {},
111
+ "pressed": {},
112
+ "disabled": {}
113
+ }
114
+ )
115
+
116
+ self.theme(mode=mode, style=style)
117
+
118
+ def _draw(self, event=None):
119
+ super()._draw(event)
120
+
121
+ width = self.winfo_width()
122
+ height = self.winfo_height()
123
+
124
+ self.delete("all")
125
+
126
+ state = self.dcget("state")
127
+
128
+ _dict = None
129
+
130
+ if state == "normal":
131
+ if self.enter:
132
+ if self.button1:
133
+ _dict = self.attributes.pressed
134
+ else:
135
+ _dict = self.attributes.hover
136
+ else:
137
+ _dict = self.attributes.rest
138
+ else:
139
+ _dict = self.attributes.disabled
140
+
141
+ _back_color = _dict.back_color
142
+ _back_opacity = _dict.back_opacity
143
+ _border_color = _dict.border_color
144
+ _border_color_opacity = _dict.border_color_opacity
145
+ _border_color2 = _dict.border_color2
146
+ _border_color2_opacity = _dict.border_color2_opacity
147
+ _border_width = _dict.border_width
148
+ _radius = _dict.radius
149
+ _text_color = _dict.text_color
150
+
151
+ self.element_border = self.create_round_rectangle(
152
+ 0, 0, width, height, _radius, temppath=self.temppath,
153
+ fill=_back_color, fill_opacity=_back_opacity,
154
+ outline=_border_color, outline_opacity=_border_color_opacity, outline2=_border_color2,
155
+ outline2_opacity=_border_color2_opacity,
156
+ width=_border_width,
157
+ )
158
+
159
+ self.element_text = self.create_text(
160
+ self.winfo_width() / 2, self.winfo_height() / 2, anchor="center",
161
+ fill=_text_color, text=self.attributes.text, font=self.attributes.font
162
+ )
163
+
164
+ def theme(self, mode=None, style=None):
165
+ if mode:
166
+ self.mode = mode
167
+ if style:
168
+ self.style = style
169
+ if self.mode.lower() == "dark":
170
+ if self.style.lower() == "accent":
171
+ self._dark_accent()
172
+ elif self.style.lower() == "menu":
173
+ self._dark_menu()
174
+ else:
175
+ self._dark()
176
+ else:
177
+ if self.style.lower() == "accent":
178
+ self._light_accent()
179
+ elif self.style.lower() == "menu":
180
+ self._light_menu()
181
+ else:
182
+ self._light()
183
+
184
+ def _theme(self, mode, style):
185
+ r = button(mode, style, "rest")
186
+ h = button(mode, style, "hover")
187
+ p = button(mode, style, "pressed")
188
+ d = button(mode, style, "disabled")
189
+ self.dconfigure(
190
+ rest={
191
+ "back_color": r["back_color"],
192
+ "back_opacity": r["back_opacity"],
193
+ "border_color": r["border_color"],
194
+ "border_color_opacity": r["border_color_opacity"],
195
+ "border_color2": r["border_color2"],
196
+ "border_color2_opacity": r["border_color2_opacity"],
197
+ "border_width": r["border_width"],
198
+ "radius": r["radius"],
199
+ "text_color": r["text_color"],
200
+ },
201
+ hover={
202
+ "back_color": h["back_color"],
203
+ "back_opacity": h["back_opacity"],
204
+ "border_color": h["border_color"],
205
+ "border_color_opacity": h["border_color_opacity"],
206
+ "border_color2": h["border_color2"],
207
+ "border_color2_opacity": h["border_color2_opacity"],
208
+ "border_width": h["border_width"],
209
+ "radius": h["radius"],
210
+ "text_color": h["text_color"],
211
+ },
212
+ pressed={
213
+ "back_color": p["back_color"],
214
+ "back_opacity": p["back_opacity"],
215
+ "border_color": p["border_color"],
216
+ "border_color_opacity": p["border_color_opacity"],
217
+ "border_color2": p["border_color2"],
218
+ "border_color2_opacity": p["border_color2_opacity"],
219
+ "border_width": p["border_width"],
220
+ "radius": p["radius"],
221
+ "text_color": p["text_color"],
222
+ },
223
+ disabled={
224
+ "back_color": d["back_color"],
225
+ "back_opacity": d["back_opacity"],
226
+ "border_color": d["border_color"],
227
+ "border_color_opacity": d["border_color_opacity"],
228
+ "border_color2": d["border_color2"],
229
+ "border_color2_opacity": d["border_color2_opacity"],
230
+ "border_width": d["border_width"],
231
+ "radius": d["radius"],
232
+ "text_color": d["text_color"],
233
+ }
234
+ )
235
+
236
+ def _light(self):
237
+ self._theme("light", "standard")
238
+
239
+ def _light_menu(self):
240
+ self._theme("light", "menu")
241
+
242
+ def _light_accent(self):
243
+ self._theme("light", "accent")
244
+
245
+ def _dark(self):
246
+ self._theme("dark", "standard")
247
+
248
+ def _dark_menu(self):
249
+ self._theme("dark", "menu")
250
+
251
+ def _dark_accent(self):
252
+ self._theme("dark", "accent")
253
+
254
+ def invoke(self):
255
+ self.attributes.command()
256
+
257
+ def _event_off_button1(self, event=None):
258
+ self.button1 = False
259
+
260
+ self._draw(event)
261
+
262
+ if self.enter:
263
+ # self.focus_set()
264
+ if self.dcget("state") == "normal":
265
+ self.event_generate("<<Clicked>>")
@@ -18,32 +18,58 @@ class BWm(object):
18
18
  if hasattr(self, "closebutton"):
19
19
  self.closebutton.dconfigure(
20
20
  rest={
21
- "back_color": self.titlebar.cget("background"),
22
- "border_color": "#f0f0f0",
23
- "border_color2": "#d6d6d6",
24
- "border_width": 0,
21
+ "back_color": "#ffffff",
22
+ "back_opacity": 0,
23
+ "border_color": "#000000",
24
+ "border_color_opacity": 0,
25
+ "border_color2": None,
26
+ "border_color2_opacity": None,
27
+ "border_width": 1,
25
28
  "radius": 0,
26
29
  "text_color": self.attributes.closebutton.text_color,
27
30
  },
28
31
  hover={
29
32
  "back_color": self.attributes.closebutton.back_color,
30
- "border_color": "#f0f0f0",
31
- "border_color2": "#d6d6d6",
32
- "border_width": 0,
33
+ "back_opacity": 1,
34
+ "border_color": "#000000",
35
+ "border_color_opacity": 0,
36
+ "border_color2": None,
37
+ "border_color2_opacity": None,
38
+ "border_width": 1,
33
39
  "radius": 0,
34
40
  "text_color": self.attributes.closebutton.text_hover_color,
35
41
  },
36
42
  pressed={
37
43
  "back_color": self.attributes.closebutton.back_color,
38
- "border_color": "#f0f0f0",
39
- "border_color2": "#f0f0f0",
40
- "border_width": 0,
44
+ "back_opacity": 0.7,
45
+ "border_color": "#000000",
46
+ "border_color_opacity": 0,
47
+ "border_color2": None,
48
+ "border_color2_opacity": None,
49
+ "border_width": 1,
41
50
  "radius": 0,
42
51
  "text_color": self.attributes.closebutton.text_hover_color,
43
- }
52
+ },
53
+ disabled={
54
+ "back_color": "#ffffff",
55
+ "back_opacity": 0.3,
56
+ "border_color": "#000000",
57
+ "border_color_opacity": 0,
58
+ "border_color2": None,
59
+ "border_color2_opacity": None,
60
+ "border_width": 1,
61
+ "radius": 0,
62
+ "text_color": "#a2a2a2",
63
+ },
44
64
  )
45
65
  self.closebutton._draw()
46
66
 
67
+ def _event_key_esc(self, event=None):
68
+ self._event_delete_window()
69
+
70
+ def _event_delete_window(self):
71
+ self.destroy()
72
+
47
73
  def _event_configure(self, event=None):
48
74
 
49
75
  """
@@ -71,9 +97,6 @@ class BWm(object):
71
97
 
72
98
  self.theme(mode)
73
99
 
74
- def _exit(self):
75
- self.quit()
76
-
77
100
  def theme(self, mode: str):
78
101
 
79
102
  """
@@ -100,27 +123,24 @@ class BWm(object):
100
123
  else:
101
124
  self._light()
102
125
 
103
- def _light(self):
126
+ def _theme(self, mode):
127
+ from .designs.window import window
128
+ n = window(mode)
104
129
  self.dconfigure(
105
- back_color="#ffffff",
106
- text_color="#000000",
130
+ back_color=n["back_color"],
131
+ text_color=n["text_color"],
107
132
  closebutton={
108
- "back_color": "red",
109
- "text_color": "#000000",
110
- "text_hover_color": "#ffffff"
133
+ "back_color": n["closebutton"]["back_color"],
134
+ "text_color": n["closebutton"]["text_color"],
135
+ "text_hover_color": n["closebutton"]["text_hover_color"]
111
136
  }
112
137
  )
113
138
 
139
+ def _light(self):
140
+ self._theme("light")
141
+
114
142
  def _dark(self):
115
- self.dconfigure(
116
- back_color="#202020",
117
- text_color="#ffffff",
118
- closebutton={
119
- "back_color": "red",
120
- "text_color": "#ffffff",
121
- "text_hover_color": "#000000"
122
- }
123
- )
143
+ self._theme("dark")
124
144
 
125
145
  def wincustom(self, wait=200, way=1):
126
146
 
@@ -139,7 +159,7 @@ class BWm(object):
139
159
  self.titlebar = Frame(self, width=180, height=35, background=self.attributes.back_color)
140
160
  self.titlelabel = FluLabel(self.titlebar, text=self.title(), width=50)
141
161
  self.titlelabel.pack(fill="y", side="left")
142
- self.closebutton = FluButton(self.titlebar, text="", width=32, height=32, command=lambda: self._exit())
162
+ self.closebutton = FluButton(self.titlebar, text="", width=32, height=32, command=lambda: self._event_delete_window())
143
163
  self.closebutton.pack(fill="y", side="right")
144
164
  self.titlebar.pack(fill="x", side="top")
145
165
 
@@ -0,0 +1,15 @@
1
+ NO = FALSE = OFF = 0
2
+ YES = TRUE = ON = 1
3
+
4
+ # Modes
5
+ LIGHT = 'light'
6
+ DARK = 'dark'
7
+
8
+ # States
9
+ NORMAL = 'normal'
10
+ DISABLED = 'disabled'
11
+
12
+ # FluButton Styles
13
+ STANDARD = 'standard'
14
+ ACCENT = 'accent'
15
+ MENU = 'menu'
@@ -0,0 +1,16 @@
1
+ def toggle_theme(toggle_button, thememanager):
2
+ if toggle_button.dcget('checked'):
3
+ thememanager.mode("dark")
4
+ else:
5
+ thememanager.mode("light")
6
+
7
+
8
+ def set_default_font(font, attributes):
9
+ if font is None:
10
+ from .designs.fonts import SegoeFont
11
+ attributes.font = SegoeFont()
12
+
13
+
14
+ def orange_primary_color():
15
+ from .designs.primary_color import set_primary_color
16
+ set_primary_color(("#c53201", "#fe7e34"))