tkfluent 0.0.6__py3-none-any.whl → 0.0.9__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.
tkflu/__init__.py CHANGED
@@ -9,19 +9,22 @@ Fluent设计的tkinter组件库(模板)
9
9
 
10
10
  from .badge import FluBadge
11
11
  from .button import FluButton
12
+ from .bwm import BWm
12
13
  from .constants import *
13
14
  from .defs import *
14
15
  from .entry import FluEntry
15
16
  from .frame import FluFrame
17
+ from .icons import *
16
18
  from .label import FluLabel
17
19
  from .menu import FluMenu
18
20
  from .menubar import FluMenuBar
19
21
  from .popupmenu import FluPopupMenu, FluPopupMenuWindow
20
22
  from .popupwindow import FluPopupWindow
23
+ from .slider import FluSlider
21
24
  from .text import FluText
22
25
  from .thememanager import FluThemeManager
23
26
  from .togglebutton import FluToggleButton
24
- from .tooltip import FluToolTip
27
+ from .tooltip import FluToolTip, FluToolTip2, FluToolTipBase
25
28
  from .toplevel import FluToplevel
26
29
  from .window import FluWindow
27
30
 
tkflu/__main__.py CHANGED
@@ -2,11 +2,26 @@ from tkflu import *
2
2
  from tkinter import *
3
3
  from tkinter.font import *
4
4
 
5
- orange_primary_color()
6
-
5
+ blue_primary_color()
6
+
7
+ def togglestate():
8
+ if button1.dcget("state") == NORMAL:
9
+ button1.dconfigure(state=DISABLED)
10
+ button2.dconfigure(state=DISABLED)
11
+ entry1.dconfigure(state=DISABLED)
12
+ button1._draw()
13
+ button2._draw()
14
+ entry1._draw()
15
+ else:
16
+ button1.dconfigure(state=NORMAL)
17
+ button2.dconfigure(state=NORMAL)
18
+ entry1.dconfigure(state=NORMAL)
19
+ button1._draw()
20
+ button2._draw()
21
+ entry1._draw()
7
22
  root = FluWindow()
8
23
  #root.wincustom(way=0)
9
- root.wm_geometry("360x500")
24
+ root.geometry("360x600")
10
25
 
11
26
  popupmenu = FluPopupMenu()
12
27
 
@@ -52,6 +67,14 @@ badge1.pack(padx=5, pady=5)
52
67
  badge2 = FluBadge(frame, text="FluBadge (Accent)", width=120, style="accent")
53
68
  badge2.pack(padx=5, pady=5)
54
69
 
70
+ label1 = FluLabel(frame, text="FluLabel(Hover Me)")
71
+ label1.tooltip(text="FluToolTip")
72
+ label1.pack(padx=5, pady=5)
73
+
74
+ label2 = FluLabel(frame, text="FluLabel2(Hover Me)")
75
+ label2.tooltip(text="FluToolTip2", way=1)
76
+ label2.pack(padx=5, pady=5)
77
+
55
78
  button1 = FluButton(
56
79
  frame, text="FluButton", command=lambda: print("FluButton -> Clicked")
57
80
  )
@@ -72,6 +95,11 @@ togglebutton2 = FluToggleButton(
72
95
  )
73
96
  togglebutton2.pack(fill="x", padx=5, pady=5)
74
97
 
98
+ togglebutton3 = FluToggleButton(
99
+ frame, text="Toggle State", command=lambda: togglestate()
100
+ )
101
+ togglebutton3.pack(fill="x", padx=5, pady=5)
102
+
75
103
  entry1 = FluEntry(frame)
76
104
  entry1.pack(fill="x", padx=5, pady=5)
77
105
 
@@ -81,6 +109,13 @@ entry2.pack(fill="x", padx=5, pady=5)
81
109
  text1 = FluText(frame)
82
110
  text1.pack(fill="x", padx=5, pady=5)
83
111
 
112
+ slider1 = FluSlider(frame, value=0)
113
+ slider1.pack(fill="x", padx=5, pady=5)
114
+
115
+ """listbox1 = FluListBox(frame)
116
+ listbox1.dconfigure()
117
+ listbox1.pack(fill="x", padx=5, pady=5)"""
118
+
84
119
  frame.pack(fill="both", expand="yes", side="right", padx=5, pady=5)
85
120
 
86
121
  root.mainloop()
tkflu/badge.py CHANGED
@@ -51,7 +51,10 @@ class FluBadgeCanvas(DCanvas):
51
51
  create_roundrect = create_round_rectangle
52
52
 
53
53
 
54
- class FluBadge(FluBadgeCanvas, DDrawWidget):
54
+ from .tooltip import FluToolTipBase
55
+
56
+
57
+ class FluBadge(FluBadgeCanvas, DDrawWidget, FluToolTipBase):
55
58
 
56
59
  def __init__(self, *args,
57
60
  text="",
tkflu/button.py CHANGED
@@ -61,16 +61,19 @@ class FluButtonCanvas(DCanvas):
61
61
  create_roundrect = create_round_rectangle
62
62
 
63
63
 
64
- class FluButton(FluButtonCanvas, DDrawWidget):
64
+ from .constants import MODE, STATE, BUTTONSTYLE
65
+ from .tooltip import FluToolTipBase
66
+
67
+ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase):
65
68
  def __init__(self, *args,
66
69
  text="",
67
70
  width=120,
68
71
  height=32,
69
72
  command=None,
70
73
  font=None,
71
- mode="light",
72
- style="standard",
73
- state="normal",
74
+ mode: MODE = "light",
75
+ style: BUTTONSTYLE = "standard",
76
+ state: STATE = "normal",
74
77
  **kwargs):
75
78
  self._init(mode, style)
76
79
 
@@ -95,7 +98,7 @@ class FluButton(FluButtonCanvas, DDrawWidget):
95
98
  from .defs import set_default_font
96
99
  set_default_font(font, self.attributes)
97
100
 
98
- def _init(self, mode, style):
101
+ def _init(self, mode: MODE, style: BUTTONSTYLE):
99
102
 
100
103
  from easydict import EasyDict
101
104
 
@@ -161,7 +164,7 @@ class FluButton(FluButtonCanvas, DDrawWidget):
161
164
  fill=_text_color, text=self.attributes.text, font=self.attributes.font
162
165
  )
163
166
 
164
- def theme(self, mode=None, style=None):
167
+ def theme(self, mode: MODE = None, style: BUTTONSTYLE = None):
165
168
  if mode:
166
169
  self.mode = mode
167
170
  if style:
tkflu/bwm.py CHANGED
@@ -126,6 +126,8 @@ class BWm(object):
126
126
  def _theme(self, mode):
127
127
  from .designs.window import window
128
128
  n = window(mode)
129
+ """if self.attributes.back_color is not None:
130
+ n["back_color"] = self.attributes.back_color"""
129
131
  self.dconfigure(
130
132
  back_color=n["back_color"],
131
133
  text_color=n["text_color"],
tkflu/constants.py CHANGED
@@ -1,15 +1,25 @@
1
+ from typing import Literal
2
+
1
3
  NO = FALSE = OFF = 0
2
4
  YES = TRUE = ON = 1
3
5
 
4
6
  # Modes
5
7
  LIGHT = 'light'
6
8
  DARK = 'dark'
9
+ MODE = Literal["light", "dark"]
7
10
 
8
11
  # States
9
12
  NORMAL = 'normal'
10
13
  DISABLED = 'disabled'
14
+ STATE = Literal["normal", "disabled"]
11
15
 
12
16
  # FluButton Styles
13
17
  STANDARD = 'standard'
14
18
  ACCENT = 'accent'
15
19
  MENU = 'menu'
20
+ BUTTONSTYLE = Literal["standard", "accent", "menu"]
21
+
22
+ # FluFrame Styles
23
+ STANDARD = 'standard'
24
+ POPUPMENU = 'popupmenu'
25
+ FRAMESTYLE = Literal["standard", "popupmenu"]
tkflu/defs.py CHANGED
@@ -11,6 +11,31 @@ def set_default_font(font, attributes):
11
11
  attributes.font = SegoeFont()
12
12
 
13
13
 
14
+ def red_primary_color():
15
+ from .designs.primary_color import set_primary_color
16
+ set_primary_color(("#d20e1e", "#f46762"))
17
+
18
+
14
19
  def orange_primary_color():
15
20
  from .designs.primary_color import set_primary_color
16
21
  set_primary_color(("#c53201", "#fe7e34"))
22
+
23
+
24
+ def yellow_primary_color():
25
+ from .designs.primary_color import set_primary_color
26
+ set_primary_color(("#e19d00", "#ffd52a"))
27
+
28
+
29
+ def green_primary_color():
30
+ from .designs.primary_color import set_primary_color
31
+ set_primary_color(("#0e6d0e", "#45e532"))
32
+
33
+
34
+ def blue_primary_color():
35
+ from .designs.primary_color import set_primary_color
36
+ set_primary_color(("#005fb8", "#60cdff"))
37
+
38
+
39
+ def purple_primary_color():
40
+ from .designs.primary_color import set_primary_color
41
+ set_primary_color(("#4f4dce", "#b5adeb"))
@@ -0,0 +1 @@
1
+ # 这里没什么好东西,请不要在项目中导入,可以自行查看该文件夹中其他demo
@@ -0,0 +1,18 @@
1
+ from tkflu import *
2
+ from pywinstyles import *
3
+
4
+
5
+ root = FluWindow()
6
+
7
+ thememanager = FluThemeManager()
8
+ thememanager.mode("dark")
9
+
10
+ root.dconfigure(back_color="#000000")
11
+
12
+ btn1 = FluButton(root, text="Normal", command=lambda: apply_style(root, "normal"))
13
+ btn1.pack(padx=5, pady=5)
14
+
15
+ btn2 = FluButton(root, text="Acrylic", command=lambda: apply_style(root, "acrylic"))
16
+ btn2.pack(padx=5, pady=5)
17
+
18
+ root.mainloop()
tkflu/demos/tooltip.py ADDED
@@ -0,0 +1,13 @@
1
+ from tkflu import *
2
+
3
+
4
+ root = FluWindow()
5
+
6
+ thememanager = FluThemeManager(root, mode="dark")
7
+
8
+ button = FluButton(root, text="Click me", command=lambda: print("Clicked"), style="standard")
9
+ button.pack()
10
+
11
+ tooltip = FluToolTip(button, text="This is a tooltip")
12
+
13
+ root.mainloop()
@@ -0,0 +1,253 @@
1
+ from .primary_color import get_primary_color
2
+
3
+
4
+ def slider(mode: str, state: str):
5
+ mode = mode.lower()
6
+ state = state.lower()
7
+
8
+ if mode == "light":
9
+ if state == "rest":
10
+ return {
11
+ "radius": 2,
12
+ "thumb": {
13
+ "radius": 12,
14
+ "inner_radius": 6,
15
+
16
+ "back_color": "#FFFFFF",
17
+ "back_opacity": 1,
18
+
19
+ "border_color": "#000000",
20
+ "border_color_opacity": 0.058824,
21
+
22
+ "border_color2": "#000000",
23
+ "border_color2_opacity": 0.160784,
24
+
25
+ "inner_back_color": get_primary_color()[0],
26
+ "inner_back_opacity": 1,
27
+ },
28
+ "track": {
29
+ "width": 4,
30
+
31
+ "back_color": get_primary_color()[0],
32
+ "back_opacity": 1
33
+ },
34
+ "rail": {
35
+ "back_color": "#000000",
36
+ "back_opacity": 0.445800
37
+ }
38
+ }
39
+ elif state == "hover":
40
+ return {
41
+ "radius": 2,
42
+ "thumb": {
43
+ "radius": 12,
44
+ "inner_radius": 8,
45
+
46
+ "back_color": "#FFFFFF",
47
+ "back_opacity": 1,
48
+
49
+ "border_color": "#000000",
50
+ "border_color_opacity": 0.058824,
51
+
52
+ "border_color2": "#000000",
53
+ "border_color2_opacity": 0.160784,
54
+
55
+ "inner_back_color": get_primary_color()[0],
56
+ "inner_back_opacity": 1,
57
+ },
58
+ "track": {
59
+ "width": 4,
60
+
61
+ "back_color": get_primary_color()[0],
62
+ "back_opacity": 1
63
+ },
64
+ "rail": {
65
+ "back_color": "#000000",
66
+ "back_opacity": 0.445800
67
+ }
68
+ }
69
+ elif state == "pressed":
70
+ return {
71
+ "radius": 2,
72
+ "thumb": {
73
+ "radius": 12,
74
+ "inner_radius": 5,
75
+
76
+ "back_color": "#FFFFFF",
77
+ "back_opacity": 1,
78
+
79
+ "border_color": "#000000",
80
+ "border_color_opacity": 0.058824,
81
+
82
+ "border_color2": "#000000",
83
+ "border_color2_opacity": 0.160784,
84
+
85
+ "inner_back_color": get_primary_color()[0],
86
+ "inner_back_opacity": 0.8,
87
+ },
88
+ "track": {
89
+ "width": 4,
90
+
91
+ "back_color": get_primary_color()[0],
92
+ "back_opacity": 1
93
+ },
94
+ "rail": {
95
+ "back_color": "#000000",
96
+ "back_opacity": 0.445800
97
+ }
98
+ }
99
+ elif state == "disabled":
100
+ return {
101
+ "radius": 2,
102
+ "thumb": {
103
+ "radius": 12,
104
+ "inner_radius": 6,
105
+
106
+ "back_color": "#FFFFFF",
107
+ "back_opacity": 1,
108
+
109
+ "border_color": "#000000",
110
+ "border_color_opacity": 0.058824,
111
+
112
+ "border_color2": "#000000",
113
+ "border_color2_opacity": 0.160784,
114
+
115
+ "inner_back_color": "#000000",
116
+ "inner_back_opacity": 0.317300,
117
+ },
118
+ "track": {
119
+ "width": 4,
120
+
121
+ "back_color": "#000000",
122
+ "back_opacity": 0.216900
123
+ },
124
+ "rail": {
125
+ "back_color": "#000000",
126
+ "back_opacity": 0.317300
127
+ }
128
+ }
129
+ else:
130
+ if state == "rest":
131
+ return {
132
+ "radius": 2,
133
+ "thumb": {
134
+ "radius": 12,
135
+
136
+ "inner_radius": 6,
137
+ "inner_back_color": get_primary_color()[1],
138
+ "inner_back_opacity": 1,
139
+
140
+ "back_color": "#454545",
141
+ "back_opacity": 1,
142
+
143
+ "border_color": "#FFFFFF",
144
+ "border_color_opacity": 0.094118,
145
+
146
+ "border_color2": "#FFFFFF",
147
+ "border_color2_opacity": 0.070588,
148
+
149
+ },
150
+ "track": {
151
+ "width": 4,
152
+
153
+ "back_color": get_primary_color()[1],
154
+ "back_opacity": 1
155
+ },
156
+ "rail": {
157
+ "back_color": "#FFFFFF",
158
+ "back_opacity": 0.544200
159
+ }
160
+ }
161
+ elif state == "hover":
162
+ return {
163
+ "radius": 2,
164
+ "thumb": {
165
+ "radius": 12,
166
+
167
+ "inner_radius": 8,
168
+ "inner_back_color": get_primary_color()[1],
169
+ "inner_back_opacity": 1,
170
+
171
+ "back_color": "#454545",
172
+ "back_opacity": 1,
173
+
174
+ "border_color": "#FFFFFF",
175
+ "border_color_opacity": 0.094118,
176
+
177
+ "border_color2": "#FFFFFF",
178
+ "border_color2_opacity": 0.070588,
179
+
180
+ },
181
+ "track": {
182
+ "width": 4,
183
+
184
+ "back_color": get_primary_color()[1],
185
+ "back_opacity": 1
186
+ },
187
+ "rail": {
188
+ "back_color": "#FFFFFF",
189
+ "back_opacity": 0.544200
190
+ }
191
+ }
192
+ elif state == "pressed":
193
+ return {
194
+ "radius": 2,
195
+ "thumb": {
196
+ "radius": 12,
197
+
198
+ "inner_radius": 5,
199
+ "inner_back_color": get_primary_color()[1],
200
+ "inner_back_opacity": 0.8,
201
+
202
+ "back_color": "#454545",
203
+ "back_opacity": 1,
204
+
205
+ "border_color": "#FFFFFF",
206
+ "border_color_opacity": 0.094118,
207
+
208
+ "border_color2": "#FFFFFF",
209
+ "border_color2_opacity": 0.070588,
210
+
211
+ },
212
+ "track": {
213
+ "width": 4,
214
+
215
+ "back_color": get_primary_color()[1],
216
+ "back_opacity": 1
217
+ },
218
+ "rail": {
219
+ "back_color": "#FFFFFF",
220
+ "back_opacity": 0.544200
221
+ }
222
+ }
223
+ elif state == "disabled":
224
+ return {
225
+ "radius": 2,
226
+ "thumb": {
227
+ "radius": 12,
228
+
229
+ "inner_radius": 6,
230
+ "inner_back_color": "#FFFFFF",
231
+ "inner_back_opacity": 0.158100,
232
+
233
+ "back_color": "#454545",
234
+ "back_opacity": 1,
235
+
236
+ "border_color": "#FFFFFF",
237
+ "border_color_opacity": 0.094118,
238
+
239
+ "border_color2": "#FFFFFF",
240
+ "border_color2_opacity": 0.070588,
241
+
242
+ },
243
+ "track": {
244
+ "width": 4,
245
+
246
+ "back_color": "#FFFFFF",
247
+ "back_opacity": 0.158100
248
+ },
249
+ "rail": {
250
+ "back_color": "#FFFFFF",
251
+ "back_opacity": 0.544200
252
+ }
253
+ }
@@ -0,0 +1,15 @@
1
+ def tooltip(mode):
2
+ if mode.lower() == "light":
3
+ return {
4
+ "back_color": "#e2e2e2",
5
+ "text_color": "#000000",
6
+ "frame_color": "#F9F9F9",
7
+ "frame_border_color": "#ebebeb"
8
+ }
9
+ else:
10
+ return {
11
+ "back_color": "#1a1a1a",
12
+ "text_color": "#ffffff",
13
+ "frame_color": "#2f2f2f",
14
+ "frame_border_color": "#161616"
15
+ }
tkflu/designs/window.py CHANGED
@@ -1,7 +1,7 @@
1
1
  def window(mode):
2
2
  if mode.lower() == "light":
3
3
  return {
4
- "back_color": "#ffffff",
4
+ "back_color": "#f9f9f9",
5
5
  "text_color": "#000000",
6
6
  "closebutton": {
7
7
  "back_color": "#cf392d",
@@ -11,7 +11,7 @@ def window(mode):
11
11
  }
12
12
  else:
13
13
  return {
14
- "back_color": "#202020",
14
+ "back_color": "#282828",
15
15
  "text_color": "#ffffff",
16
16
  "closebutton": {
17
17
  "back_color": "#c42b1c",
tkflu/entry.py CHANGED
@@ -71,7 +71,10 @@ class FluEntryCanvas(DCanvas):
71
71
  create_roundrect = create_round_rectangle
72
72
 
73
73
 
74
- class FluEntry(FluEntryCanvas, DDrawWidget):
74
+ from .tooltip import FluToolTipBase
75
+
76
+
77
+ class FluEntry(FluEntryCanvas, DDrawWidget, FluToolTipBase):
75
78
  def __init__(self, *args,
76
79
  width=120,
77
80
  height=32,
@@ -96,7 +99,7 @@ class FluEntry(FluEntryCanvas, DDrawWidget):
96
99
 
97
100
  super().__init__(*args, width=width, height=height, cursor=cursor, **kwargs)
98
101
 
99
- self.bind("<FocusIn>", self._event_focus_in, add="+")
102
+ self.bind("<Button-1>", lambda e: self.entry.focus_set())
100
103
 
101
104
  self.dconfigure(
102
105
  state=state,
@@ -188,6 +191,8 @@ class FluEntry(FluEntryCanvas, DDrawWidget):
188
191
  height=self.winfo_height() - _border_width * 2 - _radius
189
192
  )
190
193
 
194
+ self.tag_raise(self.element_text)
195
+
191
196
  def _event_focus_in(self, event=None):
192
197
  self.isfocus = True
193
198
 
tkflu/label.py CHANGED
@@ -1,7 +1,8 @@
1
1
  from tkdeft.windows.drawwidget import DDrawWidget
2
+ from .tooltip import FluToolTipBase
2
3
 
3
4
 
4
- class FluLabel(DDrawWidget):
5
+ class FluLabel(DDrawWidget, FluToolTipBase):
5
6
  def __init__(self, *args,
6
7
  text="",
7
8
  width=120,
tkflu/menu.py CHANGED
@@ -1,8 +1,9 @@
1
1
  from .popupmenu import FluPopupMenu
2
2
  from tkdeft.object import DObject
3
+ from .tooltip import FluToolTipBase
3
4
 
4
5
 
5
- class FluMenu(FluPopupMenu):
6
+ class FluMenu(FluPopupMenu, FluToolTipBase):
6
7
  def __init__(self, *args, **kwargs):
7
8
  super().__init__(*args, **kwargs)
8
9
 
@@ -84,19 +85,19 @@ class FluMenu(FluPopupMenu):
84
85
  else:
85
86
  id = widget._w
86
87
 
87
- def command():
88
+ def command(event=None):
88
89
  print(menu._w)
89
- menu.focus_set()
90
90
 
91
91
  menu.popup(widget.winfo_rootx()+widget.winfo_width()+100, widget.winfo_rooty())
92
92
  menu.window.deiconify()
93
93
  menu.window.attributes("-topmost")
94
94
 
95
95
  if hasattr(widget, "dconfigure"):
96
- widget.dconfigure(text=label, command=command)
96
+ widget.dconfigure(text=label)
97
97
  else:
98
98
  if hasattr(widget, "configure"):
99
- widget.configure(text=label, command=command)
99
+ widget.configure(text=label)
100
+ widget.bind("<Enter>", command, add="+")
100
101
  if hasattr(widget, "theme"):
101
102
  widget.theme(style=style)
102
103
 
tkflu/popupwindow.py CHANGED
@@ -2,16 +2,17 @@ from tkinter import Toplevel
2
2
 
3
3
 
4
4
  class FluPopupWindow(Toplevel):
5
- def __init__(self, *args, transparent_color="#ebebeb", mode="light", width=100, height=46, **kwargs):
5
+ def __init__(self, *args, transparent_color="#ebebeb", mode="light", width=100, height=46, custom=True, **kwargs):
6
6
  super().__init__(*args, background=transparent_color, **kwargs)
7
7
 
8
8
  self.theme(mode=mode)
9
9
 
10
10
  self.geometry(f"{width}x{height}")
11
11
 
12
- self.transient_color = transparent_color
13
- self.overrideredirect(True)
14
- self.attributes("-transparentcolor", transparent_color)
12
+ if custom:
13
+ self.transient_color = transparent_color
14
+ self.overrideredirect(True)
15
+ self.wm_attributes("-transparentcolor", transparent_color)
15
16
 
16
17
  self.withdraw()
17
18
 
@@ -22,6 +23,7 @@ class FluPopupWindow(Toplevel):
22
23
 
23
24
  def popup(self, x, y):
24
25
  self.geometry(f"+{x}+{y}")
26
+ #self.focus_set()
25
27
 
26
28
  def theme(self, mode=None):
27
29
  if mode: