tkfluent 0.0.1__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.
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.1
2
+ Name: tkfluent
3
+ Version: 0.0.1
4
+ Summary: Fluent Design for Tkinter
5
+ Author: XiangQinxi
6
+ Author-email: xiangqinxi@outlook.com
7
+ Classifier: Programming Language :: Python :: 2
8
+ Classifier: Programming Language :: Python :: 2.7
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.4
11
+ Classifier: Programming Language :: Python :: 3.5
12
+ Classifier: Programming Language :: Python :: 3.6
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Dist: tkdeft (>=0.0.7,<0.0.8)
20
+ Project-URL: Documentation, https://tkfluent.netlify.app
21
+ Description-Content-Type: text/markdown
22
+
23
+ # tkdeft
24
+
25
+ [![Netlify Status](https://api.netlify.com/api/v1/badges/c7626ce2-9556-4e4f-b28e-36dc0b513398/deploy-status)](https://app.netlify.com/sites/tkdeft/deploys)
26
+
27
+ 意为`灵巧`,灵活轻巧好用
28
+
29
+ 继`tkadw`之后的`tkinter`的现代化界面库
30
+
31
+ > 开发中
32
+
33
+ ---
34
+
35
+ ## 原理
36
+ 先使用`svgwrite`进行矢量作图(默认会将其存储到临时文件夹中),再用`tksvg`打开图片,将图片利用`Canvas`或`Label`显示出来
37
+
38
+ > 这其中还是有些坑的,比如图片不显示等
39
+
40
+
41
+ ## 计划
42
+ 未来我打算先制作出`SunValley`设计的库然后就去做别的项目
43
+
44
+ 设计来源: https://pixso.cn/community/file/ItC5JH1TOwj15EeOPcY7LQ?from_share
45
+
46
+ ### 为什么不像tkadw一样做跟易用的主题?
47
+ 因为`svg`能实现很多漂亮的组件,而我套的模板可能不对其它设计其太大的作用
48
+
49
+ 所以我将这个设计库放在这里当做模板,供其它设计者参考使用。
50
+
51
+
52
+ ## 更新日志
53
+ ### 2024-01-22
54
+ 发布`0.0.1`版本,模板组件包括`DButton`
55
+
56
+ ### 2023-01-23
57
+ 发布`0.0.2`版本,补充模板组件`DEntry`、`DFrame`、`DText`, `DBadge`
58
+
59
+ ### 2023-01-25
60
+ 发布`0.0.3` `0.0.4`版本,粗心了,两次补充依赖
61
+ 发布`0.0.5`版本,模板组件主题由`theme(mode=..., style=...)`设置,不再使用如`DDarkButton`这样的,添加`DWindow.wincustom`自定义窗口(仅限Windows)
62
+ 发布`0.0.6`版本,模板组件`DBadge`补充样式`style=accent`,并对自定义窗口进行稍微调整
@@ -0,0 +1,40 @@
1
+ # tkdeft
2
+
3
+ [![Netlify Status](https://api.netlify.com/api/v1/badges/c7626ce2-9556-4e4f-b28e-36dc0b513398/deploy-status)](https://app.netlify.com/sites/tkdeft/deploys)
4
+
5
+ 意为`灵巧`,灵活轻巧好用
6
+
7
+ 继`tkadw`之后的`tkinter`的现代化界面库
8
+
9
+ > 开发中
10
+
11
+ ---
12
+
13
+ ## 原理
14
+ 先使用`svgwrite`进行矢量作图(默认会将其存储到临时文件夹中),再用`tksvg`打开图片,将图片利用`Canvas`或`Label`显示出来
15
+
16
+ > 这其中还是有些坑的,比如图片不显示等
17
+
18
+
19
+ ## 计划
20
+ 未来我打算先制作出`SunValley`设计的库然后就去做别的项目
21
+
22
+ 设计来源: https://pixso.cn/community/file/ItC5JH1TOwj15EeOPcY7LQ?from_share
23
+
24
+ ### 为什么不像tkadw一样做跟易用的主题?
25
+ 因为`svg`能实现很多漂亮的组件,而我套的模板可能不对其它设计其太大的作用
26
+
27
+ 所以我将这个设计库放在这里当做模板,供其它设计者参考使用。
28
+
29
+
30
+ ## 更新日志
31
+ ### 2024-01-22
32
+ 发布`0.0.1`版本,模板组件包括`DButton`
33
+
34
+ ### 2023-01-23
35
+ 发布`0.0.2`版本,补充模板组件`DEntry`、`DFrame`、`DText`, `DBadge`
36
+
37
+ ### 2023-01-25
38
+ 发布`0.0.3` `0.0.4`版本,粗心了,两次补充依赖
39
+ 发布`0.0.5`版本,模板组件主题由`theme(mode=..., style=...)`设置,不再使用如`DDarkButton`这样的,添加`DWindow.wincustom`自定义窗口(仅限Windows)
40
+ 发布`0.0.6`版本,模板组件`DBadge`补充样式`style=accent`,并对自定义窗口进行稍微调整
@@ -0,0 +1,17 @@
1
+ [tool.poetry]
2
+ name = "tkfluent"
3
+ version = "0.0.1"
4
+ description = "Fluent Design for Tkinter"
5
+ authors = ["XiangQinxi <xiangqinxi@outlook.com>"]
6
+ readme = "README.md"
7
+ documentation = "https://tkfluent.netlify.app"
8
+ packages = [
9
+ { include = "tkflu" }
10
+ ]
11
+
12
+ [tool.poetry.dependencies]
13
+ tkdeft = "^0.0.7"
14
+
15
+ [build-system]
16
+ requires = ["poetry-core"]
17
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,24 @@
1
+ """、
2
+
3
+ Fluent设计的tkinter组件库(模板)
4
+
5
+ -------------
6
+ 作者:XiangQinxi
7
+ -------------
8
+ """
9
+
10
+ from .badge import FluBadge
11
+ from .button import FluButton
12
+ from .entry import FluEntry
13
+ from .frame import FluFrame
14
+ from .label import FluLabel
15
+ from .text import FluText
16
+ from .window import FluWindow
17
+
18
+ FluChip = FluBadge
19
+ FluPushButton = FluButton
20
+ FluTextInput = FluEntry
21
+ FluTextBox = FluText
22
+ FluPanel = FluFrame
23
+
24
+ # 
@@ -0,0 +1,36 @@
1
+ from tkflu import *
2
+ from tkinter import *
3
+ from tkinter.font import *
4
+
5
+ mode = "light"
6
+
7
+ root = FluWindow(mode=mode)
8
+ root.wincustom()
9
+ root.wm_geometry("180x320")
10
+
11
+ frame = FluFrame(mode=mode)
12
+
13
+ badge1 = FluBadge(frame, text="DBadge", width=60, mode=mode)
14
+ badge1.pack(padx=5, pady=5)
15
+
16
+ badge2 = FluBadge(frame, text="DBadge (Accent)", width=110, mode=mode, style="accent")
17
+ badge2.pack(padx=5, pady=5)
18
+
19
+ button1 = FluButton(
20
+ frame, text="DButton", command=lambda: print("DDarkButton -> Clicked"), mode=mode
21
+ )
22
+ button1.pack(fill="x", padx=5, pady=5)
23
+
24
+ button2 = FluButton(
25
+ frame, text="DButton (Accent)", command=lambda: print("DDarkAccentButton -> Clicked"), style="accent", mode=mode
26
+ )
27
+ button2.pack(fill="x", padx=5, pady=5)
28
+
29
+ entry1 = FluEntry(frame, mode=mode)
30
+ entry1.pack(fill="x", padx=5, pady=5)
31
+
32
+ text1 = FluText(frame, mode=mode)
33
+ text1.pack(fill="x", padx=5, pady=5)
34
+
35
+ frame.pack(fill="both", expand="yes", side="right", padx=5, pady=5)
36
+ root.mainloop()
@@ -0,0 +1,144 @@
1
+ from tkdeft.windows.draw import DSvgDraw
2
+ from tkdeft.windows.canvas import DCanvas
3
+ from tkdeft.windows.drawwidget import DDrawWidget
4
+
5
+
6
+ class FluBadgeDraw(DSvgDraw):
7
+ def create_roundrect(self,
8
+ x1, y1, x2, y2, temppath=None,
9
+ fill="transparent", outline="black", width=1
10
+ ):
11
+ drawing = self.create_drawing(x2 - x1, y2 - y1, temppath=temppath)
12
+ drawing[1].add(
13
+ drawing[1].rect(
14
+ (x1, y1), (x2 - x1, y2 - y1), 20, 25,
15
+ fill=fill, stroke_width=width,
16
+ stroke=outline,
17
+ )
18
+ )
19
+ drawing[1].save()
20
+ return drawing[0]
21
+
22
+
23
+ class FluBadgeCanvas(DCanvas):
24
+ draw = FluBadgeDraw
25
+
26
+ def create_round_rectangle(self,
27
+ x1, y1, x2, y2, temppath=None,
28
+ fill="transparent", outline="black", width=1
29
+ ):
30
+ self._img = self.svgdraw.create_roundrect(
31
+ x1, y1, x2, y2, temppath=temppath,
32
+ fill=fill, outline=outline, width=width
33
+ )
34
+ self._tkimg = self.svgdraw.create_tksvg_image(self._img)
35
+ return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
36
+
37
+ create_roundrect = create_round_rectangle
38
+
39
+
40
+ class FluBadge(FluBadgeCanvas, DDrawWidget):
41
+
42
+ def __init__(self, *args,
43
+ text="",
44
+ width=70,
45
+ height=30,
46
+ font=None,
47
+ mode="light",
48
+ style="standard",
49
+ **kwargs):
50
+ self._init(mode, style)
51
+
52
+ super().__init__(*args, width=width, height=height, **kwargs)
53
+
54
+ self.dconfigure(
55
+ text=text,
56
+ )
57
+
58
+ self.bind("<<Clicked>>", lambda event=None: self.focus_set(), add="+")
59
+
60
+ if font is None:
61
+ from tkdeft.utility.fonts import SegoeFont
62
+ self.attributes.font = SegoeFont()
63
+
64
+ def _init(self, mode, style):
65
+ from easydict import EasyDict
66
+
67
+ self.attributes = EasyDict(
68
+ {
69
+ "text": "",
70
+ "command": None,
71
+ "font": None,
72
+
73
+ "back_color": None,
74
+ "border_color": None,
75
+ "border_width": None,
76
+ "text_color": None
77
+ }
78
+ )
79
+
80
+ self.theme(mode, style)
81
+
82
+ def _draw(self, event=None):
83
+ super()._draw(event)
84
+
85
+ self.delete("all")
86
+
87
+ _back_color = self.attributes.back_color
88
+ _border_color = self.attributes.border_color
89
+ _border_width = self.attributes.border_width
90
+ _text_color = self.attributes.text_color
91
+
92
+ self.element_border = self.create_round_rectangle(
93
+ 0, 0, self.winfo_width(), self.winfo_height(), temppath=self.temppath,
94
+ fill=_back_color, outline=_border_color, width=_border_width
95
+ )
96
+
97
+ self.element_text = self.create_text(
98
+ self.winfo_width() / 2, self.winfo_height() / 2, anchor="center",
99
+ fill=_text_color, text=self.attributes.text, font=self.attributes.font
100
+ )
101
+
102
+ def theme(self, mode, style):
103
+ if mode.lower() == "dark":
104
+ if style.lower() == "accent":
105
+ self._dark_accent()
106
+ else:
107
+ self._dark()
108
+ else:
109
+ if style.lower() == "accent":
110
+ self._light_accent()
111
+ else:
112
+ self._light()
113
+
114
+ def _light(self):
115
+ self.dconfigure(
116
+ back_color="#f0f0f0",
117
+ border_color="#f0f0f0",
118
+ border_width=1,
119
+ text_color="#191919",
120
+ )
121
+
122
+ def _light_accent(self):
123
+ self.dconfigure(
124
+ back_color="#005fb8",
125
+ border_color="#005fb8",
126
+ border_width=1,
127
+ text_color="#ffffff",
128
+ )
129
+
130
+ def _dark(self):
131
+ self.dconfigure(
132
+ back_color="#242424",
133
+ border_color="#242424",
134
+ border_width=1,
135
+ text_color="#ffffff",
136
+ )
137
+
138
+ def _dark_accent(self):
139
+ self.dconfigure(
140
+ back_color="#60cdff",
141
+ border_color="#60cdff",
142
+ border_width=1,
143
+ text_color="#000000",
144
+ )
@@ -0,0 +1,283 @@
1
+ from tkdeft.windows.draw import DSvgDraw
2
+ from tkdeft.windows.canvas import DCanvas
3
+ from tkdeft.windows.drawwidget import DDrawWidget
4
+
5
+
6
+ class FluButtonDraw(DSvgDraw):
7
+ def create_roundrect(self,
8
+ x1, y1, x2, y2, radius, radiusy=None, temppath=None,
9
+ fill="transparent", outline="black", outline2="black", width=1
10
+ ):
11
+ if radiusy:
12
+ _rx = radius
13
+ _ry = radiusy
14
+ else:
15
+ _rx, _ry = radius, radius
16
+ drawing = self.create_drawing(x2 - x1, y2 - y1, temppath=temppath)
17
+ border = drawing[1].linearGradient(start=(x1, y1), end=(x1, y2), id="DButton.Border")
18
+ border.add_stop_color("0%", outline)
19
+ border.add_stop_color("100%", outline2)
20
+ drawing[1].defs.add(border)
21
+ drawing[1].add(
22
+ drawing[1].rect(
23
+ (x1, y1), (x2 - x1, y2 - y1), _rx, _ry,
24
+ fill=fill, stroke_width=width,
25
+ stroke=f"url(#{border.get_id()})",
26
+ )
27
+ )
28
+ drawing[1].save()
29
+ return drawing[0]
30
+
31
+
32
+ class FluButtonCanvas(DCanvas):
33
+ draw = FluButtonDraw
34
+
35
+ def create_round_rectangle(self,
36
+ x1, y1, x2, y2, r1, r2=None, temppath=None,
37
+ fill="transparent", outline="black", outline2="black", width=1
38
+ ):
39
+ self._img = self.svgdraw.create_roundrect(
40
+ x1, y1, x2, y2, r1, r2, temppath=temppath,
41
+ fill=fill, outline=outline, outline2=outline2, width=width
42
+ )
43
+ self._tkimg = self.svgdraw.create_tksvg_image(self._img)
44
+ return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
45
+
46
+ create_roundrect = create_round_rectangle
47
+
48
+
49
+ class FluButton(FluButtonCanvas, DDrawWidget):
50
+ def __init__(self, *args,
51
+ text="",
52
+ width=120,
53
+ height=32,
54
+ command=None,
55
+ font=None,
56
+ mode="light",
57
+ style="standard",
58
+ **kwargs):
59
+ self._init(mode, style)
60
+
61
+ super().__init__(*args, width=width, height=height, **kwargs)
62
+
63
+ if command is None:
64
+ def empty(): pass
65
+
66
+ command = empty
67
+
68
+ self.dconfigure(
69
+ text=text,
70
+ command=command
71
+ )
72
+
73
+ self.bind("<<Clicked>>", lambda event=None: self.focus_set(), add="+")
74
+ self.bind("<<Clicked>>", lambda event=None: self.attributes.command(), add="+")
75
+
76
+ self.bind("<Return>", lambda event=None: self.attributes.command(), add="+") # 可以使用回车键模拟点击
77
+
78
+ if font is None:
79
+ from tkdeft.utility.fonts import SegoeFont
80
+ self.attributes.font = SegoeFont()
81
+
82
+ def _init(self, mode, style):
83
+
84
+ from easydict import EasyDict
85
+
86
+ self.attributes = EasyDict(
87
+ {
88
+ "text": "",
89
+ "command": None,
90
+ "font": None,
91
+
92
+ "rest": {
93
+ "back_color": "#ffffff",
94
+ "border_color": "#f0f0f0",
95
+ "border_color2": "#d6d6d6",
96
+ "border_width": 1,
97
+ "radius": 6,
98
+ "text_color": "#1b1b1b",
99
+ },
100
+ "hover": {
101
+ "back_color": "#fcfcfc",
102
+ "border_color": "#f0f0f0",
103
+ "border_color2": "#d6d6d6",
104
+ "border_width": 1,
105
+ "radius": 6,
106
+ "text_color": "#1b1b1b",
107
+ },
108
+ "pressed": {
109
+ "back_color": "#fdfdfd",
110
+ "border_color": "#f0f0f0",
111
+ "border_color2": "#f0f0f0",
112
+ "border_width": 1,
113
+ "radius": 6,
114
+ "text_color": "#636363",
115
+ }
116
+ }
117
+ )
118
+
119
+ self.theme(mode=mode, style=style)
120
+
121
+ def _draw(self, event=None):
122
+ super()._draw(event)
123
+
124
+ self.delete("all")
125
+
126
+ if self.enter:
127
+ if self.button1:
128
+ _back_color = self.attributes.pressed.back_color
129
+ _border_color = self.attributes.pressed.border_color
130
+ _border_color2 = self.attributes.pressed.border_color2
131
+ _border_width = self.attributes.pressed.border_width
132
+ _radius = self.attributes.pressed.radius
133
+ _text_color = self.attributes.pressed.text_color
134
+ else:
135
+ _back_color = self.attributes.hover.back_color
136
+ _border_color = self.attributes.hover.border_color
137
+ _border_color2 = self.attributes.hover.border_color2
138
+ _border_width = self.attributes.hover.border_width
139
+ _radius = self.attributes.hover.radius
140
+ _text_color = self.attributes.hover.text_color
141
+ else:
142
+ _back_color = self.attributes.rest.back_color
143
+ _border_color = self.attributes.rest.border_color
144
+ _border_color2 = self.attributes.rest.border_color2
145
+ _border_width = self.attributes.rest.border_width
146
+ _radius = self.attributes.rest.radius
147
+ _text_color = self.attributes.rest.text_color
148
+
149
+ self.element_border = self.create_round_rectangle(
150
+ 0, 0, self.winfo_width(), self.winfo_height(), _radius, temppath=self.temppath,
151
+ fill=_back_color, outline=_border_color, outline2=_border_color2, width=_border_width
152
+ )
153
+ self.element_text = self.create_text(
154
+ self.winfo_width() / 2, self.winfo_height() / 2, anchor="center",
155
+ fill=_text_color, text=self.attributes.text, font=self.attributes.font
156
+ )
157
+
158
+ def theme(self, mode="light", style="standard"):
159
+ if mode.lower() == "dark":
160
+ if style.lower() == "accent":
161
+ self._dark_accent()
162
+ else:
163
+ self._dark()
164
+ else:
165
+ if style.lower() == "accent":
166
+ self._light_accent()
167
+ else:
168
+ self._light()
169
+
170
+ def _light(self):
171
+ self.dconfigure(
172
+ rest={
173
+ "back_color": "#ffffff",
174
+ "border_color": "#f0f0f0",
175
+ "border_color2": "#d6d6d6",
176
+ "border_width": 1,
177
+ "radius": 6,
178
+ "text_color": "#1b1b1b",
179
+ },
180
+ hover={
181
+ "back_color": "#fcfcfc",
182
+ "border_color": "#f0f0f0",
183
+ "border_color2": "#d6d6d6",
184
+ "border_width": 1,
185
+ "radius": 6,
186
+ "text_color": "#1b1b1b",
187
+ },
188
+ pressed={
189
+ "back_color": "#fdfdfd",
190
+ "border_color": "#f0f0f0",
191
+ "border_color2": "#f0f0f0",
192
+ "border_width": 1,
193
+ "radius": 6,
194
+ "text_color": "#636363",
195
+ }
196
+ )
197
+
198
+ def _light_accent(self):
199
+ self.dconfigure(
200
+ rest={
201
+ "back_color": "#005fb8",
202
+ "border_color": "#146cbe",
203
+ "border_color2": "#00396e",
204
+ "border_width": 1,
205
+ "radius": 6,
206
+ "text_color": "#ffffff",
207
+ },
208
+ hover={
209
+ "back_color": "#0359a9",
210
+ "border_color": "#1766b0",
211
+ "border_color2": "#0f4373",
212
+ "border_width": 1,
213
+ "radius": 6,
214
+ "text_color": "#ffffff",
215
+ },
216
+ pressed={
217
+ "back_color": "#005fb8",
218
+ "border_color": "#4389ca",
219
+ "border_color2": "#4389ca",
220
+ "border_width": 1,
221
+ "radius": 6,
222
+ "text_color": "#b4cbe0",
223
+ }
224
+ )
225
+
226
+ def _dark(self):
227
+ self.dconfigure(
228
+ rest={
229
+ "back_color": "#272727",
230
+ "border_color": "#303030",
231
+ "border_color2": "#262626",
232
+ "border_width": 1,
233
+ "radius": 6,
234
+ "text_color": "#ffffff",
235
+ },
236
+ hover={
237
+ "back_color": "#2d2d2d",
238
+ "border_color": "#303030",
239
+ "border_color2": "#262626",
240
+ "border_width": 1,
241
+ "radius": 6,
242
+ "text_color": "#ffffff",
243
+ },
244
+ pressed={
245
+ "back_color": "#212121",
246
+ "border_color": "#2a2a2a",
247
+ "border_color2": "#262626",
248
+ "border_width": 1,
249
+ "radius": 6,
250
+ "text_color": "#cfcfcf",
251
+ }
252
+ )
253
+
254
+ def _dark_accent(self):
255
+ self.dconfigure(
256
+ rest={
257
+ "back_color": "#60cdff",
258
+ "border_color": "#6cd1ff",
259
+ "border_color2": "#56b4df",
260
+ "border_width": 1,
261
+ "radius": 6,
262
+ "text_color": "#000000",
263
+ },
264
+ hover={
265
+ "back_color": "#5abce9",
266
+ "border_color": "#67c1eb",
267
+ "border_color2": "#50a5cc",
268
+ "border_width": 1,
269
+ "radius": 6,
270
+ "text_color": "#000000",
271
+ },
272
+ pressed={
273
+ "back_color": "#52a9d1",
274
+ "border_color": "#60b0d5",
275
+ "border_color2": "#60b0d5",
276
+ "border_width": 1,
277
+ "radius": 6,
278
+ "text_color": "#295468",
279
+ }
280
+ )
281
+
282
+ def invoke(self):
283
+ self.attributes.command()