tkfluent 0.0.8__tar.gz → 0.0.9__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 (54) hide show
  1. tkfluent-0.0.9/PKG-INFO +82 -0
  2. tkfluent-0.0.9/README.md +45 -0
  3. tkfluent-0.0.9/pyproject.toml +44 -0
  4. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/__init__.py +1 -1
  5. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/__main__.py +8 -2
  6. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/badge.py +4 -1
  7. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/button.py +3 -3
  8. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/bwm.py +2 -0
  9. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/constants.py +5 -0
  10. tkfluent-0.0.9/tkflu/demos/__init__.py +1 -0
  11. tkfluent-0.0.9/tkflu/demos/acrylic1.py +18 -0
  12. tkfluent-0.0.9/tkflu/demos/tooltip.py +13 -0
  13. tkfluent-0.0.9/tkflu/designs/tooltip.py +15 -0
  14. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/entry.py +4 -1
  15. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/label.py +2 -1
  16. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/menu.py +2 -1
  17. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/popupwindow.py +6 -4
  18. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/slider.py +7 -7
  19. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/text.py +4 -1
  20. tkfluent-0.0.9/tkflu/thememanager.py +33 -0
  21. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/togglebutton.py +4 -1
  22. tkfluent-0.0.9/tkflu/tooltip.py +151 -0
  23. tkfluent-0.0.9/tkflu/window.py +38 -0
  24. tkfluent-0.0.8/PKG-INFO +0 -29
  25. tkfluent-0.0.8/README.md +0 -5
  26. tkfluent-0.0.8/pyproject.toml +0 -23
  27. tkfluent-0.0.8/tkflu/thememanager.py +0 -28
  28. tkfluent-0.0.8/tkflu/tooltip.py +0 -8
  29. tkfluent-0.0.8/tkflu/window.py +0 -34
  30. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/checkbox.py +0 -0
  31. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/customwindow.py +0 -0
  32. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/customwindow2.py +0 -0
  33. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/defs.py +0 -0
  34. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/__init__.py +0 -0
  35. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/badge.py +0 -0
  36. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/button.py +0 -0
  37. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/design.py +0 -0
  38. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/entry.py +0 -0
  39. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/fonts/__init__.py +0 -0
  40. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/fonts/segoeui.ttf +0 -0
  41. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/frame.py +0 -0
  42. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/primary_color.py +0 -0
  43. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/slider.py +0 -0
  44. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/text.py +0 -0
  45. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/designs/window.py +0 -0
  46. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/frame.py +0 -0
  47. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/icons.py +0 -0
  48. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/image.py +0 -0
  49. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/listbox.py +0 -0
  50. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/litenav.py +0 -0
  51. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/menubar.py +0 -0
  52. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/popupmenu.py +0 -0
  53. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/scrollbar.py +0 -0
  54. {tkfluent-0.0.8 → tkfluent-0.0.9}/tkflu/toplevel.py +0 -0
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.3
2
+ Name: tkfluent
3
+ Version: 0.0.9
4
+ Summary: Fluent Design for Tkinter
5
+ License: MIT
6
+ Keywords: tkfluent,tksvg,tkinter,fluent,modern,UI,interface
7
+ Author: XiangQinxi
8
+ Author-email: xiangqinxi@outlook.com
9
+ Requires-Python: >=3.8,<4.0
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: MacOS X
12
+ Classifier: Environment :: Win32 (MS Windows)
13
+ Classifier: Environment :: X11 Applications
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Natural Language :: Chinese (Simplified)
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: 3.13
27
+ Classifier: Programming Language :: Tcl
28
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
+ Requires-Dist: easydict (>=1.13,<2.0)
30
+ Requires-Dist: pillow (>=10.2.0,<11.0.0)
31
+ Requires-Dist: svgwrite (>=1.4.3,<2.0.0)
32
+ Requires-Dist: tkdeft (>=0.0.9,<0.0.10)
33
+ Requires-Dist: tkextrafont (>=0.6.3,<0.7.0)
34
+ Requires-Dist: tksvg (>=0.7.4,<0.8.0)
35
+ Project-URL: Documentation, https://tkfluent.netlify.app
36
+ Description-Content-Type: text/markdown
37
+
38
+ # tkfluent
39
+
40
+ `tkinter`现代化组件库。设计来于`Fluent` `WinUI3` 设计
41
+
42
+ ![](https://learn.microsoft.com/zh-cn/windows/apps/images/logo-winui.png)
43
+
44
+ ## 依赖图
45
+ ```bash
46
+ PS .\tkfluent> poetry show --tree
47
+ easydict 1.13 Access dict values as attributes (works recursively).
48
+ pillow 10.4.0 Python Imaging Library (Fork)
49
+ svgwrite 1.4.3 A Python library to create SVG drawings.
50
+ tkdeft 0.0.9 使用tkinter+tksvg开发的现代化界面库
51
+ ├── easydict >=1.13,<2.0
52
+ ├── pillow >=10.2.0,<11.0.0
53
+ ├── svgwrite >=1.4.3,<2.0.0
54
+ ├── tkextrafont >=0.6.3,<0.7.0
55
+ │ └── scikit-build *
56
+ │ ├── distro *
57
+ │ ├── packaging *
58
+ │ ├── setuptools >=42.0.0
59
+ │ ├── tomli *
60
+ │ └── wheel >=0.32.0
61
+ └── tksvg >=0.7.4,<0.8.0
62
+ └── scikit-build *
63
+ ├── distro *
64
+ ├── packaging *
65
+ ├── setuptools >=42.0.0
66
+ ├── tomli *
67
+ └── wheel >=0.32.0
68
+ tkextrafont 0.6.3 Fonts loader for Tkinter
69
+ └── scikit-build *
70
+ ├── distro *
71
+ ├── packaging *
72
+ ├── setuptools >=42.0.0
73
+ ├── tomli *
74
+ └── wheel >=0.32.0
75
+ tksvg 0.7.4 SVG support for PhotoImage in Tk 8.6
76
+ └── scikit-build *
77
+ ├── distro *
78
+ ├── packaging *
79
+ ├── setuptools >=42.0.0
80
+ ├── tomli *
81
+ └── wheel >=0.32.0
82
+ ```
@@ -0,0 +1,45 @@
1
+ # tkfluent
2
+
3
+ `tkinter`现代化组件库。设计来于`Fluent` `WinUI3` 设计
4
+
5
+ ![](https://learn.microsoft.com/zh-cn/windows/apps/images/logo-winui.png)
6
+
7
+ ## 依赖图
8
+ ```bash
9
+ PS .\tkfluent> poetry show --tree
10
+ easydict 1.13 Access dict values as attributes (works recursively).
11
+ pillow 10.4.0 Python Imaging Library (Fork)
12
+ svgwrite 1.4.3 A Python library to create SVG drawings.
13
+ tkdeft 0.0.9 使用tkinter+tksvg开发的现代化界面库
14
+ ├── easydict >=1.13,<2.0
15
+ ├── pillow >=10.2.0,<11.0.0
16
+ ├── svgwrite >=1.4.3,<2.0.0
17
+ ├── tkextrafont >=0.6.3,<0.7.0
18
+ │ └── scikit-build *
19
+ │ ├── distro *
20
+ │ ├── packaging *
21
+ │ ├── setuptools >=42.0.0
22
+ │ ├── tomli *
23
+ │ └── wheel >=0.32.0
24
+ └── tksvg >=0.7.4,<0.8.0
25
+ └── scikit-build *
26
+ ├── distro *
27
+ ├── packaging *
28
+ ├── setuptools >=42.0.0
29
+ ├── tomli *
30
+ └── wheel >=0.32.0
31
+ tkextrafont 0.6.3 Fonts loader for Tkinter
32
+ └── scikit-build *
33
+ ├── distro *
34
+ ├── packaging *
35
+ ├── setuptools >=42.0.0
36
+ ├── tomli *
37
+ └── wheel >=0.32.0
38
+ tksvg 0.7.4 SVG support for PhotoImage in Tk 8.6
39
+ └── scikit-build *
40
+ ├── distro *
41
+ ├── packaging *
42
+ ├── setuptools >=42.0.0
43
+ ├── tomli *
44
+ └── wheel >=0.32.0
45
+ ```
@@ -0,0 +1,44 @@
1
+ [tool.poetry]
2
+ name = "tkfluent"
3
+ version = "0.0.9"
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
+ license = "MIT"
12
+ keywords = [ "tkfluent", "tksvg", "tkinter", "fluent", "modern", "UI", "interface" ]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Environment :: MacOS X",
16
+ "Environment :: Win32 (MS Windows)",
17
+ "Environment :: X11 Applications",
18
+ "Natural Language :: Chinese (Simplified)",
19
+ "Natural Language :: English",
20
+ "Operating System :: Microsoft :: Windows",
21
+ "Operating System :: MacOS",
22
+ "Operating System :: POSIX :: Linux",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Tcl",
30
+ "Topic :: Software Development :: Libraries :: Python Modules"
31
+ ]
32
+
33
+ [tool.poetry.dependencies]
34
+ python = "^3.8"
35
+ tksvg = "^0.7.4"
36
+ tkextrafont = "^0.6.3"
37
+ svgwrite = "^1.4.3"
38
+ pillow = "^10.2.0"
39
+ tkdeft = "^0.0.9"
40
+ easydict = "^1.13"
41
+
42
+ [build-system]
43
+ requires = ["poetry-core"]
44
+ build-backend = "poetry.core.masonry.api"
@@ -24,7 +24,7 @@ from .slider import FluSlider
24
24
  from .text import FluText
25
25
  from .thememanager import FluThemeManager
26
26
  from .togglebutton import FluToggleButton
27
- from .tooltip import FluToolTip
27
+ from .tooltip import FluToolTip, FluToolTip2, FluToolTipBase
28
28
  from .toplevel import FluToplevel
29
29
  from .window import FluWindow
30
30
 
@@ -2,8 +2,6 @@ from tkflu import *
2
2
  from tkinter import *
3
3
  from tkinter.font import *
4
4
 
5
- from tkflu.listbox import FluListBox
6
-
7
5
  blue_primary_color()
8
6
 
9
7
  def togglestate():
@@ -69,6 +67,14 @@ badge1.pack(padx=5, pady=5)
69
67
  badge2 = FluBadge(frame, text="FluBadge (Accent)", width=120, style="accent")
70
68
  badge2.pack(padx=5, pady=5)
71
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
+
72
78
  button1 = FluButton(
73
79
  frame, text="FluButton", command=lambda: print("FluButton -> Clicked")
74
80
  )
@@ -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="",
@@ -62,9 +62,9 @@ class FluButtonCanvas(DCanvas):
62
62
 
63
63
 
64
64
  from .constants import MODE, STATE, BUTTONSTYLE
65
+ from .tooltip import FluToolTipBase
65
66
 
66
-
67
- class FluButton(FluButtonCanvas, DDrawWidget):
67
+ class FluButton(FluButtonCanvas, DDrawWidget, FluToolTipBase):
68
68
  def __init__(self, *args,
69
69
  text="",
70
70
  width=120,
@@ -98,7 +98,7 @@ class FluButton(FluButtonCanvas, DDrawWidget):
98
98
  from .defs import set_default_font
99
99
  set_default_font(font, self.attributes)
100
100
 
101
- def _init(self, mode: MODE, style: STATE):
101
+ def _init(self, mode: MODE, style: BUTTONSTYLE):
102
102
 
103
103
  from easydict import EasyDict
104
104
 
@@ -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"],
@@ -18,3 +18,8 @@ STANDARD = 'standard'
18
18
  ACCENT = 'accent'
19
19
  MENU = 'menu'
20
20
  BUTTONSTYLE = Literal["standard", "accent", "menu"]
21
+
22
+ # FluFrame Styles
23
+ STANDARD = 'standard'
24
+ POPUPMENU = 'popupmenu'
25
+ FRAMESTYLE = Literal["standard", "popupmenu"]
@@ -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()
@@ -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,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
+ }
@@ -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,
@@ -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,
@@ -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
 
@@ -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:
@@ -29,14 +29,14 @@ class FluSliderDraw(DSvgDraw):
29
29
  border.add_stop_color(0.954545, outline2, outline2_opacity)
30
30
  drawing[1].defs.add(border)
31
31
  stroke = f"url(#{border.get_id()})"
32
- print("x1:", x1, "\n", "y1:", y1, "\n", "x2:", x2, "\n", "y2:", y2, "\n", "r1:", r1, "\n", sep="")
32
+ #print("x1:", x1, "\n", "y1:", y1, "\n", "x2:", x2, "\n", "y2:", y2, "\n", "r1:", r1, "\n", sep="")
33
33
 
34
34
  x = x1 + r1 - 4
35
35
  xx = x2 - r1 + 4
36
36
 
37
- print("track_x1:", x, "\n", "track_x2:", xx, sep="")
37
+ #print("track_x1:", x, "\n", "track_x2:", xx, sep="")
38
38
 
39
- print("")
39
+ #print("")
40
40
 
41
41
  drawing[1].add(
42
42
  drawing[1].rect(
@@ -188,9 +188,9 @@ class FluSlider(FluSliderCanvas, DDrawWidget):
188
188
 
189
189
  super()._draw(event)
190
190
 
191
- print("width:", self.winfo_width(), "\n", "height:", self.winfo_height(), sep="")
191
+ #print("width:", self.winfo_width(), "\n", "height:", self.winfo_height(), sep="")
192
192
 
193
- print("")
193
+ #print("")
194
194
 
195
195
  self.delete("all")
196
196
 
@@ -263,8 +263,8 @@ class FluSlider(FluSliderCanvas, DDrawWidget):
263
263
  self.dconfigure(
264
264
  value=value
265
265
  )
266
- print("value:", value, sep="")
267
- print("")
266
+ #print("value:", value, sep="")
267
+ #print("")
268
268
 
269
269
  def _event_button1_motion(self, event):
270
270
  self.pos(event)
@@ -72,7 +72,10 @@ class FluTextCanvas(DCanvas):
72
72
  create_roundrect = create_round_rectangle
73
73
 
74
74
 
75
- class FluText(FluTextCanvas, DDrawWidget):
75
+ from .tooltip import FluToolTipBase
76
+
77
+
78
+ class FluText(FluTextCanvas, DDrawWidget, FluToolTipBase):
76
79
  def __init__(self, *args,
77
80
  width=120,
78
81
  height=90,
@@ -0,0 +1,33 @@
1
+ from .window import FluWindow
2
+ from .toplevel import FluToplevel
3
+
4
+
5
+ class FluThemeManager(object):
6
+ def __init__(self, window=None, mode: str = "light", delay: int or None = 100):
7
+ if window:
8
+ self._window = window
9
+ else:
10
+ from tkinter import _default_root
11
+ self._window = _default_root
12
+ self._mode = mode
13
+ self.mode(self._mode)
14
+ self._window.after(delay, lambda: self.mode(self._mode))
15
+
16
+ def mode(self, mode: str, delay: int or None = None):
17
+ def _():
18
+ self._mode = mode
19
+ if hasattr(self._window, "theme"):
20
+ self._window.theme(mode=mode)
21
+ if hasattr(self._window, "_draw"):
22
+ self._window._draw()
23
+ self._window.update()
24
+ for widget in self._window.winfo_children():
25
+ if hasattr(widget, "theme"):
26
+ widget.theme(mode=mode)
27
+ if hasattr(widget, "_draw"):
28
+ widget._draw()
29
+ widget.update()
30
+ if delay:
31
+ self._window.after(delay, _)
32
+ else:
33
+ _()
@@ -59,7 +59,10 @@ class FluToggleButtonCanvas(DCanvas):
59
59
  create_roundrect = create_round_rectangle_with_text
60
60
 
61
61
 
62
- class FluToggleButton(FluToggleButtonCanvas, DDrawWidget):
62
+ from .tooltip import FluToolTipBase
63
+
64
+
65
+ class FluToggleButton(FluToggleButtonCanvas, DDrawWidget, FluToolTipBase):
63
66
  def __init__(self, *args,
64
67
  text="",
65
68
  width=120,
@@ -0,0 +1,151 @@
1
+ from .popupwindow import FluPopupWindow
2
+ from tkinter import Event, Widget
3
+
4
+
5
+ class FluToolTip(FluPopupWindow):
6
+ def __init__(self, widget: Widget, text, mode="light", delay=400, show_time=100.0, *args, **kwargs):
7
+ super().__init__(*args, transparent_color="#ebebeb", **kwargs)
8
+
9
+ from .label import FluLabel
10
+ from .frame import FluFrame
11
+
12
+ self.overrideredirect(True)
13
+
14
+ self._delay = delay
15
+ self._show_time = show_time
16
+ self._widget = widget
17
+
18
+ self._frame = FluFrame(self)
19
+ self._frame.theme(mode, style="popupmenu")
20
+
21
+ self._label = FluLabel(self._frame, text=text)
22
+ self._label.pack(fill="both", expand=True, padx=3, pady=3)
23
+
24
+ self._frame.pack(fill="both", expand=True, padx=3, pady=3)
25
+
26
+ self._widget.bind('<Enter>', self.enter, add="+")
27
+ self._widget.bind('<Leave>', self.leave, add="+")
28
+
29
+ #self.theme(mode)
30
+
31
+ def enter(self, event: Event):
32
+ def check() -> None:
33
+ if self._enter:
34
+ # 先定位工具提示位置
35
+ self.popup(
36
+ round(self._widget.winfo_rootx() + self._widget.winfo_width() / 2 - self.winfo_width() / 2),
37
+ round(self._widget.winfo_rooty() + self._widget.winfo_height() + 2)
38
+ )
39
+ self.wm_attributes("-alpha", 0.0)
40
+ self.deiconify()
41
+
42
+ # 设置初始透明度为0
43
+
44
+
45
+ # 渐显动画
46
+ def fade_in(step=0):
47
+ alpha = step / 10 # 分10步从0到1
48
+ self.wm_attributes("-alpha", alpha)
49
+ if step < 10:
50
+ self.after(int(round(self._show_time/10)), lambda: fade_in(step + 1)) # 每50ms增加一次透明度
51
+
52
+ fade_in() # 启动动画
53
+
54
+ self.id = self.after(self._delay, check)
55
+ self._enter = True
56
+
57
+ def leave(self, event):
58
+ self.after_cancel(self.id)
59
+ self._enter = False
60
+ self.withdraw()
61
+
62
+ def theme(self, mode=None):
63
+ from .designs.tooltip import tooltip
64
+ n = tooltip(mode)
65
+ self.configure(
66
+ background=n["back_color"]
67
+ )
68
+ self.wm_attributes("-transparentcolor", n["back_color"])
69
+ print(n["back_color"])
70
+ if hasattr(self, "_frame"):
71
+ self._frame.dconfigure(
72
+ back_color=n["frame_color"],
73
+ border_color=n["frame_border_color"],
74
+ border_color_opacity=1,
75
+ border_width=2,
76
+ radius=7,
77
+ )
78
+ if hasattr(self, "_label"):
79
+ self._label.theme(mode)
80
+ super().theme(mode)
81
+
82
+
83
+ class FluToolTip2(FluPopupWindow):
84
+ def __init__(self, widget, text, mode="light", *args, **kwargs):
85
+ super().__init__(*args, transparent_color="#ebebeb", **kwargs)
86
+
87
+ from .label import FluLabel
88
+ from .frame import FluFrame
89
+
90
+ self.overrideredirect(True)
91
+
92
+ self._widget = widget
93
+
94
+ self._frame = FluFrame(self)
95
+ self._frame.theme(mode, style="popupmenu")
96
+
97
+ self._label = FluLabel(self._frame, text=text)
98
+ self._label.pack(fill="both", expand=True, padx=3, pady=3)
99
+
100
+ self._frame.pack(fill="both", expand=True, padx=3, pady=3)
101
+
102
+ self._widget.bind('<Enter>', self.show, add="+")
103
+ self._widget.bind('<Leave>', self.hide, add="+")
104
+ self._widget.bind('<Motion>', self.move, add="+")
105
+
106
+ #self.theme(mode)
107
+
108
+ def show(self, event: Event):
109
+ self.popup(
110
+ round(event.x_root - self.winfo_width() / 2),
111
+ round(event.y_root + 10)
112
+ )
113
+ self.deiconify()
114
+
115
+ def hide(self, event):
116
+ self.withdraw()
117
+
118
+ def move(self, event):
119
+ self.popup(
120
+ round(event.x_root - self.winfo_width() / 2),
121
+ round(event.y_root + 10)
122
+ )
123
+
124
+ def theme(self, mode=None):
125
+ from .designs.tooltip import tooltip
126
+ n = tooltip(mode)
127
+ self.configure(
128
+ background=n["back_color"]
129
+ )
130
+ self.wm_attributes("-transparentcolor", n["back_color"])
131
+ print(n["back_color"])
132
+ if hasattr(self, "_frame"):
133
+ self._frame.dconfigure(
134
+ back_color=n["frame_color"],
135
+ border_color=n["frame_border_color"],
136
+ border_color_opacity=1,
137
+ border_width=2,
138
+ radius=7,
139
+ )
140
+ if hasattr(self, "_label"):
141
+ self._label.theme(mode)
142
+ super().theme(mode)
143
+
144
+
145
+ class FluToolTipBase:
146
+ def tooltip(self, *args, way=0, **kwargs):
147
+ if way == 0:
148
+ self._tooltip = FluToolTip(*args, widget=self, **kwargs)
149
+ elif way == 1:
150
+ self._tooltip = FluToolTip2(*args, widget=self, **kwargs)
151
+
@@ -0,0 +1,38 @@
1
+ from tkinter import Tk, Toplevel
2
+ from tkdeft.object import DObject
3
+ from .bwm import BWm
4
+
5
+
6
+ class FluWindow(Tk, BWm, DObject):
7
+
8
+ """Fluent设计的主窗口"""
9
+
10
+ def __init__(self, *args, className="tkdeft", mode="light", **kwargs):
11
+ """
12
+ 初始化类实例,继承自tkinter.TK并添加Fluent主题支持
13
+
14
+ :param args: 可变位置参数,传递给父类tkinter.TK.__init__的未命名参数
15
+ :param className: 窗口类名,默认"tkdeft",传递给父类tkinter.TK.__init__
16
+ :param mode: Fluent主题模式,可选值为"light"(明亮)或"dark"(暗黑),默认"light"
17
+ :param kwargs: 可变关键字参数,传递给父类tkinter.TK.__init__的命名参数
18
+ """
19
+
20
+ # 初始化Fluent主题
21
+ self._init(mode)
22
+
23
+ # 标记为未使用自定义配置
24
+ self.custom = False
25
+
26
+ # 调用父类tkinter.TK的初始化方法
27
+ super().__init__(*args, className=className, **kwargs)
28
+
29
+ # 设置窗口图标
30
+ from .icons import light
31
+ from tkinter import PhotoImage
32
+ self.iconphoto(False, PhotoImage(file=light()))
33
+
34
+ # 绑定事件处理函数
35
+ self.bind("<Configure>", self._event_configure, add="+") # 窗口大小/位置改变事件
36
+ self.bind("<Escape>", self._event_key_esc, add="+") # ESC键按下事件
37
+ self.protocol("WM_DELETE_WINDOW", self._event_delete_window) # 窗口关闭事件
38
+
tkfluent-0.0.8/PKG-INFO DELETED
@@ -1,29 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: tkfluent
3
- Version: 0.0.8
4
- Summary: Fluent Design for Tkinter
5
- Author: XiangQinxi
6
- Author-email: xiangqinxi@outlook.com
7
- Requires-Python: >=3.7,<4.0
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.7
10
- Classifier: Programming Language :: Python :: 3.8
11
- Classifier: Programming Language :: Python :: 3.9
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Requires-Dist: easydict (>=1.13,<2.0)
17
- Requires-Dist: pillow (>=10.2.0,<11.0.0)
18
- Requires-Dist: svgwrite (>=1.4.3,<2.0.0)
19
- Requires-Dist: tkdeft (>=0.0.9,<0.0.10)
20
- Requires-Dist: tkextrafont (>=0.6.3,<0.7.0)
21
- Requires-Dist: tksvg (>=0.7.4,<0.8.0)
22
- Project-URL: Documentation, https://tkfluent.netlify.app
23
- Description-Content-Type: text/markdown
24
-
25
- # tkfluent
26
-
27
- `tkinter`现代化组件库。设计来于`Fluent` `WinUI3` 设计
28
-
29
- ![](https://learn.microsoft.com/zh-cn/windows/apps/images/logo-winui.png)
tkfluent-0.0.8/README.md DELETED
@@ -1,5 +0,0 @@
1
- # tkfluent
2
-
3
- `tkinter`现代化组件库。设计来于`Fluent` `WinUI3` 设计
4
-
5
- ![](https://learn.microsoft.com/zh-cn/windows/apps/images/logo-winui.png)
@@ -1,23 +0,0 @@
1
- [tool.poetry]
2
- name = "tkfluent"
3
- version = "0.0.8"
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
- python = "^3.7"
14
- tksvg = "^0.7.4"
15
- tkextrafont = "^0.6.3"
16
- svgwrite = "^1.4.3"
17
- pillow = "^10.2.0"
18
- tkdeft = "^0.0.9"
19
- easydict = "^1.13"
20
-
21
- [build-system]
22
- requires = ["poetry-core"]
23
- build-backend = "poetry.core.masonry.api"
@@ -1,28 +0,0 @@
1
- from .window import FluWindow
2
- from .toplevel import FluToplevel
3
-
4
-
5
- class FluThemeManager(object):
6
- def __init__(self, window=None, mode: str = "light"):
7
- if window:
8
- self._window = window
9
- else:
10
- from tkinter import _default_root
11
- self._window = _default_root
12
- self._mode = mode
13
- self.mode(self._mode)
14
- self._window.after(100, lambda: self.mode(self._mode))
15
-
16
- def mode(self, mode: str):
17
- self._mode = mode
18
- if hasattr(self._window, "theme"):
19
- self._window.theme(mode=mode)
20
- if hasattr(self._window, "_draw"):
21
- self._window._draw()
22
- self._window.update()
23
- for widget in self._window.winfo_children():
24
- if hasattr(widget, "theme"):
25
- widget.theme(mode=mode)
26
- if hasattr(widget, "_draw"):
27
- widget._draw()
28
- widget.update()
@@ -1,8 +0,0 @@
1
- from .popupwindow import FluPopupWindow
2
-
3
-
4
- class FluToolTip(FluPopupWindow):
5
- def __init__(self, widget, *args, **kwargs):
6
- super().__init__(*args, **kwargs)
7
-
8
- self.widget = widget
@@ -1,34 +0,0 @@
1
- from tkinter import Tk, Toplevel
2
- from tkdeft.object import DObject
3
- from .bwm import BWm
4
-
5
-
6
- class FluWindow(Tk, BWm, DObject):
7
-
8
- """Fluent设计的主窗口"""
9
-
10
- def __init__(self, *args, className="tkdeft", mode="light", **kwargs):
11
-
12
- """
13
- 初始化类
14
-
15
- :param args: 参照tkinter.TK.__init__
16
- :param className: 参照tkinter.TK.__init__
17
- :param mode: Fluent主题模式 分为 “light” “dark”
18
- :param kwargs: 参照tkinter.TK.__init__
19
- """
20
-
21
- self._init(mode)
22
-
23
- self.custom = False
24
-
25
- super().__init__(*args, className=className, **kwargs)
26
-
27
- from .icons import light
28
- from tkinter import PhotoImage
29
-
30
- self.iconphoto(False, PhotoImage(file=light()))
31
-
32
- self.bind("<Configure>", self._event_configure, add="+")
33
- self.bind("<Escape>", self._event_key_esc, add="+")
34
- self.protocol("WM_DELETE_WINDOW", self._event_delete_window)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes