tkfluent 0.0.2__tar.gz → 0.0.3__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 (29) hide show
  1. {tkfluent-0.0.2 → tkfluent-0.0.3}/PKG-INFO +1 -1
  2. {tkfluent-0.0.2 → tkfluent-0.0.3}/pyproject.toml +1 -1
  3. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/__init__.py +3 -0
  4. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/__main__.py +22 -2
  5. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/button.py +6 -6
  6. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/entry.py +4 -2
  7. tkfluent-0.0.3/tkflu/menu.py +65 -0
  8. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/menubar.py +13 -8
  9. tkfluent-0.0.3/tkflu/popupmenu.py +81 -0
  10. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/text.py +4 -2
  11. tkfluent-0.0.3/tkflu/winico.py +25 -0
  12. tkfluent-0.0.2/tkflu/menu.py +0 -7
  13. tkfluent-0.0.2/tkflu/popupmenu.py +0 -37
  14. {tkfluent-0.0.2 → tkfluent-0.0.3}/README.md +0 -0
  15. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/badge.py +0 -0
  16. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/bwm.py +0 -0
  17. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/checkbox.py +0 -0
  18. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/customwindow.py +0 -0
  19. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/customwindow2.py +0 -0
  20. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/frame.py +0 -0
  21. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/image.py +0 -0
  22. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/label.py +0 -0
  23. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/listbox.py +0 -0
  24. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/litenav.py +0 -0
  25. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/scrollbar.py +0 -0
  26. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/thememanager.py +0 -0
  27. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/togglebutton.py +0 -0
  28. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/toplevel.py +0 -0
  29. {tkfluent-0.0.2 → tkfluent-0.0.3}/tkflu/window.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tkfluent
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: Fluent Design for Tkinter
5
5
  Author: XiangQinxi
6
6
  Author-email: xiangqinxi@outlook.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tkfluent"
3
- version = "0.0.2"
3
+ version = "0.0.3"
4
4
  description = "Fluent Design for Tkinter"
5
5
  authors = ["XiangQinxi <xiangqinxi@outlook.com>"]
6
6
  readme = "README.md"
@@ -12,6 +12,7 @@ from .button import FluButton
12
12
  from .entry import FluEntry
13
13
  from .frame import FluFrame
14
14
  from .label import FluLabel
15
+ from .menu import FluMenu
15
16
  from .menubar import FluMenuBar
16
17
  from .popupmenu import FluPopupMenu
17
18
  from .text import FluText
@@ -19,6 +20,8 @@ from .thememanager import FluThemeManager
19
20
  from .togglebutton import FluToggleButton
20
21
  from .toplevel import FluToplevel
21
22
  from .window import FluWindow
23
+ #from .winico import FluWinico
24
+
22
25
 
23
26
  FluChip = FluBadge
24
27
  FluPushButton = FluButton
@@ -4,7 +4,7 @@ from tkinter.font import *
4
4
 
5
5
  root = FluWindow()
6
6
  #root.wincustom(way=0)
7
- root.wm_geometry("220x400")
7
+ root.wm_geometry("360x500")
8
8
 
9
9
  popupmenu = FluPopupMenu()
10
10
 
@@ -12,8 +12,28 @@ thememanager = FluThemeManager()
12
12
 
13
13
  menubar = FluMenuBar(root)
14
14
  menubar.add_command(
15
- label="FluMenu1", width=80, command=lambda: print("FluMenu -> Clicked")
15
+ label="FluMenu1", width=80, command=lambda: print("FluMenu1 -> Clicked")
16
16
  )
17
+
18
+ menu1 = FluMenu()
19
+ menu1.add_command(
20
+ label="FluMenu2-1", width=80, command=lambda: print("FluMenu2-1 -> Clicked")
21
+ )
22
+ menubar.add_cascade(
23
+ label="FluMenu2", width=80, menu=menu1
24
+ )
25
+
26
+ menu2 = FluMenu(height=93)
27
+ menu2.add_command(
28
+ label="FluMenu3-1", width=80, command=lambda: print("FluMenu3-1 -> Clicked")
29
+ )
30
+ menu2.add_command(
31
+ label="FluMenu3-2", width=80, command=lambda: print("FluMenu3-2 -> Clicked")
32
+ )
33
+ menubar.add_cascade(
34
+ label="FluMenu3", width=80, menu=menu2
35
+ )
36
+
17
37
  menubar.pack(fill="x",)
18
38
 
19
39
  frame = FluFrame(root)
@@ -179,24 +179,24 @@ class FluButton(FluButtonCanvas, DDrawWidget):
179
179
  self.dconfigure(
180
180
  rest={
181
181
  "back_color": "#ffffff",
182
- "border_color": "#f0f0f0",
183
- "border_color2": "#d6d6d6",
182
+ "border_color": "#e5e5e5",
183
+ "border_color2": "#cccccc",
184
184
  "border_width": 1,
185
185
  "radius": 6,
186
186
  "text_color": "#1b1b1b",
187
187
  },
188
188
  hover={
189
189
  "back_color": "#fcfcfc",
190
- "border_color": "#f0f0f0",
191
- "border_color2": "#d6d6d6",
190
+ "border_color": "#e5e5e5",
191
+ "border_color2": "#cccccc",
192
192
  "border_width": 1,
193
193
  "radius": 6,
194
194
  "text_color": "#1b1b1b",
195
195
  },
196
196
  pressed={
197
197
  "back_color": "#fdfdfd",
198
- "border_color": "#f0f0f0",
199
- "border_color2": "#f0f0f0",
198
+ "border_color": "#e5e5e5",
199
+ "border_color2": "#e5e5e5",
200
200
  "border_width": 1,
201
201
  "radius": 6,
202
202
  "text_color": "#636363",
@@ -71,6 +71,8 @@ class FluEntry(FluEntryCanvas, DDrawWidget):
71
71
 
72
72
  super().__init__(*args, width=width, height=height, cursor=cursor, **kwargs)
73
73
 
74
+ self.bind("<FocusIn>", self._event_focus_in, add="+")
75
+
74
76
  if font is None:
75
77
  from tkdeft.utility.fonts import SegoeFont
76
78
  self.attributes.font = SegoeFont()
@@ -148,7 +150,7 @@ class FluEntry(FluEntryCanvas, DDrawWidget):
148
150
  self.dconfigure(
149
151
  rest={
150
152
  "back_color": "#ffffff",
151
- "border_color": "#f0f0f0",
153
+ "border_color": "#e5e5e5",
152
154
  "border_color2": "#8d8d8d",
153
155
  "border_width": 1,
154
156
  "radius": 6,
@@ -156,7 +158,7 @@ class FluEntry(FluEntryCanvas, DDrawWidget):
156
158
  },
157
159
  focus={
158
160
  "back_color": "#ffffff",
159
- "border_color": "#f0f0f0",
161
+ "border_color": "#e5e5e5",
160
162
  "border_color2": "#005fb8",
161
163
  "border_width": 2,
162
164
  "radius": 6,
@@ -0,0 +1,65 @@
1
+ from .popupmenu import FluPopupMenu
2
+ from tkdeft.object import DObject
3
+
4
+
5
+ class FluMenu(FluPopupMenu):
6
+ def __init__(self, *args, **kwargs):
7
+ super().__init__(*args, **kwargs)
8
+
9
+ def _init(self, mode, style):
10
+ from easydict import EasyDict
11
+
12
+ self.attributes = EasyDict(
13
+ {
14
+ "back_color": None,
15
+ "border_color": None,
16
+ "border_color2": None,
17
+ "border_width": None,
18
+ "radius": None,
19
+
20
+ "actions": {}
21
+ }
22
+ )
23
+
24
+ self.theme(mode=mode, style=style)
25
+
26
+ def add_command(self, custom_widget=None, width=40, **kwargs):
27
+ if custom_widget:
28
+ widget = custom_widget(self)
29
+ else:
30
+ from .button import FluButton
31
+ widget = FluButton(self, width=width)
32
+ if "label" in kwargs:
33
+ label = kwargs.pop("label")
34
+ else:
35
+ label = ""
36
+ if "style" in kwargs:
37
+ style = kwargs.pop("style")
38
+ else:
39
+ style = "menu"
40
+ if "command" in kwargs:
41
+ c = kwargs.pop("command")
42
+
43
+ def command():
44
+ c()
45
+ self.window.wm_withdraw()
46
+
47
+ else:
48
+ def empty():
49
+ pass
50
+
51
+ command = empty
52
+ if "id" in kwargs:
53
+ id = kwargs.pop("id")
54
+ else:
55
+ id = widget._w
56
+ if hasattr(widget, "dconfigure"):
57
+ widget.dconfigure(text=label, command=command)
58
+ else:
59
+ if hasattr(widget, "configure"):
60
+ widget.configure(text=label, command=command)
61
+ if hasattr(widget, "theme"):
62
+ widget.theme(style=style)
63
+
64
+ widget.pack(side="top", fill="x", padx=1, pady=(1, 0))
65
+ self.dcget("actions")[id] = widget
@@ -62,7 +62,9 @@ class FluMenuBar(Frame, DObject):
62
62
  widget.pack(side="left", padx=5, pady=5)
63
63
  self.dcget("actions")[id] = widget
64
64
 
65
- def add_cascade(self, custom_widget=None, width=40, menu=None, **kwargs):
65
+ from .menu import FluMenu
66
+
67
+ def add_cascade(self, custom_widget=None, width=40, menu: FluMenu = None, **kwargs):
66
68
  if custom_widget:
67
69
  widget = custom_widget(self)
68
70
  else:
@@ -76,17 +78,17 @@ class FluMenuBar(Frame, DObject):
76
78
  style = kwargs.pop("style")
77
79
  else:
78
80
  style = "menu"
79
- if "command" in kwargs:
80
- command = kwargs.pop("command")
81
- else:
82
- def empty():
83
- pass
84
-
85
- command = empty
86
81
  if "id" in kwargs:
87
82
  id = kwargs.pop("id")
88
83
  else:
89
84
  id = widget._w
85
+
86
+ def command():
87
+ menu.focus_set()
88
+ menu.popup(widget.winfo_rootx(), widget.winfo_rooty() + widget.winfo_height())
89
+ menu.window.deiconify()
90
+ menu.window.attributes("-topmost")
91
+
90
92
  if hasattr(widget, "dconfigure"):
91
93
  widget.dconfigure(text=label, command=command)
92
94
  else:
@@ -98,6 +100,9 @@ class FluMenuBar(Frame, DObject):
98
100
  widget.pack(side="left", padx=5, pady=5)
99
101
  self.dcget("actions")[id] = widget
100
102
 
103
+ def action(self, id):
104
+ return self.dcget("actions")[id]
105
+
101
106
  def theme(self, mode="light"):
102
107
  self.theme_myself(mode=mode)
103
108
 
@@ -0,0 +1,81 @@
1
+ from tkinter import Toplevel
2
+ from .frame import FluFrame
3
+
4
+
5
+ class FluPopupMenuWindow(Toplevel):
6
+ def __init__(self, *args, transparent_color="#ffefa2", mode="light", width=100, height=46, **kwargs):
7
+ super().__init__(*args, background=transparent_color, **kwargs)
8
+
9
+ self.theme(mode=mode)
10
+
11
+ self.geometry(f"{width}x{height}")
12
+
13
+ self.transient_color = transparent_color
14
+ self.overrideredirect(True)
15
+ self.attributes("-transparentcolor", transparent_color)
16
+
17
+ self.withdraw()
18
+
19
+ self.bind("<FocusOut>", self._event_focusout)
20
+
21
+ def _event_focusout(self, event=None):
22
+ self.withdraw()
23
+
24
+ def popup(self, x, y):
25
+ self.geometry(f"+{x}+{y}")
26
+
27
+ def theme(self, mode=None):
28
+ if mode:
29
+ self.mode = mode
30
+ for widget in self.winfo_children():
31
+ if hasattr(widget, "theme"):
32
+ widget.theme(mode=self.mode.lower())
33
+
34
+
35
+ class FluPopupMenu(FluFrame):
36
+ def __init__(self, *args, width=100, height=46, transparent_color="#ffefa2", style="popupmenu", **kwargs):
37
+ self.window = FluPopupMenuWindow(transparent_color=transparent_color, width=width, height=height)
38
+
39
+ super().__init__(self.window, *args, style=style, **kwargs)
40
+
41
+ self.pack(fill="both", expand="yes", padx=5, pady=5)
42
+
43
+ def wm_attributes(self, *args, **kwargs):
44
+ self.window.wm_attributes(*args, **kwargs)
45
+
46
+ attributes = wm_attributes
47
+
48
+ def wm_protocol(self, *args, **kwargs):
49
+ self.window.wm_protocol(*args, **kwargs)
50
+
51
+ protocol = wm_protocol
52
+
53
+ def wm_deiconify(self, *args, **kwargs):
54
+ self.window.wm_deiconify(*args, **kwargs)
55
+
56
+ deiconify = wm_deiconify
57
+
58
+ def wm_withdraw(self, *args, **kwargs):
59
+ self.window.wm_withdraw(*args, **kwargs)
60
+
61
+ withdraw = wm_withdraw
62
+
63
+ def wm_iconify(self, *args, **kwargs):
64
+ self.window.wm_iconify(*args, **kwargs)
65
+
66
+ iconify = wm_iconify
67
+
68
+ def wm_resizable(self, *args, **kwargs):
69
+ self.window.wm_resizable(*args, **kwargs)
70
+
71
+ resizable = wm_resizable
72
+
73
+ def wm_geometry(self, *args, **kwargs):
74
+ self.window.wm_geometry(*args, **kwargs)
75
+
76
+ geometry = wm_geometry
77
+
78
+ def wm_popup(self, x, y):
79
+ self.window.popup(x=x, y=y)
80
+
81
+ popup = wm_popup
@@ -70,6 +70,8 @@ class FluText(FluTextCanvas, DDrawWidget):
70
70
 
71
71
  super().__init__(*args, width=width, height=height, cursor=cursor, **kwargs)
72
72
 
73
+ self.bind("<FocusIn>", self._event_focus_in, add="+")
74
+
73
75
  if font is None:
74
76
  from tkdeft.utility.fonts import SegoeFont
75
77
  self.attributes.font = SegoeFont()
@@ -151,7 +153,7 @@ class FluText(FluTextCanvas, DDrawWidget):
151
153
  self.dconfigure(
152
154
  rest={
153
155
  "back_color": "#ffffff",
154
- "border_color": "#f0f0f0",
156
+ "border_color": "#e5e5e5",
155
157
  "border_color2": "#8d8d8d",
156
158
  "border_width": 1,
157
159
  "radius": 6,
@@ -159,7 +161,7 @@ class FluText(FluTextCanvas, DDrawWidget):
159
161
  },
160
162
  focus={
161
163
  "back_color": "#ffffff",
162
- "border_color": "#f0f0f0",
164
+ "border_color": "#e5e5e5",
163
165
  "border_color2": "#005fb8",
164
166
  "border_width": 2,
165
167
  "radius": 6,
@@ -0,0 +1,25 @@
1
+ from tkdeft.object import DObject
2
+
3
+ try:
4
+ from tkwinico import *
5
+ except:
6
+ class FluWinico(DObject):
7
+ pass
8
+ else:
9
+ class FluWinico(Winico, DObject):
10
+ def __init__(self, *args, icon_name=None, icon_file=None, **kwargs):
11
+ super().__init__(*args, **kwargs)
12
+
13
+ self.tray_add(self.icon(icon_name=icon_name, icon_file=icon_file), callback=self.callback, callback_args=[MESSAGE, X, Y])
14
+
15
+ from .popupmenu import FluPopupMenu
16
+
17
+ self.menu = FluPopupMenu()
18
+ self.menu.window.geometry("100x40")
19
+
20
+ def callback(self, message, x, y):
21
+ if message == "WM_RBUTTONDOWNessage":
22
+ self.menu.window.attributes("-topmost", True)
23
+ self.menu.window.deiconify()
24
+ self.menu.popup(x, y)
25
+ self.menu.focus_set()
@@ -1,7 +0,0 @@
1
- from .popupmenu import FluPopupMenu
2
- from tkdeft.object import DObject
3
-
4
-
5
- class FluMenu(FluPopupMenu):
6
- def __init__(self, *args, **kwargs):
7
- super().__init__(*args, **kwargs)
@@ -1,37 +0,0 @@
1
- from tkinter import Toplevel
2
- from .frame import FluFrame
3
-
4
-
5
- class FluPopupMenuWindow(Toplevel):
6
- def __init__(self, *args, transparent_color="#ffefa2", mode="light", width=200, height=400, **kwargs):
7
- super().__init__(*args, background=transparent_color, width=width, height=height, **kwargs)
8
-
9
- self.theme(mode=mode)
10
-
11
- self.transient_color = transparent_color
12
- self.overrideredirect(True)
13
- self.attributes("-transparentcolor", transparent_color)
14
-
15
- self.withdraw()
16
-
17
- def popup(self, x, y):
18
- self.geometry(f"+{x}+{y}")
19
-
20
- def theme(self, mode=None):
21
- if mode:
22
- self.mode = mode
23
- for widget in self.winfo_children():
24
- if hasattr(widget, "theme"):
25
- widget.theme(mode=self.mode.lower())
26
-
27
-
28
- class FluPopupMenu(FluFrame):
29
- def __init__(self, *args, transparent_color="#ffefa2", style="popupmenu", **kwargs):
30
- self.window = FluPopupMenuWindow(transparent_color=transparent_color)
31
-
32
- super().__init__(self.window, *args, style=style, **kwargs)
33
-
34
- self.pack(fill="both", expand="yes", padx=5, pady=5)
35
-
36
- def popup(self, x, y):
37
- self.window.popup(x=x, y=y)
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
File without changes
File without changes