tkfluent 0.1.4__py3-none-any.whl → 0.1.6__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 +1 -0
- tkflu/__main__.py +32 -18
- tkflu/badge.py +12 -4
- tkflu/button.py +12 -3
- tkflu/bwm.py +10 -0
- tkflu/demos/demo.py +137 -0
- tkflu/demos/designer.py +19 -4
- tkflu/demos/screenshot.py +8 -0
- tkflu/demos/scroll.py +19 -0
- tkflu/designs/__init__.py +4 -1
- tkflu/designs/animation.py +2 -2
- tkflu/designs/button.py +4 -4
- tkflu/designs/design.py +20 -0
- tkflu/designs/fonts/__init__.py +16 -1
- tkflu/designs/fonts/segoe_fluent_icons.ttf +0 -0
- tkflu/designs/frame.py +2 -2
- tkflu/designs/menubar.py +2 -0
- tkflu/designs/renderer.py +19 -0
- tkflu/designs/scrollbar.py +17 -39
- tkflu/designs/text.py +5 -5
- tkflu/designs/window.py +4 -2
- tkflu/entry.py +8 -4
- tkflu/frame.py +3 -2
- tkflu/label.py +11 -8
- tkflu/listbox.py +1 -1
- tkflu/menu.py +13 -13
- tkflu/menubar.py +26 -26
- tkflu/popupmenu.py +1 -1
- tkflu/popupwindow.py +38 -14
- tkflu/scrollbar.py +347 -133
- tkflu/slider.py +113 -66
- tkflu/text.py +20 -12
- tkflu/togglebutton.py +98 -89
- tkflu/tooltip.py +6 -15
- {tkfluent-0.1.4.dist-info → tkfluent-0.1.6.dist-info}/METADATA +7 -4
- tkfluent-0.1.6.dist-info/RECORD +64 -0
- tkfluent-0.1.4.dist-info/RECORD +0 -59
- {tkfluent-0.1.4.dist-info → tkfluent-0.1.6.dist-info}/WHEEL +0 -0
tkflu/slider.py
CHANGED
@@ -82,7 +82,7 @@ class FluSliderCanvas(DCanvas):
|
|
82
82
|
|
83
83
|
def create_track(
|
84
84
|
self,
|
85
|
-
x1, y1, width, height, width2, temppath=None, radius=3,
|
85
|
+
x1, y1, width, height, width2, temppath=None, temppath2=None, radius=3,
|
86
86
|
track_fill="transparent", track_opacity=1,
|
87
87
|
rail_fill="transparent", rail_opacity=1
|
88
88
|
):
|
@@ -91,13 +91,14 @@ class FluSliderCanvas(DCanvas):
|
|
91
91
|
track_fill=track_fill, track_opacity=track_opacity,
|
92
92
|
rail_fill=rail_fill, rail_opacity=rail_opacity
|
93
93
|
)
|
94
|
-
|
94
|
+
from .designs.renderer import get_renderer
|
95
|
+
self._tkimg2 = self.svgdraw.create_svg_image(self._img2, temppath2, way=get_renderer())
|
95
96
|
#print(self._img2)
|
96
97
|
return self.create_image(x1, y1, anchor="nw", image=self._tkimg2)
|
97
98
|
|
98
99
|
def create_thumb(
|
99
100
|
self,
|
100
|
-
x1, y1, width, height, r1, r2, temppath=None,
|
101
|
+
x1, y1, width, height, r1, r2, temppath=None, temppath2=None,
|
101
102
|
fill="transparent", fill_opacity=1,
|
102
103
|
outline="transparent", outline_opacity=1,
|
103
104
|
outline2="transparent", outline2_opacity=1,
|
@@ -110,7 +111,8 @@ class FluSliderCanvas(DCanvas):
|
|
110
111
|
outline2=outline2, outline2_opacity=outline2_opacity,
|
111
112
|
inner_fill=inner_fill, inner_fill_opacity=inner_fill_opacity,
|
112
113
|
)
|
113
|
-
|
114
|
+
from .designs.renderer import get_renderer
|
115
|
+
self._tkimg = self.svgdraw.create_svg_image(self._img, temppath2, way=get_renderer())
|
114
116
|
return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
|
115
117
|
|
116
118
|
|
@@ -119,12 +121,15 @@ class FluSlider(FluSliderCanvas, DDrawWidget):
|
|
119
121
|
text="",
|
120
122
|
width=70,
|
121
123
|
height=28,
|
124
|
+
orient="horizontal",
|
125
|
+
tick=False, # 自动吸附
|
122
126
|
font=None,
|
123
127
|
mode="light",
|
124
128
|
state="normal",
|
125
129
|
value=20,
|
126
130
|
max=100,
|
127
131
|
min=0,
|
132
|
+
changed=None,
|
128
133
|
**kwargs
|
129
134
|
):
|
130
135
|
|
@@ -148,12 +153,17 @@ class FluSlider(FluSliderCanvas, DDrawWidget):
|
|
148
153
|
state=state,
|
149
154
|
value=value,
|
150
155
|
max=max, min=min,
|
156
|
+
orient=orient, tick=tick, changed=changed,
|
151
157
|
)
|
152
158
|
|
159
|
+
|
160
|
+
|
153
161
|
super().__init__(*args, width=width, height=height, **kwargs)
|
154
162
|
|
155
163
|
self.bind("<<Clicked>>", lambda event=None: self.focus_set(), add="+")
|
156
164
|
|
165
|
+
#self.bind("<Left>", lambda event:print("asd1"))
|
166
|
+
|
157
167
|
self.bind("<B1-Motion>", self._event_button1_motion)
|
158
168
|
|
159
169
|
self.enter_thumb = False
|
@@ -168,6 +178,9 @@ class FluSlider(FluSliderCanvas, DDrawWidget):
|
|
168
178
|
{
|
169
179
|
"command": None,
|
170
180
|
"state": None,
|
181
|
+
"orient": "horizontal",
|
182
|
+
"tick": False,
|
183
|
+
"changed": None,
|
171
184
|
|
172
185
|
"value": 20,
|
173
186
|
"max": 100,
|
@@ -250,74 +263,108 @@ class FluSlider(FluSliderCanvas, DDrawWidget):
|
|
250
263
|
_thumb_inner_back_color = _dict.thumb.inner_back_color
|
251
264
|
_thumb_inner_back_opacity = _dict.thumb.inner_back_opacity
|
252
265
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
266
|
+
if self.attributes.orient == "horizontal":
|
267
|
+
thumb_xp = self.attributes.value / (self.attributes.max - self.attributes.min) # 滑块对应数值的比例
|
268
|
+
thumb_x = self.winfo_width() * thumb_xp # 滑块对应数值的x左边
|
269
|
+
|
270
|
+
width = self.winfo_width()
|
271
|
+
height = self.winfo_height()
|
272
|
+
# 修改滑块位置计算
|
273
|
+
thumb_width = _thumb_width
|
274
|
+
min_x = thumb_width / 2
|
275
|
+
max_x = self.winfo_width() - thumb_width / 2
|
276
|
+
track_length = max_x - min_x
|
277
|
+
|
278
|
+
# 计算轨道实际可用宽度(减去滑块宽度)
|
279
|
+
effective_track_width = self.winfo_width() - thumb_width
|
280
|
+
|
281
|
+
thumb_xp = (self.attributes.value - self.attributes.min) / (self.attributes.max - self.attributes.min)
|
282
|
+
thumb_center = thumb_width / 2 + thumb_xp * effective_track_width
|
283
|
+
|
284
|
+
thumb_width = _thumb_width
|
285
|
+
effective_width = self.winfo_width() - thumb_width
|
286
|
+
ratio = (self.attributes.value - self.attributes.min) / (self.attributes.max - self.attributes.min)
|
287
|
+
thumb_left = thumb_width / 2 + ratio * effective_width - thumb_width / 2
|
288
|
+
|
289
|
+
# 确保不会超出右边界
|
290
|
+
thumb_left = min(thumb_left, self.winfo_width() - thumb_width)
|
291
|
+
from .designs.renderer import get_renderer
|
292
|
+
if get_renderer() == 0:
|
293
|
+
# 创建轨道时,width2 参数应为选中部分的宽度(滑块中心位置)
|
294
|
+
self.element_track = self.create_track(
|
295
|
+
_thumb_width / 4,
|
296
|
+
height / 2 - _track_height,
|
297
|
+
self.winfo_width() - _thumb_width / 2,
|
298
|
+
_track_height,
|
299
|
+
thumb_center - _thumb_width / 4, # 关键修正:使用滑块中心相对于轨道起点的距离
|
300
|
+
temppath=self.temppath, temppath2=self.temppath3, radius=_radius,
|
301
|
+
track_fill=_track_back_color, track_opacity=_track_back_opacity,
|
302
|
+
rail_fill=_rail_back_color, rail_opacity=_rail_back_opacity
|
303
|
+
)
|
304
|
+
|
305
|
+
self.element_thumb = self.create_thumb(
|
306
|
+
thumb_left, 0, # 直接使用计算出的左上角位置
|
307
|
+
thumb_width, thumb_width,
|
308
|
+
_thumb_radius, _thumb_inner_radius,
|
309
|
+
temppath=self.temppath2, temppath2=self.temppath4, fill=_thumb_back_color, fill_opacity=_thumb_back_opacity,
|
310
|
+
outline=_thumb_border_color, outline_opacity=_thumb_border_color_opacity,
|
311
|
+
outline2=_thumb_border_color2, outline2_opacity=_thumb_border_color2_opacity,
|
312
|
+
inner_fill=_thumb_inner_back_color, inner_fill_opacity=_thumb_inner_back_opacity,
|
313
|
+
)
|
314
|
+
elif get_renderer() == 1:
|
315
|
+
# 创建轨道时,width2 参数应为选中部分的宽度(滑块中心位置)
|
316
|
+
self.element_track = self.create_track(
|
317
|
+
_thumb_width / 4,
|
318
|
+
height / 2 - _track_height,
|
319
|
+
self.winfo_width() - _thumb_width / 2 - 1,
|
320
|
+
_track_height - 1,
|
321
|
+
thumb_center - _thumb_width / 4, # 关键修正:使用滑块中心相对于轨道起点的距离
|
322
|
+
temppath=self.temppath, temppath2=self.temppath3, radius=_radius,
|
323
|
+
track_fill=_track_back_color, track_opacity=_track_back_opacity,
|
324
|
+
rail_fill=_rail_back_color, rail_opacity=_rail_back_opacity
|
325
|
+
)
|
326
|
+
|
327
|
+
self.element_thumb = self.create_thumb(
|
328
|
+
thumb_left, 0, # 直接使用计算出的左上角位置
|
329
|
+
thumb_width - 3.5, thumb_width - 3.5,
|
330
|
+
_thumb_radius, _thumb_inner_radius,
|
331
|
+
temppath=self.temppath2, temppath2=self.temppath4, fill=_thumb_back_color,
|
332
|
+
fill_opacity=_thumb_back_opacity,
|
333
|
+
outline=_thumb_border_color, outline_opacity=_thumb_border_color_opacity,
|
334
|
+
outline2=_thumb_border_color2, outline2_opacity=_thumb_border_color2_opacity,
|
335
|
+
inner_fill=_thumb_inner_back_color, inner_fill_opacity=_thumb_inner_back_opacity,
|
336
|
+
)
|
289
337
|
|
290
|
-
self.element_thumb = self.create_thumb(
|
291
|
-
thumb_left, 0, # 直接使用计算出的左上角位置
|
292
|
-
thumb_width, thumb_width,
|
293
|
-
_thumb_radius, _thumb_inner_radius,
|
294
|
-
temppath=self.temppath2, fill=_thumb_back_color, fill_opacity=_thumb_back_opacity,
|
295
|
-
outline=_thumb_border_color, outline_opacity=_thumb_border_color_opacity,
|
296
|
-
outline2=_thumb_border_color2, outline2_opacity=_thumb_border_color2_opacity,
|
297
|
-
inner_fill=_thumb_inner_back_color, inner_fill_opacity=_thumb_inner_back_opacity,
|
298
|
-
)
|
299
338
|
|
300
339
|
self._e1 = self.tag_bind(self.element_thumb, "<Enter>", self._event_enter_thumb, add="+")
|
301
340
|
self._e2 = self.tag_bind(self.element_thumb, "<Leave>", self._event_leave_thumb, add="+")
|
302
341
|
|
303
342
|
def pos(self, event):
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
343
|
+
if self.attributes.state == "normal":
|
344
|
+
#print(event.x, event.y)
|
345
|
+
#if self.enter and self.button1:
|
346
|
+
# 获取滑块宽度
|
347
|
+
thumb_width = self.attributes.pressed.thumb.width
|
348
|
+
|
349
|
+
# 计算有效轨道长度
|
350
|
+
effective_width = self.winfo_width() - thumb_width
|
351
|
+
|
352
|
+
# 计算滑块位置比例(考虑滑块宽度边界)
|
353
|
+
ratio = (event.x - thumb_width/2) / effective_width
|
354
|
+
ratio = max(0, min(1, ratio)) # 限制在0-1范围内
|
355
|
+
|
356
|
+
# 计算实际值
|
357
|
+
value = self.attributes.min + ratio * (self.attributes.max - self.attributes.min)
|
358
|
+
if self.attributes.tick:
|
359
|
+
value = round(value)
|
360
|
+
self.dconfigure(value=value)
|
361
|
+
self._draw()
|
362
|
+
#print(self.focus_get())
|
363
|
+
|
364
|
+
def _event_off_button1(self, event=None):
|
365
|
+
if self.attributes.state == "normal":
|
366
|
+
if self.attributes.changed:
|
367
|
+
self.attributes.changed()
|
321
368
|
|
322
369
|
|
323
370
|
def _event_enter_thumb(self, event=None):
|
tkflu/text.py
CHANGED
@@ -55,7 +55,7 @@ class FluTextCanvas(DCanvas):
|
|
55
55
|
draw = FluTextDraw
|
56
56
|
|
57
57
|
def create_round_rectangle(self,
|
58
|
-
x1, y1, x2, y2, r1, r2=None, temppath=None,
|
58
|
+
x1, y1, x2, y2, r1, r2=None, temppath=None, temppath2=None,
|
59
59
|
fill="transparent", fill_opacity=1, stop1="0.93", stop2="0.94",
|
60
60
|
outline="black", outline2="black", outline_opacity=1, outline2_opacity=1,
|
61
61
|
width=1
|
@@ -66,7 +66,8 @@ class FluTextCanvas(DCanvas):
|
|
66
66
|
outline=outline, outline2=outline2, outline_opacity=outline_opacity, outline2_opacity=outline2_opacity,
|
67
67
|
width=width
|
68
68
|
)
|
69
|
-
|
69
|
+
from .designs.renderer import get_renderer
|
70
|
+
self._tkimg = self.svgdraw.create_svg_image(self._img, temppath2, way=get_renderer())
|
70
71
|
return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
|
71
72
|
|
72
73
|
create_roundrect = create_round_rectangle
|
@@ -174,8 +175,14 @@ class FluText(FluTextCanvas, DDrawWidget, FluToolTipBase):
|
|
174
175
|
|
175
176
|
if hasattr(self, "element_border"):
|
176
177
|
self.delete(self.element_border)
|
178
|
+
|
179
|
+
from .designs.renderer import get_renderer
|
180
|
+
if get_renderer() == 1:
|
181
|
+
width -= 1
|
182
|
+
height -= 1
|
183
|
+
|
177
184
|
self.element_border = self.create_round_rectangle(
|
178
|
-
0, 0, width, height, _radius, temppath=self.temppath,
|
185
|
+
0, 0, width, height, _radius, temppath=self.temppath, temppath2=self.temppath3,
|
179
186
|
fill=_back_color, fill_opacity=_back_opacity, stop1=_stop1, stop2=_stop2,
|
180
187
|
outline=_border_color, outline_opacity=_border_color_opacity, outline2=_border_color2,
|
181
188
|
outline2_opacity=_border_color2_opacity,
|
@@ -195,14 +202,7 @@ class FluText(FluTextCanvas, DDrawWidget, FluToolTipBase):
|
|
195
202
|
)
|
196
203
|
self.itemconfigure(self.element_line, width=_underline_width, fill=_underline_fill)
|
197
204
|
"""
|
198
|
-
|
199
|
-
self.delete(self.element_line)
|
200
|
-
if _underline_fill:
|
201
|
-
self.element_line = self.create_line(
|
202
|
-
_radius / 3 + _border_width, self.winfo_height() - _radius / 3,
|
203
|
-
self.winfo_width() - _radius / 3 - _border_width * 2, self.winfo_height() - _radius / 3,
|
204
|
-
width=_underline_width, fill=_underline_fill
|
205
|
-
)
|
205
|
+
|
206
206
|
"""
|
207
207
|
if not hasattr(self, "element_text"):
|
208
208
|
self.element_text = self.create_window(
|
@@ -223,8 +223,16 @@ class FluText(FluTextCanvas, DDrawWidget, FluToolTipBase):
|
|
223
223
|
width=self.winfo_width() - _border_width * 2 - _radius,
|
224
224
|
height=self.winfo_height() - _border_width * 2 - _radius
|
225
225
|
)
|
226
|
+
if hasattr(self, "element_line"):
|
227
|
+
self.delete(self.element_line)
|
228
|
+
if _underline_fill:
|
229
|
+
self.element_line = self.create_line(
|
230
|
+
_radius / 3 + _border_width, self.winfo_height() - _radius / 3,
|
231
|
+
self.winfo_width() - _radius / 3 - _border_width * 2, self.winfo_height() - _radius / 3,
|
232
|
+
width=_underline_width, fill=_underline_fill
|
233
|
+
)
|
226
234
|
self.tag_raise(self.element_text, self.element_border)
|
227
|
-
self.tag_raise(self.element_line, self.
|
235
|
+
#self.tag_raise(self.element_line, self.element_text)
|
228
236
|
|
229
237
|
#self.tag_raise(self.element_text)
|
230
238
|
|
tkflu/togglebutton.py
CHANGED
@@ -43,7 +43,7 @@ class FluToggleButtonCanvas(DCanvas):
|
|
43
43
|
draw = FluToggleButtonDraw
|
44
44
|
|
45
45
|
def create_round_rectangle_with_text(self,
|
46
|
-
x1, y1, x2, y2, r1, r2=None, temppath=None,
|
46
|
+
x1, y1, x2, y2, r1, r2=None, temppath=None, temppath2=None,
|
47
47
|
fill="transparent", fill_opacity=1,
|
48
48
|
outline="black", outline2="black", outline_opacity=1, outline2_opacity=1,
|
49
49
|
width=1,
|
@@ -54,7 +54,8 @@ class FluToggleButtonCanvas(DCanvas):
|
|
54
54
|
outline=outline, outline2=outline2, outline_opacity=outline_opacity, outline2_opacity=outline2_opacity,
|
55
55
|
width=width,
|
56
56
|
)
|
57
|
-
|
57
|
+
from .designs.renderer import get_renderer
|
58
|
+
self._tkimg = self.svgdraw.create_svg_image(self._img, temppath2, way=get_renderer())
|
58
59
|
return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
|
59
60
|
|
60
61
|
create_roundrect = create_round_rectangle_with_text
|
@@ -91,9 +92,9 @@ class FluToggleButton(FluToggleButtonCanvas, DDrawWidget, FluToolTipBase, FluGra
|
|
91
92
|
|
92
93
|
self.bind("<<Clicked>>", lambda event=None: self.toggle(), add="+")
|
93
94
|
self.bind("<<Clicked>>", lambda event=None: self.focus_set(), add="+")
|
94
|
-
self.bind("<<Clicked>>", lambda event=None: self.
|
95
|
+
self.bind("<<Clicked>>", lambda event=None: self.invoke(), add="+")
|
95
96
|
|
96
|
-
self.bind("<Return>", lambda event=None: self.
|
97
|
+
self.bind("<Return>", lambda event=None: self.invoke(), add="+") # 可以使用回车键模拟点击
|
97
98
|
self.bind("<Return>", lambda event=None: self.toggle(), add="+") # 可以使用回车键模拟点击
|
98
99
|
|
99
100
|
from .defs import set_default_font
|
@@ -174,8 +175,13 @@ class FluToggleButton(FluToggleButtonCanvas, DDrawWidget, FluToolTipBase, FluGra
|
|
174
175
|
_radius = tempcolor.radius
|
175
176
|
_text_color = tempcolor.text_color
|
176
177
|
|
178
|
+
from .designs.renderer import get_renderer
|
179
|
+
if get_renderer() == 1:
|
180
|
+
width -= 1
|
181
|
+
height -= 1
|
182
|
+
|
177
183
|
self.element_border = self.create_round_rectangle_with_text(
|
178
|
-
0, 0, width, height, _radius, temppath=self.temppath,
|
184
|
+
0, 0, width, height, _radius, temppath=self.temppath, temppath2=self.temppath3,
|
179
185
|
fill=_back_color, fill_opacity=_back_opacity,
|
180
186
|
outline=_border_color, outline_opacity=_border_color_opacity, outline2=_border_color2,
|
181
187
|
outline2_opacity=_border_color2_opacity,
|
@@ -389,91 +395,94 @@ class FluToggleButton(FluToggleButtonCanvas, DDrawWidget, FluToolTipBase, FluGra
|
|
389
395
|
)
|
390
396
|
|
391
397
|
def invoke(self):
|
392
|
-
self.attributes.
|
398
|
+
if self.attributes.state == "normal":
|
399
|
+
self.attributes.command()
|
393
400
|
|
394
401
|
def toggle(self, animation_steps: int = None, animation_step_time: int = None):
|
395
|
-
if
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
uncheck.pressed.border_color2
|
407
|
-
|
408
|
-
check.pressed.border_color2
|
409
|
-
|
410
|
-
uncheck.pressed.border_color2_opacity
|
411
|
-
|
412
|
-
check.pressed.border_color2_opacity
|
413
|
-
|
414
|
-
self.attributes.checked
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
border_colors = self.generate_hex2hex(
|
419
|
-
check.pressed.border_color, uncheck.rest.border_color, steps
|
420
|
-
)
|
421
|
-
border_colors2 = self.generate_hex2hex(
|
422
|
-
check.pressed.border_color2, uncheck.rest.border_color2, steps
|
423
|
-
)
|
424
|
-
text_colors = self.generate_hex2hex(
|
425
|
-
check.pressed.text_color, uncheck.rest.text_color, steps
|
426
|
-
)
|
427
|
-
import numpy as np
|
428
|
-
back_opacitys = np.linspace(
|
429
|
-
float(check.pressed.back_opacity), float(uncheck.rest.back_opacity), steps).tolist()
|
430
|
-
border_color_opacitys = np.linspace(
|
431
|
-
float(check.pressed.border_color_opacity), float(uncheck.rest.border_color_opacity), steps).tolist()
|
432
|
-
border_color2_opacitys = np.linspace(
|
433
|
-
float(check.pressed.border_color2_opacity), float(uncheck.rest.border_color2_opacity), steps).tolist()
|
434
|
-
else:
|
435
|
-
self.attributes.checked = True
|
436
|
-
back_colors = self.generate_hex2hex(
|
437
|
-
uncheck.pressed.back_color, check.rest.back_color, steps
|
438
|
-
)
|
439
|
-
border_colors = self.generate_hex2hex(
|
440
|
-
uncheck.pressed.back_color, check.rest.back_color, steps
|
441
|
-
)
|
442
|
-
border_colors2 = self.generate_hex2hex(
|
443
|
-
uncheck.pressed.border_color2, check.rest.border_color2, steps
|
444
|
-
)
|
445
|
-
text_colors = self.generate_hex2hex(
|
446
|
-
uncheck.pressed.text_color, check.rest.text_color, steps
|
447
|
-
)
|
448
|
-
import numpy as np
|
449
|
-
back_opacitys = np.linspace(float(uncheck.pressed.back_opacity), float(check.rest.back_opacity),
|
450
|
-
steps).tolist()
|
451
|
-
border_color_opacitys = np.linspace(float(uncheck.pressed.border_color_opacity), float(check.rest.border_color_opacity),
|
452
|
-
steps).tolist()
|
453
|
-
border_color2_opacitys = np.linspace(float(uncheck.pressed.border_color2_opacity),
|
454
|
-
float(check.rest.border_color2_opacity),
|
455
|
-
steps).tolist()
|
456
|
-
for i in range(steps):
|
457
|
-
def update(ii=i):
|
458
|
-
from easydict import EasyDict
|
459
|
-
tempcolor = EasyDict(
|
460
|
-
{
|
461
|
-
"back_color": back_colors[ii],
|
462
|
-
"back_opacity": back_opacitys[ii],
|
463
|
-
"border_color": border_colors[ii],
|
464
|
-
"border_color_opacity": str(border_color_opacitys[ii]),
|
465
|
-
"border_color2": border_colors2[ii],
|
466
|
-
"border_color2_opacity": str(border_color2_opacitys[ii]),
|
467
|
-
"border_width": 1,
|
468
|
-
"text_color": text_colors[ii],
|
469
|
-
"radius": 6,
|
470
|
-
}
|
402
|
+
if self.attributes.state == "normal":
|
403
|
+
if animation_steps is None:
|
404
|
+
from .designs.animation import get_animation_steps
|
405
|
+
animation_steps = get_animation_steps()
|
406
|
+
if animation_step_time is None:
|
407
|
+
from .designs.animation import get_animation_step_time
|
408
|
+
animation_step_time = get_animation_step_time()
|
409
|
+
check = self.attributes.check
|
410
|
+
uncheck = self.attributes.uncheck
|
411
|
+
if not animation_steps == 0 or not animation_step_time == 0:
|
412
|
+
steps = animation_steps
|
413
|
+
if uncheck.pressed.border_color2 is None:
|
414
|
+
uncheck.pressed.border_color2 = uncheck.pressed.border_color
|
415
|
+
if check.pressed.border_color2 is None:
|
416
|
+
check.pressed.border_color2 = check.pressed.border_color
|
417
|
+
if uncheck.pressed.border_color2_opacity is None:
|
418
|
+
uncheck.pressed.border_color2_opacity = uncheck.pressed.border_color_opacity
|
419
|
+
if check.pressed.border_color2_opacity is None:
|
420
|
+
check.pressed.border_color2_opacity = check.pressed.border_color_opacity
|
421
|
+
if self.attributes.checked:
|
422
|
+
self.attributes.checked = False
|
423
|
+
back_colors = self.generate_hex2hex(
|
424
|
+
check.pressed.back_color, uncheck.rest.back_color, steps
|
471
425
|
)
|
472
|
-
self.
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
426
|
+
border_colors = self.generate_hex2hex(
|
427
|
+
check.pressed.border_color, uncheck.rest.border_color, steps
|
428
|
+
)
|
429
|
+
border_colors2 = self.generate_hex2hex(
|
430
|
+
check.pressed.border_color2, uncheck.rest.border_color2, steps
|
431
|
+
)
|
432
|
+
text_colors = self.generate_hex2hex(
|
433
|
+
check.pressed.text_color, uncheck.rest.text_color, steps
|
434
|
+
)
|
435
|
+
import numpy as np
|
436
|
+
back_opacitys = np.linspace(
|
437
|
+
float(check.pressed.back_opacity), float(uncheck.rest.back_opacity), steps).tolist()
|
438
|
+
border_color_opacitys = np.linspace(
|
439
|
+
float(check.pressed.border_color_opacity), float(uncheck.rest.border_color_opacity), steps).tolist()
|
440
|
+
border_color2_opacitys = np.linspace(
|
441
|
+
float(check.pressed.border_color2_opacity), float(uncheck.rest.border_color2_opacity), steps).tolist()
|
442
|
+
else:
|
443
|
+
self.attributes.checked = True
|
444
|
+
back_colors = self.generate_hex2hex(
|
445
|
+
uncheck.pressed.back_color, check.rest.back_color, steps
|
446
|
+
)
|
447
|
+
border_colors = self.generate_hex2hex(
|
448
|
+
uncheck.pressed.back_color, check.rest.back_color, steps
|
449
|
+
)
|
450
|
+
border_colors2 = self.generate_hex2hex(
|
451
|
+
uncheck.pressed.border_color2, check.rest.border_color2, steps
|
452
|
+
)
|
453
|
+
text_colors = self.generate_hex2hex(
|
454
|
+
uncheck.pressed.text_color, check.rest.text_color, steps
|
455
|
+
)
|
456
|
+
import numpy as np
|
457
|
+
back_opacitys = np.linspace(float(uncheck.pressed.back_opacity), float(check.rest.back_opacity),
|
458
|
+
steps).tolist()
|
459
|
+
border_color_opacitys = np.linspace(float(uncheck.pressed.border_color_opacity), float(check.rest.border_color_opacity),
|
460
|
+
steps).tolist()
|
461
|
+
border_color2_opacitys = np.linspace(float(uncheck.pressed.border_color2_opacity),
|
462
|
+
float(check.rest.border_color2_opacity),
|
463
|
+
steps).tolist()
|
464
|
+
for i in range(steps):
|
465
|
+
def update(ii=i):
|
466
|
+
from easydict import EasyDict
|
467
|
+
tempcolor = EasyDict(
|
468
|
+
{
|
469
|
+
"back_color": back_colors[ii],
|
470
|
+
"back_opacity": back_opacitys[ii],
|
471
|
+
"border_color": border_colors[ii],
|
472
|
+
"border_color_opacity": str(border_color_opacitys[ii]),
|
473
|
+
"border_color2": border_colors2[ii],
|
474
|
+
"border_color2_opacity": str(border_color2_opacitys[ii]),
|
475
|
+
"border_width": 1,
|
476
|
+
"text_color": text_colors[ii],
|
477
|
+
"radius": 6,
|
478
|
+
}
|
479
|
+
)
|
480
|
+
self._draw(None, tempcolor)
|
481
|
+
self.after(i*animation_step_time, update)
|
482
|
+
self.after(steps*animation_step_time+10, lambda: self._draw(None, None))
|
478
483
|
else:
|
479
|
-
self.attributes.checked
|
484
|
+
if self.attributes.checked:
|
485
|
+
self.attributes.checked = False
|
486
|
+
else:
|
487
|
+
self.attributes.checked = True
|
488
|
+
self._draw()
|
tkflu/tooltip.py
CHANGED
@@ -5,7 +5,7 @@ import sys
|
|
5
5
|
|
6
6
|
class FluToolTip(FluPopupWindow):
|
7
7
|
def __init__(self, widget: Widget, text, mode="light", delay=400, show_time=100.0, *args, **kwargs):
|
8
|
-
super().__init__(*args,
|
8
|
+
super().__init__(*args, **kwargs)
|
9
9
|
|
10
10
|
from .label import FluLabel
|
11
11
|
from .frame import FluFrame
|
@@ -37,18 +37,6 @@ class FluToolTip(FluPopupWindow):
|
|
37
37
|
round(self._widget.winfo_rootx() + self._widget.winfo_width() / 2 - self.winfo_width() / 2),
|
38
38
|
round(self._widget.winfo_rooty() + self._widget.winfo_height() + 2)
|
39
39
|
)
|
40
|
-
self.wm_attributes("-alpha", 0.0)
|
41
|
-
self.deiconify()
|
42
|
-
|
43
|
-
def fade_in(step=0):
|
44
|
-
FRAMES_COUNT = 20
|
45
|
-
alpha = step / FRAMES_COUNT # 按帧数变化,从0到1
|
46
|
-
self.wm_attributes("-alpha", alpha)
|
47
|
-
if step < FRAMES_COUNT:
|
48
|
-
# 每执行一次,增加一次透明度,间隔由帧数决定
|
49
|
-
self.after(int(round(self._show_time/FRAMES_COUNT)), lambda: fade_in(step + 1))
|
50
|
-
|
51
|
-
fade_in() # 启动动画
|
52
40
|
|
53
41
|
self.id = self.after(self._delay, check)
|
54
42
|
self._enter = True
|
@@ -81,7 +69,7 @@ class FluToolTip(FluPopupWindow):
|
|
81
69
|
|
82
70
|
class FluToolTip2(FluPopupWindow):
|
83
71
|
def __init__(self, widget, text, mode="light", *args, **kwargs):
|
84
|
-
super().__init__(*args,
|
72
|
+
super().__init__(*args, **kwargs)
|
85
73
|
|
86
74
|
from .label import FluLabel
|
87
75
|
from .frame import FluFrame
|
@@ -104,6 +92,9 @@ class FluToolTip2(FluPopupWindow):
|
|
104
92
|
|
105
93
|
self.theme(mode)
|
106
94
|
|
95
|
+
def popup2(self, x, y):
|
96
|
+
self.geometry(f"+{x}+{y}")
|
97
|
+
|
107
98
|
def show(self, event: Event):
|
108
99
|
self.popup(
|
109
100
|
round(event.x_root - self.winfo_width() / 2),
|
@@ -115,7 +106,7 @@ class FluToolTip2(FluPopupWindow):
|
|
115
106
|
self.withdraw()
|
116
107
|
|
117
108
|
def move(self, event):
|
118
|
-
self.
|
109
|
+
self.popup2(
|
119
110
|
round(event.x_root - self.winfo_width() / 2),
|
120
111
|
round(event.y_root + 10)
|
121
112
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: tkfluent
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.6
|
4
4
|
Summary: Fluent(SunValley) Design for Tkinter. Modern GUI
|
5
5
|
License: GPL-3.0
|
6
6
|
Keywords: tkfluent,tksvg,tkinter,fluent,modern,GUI,interface
|
@@ -30,17 +30,20 @@ Requires-Dist: easydict (>=1.13,<2.0)
|
|
30
30
|
Requires-Dist: numpy
|
31
31
|
Requires-Dist: pillow (>=10.2.0,<11.0.0)
|
32
32
|
Requires-Dist: svgwrite (>=1.4.3,<2.0.0)
|
33
|
-
Requires-Dist: tkdeft (==0.1.
|
33
|
+
Requires-Dist: tkdeft (==0.1.2)
|
34
34
|
Requires-Dist: tkextrafont (>=0.6.3,<0.7.0)
|
35
35
|
Requires-Dist: tksvg (>=0.7.4,<0.8.0)
|
36
36
|
Project-URL: Documentation, https://tkfluent.netlify.app
|
37
37
|
Description-Content-Type: text/markdown
|
38
38
|
|
39
|
-
|
39
|
+
<div align="center">
|
40
40
|
|
41
|
+
# tkfluent
|
41
42
|
`tkinter`现代化组件库。设计来于`Fluent` `WinUI3` 设计
|
42
43
|
|
43
|
-
|
44
|
+
</div>
|
45
|
+
|
46
|
+
|
44
47
|

|
45
48
|

|
46
49
|
|