tkfluent 0.0.4__py3-none-any.whl → 0.0.5__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/frame.py CHANGED
@@ -1,11 +1,14 @@
1
1
  from tkdeft.windows.draw import DSvgDraw
2
2
  from tkdeft.windows.canvas import DCanvas
3
3
 
4
+ from .designs.frame import frame
5
+
4
6
 
5
7
  class FluFrameDraw(DSvgDraw):
6
8
  def create_roundrect(self,
7
9
  x1, y1, x2, y2, radius, radiusy=None, temppath=None,
8
- fill="transparent", outline="black", outline2="black", width=1
10
+ fill="transparent", #fill_opacity=1,
11
+ outline="black", outline_opacity=1, width=1
9
12
  ):
10
13
  if radiusy:
11
14
  _rx = radius
@@ -13,15 +16,63 @@ class FluFrameDraw(DSvgDraw):
13
16
  else:
14
17
  _rx, _ry = radius, radius
15
18
  drawing = self.create_drawing(x2 - x1, y2 - y1, temppath=temppath)
16
- border = drawing[1].linearGradient(start=(x1, y1), end=(x1, y2), id="DButton.Border")
17
- border.add_stop_color("0%", outline)
18
- border.add_stop_color("100%", outline2)
19
- drawing[1].defs.add(border)
19
+ filter1 = drawing[1].defs.add(
20
+ drawing[1].filter(id="filter", start=(0, 0), size=(x2 - x1, y2 - y1), filterUnits="userSpaceOnUse",
21
+ color_interpolation_filters="sRGB")
22
+ )
23
+
24
+ filter1.feFlood(flood_opacity="0", result="BackgroundImageFix")
25
+ filter1.feColorMatrix("SourceAlpha", type="matrix", values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",
26
+ result="hardAlpha")
27
+ filter1.feOffset(dx="0", dy="2")
28
+ filter1.feGaussianBlur(stdDeviation="1.33333")
29
+ filter1.feComposite(in2="hardAlpha", operator="out", k2="-1", k3="1")
30
+ filter1.feColorMatrix(type="matrix", values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.039 0")
31
+ filter1.feBlend(mode="normal", in2="BackgroundImageFix", result="effect_dropShadow_1")
32
+ filter1.feBlend(mode="normal", in2="effect_dropShadow_1", result="shape")
33
+
34
+ """if outline2:
35
+ border = drawing[1].linearGradient(start=(x1, y1), end=(x1, y2), id="DButton.Border")
36
+ border.add_stop_color("0%", outline)
37
+ border.add_stop_color("100%", outline2)
38
+ drawing[1].defs.add(border)
39
+ _border = f"url(#{border.get_id()})"
40
+ else:
41
+ _border = outline"""
42
+
43
+ """
44
+ <rect id="Surface / Card Surface" rx="-0.500000" width="159.000000" height="79.000000" transform="translate(3.500000 1.500000)" fill="#FFFFFF" fill-opacity="0"/>
45
+ """
46
+ """drawing[1].add(
47
+ drawing[1].rect(
48
+ rx="-0.500000",
49
+ size=(x2 - x1 - 7, y2 - y1 - 7),
50
+ transform="translate(3.500000 1.500000)",
51
+ fill="#FFFFFF",
52
+ fill_opacity="0"
53
+ )
54
+ )
55
+ drawing[1].add(
56
+ drawing[1].rect(
57
+ (4, 2), (x2 - x1 - 8, y2 - y1 - 8), _rx, _ry,
58
+ fill="#FFFFFF",
59
+ fill_opacity="0.700000",
60
+ )
61
+ )
62
+ group = drawing[1].g(filter="url(#filter)", style="mix-blend-mode:multiply")
63
+ group.add(
64
+ drawing[1].rect(
65
+ (4, 2), (x2 - x1 - 8, y2 - y1 - 8), _rx, _ry,
66
+ fill="#FFFFFF",
67
+ fill_opacity="1",
68
+ )
69
+ )"""
20
70
  drawing[1].add(
21
71
  drawing[1].rect(
22
72
  (x1, y1), (x2 - x1, y2 - y1), _rx, _ry,
23
- fill=fill, stroke_width=width,
24
- stroke=f"url(#{border.get_id()})",
73
+ fill=fill, #fill_opacity=fill_opacity,
74
+ stroke_width=width,
75
+ stroke=outline, stroke_opacity=outline_opacity
25
76
  )
26
77
  )
27
78
  drawing[1].save()
@@ -51,11 +102,13 @@ class FluFrameCanvas(DCanvas):
51
102
 
52
103
  def create_round_rectangle(self,
53
104
  x1, y1, x2, y2, r1, r2=None, temppath=None,
54
- fill="transparent", outline="black", outline2="black", width=1
105
+ fill="transparent", #fill_opacity=1,
106
+ outline="black", outline_opacity=1, width=1
55
107
  ):
56
108
  self._img = self.svgdraw.create_roundrect(
57
109
  x1, y1, x2, y2, r1, r2, temppath=temppath,
58
- fill=fill, outline=outline, outline2=outline2, width=width
110
+ fill=fill, #fill_opacity=fill_opacity,
111
+ outline=outline, outline_opacity=outline_opacity, width=width
59
112
  )
60
113
  self._tkimg = self.svgdraw.create_tksvg_image(self._img)
61
114
  return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
@@ -100,8 +153,9 @@ class FluFrame(Frame, DObject):
100
153
  self.attributes = EasyDict(
101
154
  {
102
155
  "back_color": None,
156
+ #"back_opacity": None,
103
157
  "border_color": None,
104
- "border_color2": None,
158
+ "border_color_opacity": None,
105
159
  "border_width": None,
106
160
  "radius": None,
107
161
  }
@@ -125,41 +179,26 @@ class FluFrame(Frame, DObject):
125
179
  else:
126
180
  self._light()
127
181
 
128
- def _light(self):
182
+ def _theme(self, mode, style):
183
+ n = frame(mode, style)
129
184
  self.dconfigure(
130
- back_color="#f9f9f9",
131
- border_color="#ebebeb",
132
- border_color2="#e4e4e4",
133
- border_width=1.5,
134
- radius=6,
185
+ back_color=n["back_color"],
186
+ border_color=n["border_color"],
187
+ border_color_opacity=n["border_color_opacity"],
188
+ border_width=n["border_width"],
189
+ radius=n["radius"],
135
190
  )
136
191
 
192
+ def _light(self):
193
+ self._theme("light", "standard")
194
+
137
195
  def _light_popupmenu(self):
138
- self.dconfigure(
139
- back_color="#f9f9f9",
140
- border_color="#4d5056",
141
- border_color2="#4d5056",
142
- border_width=1.5,
143
- radius=8,
144
- )
196
+ self._theme("light", "popupmenu")
145
197
 
146
198
  def _dark(self):
147
- self.dconfigure(
148
- back_color="#242424",
149
- border_color="#303030",
150
- border_color2="#282828",
151
- border_width=1.5,
152
- radius=6,
153
- )
154
-
199
+ self._theme("dark", "standard")
155
200
  def _dark_popupmenu(self):
156
- self.dconfigure(
157
- back_color="#242424",
158
- border_color="#4d5056",
159
- border_color2="#4d5056",
160
- border_width=1.5,
161
- radius=8,
162
- )
201
+ self._theme("dark", "popupmenu")
163
202
 
164
203
  def pack_info(self):
165
204
  return self.canvas.pack_info()
@@ -231,21 +270,24 @@ class FluFrame(Frame, DObject):
231
270
  place = place_configure
232
271
 
233
272
  def _draw(self, event=None):
273
+
234
274
  self.canvas.delete("all")
235
275
  self.canvas.config(background=self.canvas.master.cget("background"))
236
- self.config(background=self.attributes.back_color)
237
-
238
276
  _back_color = self.attributes.back_color
277
+ #_back_opacity = self.attributes.back_opacity
239
278
  _border_color = self.attributes.border_color
240
- _border_color2 = self.attributes.border_color2
279
+ _border_color_opacity = self.attributes.border_color_opacity
241
280
  _border_width = self.attributes.border_width
242
281
  _radius = self.attributes.radius
243
282
 
244
283
  self.element1 = self.canvas.create_round_rectangle(
245
284
  0, 0, self.canvas.winfo_width(), self.canvas.winfo_height(), _radius, temppath=self.temppath,
246
- fill=_back_color, outline=_border_color, outline2=_border_color2, width=_border_width
285
+ fill=_back_color, #fill_opacity=_back_opacity,
286
+ outline=_border_color, outline_opacity=_border_color_opacity, width=_border_width
247
287
  )
248
288
 
289
+ self.config(background=_back_color)
290
+
249
291
  self.element2 = self.canvas.create_window(
250
292
  self.canvas.winfo_width() / 2, self.canvas.winfo_height() / 2,
251
293
  window=self,
@@ -255,4 +297,3 @@ class FluFrame(Frame, DObject):
255
297
 
256
298
  def _event_configure(self, event=None):
257
299
  self._draw(event)
258
-
tkflu/label.py CHANGED
@@ -17,9 +17,8 @@ class FluLabel(DDrawWidget):
17
17
  text=text,
18
18
  )
19
19
 
20
- if font is None:
21
- from tkdeft.utility.fonts import SegoeFont
22
- self.attributes.font = SegoeFont()
20
+ from .defs import set_default_font
21
+ set_default_font(font, self.attributes)
23
22
 
24
23
  def _init(self, mode):
25
24
 
tkflu/menu.py CHANGED
@@ -12,8 +12,9 @@ class FluMenu(FluPopupMenu):
12
12
  self.attributes = EasyDict(
13
13
  {
14
14
  "back_color": None,
15
+ "back_opacity": None,
15
16
  "border_color": None,
16
- "border_color2": None,
17
+ "border_color_opacity": None,
17
18
  "border_width": None,
18
19
  "radius": None,
19
20
 
tkflu/popupwindow.py CHANGED
@@ -2,7 +2,7 @@ from tkinter import Toplevel
2
2
 
3
3
 
4
4
  class FluPopupWindow(Toplevel):
5
- def __init__(self, *args, transparent_color="#ffefa2", mode="light", width=100, height=46, **kwargs):
5
+ def __init__(self, *args, transparent_color="#ebebeb", mode="light", width=100, height=46, **kwargs):
6
6
  super().__init__(*args, background=transparent_color, **kwargs)
7
7
 
8
8
  self.theme(mode=mode)
tkflu/text.py CHANGED
@@ -2,30 +2,51 @@ from tkdeft.windows.draw import DSvgDraw
2
2
  from tkdeft.windows.canvas import DCanvas
3
3
  from tkdeft.windows.drawwidget import DDrawWidget
4
4
 
5
+ from .designs.text import text
6
+
5
7
 
6
8
  class FluTextDraw(DSvgDraw):
7
9
  def create_roundrect(self,
8
10
  x1, y1, x2, y2, radius, radiusy=None, temppath=None,
9
- fill="transparent", outline="black", outline2="black", width=1
11
+ fill="transparent", fill_opacity=1,
12
+ stop1="0.93", outline="black", outline_opacity=1,
13
+ stop2="0.94", outline2=None, outline2_opacity=1,
14
+ width=1
10
15
  ):
11
16
  if radiusy:
12
17
  _rx = radius
13
18
  _ry = radiusy
14
19
  else:
15
20
  _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("90%", outline)
20
- border.add_stop_color("100%", outline2)
21
- drawing[1].defs.add(border)
21
+ drawing = self.create_drawing(x2 - x1, y2 - y1, temppath=temppath, fill="none")
22
+ if outline2:
23
+ border = drawing[1].linearGradient(start=(x1, y1 + 1), end=(x1, y2 - 1), id="DButton.Border",
24
+ gradientUnits="userSpaceOnUse")
25
+ border.add_stop_color(stop1, outline, outline_opacity)
26
+ border.add_stop_color(stop2, outline2, outline2_opacity)
27
+ drawing[1].defs.add(border)
28
+ stroke = f"url(#{border.get_id()})"
29
+ stroke_opacity = 1
30
+ else:
31
+ stroke = outline
32
+ stroke_opacity = outline_opacity
33
+
22
34
  drawing[1].add(
23
35
  drawing[1].rect(
24
- (x1, y1), (x2 - x1, y2 - y1), _rx, _ry,
25
- fill=fill, stroke_width=width,
26
- stroke=f"url(#{border.get_id()})",
36
+ (x1 + 1, y1 + 1), (x2 - x1 - 2, y2 - y1 - 2), _rx, _ry,
37
+ id="Base",
38
+ fill=fill, fill_opacity=fill_opacity,
27
39
  )
28
40
  )
41
+ drawing[1].add(
42
+ drawing[1].rect(
43
+ (x1 + 0.5, y1 + 0.5), (x2 - x1 - 1, y2 - y1 - 1), _rx, _ry,
44
+ id="Base",
45
+ fill="white", fill_opacity="0",
46
+ stroke=stroke, stroke_width=width, stroke_opacity=stroke_opacity,
47
+ )
48
+ )
49
+ #print("FluEntry", drawing[0])
29
50
  drawing[1].save()
30
51
  return drawing[0]
31
52
 
@@ -35,11 +56,15 @@ class FluTextCanvas(DCanvas):
35
56
 
36
57
  def create_round_rectangle(self,
37
58
  x1, y1, x2, y2, r1, r2=None, temppath=None,
38
- fill="transparent", outline="black", outline2="black", width=1
59
+ fill="transparent", fill_opacity=1, stop1="0.93", stop2="0.94",
60
+ outline="black", outline2="black", outline_opacity=1, outline2_opacity=1,
61
+ width=1
39
62
  ):
40
63
  self._img = self.svgdraw.create_roundrect(
41
64
  x1, y1, x2, y2, r1, r2, temppath=temppath,
42
- fill=fill, outline=outline, outline2=outline2, width=width
65
+ fill=fill, fill_opacity=fill_opacity, stop1=stop1, stop2=stop2,
66
+ outline=outline, outline2=outline2, outline_opacity=outline_opacity, outline2_opacity=outline2_opacity,
67
+ width=width
43
68
  )
44
69
  self._tkimg = self.svgdraw.create_tksvg_image(self._img)
45
70
  return self.create_image(x1, y1, anchor="nw", image=self._tkimg)
@@ -77,9 +102,8 @@ class FluText(FluTextCanvas, DDrawWidget):
77
102
  state=state,
78
103
  )
79
104
 
80
- if font is None:
81
- from tkdeft.utility.fonts import SegoeFont
82
- self.attributes.font = SegoeFont()
105
+ from .defs import set_default_font
106
+ set_default_font(font, self.attributes)
83
107
 
84
108
  def _init(self, mode):
85
109
  from easydict import EasyDict
@@ -90,7 +114,8 @@ class FluText(FluTextCanvas, DDrawWidget):
90
114
  "state": "normal",
91
115
 
92
116
  "rest": {},
93
- "focus": {},
117
+ "hover": {},
118
+ "pressed": {},
94
119
  "disabled": {},
95
120
  }
96
121
  )
@@ -100,36 +125,43 @@ class FluText(FluTextCanvas, DDrawWidget):
100
125
  def _draw(self, event=None):
101
126
  super()._draw(event)
102
127
 
128
+ width = self.winfo_width()
129
+ height = self.winfo_height()
130
+
103
131
  self.text.configure(font=self.attributes.font)
104
132
 
105
133
  self.delete("all")
106
134
 
107
135
  state = self.dcget("state")
108
136
 
137
+ _dict = None
138
+
109
139
  if state == "normal":
110
- self.text.configure(state="normal")
111
140
  if self.isfocus:
112
- _back_color = self.attributes.focus.back_color
113
- _border_color = self.attributes.focus.border_color
114
- _border_color2 = self.attributes.focus.border_color2
115
- _border_width = self.attributes.focus.border_width
116
- _radius = self.attributes.focus.radius
117
- _text_color = self.attributes.focus.text_color
141
+ _dict = self.attributes.pressed
118
142
  else:
119
- _back_color = self.attributes.rest.back_color
120
- _border_color = self.attributes.rest.border_color
121
- _border_color2 = self.attributes.rest.border_color2
122
- _border_width = self.attributes.rest.border_width
123
- _radius = self.attributes.rest.radius
124
- _text_color = self.attributes.rest.text_color
143
+ if self.enter:
144
+ _dict = self.attributes.hover
145
+ else:
146
+ _dict = self.attributes.rest
147
+ self.text.configure(state="normal")
125
148
  else:
149
+ _dict = self.attributes.disabled
126
150
  self.text.configure(state="disabled")
127
- _back_color = self.attributes.disabled.back_color
128
- _border_color = self.attributes.disabled.border_color
129
- _border_color2 = self.attributes.disabled.border_color2
130
- _border_width = self.attributes.disabled.border_width
131
- _radius = self.attributes.disabled.radius
132
- _text_color = self.attributes.disabled.text_color
151
+
152
+ _stop1 = _dict.stop1
153
+ _stop2 = _dict.stop2
154
+ _back_color = _dict.back_color
155
+ _back_opacity = _dict.back_opacity
156
+ _border_color = _dict.border_color
157
+ _border_color_opacity = _dict.border_color_opacity
158
+ _border_color2 = _dict.border_color2
159
+ _border_color2_opacity = _dict.border_color2_opacity
160
+ _border_width = _dict.border_width
161
+ _radius = _dict.radius
162
+ _text_color = _dict.text_color
163
+ _underline_fill = _dict.underline_fill
164
+ _underline_width = _dict.underline_width
133
165
 
134
166
  self.text.configure(
135
167
  background=_back_color, insertbackground=_text_color, foreground=_text_color,
@@ -138,14 +170,19 @@ class FluText(FluTextCanvas, DDrawWidget):
138
170
  )
139
171
 
140
172
  self.element_border = self.create_round_rectangle(
141
- 0, 0, self.winfo_width(), self.winfo_height(), _radius, temppath=self.temppath,
142
- fill=_back_color, outline=_border_color, outline2=_border_color2, width=_border_width
173
+ 0, 0, width, height, _radius, temppath=self.temppath,
174
+ fill=_back_color, fill_opacity=_back_opacity, stop1=_stop1, stop2=_stop2,
175
+ outline=_border_color, outline_opacity=_border_color_opacity, outline2=_border_color2,
176
+ outline2_opacity=_border_color2_opacity,
177
+ width=_border_width
143
178
  )
144
179
 
145
- self.element_line = self.create_line(
146
- _radius / 3, self.winfo_height() - _radius / 3, self.winfo_width() - _radius / 3, self.winfo_height() - _radius / 3,
147
- width=1, fill=_border_color2
148
- )
180
+ if _underline_fill:
181
+ self.element_line = self.create_line(
182
+ _radius / 3 + _border_width, self.winfo_height() - _radius / 3,
183
+ self.winfo_width() - _radius / 3 - _border_width * 2, self.winfo_height() - _radius / 3,
184
+ width=_underline_width, fill=_underline_fill
185
+ )
149
186
 
150
187
  self.element_text = self.create_window(
151
188
  self.winfo_width() / 2, self.winfo_height() / 2,
@@ -171,58 +208,92 @@ class FluText(FluTextCanvas, DDrawWidget):
171
208
  else:
172
209
  self._light()
173
210
 
174
- def _light(self):
211
+ def _theme(self, mode):
212
+ r = text(mode, "rest")
213
+ h = text(mode, "hover")
214
+ p = text(mode, "pressed")
215
+ d = text(mode, "disabled")
175
216
  self.dconfigure(
176
217
  rest={
177
- "back_color": "#ffffff",
178
- "border_color": "#e5e5e5",
179
- "border_color2": "#8d8d8d",
180
- "border_width": 1,
181
- "radius": 6,
182
- "text_color": "#646464",
183
- },
184
- focus={
185
- "back_color": "#ffffff",
186
- "border_color": "#e5e5e5",
187
- "border_color2": "#005fb8",
188
- "border_width": 2,
189
- "radius": 6,
190
- "text_color": "#636363",
218
+ "back_color": r["back_color"],
219
+ "back_opacity": r["back_opacity"],
220
+
221
+ "stop1": r["stop1"],
222
+ "border_color": r["border_color"],
223
+ "border_color_opacity": r["border_color_opacity"],
224
+
225
+ "stop2": r["stop2"],
226
+ "border_color2": r["border_color2"],
227
+ "border_color2_opacity": r["border_color2_opacity"],
228
+
229
+ "border_width": r["border_width"],
230
+ "radius": r["radius"],
231
+ "text_color": r["text_color"],
232
+
233
+ "underline_fill": r["underline_fill"],
234
+ "underline_width": r["underline_width"]
191
235
  },
192
- disabled={
193
- "back_color": "#fdfdfd",
194
- "border_color": "#e5e5e5",
195
- "border_color2": "#e5e5e5",
196
- "border_width": 1,
197
- "radius": 6,
198
- "text_color": "#a2a2a2",
199
- }
200
- )
236
+ hover={
237
+ "back_color": h["back_color"],
238
+ "back_opacity": h["back_opacity"],
201
239
 
202
- def _dark(self):
203
- self.dconfigure(
204
- rest={
205
- "back_color": "#272727",
206
- "border_color": "#2c2c2c",
207
- "border_color2": "#979797",
208
- "border_width": 1,
209
- "radius": 6,
210
- "text_color": "#ffffff",
240
+ "stop1": h["stop1"],
241
+ "border_color": h["border_color"],
242
+ "border_color_opacity": h["border_color_opacity"],
243
+
244
+ "stop2": h["stop2"],
245
+ "border_color2": h["border_color2"],
246
+ "border_color2_opacity": h["border_color2_opacity"],
247
+
248
+ "border_width": h["border_width"],
249
+ "radius": h["radius"],
250
+ "text_color": h["text_color"],
251
+
252
+ "underline_fill": h["underline_fill"],
253
+ "underline_width": r["underline_width"]
211
254
  },
212
- focus={
213
- "back_color": "#1d1d1d",
214
- "border_color": "#272727",
215
- "border_color2": "#60cdff",
216
- "border_width": 2,
217
- "radius": 6,
218
- "text_color": "#ffffff",
255
+ pressed={
256
+ "back_color": p["back_color"],
257
+ "back_opacity": p["back_opacity"],
258
+
259
+ "stop1": p["stop1"],
260
+ "border_color": p["border_color"],
261
+ "border_color_opacity": p["border_color_opacity"],
262
+
263
+ "stop2": p["stop2"],
264
+ "border_color2": p["border_color2"],
265
+ "border_color2_opacity": p["border_color2_opacity"],
266
+
267
+ "border_width": p["border_width"],
268
+ "radius": p["radius"],
269
+ "text_color": p["text_color"],
270
+
271
+ "underline_fill": p["underline_fill"],
272
+ "underline_width": r["underline_width"]
219
273
  },
220
274
  disabled={
221
- "back_color": "#2a2a2a",
222
- "border_color": "#303030",
223
- "border_color2": "#303030",
224
- "border_width": 1,
225
- "radius": 6,
226
- "text_color": "#787878",
275
+ "back_color": d["back_color"],
276
+ "back_opacity": r["back_opacity"],
277
+
278
+ "stop1": d["stop1"],
279
+ "border_color": d["border_color"],
280
+ "border_color_opacity": d["border_color_opacity"],
281
+
282
+ "stop2": d["stop2"],
283
+ "border_color2": d["border_color2"],
284
+ "border_color2_opacity": d["border_color2_opacity"],
285
+
286
+ "border_width": d["border_width"],
287
+ "radius": d["radius"],
288
+ "text_color": d["text_color"],
289
+
290
+ "underline_fill": d["underline_fill"],
291
+ "underline_width": r["underline_width"]
227
292
  }
228
293
  )
294
+
295
+ def _light(self):
296
+ self._theme("light")
297
+
298
+ def _dark(self):
299
+ self._theme("dark")