tkfluent 0.1.2__py3-none-any.whl → 0.1.4__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
@@ -1,9 +1,11 @@
1
- """
1
+ """
2
2
 
3
3
  Fluent设计的tkinter组件库(模板)
4
4
 
5
5
  -------------
6
6
  作者:XiangQinxi
7
+
8
+ 贡献者:totowang-hhh
7
9
  -------------
8
10
  """
9
11
 
tkflu/__main__.py CHANGED
@@ -2,9 +2,9 @@ from tkflu import *
2
2
  from tkinter import *
3
3
  from tkinter.font import *
4
4
 
5
- orange_primary_color()
5
+ purple_primary_color()
6
6
  set_animation_steps(10)
7
- set_animation_step_time(20)
7
+ set_animation_step_time(12)
8
8
 
9
9
  def togglestate():
10
10
  if button1.dcget("state") == NORMAL:
@@ -23,7 +23,7 @@ def togglestate():
23
23
  entry1._draw()
24
24
  root = FluWindow()
25
25
  #root.wincustom(way=0)
26
- root.geometry("360x600")
26
+ root.geometry("360x650")
27
27
 
28
28
  popupmenu = FluPopupMenu()
29
29
 
@@ -108,7 +108,7 @@ entry1.pack(fill="x", padx=5, pady=5)
108
108
  text1 = FluText(frame)
109
109
  text1.pack(fill="x", padx=5, pady=5)
110
110
 
111
- slider1 = FluSlider(frame, value=0)
111
+ slider1 = FluSlider(frame, value=0, max=200)
112
112
  slider1.pack(fill="x", padx=5, pady=5)
113
113
 
114
114
  """listbox1 = FluListBox(frame)
@@ -116,5 +116,8 @@ listbox1.dconfigure()
116
116
  listbox1.pack(fill="x", padx=5, pady=5)"""
117
117
 
118
118
  frame.pack(fill="both", expand="yes", side="right", padx=15, pady=15)
119
- frame.update_idletasks()
119
+ #frame.update_idletasks()
120
+
121
+ #thememanager.mode("light")
122
+
120
123
  root.mainloop()
tkflu/button.py CHANGED
@@ -4,13 +4,39 @@ from tkdeft.windows.drawwidget import DDrawWidget
4
4
 
5
5
  from .designs.button import button
6
6
 
7
+ from typing import Union
8
+
7
9
 
8
10
  class FluButtonDraw(DSvgDraw):
9
11
  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
- ):
12
+ x1: Union[int, float], y1: Union[int, float], x2: Union[int, float], y2: Union[int, float],
13
+ radius: Union[int, float], radiusy: Union[int, float] = None, temppath: Union[str, None] = None,
14
+ fill: Union[str, tuple]="transparent", fill_opacity: Union[int, float]=1,
15
+ outline: Union[str, tuple] = "black", outline2: Union[str, tuple] = None,
16
+ outline_opacity: Union[int, float] = 1, outline2_opacity: Union[int, float] = 1, width: Union[int, float] = 1,
17
+ ) -> str:
18
+ """
19
+ 用于生成svg圆角矩形图片,图片默认将会保存至临时文件夹。
20
+
21
+ Parameters:
22
+ x1: 第一个x轴的坐标
23
+ y1: 第一个y轴的坐标
24
+ x2: 第二个x轴的坐标,与x1连起来
25
+ y2: 第二个y轴的坐标,与y1连起来
26
+ radius: 圆角大小
27
+ radiusy: 圆角大小(y轴方向),如果不设置,将默认为参数radius的值
28
+ temppath: 临时文件地址,如果你不知道,就别设置
29
+ fill: 背景颜色
30
+ fill_opacity: 背景透明度
31
+ outline: 边框颜色
32
+ outline2: 边框颜色2(渐变),如果取了这个值,边框将会变为渐变,从左到右,outline为第一个渐变色,outline2为第二个渐变色
33
+ outline_opacity: 边框透明度
34
+ outline2_opacity: 第二个边框渐变颜色的透明度,如果outline没有设置,则这个值不会被用到
35
+ width: 边框宽度
36
+
37
+ Returns:
38
+ svg图片保存地址
39
+ """
14
40
  if radiusy:
15
41
  _rx = radius
16
42
  _ry = radiusy
@@ -19,9 +45,9 @@ class FluButtonDraw(DSvgDraw):
19
45
  drawing = self.create_drawing(x2 - x1, y2 - y1, temppath=temppath)
20
46
  if outline2:
21
47
  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)
48
+ gradientUnits="userSpaceOnUse") # 渐变色配置
49
+ border.add_stop_color("0.9", outline, outline_opacity) # 第一个渐变色的位置、第一个渐变色、第一个渐变色的透明度
50
+ border.add_stop_color("1", outline2, outline2_opacity) # 第二个渐变色的位置、第二个渐变色、第二个渐变色的透明度
25
51
  drawing[1].defs.add(border)
26
52
  stroke = f"url(#{border.get_id()})"
27
53
  stroke_opacity = 1
@@ -41,41 +67,80 @@ class FluButtonDraw(DSvgDraw):
41
67
 
42
68
 
43
69
  class FluButtonCanvas(DCanvas):
44
- draw = FluButtonDraw
70
+
71
+ draw = FluButtonDraw # 设置svg绘图引擎
45
72
 
46
73
  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
- ):
74
+ x1: Union[int, float], y1: Union[int, float], x2: Union[int, float], y2: Union[int, float],
75
+ r1: Union[int, float], r2: Union[int, float] = None, temppath: Union[str, None] = None,
76
+ fill: Union[str, tuple]="transparent", fill_opacity: Union[int, float] = 1,
77
+ outline: Union[str, tuple] = "black", outline2: Union[str, tuple] = "black",
78
+ outline_opacity: Union[int, float] = 1, outline2_opacity: Union[int, float] = 1,
79
+ width: Union[int, float] = 1, *args, **kwargs
80
+ ) -> int:
81
+ """
82
+ 在画布上创建个圆角矩形
83
+
84
+ Parameters:
85
+ x1: 第一个x轴的坐标
86
+ y1: 第一个y轴的坐标
87
+ x2: 第二个x轴的坐标,与x1连起来
88
+ y2: 第二个y轴的坐标,与y1连起来
89
+ r1: 圆角大小
90
+ r2: 圆角大小(y轴方向),如果不设置,将默认为参数r1的值
91
+ temppath: 临时文件地址,如果你不知道,就别设置
92
+ fill: 背景颜色
93
+ fill_opacity: 背景透明度
94
+ outline: 边框颜色
95
+ outline2: 边框颜色2(渐变),如果取了这个值,边框将会变为渐变,从左到右,outline为第一个渐变色,outline2为第二个渐变色
96
+ outline_opacity: 边框透明度
97
+ outline2_opacity: 第二个边框渐变颜色的透明度,如果outline没有设置,则这个值不会被用到
98
+ width: 边框宽度
99
+
100
+ Returns: svg图片保存地址
101
+ """
52
102
  self._img = self.svgdraw.create_roundrect(
53
103
  x1, y1, x2, y2, r1, r2, temppath=temppath,
54
104
  fill=fill, fill_opacity=fill_opacity,
55
105
  outline=outline, outline2=outline2, outline_opacity=outline_opacity, outline2_opacity=outline2_opacity,
56
106
  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)
107
+ ) # 创建个svg圆角矩形图片
108
+ self._tkimg = self.svgdraw.create_tksvg_image(self._img) # 用tksvg读取svg图片
109
+ return self.create_image(x1, y1, anchor="nw", image=self._tkimg, *args, **kwargs) # 在画布上创建个以svg图片为图片的元件
60
110
 
61
- create_roundrect = create_round_rectangle
111
+ create_roundrect = create_round_rectangle # 缩写
62
112
 
63
113
 
64
114
  from .constants import MODE, STATE, BUTTONSTYLE
65
115
  from .tooltip import FluToolTipBase
66
116
  from .designs.gradient import FluGradient
117
+ from tkinter import Event
118
+ from tkinter.font import Font
67
119
 
68
120
  class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
69
121
  def __init__(self, *args,
70
- text="",
71
- width=120,
72
- height=32,
73
- command=None,
74
- font=None,
122
+ text: Union[str, int, float]= "",
123
+ width: Union[int, float] = 120,
124
+ height: Union[int, float] = 32,
125
+ command: callable = None,
126
+ font: Union[Font, tuple] = None,
75
127
  mode: MODE = "light",
76
128
  style: BUTTONSTYLE = "standard",
77
129
  state: STATE = "normal",
78
- **kwargs):
130
+ **kwargs) -> None:
131
+ """
132
+ 按钮组件
133
+
134
+ Parameters:
135
+ text: 按钮的标签文本
136
+ width: 默认宽带
137
+ height: 默认高度
138
+ command: 点击时出发的事件
139
+ font: 自定义标签字体
140
+ mode: 按钮深浅主题,参考tkflu.constants.MODE
141
+ style: 按钮样式,参考tkflu.constants.BUTTONSTYLE
142
+ state: 按钮的状态,参考tkflu.constants.STATE
143
+ """
79
144
  self._init(mode, style)
80
145
 
81
146
  super().__init__(*args, width=width, height=height, **kwargs)
@@ -101,6 +166,14 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
101
166
 
102
167
  def _init(self, mode: MODE, style: BUTTONSTYLE):
103
168
 
169
+ """
170
+ 初始化按钮,正常情况下无需在程序中调用
171
+
172
+ Parameters:
173
+ mode: 按钮深浅主题,参考tkflu.constants.MODE
174
+ style: 按钮样式,参考tkflu.constants.BUTTONSTYLE
175
+ """
176
+
104
177
  from easydict import EasyDict
105
178
 
106
179
  self.enter = False
@@ -122,13 +195,17 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
122
195
 
123
196
  self.theme(mode=mode, style=style)
124
197
 
125
- def _draw(self, event=None, tempcolor: dict = None):
198
+ def _draw(self, event: Union[Event, None] = None, tempcolor: Union[dict, None] = None):
199
+ """
200
+
201
+ Parameters:
202
+ 绘制按钮
203
+ """
126
204
  super()._draw(event)
127
205
 
128
206
  width = self.winfo_width()
129
207
  height = self.winfo_height()
130
-
131
- self.delete("all")
208
+ # 提前定义,反正多次调用浪费资源
132
209
 
133
210
  state = self.dcget("state")
134
211
 
@@ -166,6 +243,9 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
166
243
  _radius = tempcolor.radius
167
244
  _text_color = tempcolor.text_color
168
245
 
246
+ if hasattr(self, "element_border"):
247
+ self.delete(self.element_border)
248
+
169
249
  self.element_border = self.create_round_rectangle(
170
250
  0, 0, width, height, _radius, temppath=self.temppath,
171
251
  fill=_back_color, fill_opacity=_back_opacity,
@@ -174,10 +254,15 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
174
254
  width=_border_width,
175
255
  )
176
256
 
177
- self.element_text = self.create_text(
178
- self.winfo_width() / 2, self.winfo_height() / 2, anchor="center",
179
- fill=_text_color, text=self.attributes.text, font=self.attributes.font
180
- )
257
+ if hasattr(self, "element_text"):
258
+ self.itemconfigure(self.element_text, fill=_text_color, text=self.attributes.text, font=self.attributes.font)
259
+ self.coords(self.element_text, width / 2, height / 2)
260
+ else:
261
+ self.element_text = self.create_text(
262
+ width / 2, height / 2, anchor="center",
263
+ fill=_text_color, text=self.attributes.text, font=self.attributes.font
264
+ )
265
+ self.tag_raise(self.element_text, self.element_border)
181
266
 
182
267
  self.update()
183
268
 
@@ -186,7 +271,17 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
186
271
  self.mode = mode
187
272
  if style:
188
273
  self.style = style
189
- if self.mode.lower() == "dark":
274
+ theme_handlers = {
275
+ ("light", "accent"): self._light_accent,
276
+ ("light", "menu"): self._light_menu,
277
+ ("light", "standard"): self._light,
278
+ ("dark", "accent"): self._dark_accent,
279
+ ("dark", "menu"): self._dark_menu,
280
+ ("dark", "standard"): self._dark,
281
+ }
282
+ handler = theme_handlers.get((self.mode.lower(), self.style.lower()))
283
+ handler()
284
+ """if self.mode.lower() == "dark":
190
285
  if self.style.lower() == "accent":
191
286
  self._dark_accent()
192
287
  elif self.style.lower() == "menu":
@@ -199,9 +294,9 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
199
294
  elif self.style.lower() == "menu":
200
295
  self._light_menu()
201
296
  else:
202
- self._light()
297
+ self._light()"""
203
298
 
204
- def _theme(self, mode, style, animation_steps: int = None, animation_step_time: int = None):
299
+ def _theme(self, mode: MODE, style: BUTTONSTYLE, animation_steps: int = None, animation_step_time: int = None):
205
300
  if animation_steps is None:
206
301
  from .designs.animation import get_animation_steps
207
302
  animation_steps = get_animation_steps()
@@ -212,66 +307,67 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
212
307
  h = button(mode, style, "hover")
213
308
  p = button(mode, style, "pressed")
214
309
  d = button(mode, style, "disabled")
215
- if self.dcget("state") == "normal":
216
- if self.enter:
217
- if self.button1:
218
- now = p
310
+ if not animation_steps == 0 or not animation_step_time == 0:
311
+ if self.dcget("state") == "normal":
312
+ if self.enter:
313
+ if self.button1:
314
+ now = p
315
+ else:
316
+ now = h
219
317
  else:
220
- now = h
318
+ now = r
221
319
  else:
222
- now = r
223
- else:
224
- now = d
225
- #print(animation_step_time)
226
- #print(type(animation_step_time))
227
- if hasattr(self.attributes.rest, "back_color"):
228
- back_colors = self.generate_hex2hex(
229
- self.attributes.rest.back_color, now["back_color"], animation_steps
230
- )
231
- border_colors = self.generate_hex2hex(
232
- self.attributes.rest.border_color, now["border_color"], animation_steps
233
- )
234
- if self.attributes.rest.border_color2 is None:
235
- self.attributes.rest.border_color2 = self.attributes.rest.border_color
236
- if now["border_color2"] is None:
237
- now["border_color2"] = now["border_color"]
238
- border_colors2 = self.generate_hex2hex(
239
- self.attributes.rest.border_color2, now["border_color2"], animation_steps
240
- )
241
- text_colors = self.generate_hex2hex(
242
- self.attributes.rest.text_color, now["text_color"], animation_steps
243
- )
244
- import numpy as np
245
- back_opacitys = np.linspace(
246
- float(self.attributes.rest.back_opacity), float(now["back_opacity"]), animation_steps).tolist()
247
- border_color_opacitys = np.linspace(
248
- float(self.attributes.rest.border_color_opacity), float(now["border_color_opacity"]), animation_steps).tolist()
249
- if self.attributes.rest.border_color2_opacity is None:
250
- self.attributes.rest.border_color2_opacity = self.attributes.rest.border_color_opacity
251
- if now["border_color2_opacity"] is None:
252
- now["border_color2_opacity"] = now["border_color_opacity"]
253
- border_color2_opacitys = np.linspace(
254
- float(self.attributes.rest.border_color2_opacity), float(now["border_color2_opacity"]), animation_steps).tolist()
255
- for i in range(animation_steps):
256
- def update(ii=i):
257
- from easydict import EasyDict
258
- tempcolor = EasyDict(
259
- {
260
- "back_color": back_colors[ii],
261
- "back_opacity": back_opacitys[ii],
262
- "border_color": border_colors[ii],
263
- "border_color_opacity": str(border_color_opacitys[ii]),
264
- "border_color2": border_colors2[ii],
265
- "border_color2_opacity": str(border_color2_opacitys[ii]),
266
- "border_width": 1,
267
- "text_color": text_colors[ii],
268
- "radius": 6,
269
- }
270
- )
271
- self._draw(None, tempcolor)
272
-
273
- self.after(i * animation_step_time, update)
274
- #self.after(animation_steps * animation_step_time + 10, lambda: self._draw(None, None))
320
+ now = d
321
+ #print(animation_step_time)
322
+ #print(type(animation_step_time))
323
+ if hasattr(self.attributes.rest, "back_color"):
324
+ back_colors = self.generate_hex2hex(
325
+ self.attributes.rest.back_color, now["back_color"], animation_steps
326
+ )
327
+ border_colors = self.generate_hex2hex(
328
+ self.attributes.rest.border_color, now["border_color"], animation_steps
329
+ )
330
+ if self.attributes.rest.border_color2 is None:
331
+ self.attributes.rest.border_color2 = self.attributes.rest.border_color
332
+ if now["border_color2"] is None:
333
+ now["border_color2"] = now["border_color"]
334
+ border_colors2 = self.generate_hex2hex(
335
+ self.attributes.rest.border_color2, now["border_color2"], animation_steps
336
+ )
337
+ text_colors = self.generate_hex2hex(
338
+ self.attributes.rest.text_color, now["text_color"], animation_steps
339
+ )
340
+ import numpy as np
341
+ back_opacitys = np.linspace(
342
+ float(self.attributes.rest.back_opacity), float(now["back_opacity"]), animation_steps).tolist()
343
+ border_color_opacitys = np.linspace(
344
+ float(self.attributes.rest.border_color_opacity), float(now["border_color_opacity"]), animation_steps).tolist()
345
+ if self.attributes.rest.border_color2_opacity is None:
346
+ self.attributes.rest.border_color2_opacity = self.attributes.rest.border_color_opacity
347
+ if now["border_color2_opacity"] is None:
348
+ now["border_color2_opacity"] = now["border_color_opacity"]
349
+ border_color2_opacitys = np.linspace(
350
+ float(self.attributes.rest.border_color2_opacity), float(now["border_color2_opacity"]), animation_steps).tolist()
351
+ for i in range(animation_steps):
352
+ def update(ii=i):
353
+ from easydict import EasyDict
354
+ tempcolor = EasyDict(
355
+ {
356
+ "back_color": back_colors[ii],
357
+ "back_opacity": back_opacitys[ii],
358
+ "border_color": border_colors[ii],
359
+ "border_color_opacity": str(border_color_opacitys[ii]),
360
+ "border_color2": border_colors2[ii],
361
+ "border_color2_opacity": str(border_color2_opacitys[ii]),
362
+ "border_width": 1,
363
+ "text_color": text_colors[ii],
364
+ "radius": 6,
365
+ }
366
+ )
367
+ self._draw(None, tempcolor)
368
+
369
+ self.after(i * animation_step_time, update)
370
+ #self.after(animation_steps * animation_step_time + 10, lambda: self._draw(None, None))
275
371
 
276
372
  self.dconfigure(
277
373
  rest={
@@ -341,7 +437,7 @@ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase, FluGradient):
341
437
  def invoke(self):
342
438
  self.attributes.command()
343
439
 
344
- def _event_off_button1(self, event=None):
440
+ def _event_off_button1(self, event: Event = None):
345
441
  self.button1 = False
346
442
 
347
443
  self._draw(event)
tkflu/bwm.py CHANGED
@@ -137,14 +137,15 @@ class BWm(FluGradient):
137
137
  if animation_step_time is None:
138
138
  from .designs.animation import get_animation_step_time
139
139
  animation_step_time = get_animation_step_time()
140
- if self.dcget("back_color"):
141
- back_colors = self.generate_hex2hex(self.dcget("back_color"), n["back_color"], steps=animation_steps)
142
- for i in range(animation_steps):
143
- def update(ii=i): # 使用默认参数立即捕获i的值
144
- self.dconfigure(back_color=back_colors[ii])
145
- self._draw()
140
+ if not animation_steps == 0 or not animation_step_time == 0:
141
+ if self.dcget("back_color"):
142
+ back_colors = self.generate_hex2hex(self.dcget("back_color"), n["back_color"], steps=animation_steps)
143
+ for i in range(animation_steps):
144
+ def update(ii=i): # 使用默认参数立即捕获i的值
145
+ self.dconfigure(back_color=back_colors[ii])
146
+ self._draw()
146
147
 
147
- self.after(i * animation_step_time, update) # 直接传递函数,不需要lambda
148
+ self.after(i * animation_step_time, update) # 直接传递函数,不需要lambda
148
149
 
149
150
  self.dconfigure(
150
151
  back_color=n["back_color"],
@@ -186,6 +187,8 @@ class BWm(FluGradient):
186
187
  if platform == "win32":
187
188
  if way == 0:
188
189
  from .customwindow import CustomWindow
190
+ import warnings
191
+ warnings.warn("This is EXPERIMENTAL! Please consider way=1 in production.")
189
192
  self.customwindow = CustomWindow(self, wait=wait)
190
193
  self.customwindow.bind_drag(self.titlebar)
191
194
  self.customwindow.bind_drag(self.titlelabel)
tkflu/demos/grad2.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from tkflu import *
2
2
 
3
3
  set_animation_steps(20)
4
- set_animation_step_time(50)
4
+ set_animation_step_time(20)
5
5
 
6
6
  root = FluWindow()
7
7
 
@@ -0,0 +1,56 @@
1
+ def scrollbar(mode, state=None):
2
+ """滚动栏设计配置"""
3
+ if mode.lower() == "dark":
4
+ return {
5
+ "rest": {
6
+ "track_color": "#202020",
7
+ "track_opacity": 0.5,
8
+ "thumb_color": "#606060",
9
+ "thumb_opacity": 0.8
10
+ },
11
+ "hover": {
12
+ "track_color": "#202020",
13
+ "track_opacity": 0.7,
14
+ "thumb_color": "#808080",
15
+ "thumb_opacity": 1.0
16
+ },
17
+ "pressed": {
18
+ "track_color": "#202020",
19
+ "track_opacity": 0.9,
20
+ "thumb_color": "#A0A0A0",
21
+ "thumb_opacity": 1.0
22
+ },
23
+ "disabled": {
24
+ "track_color": "#202020",
25
+ "track_opacity": 0.3,
26
+ "thumb_color": "#404040",
27
+ "thumb_opacity": 0.5
28
+ }
29
+ }
30
+ else: # light mode
31
+ return {
32
+ "rest": {
33
+ "track_color": "#F0F0F0",
34
+ "track_opacity": 0.5,
35
+ "thumb_color": "#C0C0C0",
36
+ "thumb_opacity": 0.8
37
+ },
38
+ "hover": {
39
+ "track_color": "#F0F0F0",
40
+ "track_opacity": 0.7,
41
+ "thumb_color": "#A0A0A0",
42
+ "thumb_opacity": 1.0
43
+ },
44
+ "pressed": {
45
+ "track_color": "#F0F0F0",
46
+ "track_opacity": 0.9,
47
+ "thumb_color": "#808080",
48
+ "thumb_opacity": 1.0
49
+ },
50
+ "disabled": {
51
+ "track_color": "#F0F0F0",
52
+ "track_opacity": 0.3,
53
+ "thumb_color": "#E0E0E0",
54
+ "thumb_opacity": 0.5
55
+ }
56
+ }
tkflu/designs/slider.py CHANGED
@@ -13,6 +13,8 @@ def slider(mode: str, state: str):
13
13
  "radius": 12,
14
14
  "inner_radius": 6,
15
15
 
16
+ "width": 28,
17
+
16
18
  "back_color": "#FFFFFF",
17
19
  "back_opacity": 1,
18
20
 
@@ -43,6 +45,8 @@ def slider(mode: str, state: str):
43
45
  "radius": 12,
44
46
  "inner_radius": 8,
45
47
 
48
+ "width": 28,
49
+
46
50
  "back_color": "#FFFFFF",
47
51
  "back_opacity": 1,
48
52
 
@@ -73,6 +77,8 @@ def slider(mode: str, state: str):
73
77
  "radius": 12,
74
78
  "inner_radius": 5,
75
79
 
80
+ "width": 28,
81
+
76
82
  "back_color": "#FFFFFF",
77
83
  "back_opacity": 1,
78
84
 
@@ -103,6 +109,8 @@ def slider(mode: str, state: str):
103
109
  "radius": 12,
104
110
  "inner_radius": 6,
105
111
 
112
+ "width": 28,
113
+
106
114
  "back_color": "#FFFFFF",
107
115
  "back_opacity": 1,
108
116
 
@@ -133,6 +141,8 @@ def slider(mode: str, state: str):
133
141
  "thumb": {
134
142
  "radius": 12,
135
143
 
144
+ "width": 28,
145
+
136
146
  "inner_radius": 6,
137
147
  "inner_back_color": get_primary_color()[1],
138
148
  "inner_back_opacity": 1,
@@ -164,6 +174,8 @@ def slider(mode: str, state: str):
164
174
  "thumb": {
165
175
  "radius": 12,
166
176
 
177
+ "width": 28,
178
+
167
179
  "inner_radius": 8,
168
180
  "inner_back_color": get_primary_color()[1],
169
181
  "inner_back_opacity": 1,
@@ -195,6 +207,8 @@ def slider(mode: str, state: str):
195
207
  "thumb": {
196
208
  "radius": 12,
197
209
 
210
+ "width": 28,
211
+
198
212
  "inner_radius": 5,
199
213
  "inner_back_color": get_primary_color()[1],
200
214
  "inner_back_opacity": 0.8,
@@ -226,6 +240,8 @@ def slider(mode: str, state: str):
226
240
  "thumb": {
227
241
  "radius": 12,
228
242
 
243
+ "width": 28,
244
+
229
245
  "inner_radius": 6,
230
246
  "inner_back_color": "#FFFFFF",
231
247
  "inner_back_opacity": 0.158100,
tkflu/frame.py CHANGED
@@ -189,17 +189,17 @@ class FluFrame(Frame, DObject, FluGradient):
189
189
  if animation_step_time is None:
190
190
  from .designs.animation import get_animation_step_time
191
191
  animation_step_time = get_animation_step_time()
192
-
193
- if hasattr(self.attributes, "back_color") and hasattr(n, "back_color"):
194
- back_colors = self.generate_hex2hex(self.attributes.back_color, n["back_color"], steps=animation_steps)
195
- for i in range(animation_steps):
196
- def update(ii=i): # 使用默认参数立即捕获i的值
197
- print(back_colors[ii])
198
- self._draw(tempcolor=back_colors[ii])
199
- self.update()
200
-
201
- self.after(i * animation_step_time, update) # 直接传递函数,不需要lambda
202
- self.after(animation_steps * animation_step_time + 10, lambda: self._draw())
192
+ if not animation_steps == 0 or not animation_step_time == 0:
193
+ if hasattr(self.attributes, "back_color") and hasattr(n, "back_color"):
194
+ back_colors = self.generate_hex2hex(self.attributes.back_color, n["back_color"], steps=animation_steps)
195
+ for i in range(animation_steps):
196
+ def update(ii=i): # 使用默认参数立即捕获i的值
197
+ print(back_colors[ii])
198
+ self._draw(tempcolor=back_colors[ii])
199
+ self.update()
200
+
201
+ self.after(i * animation_step_time, update) # 直接传递函数,不需要lambda
202
+ self.after(animation_steps * animation_step_time + 10, lambda: self._draw())
203
203
  self.dconfigure(
204
204
  back_color=n["back_color"],
205
205
  border_color=n["border_color"],
tkflu/image.py CHANGED
@@ -0,0 +1,4 @@
1
+ from .frame import FluFrame
2
+
3
+
4
+ class FluImage(FluFrame):