fluidp 1.0.0__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.
fluidp/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .fluidp import *
fluidp/fluidp.py ADDED
@@ -0,0 +1,444 @@
1
+ import tkinter as tk
2
+
3
+
4
+ # ==================================
5
+ # BOTON LIQUID GLASS
6
+ # ==================================
7
+
8
+ class GlassButton(tk.Canvas):
9
+
10
+ def __init__(self, parent, text, width, height, color):
11
+
12
+ super().__init__(
13
+ parent,
14
+ width=width,
15
+ height=height,
16
+ bg=parent.cget("bg"),
17
+ highlightthickness=0
18
+ )
19
+
20
+ self.text = text
21
+ self.color = color
22
+ self.command = None
23
+
24
+ self.draw()
25
+
26
+ self.bind("<Button-1>", self.click)
27
+ self.bind("<Enter>", self.hover)
28
+ self.bind("<Leave>", self.leave)
29
+
30
+ def draw(self, color=None):
31
+
32
+ self.delete("all")
33
+
34
+ color = color or self.color
35
+
36
+ w = int(self["width"])
37
+ h = int(self["height"])
38
+
39
+ self.create_polygon(
40
+ 12, 0, w-12, 0,
41
+ w, 12, w, h-12,
42
+ w-12, h, 12, h,
43
+ 0, h-12, 0, 12,
44
+ smooth=True,
45
+ fill=color
46
+ )
47
+
48
+ self.create_text(
49
+ w/2,
50
+ h/2,
51
+ text=self.text,
52
+ fill="white",
53
+ font=("Arial", 11, "bold")
54
+ )
55
+
56
+ def click(self, event=None):
57
+
58
+ if self.command:
59
+ self.command()
60
+
61
+ def hover(self, event=None):
62
+ self.draw("#7895B8")
63
+
64
+ def leave(self, event=None):
65
+ self.draw()
66
+
67
+ def set_command(self, command):
68
+ self.command = command
69
+
70
+
71
+ # ==================================
72
+ # ESCENAS
73
+ # ==================================
74
+
75
+ class Scene:
76
+
77
+ def __init__(self, id, name, window, color):
78
+
79
+ self.id = id
80
+ self.name = name
81
+
82
+ self.frame = tk.Frame(
83
+ window,
84
+ bg=color
85
+ )
86
+
87
+
88
+ # ==================================
89
+ # FLUIDP
90
+ # ==================================
91
+
92
+ class InitWindow:
93
+
94
+ def __init__(self, geometry="600x400", title="FluidP"):
95
+
96
+ self.window = tk.Tk()
97
+ self.window.geometry(geometry)
98
+ self.window.title(title)
99
+
100
+ self.objects = {}
101
+ self.scenes = {}
102
+ self.hidden = {}
103
+
104
+ self.active_scene = None
105
+
106
+ # TEMAS
107
+
108
+ self.themes = {
109
+
110
+ "Light": {
111
+ "background": "#EEEEEE",
112
+ "foreground": "#111111",
113
+ "button": "#CCCCCC",
114
+ "entry": "#FFFFFF"
115
+ },
116
+
117
+ "Dark": {
118
+ "background": "#181818",
119
+ "foreground": "#FFFFFF",
120
+ "button": "#333333",
121
+ "entry": "#252525"
122
+ },
123
+
124
+ "LiquidGlass": {
125
+ "background": "#172B45",
126
+ "foreground": "#FFFFFF",
127
+ "button": "#526783",
128
+ "entry": "#34465F"
129
+ }
130
+
131
+ }
132
+
133
+ self.SetTheme("LiquidGlass")
134
+
135
+ # ==================================
136
+ # TEMAS
137
+ # ==================================
138
+
139
+ def SetTheme(self, name):
140
+
141
+ if name not in self.themes:
142
+ raise ValueError("Tema no encontrado")
143
+
144
+ self.theme_name = name
145
+ self.theme = self.themes[name]
146
+
147
+ self.window.configure(
148
+ bg=self.theme["background"]
149
+ )
150
+
151
+ for scene in self.scenes.values():
152
+
153
+ scene.frame.configure(
154
+ bg=self.theme["background"]
155
+ )
156
+
157
+ for obj in self.objects.values():
158
+
159
+ if isinstance(obj, GlassButton):
160
+
161
+ obj.color = self.theme["button"]
162
+ obj.configure(bg=obj.master.cget("bg"))
163
+ obj.draw()
164
+
165
+ elif isinstance(obj, tk.Label):
166
+
167
+ obj.configure(
168
+ bg=obj.master.cget("bg"),
169
+ fg=self.theme["foreground"]
170
+ )
171
+
172
+ elif isinstance(obj, tk.Entry):
173
+
174
+ obj.configure(
175
+ bg=self.theme["entry"],
176
+ fg=self.theme["foreground"],
177
+ insertbackground=self.theme["foreground"]
178
+ )
179
+
180
+ # ==================================
181
+ # CREAR ESCENA
182
+ # ==================================
183
+
184
+ def scene(self, id, name):
185
+
186
+ if id in self.scenes:
187
+ raise ValueError("La escena ya existe")
188
+
189
+ new_scene = Scene(
190
+ id,
191
+ name,
192
+ self.window,
193
+ self.theme["background"]
194
+ )
195
+
196
+ self.scenes[id] = new_scene
197
+
198
+ return new_scene
199
+
200
+ # ==================================
201
+ # CAMBIAR ESCENA
202
+ # ==================================
203
+
204
+ def ChangeScene(self, scene):
205
+
206
+ if isinstance(scene, (int, str)):
207
+ scene = self.scenes[scene]
208
+
209
+ # Ocultar escena anterior
210
+ if self.active_scene:
211
+ self.active_scene.frame.pack_forget()
212
+
213
+ # Activar nueva escena
214
+ self.active_scene = scene
215
+
216
+ scene.frame.pack(
217
+ fill="both",
218
+ expand=True
219
+ )
220
+
221
+ # ==================================
222
+ # CREAR OBJETOS
223
+ # ==================================
224
+
225
+ def InitObject(
226
+ self,
227
+ OBJ,
228
+ size1=10,
229
+ size2=2,
230
+ text="",
231
+ Color=None,
232
+ name=None,
233
+ scene=None # <-- Parámetro escena integrado
234
+ ):
235
+
236
+ # Determinar el padre correcto
237
+ if scene is not None:
238
+ if isinstance(scene, (int, str)):
239
+ scene = self.scenes[scene]
240
+ parent = scene.frame
241
+ elif self.active_scene:
242
+ parent = self.active_scene.frame
243
+ else:
244
+ parent = self.window
245
+
246
+ if OBJ == "Button":
247
+
248
+ obj = GlassButton(
249
+ parent,
250
+ text,
251
+ size1 * 10,
252
+ size2 * 20,
253
+ Color or self.theme["button"]
254
+ )
255
+
256
+ elif OBJ == "Text":
257
+
258
+ obj = tk.Label(
259
+ parent,
260
+ text=text,
261
+ bg=Color or self.theme["background"],
262
+ fg=self.theme["foreground"],
263
+ font=("Arial", 12)
264
+ )
265
+
266
+ elif OBJ == "Entry":
267
+
268
+ obj = tk.Entry(
269
+ parent,
270
+ width=size1,
271
+ bg=Color or self.theme["entry"],
272
+ fg=self.theme["foreground"],
273
+ insertbackground=self.theme["foreground"],
274
+ relief="flat"
275
+ )
276
+
277
+ else:
278
+
279
+ raise ValueError("Objeto no válido")
280
+
281
+ if name:
282
+
283
+ if name in self.objects:
284
+ raise ValueError("Nombre duplicado")
285
+
286
+ self.objects[name] = obj
287
+
288
+ return obj
289
+
290
+ # ==================================
291
+ # AGREGAR OBJETOS
292
+ # ==================================
293
+
294
+ def add(self, obj, x, y, *args):
295
+
296
+ if isinstance(obj, str):
297
+ obj = self.objects[obj]
298
+
299
+ obj.place(x=x, y=y)
300
+
301
+ # ==================================
302
+ # COMANDOS
303
+ # ==================================
304
+
305
+ def command(self, obj, function):
306
+
307
+ if isinstance(obj, str):
308
+ obj = self.objects[obj]
309
+
310
+ if not callable(function):
311
+ raise TypeError("El comando debe ser una función")
312
+
313
+ obj.set_command(function)
314
+
315
+ # ==================================
316
+ # VISIBILIDAD
317
+ # ==================================
318
+
319
+ def visible(self, obj, show=True):
320
+
321
+ if isinstance(obj, str):
322
+ obj = self.objects[obj]
323
+
324
+ if show:
325
+
326
+ if obj in self.hidden:
327
+
328
+ obj.place(**self.hidden[obj])
329
+
330
+ del self.hidden[obj]
331
+
332
+ else:
333
+
334
+ self.hidden[obj] = obj.place_info()
335
+
336
+ obj.place_forget()
337
+
338
+ # ==================================
339
+ # CAMBIAR TEXTO
340
+ # ==================================
341
+
342
+ def ChangeText(self, obj, text):
343
+
344
+ if isinstance(obj, str):
345
+ obj = self.objects[obj]
346
+
347
+ if isinstance(obj, GlassButton):
348
+
349
+ obj.text = text
350
+ obj.draw()
351
+
352
+ elif isinstance(obj, tk.Label):
353
+
354
+ obj.configure(text=text)
355
+
356
+ elif isinstance(obj, tk.Entry):
357
+
358
+ obj.delete(0, tk.END)
359
+ obj.insert(0, text)
360
+
361
+ # ==================================
362
+ # OBTENER TEXTO
363
+ # ==================================
364
+
365
+ def GetText(self, obj):
366
+
367
+ if isinstance(obj, str):
368
+ obj = self.objects[obj]
369
+
370
+ return obj.get()
371
+
372
+ # ==================================
373
+ # CAMBIAR COLOR
374
+ # ==================================
375
+
376
+ def ChangeColor(self, obj, color):
377
+
378
+ if isinstance(obj, str):
379
+ obj = self.objects[obj]
380
+
381
+ if isinstance(obj, GlassButton):
382
+
383
+ obj.color = color
384
+ obj.draw()
385
+
386
+ else:
387
+
388
+ obj.configure(bg=color)
389
+
390
+ # ==================================
391
+ # CAMBIAR FONDO
392
+ # ==================================
393
+
394
+ def InitBackground(self, color):
395
+
396
+ self.window.configure(bg=color)
397
+
398
+ # ==================================
399
+ # ELIMINAR OBJETO
400
+ # ==================================
401
+
402
+ def Delete(self, obj):
403
+
404
+ if isinstance(obj, str):
405
+ obj = self.objects[obj]
406
+
407
+ for name, item in list(self.objects.items()):
408
+
409
+ if item == obj:
410
+ del self.objects[name]
411
+
412
+ self.hidden.pop(obj, None)
413
+
414
+ obj.destroy()
415
+
416
+ # ==================================
417
+ # CENTRAR VENTANA
418
+ # ==================================
419
+
420
+ def CenterWindow(self):
421
+
422
+ self.window.update_idletasks()
423
+
424
+ w = self.window.winfo_width()
425
+ h = self.window.winfo_height()
426
+
427
+ x = (self.window.winfo_screenwidth() - w) // 2
428
+ y = (self.window.winfo_screenheight() - h) // 2
429
+
430
+ self.window.geometry(
431
+ f"{w}x{h}+{x}+{y}"
432
+ )
433
+
434
+ # ==================================
435
+ # CERRAR
436
+ # ==================================
437
+
438
+ def Exit(self):
439
+
440
+ self.window.destroy()
441
+
442
+ def CloseWindow(self):
443
+
444
+ self.window.mainloop()
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: fluidp
3
+ Version: 1.0.0
4
+ Summary: Una librería moderna de Tkinter con componentes personalizados y diseño fluido.
5
+ Author: Sbtias
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+
10
+ # FluidP
11
+
12
+ Basado en tkinter
13
+
14
+
15
+ cada mes actualizado!
@@ -0,0 +1,6 @@
1
+ fluidp/__init__.py,sha256=aCuFRH2IFoiY97rZqWR4YCNX98-rGMIgyAZW3AWi7xo,24
2
+ fluidp/fluidp.py,sha256=6v13b-uG-UtzE4YjnrKM88n9LvzTxjGAlR55IeqqOjY,10224
3
+ fluidp-1.0.0.dist-info/METADATA,sha256=DJtHTu12SMzeFcvbzQ60XGJ4yNcBl-hJS40cb-kLV0k,316
4
+ fluidp-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ fluidp-1.0.0.dist-info/top_level.txt,sha256=YrzhbIK6mNDydjg1znZCcxRc2ymY7wbcyr37Os1LtCI,7
6
+ fluidp-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ fluidp