opentkinter 1.0.0__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,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: opentkinter
3
+ Version: 1.0.0
4
+ Summary: OpenTkinter — обгортка над tkinter
5
+ Author: Poowo1101
6
+ Requires-Python: >=3.6
7
+ Requires-Dist: pillow>=9.0.0
8
+ Dynamic: author
9
+ Dynamic: requires-dist
10
+ Dynamic: requires-python
11
+ Dynamic: summary
@@ -0,0 +1,34 @@
1
+ \# OpenTkinter
2
+
3
+
4
+
5
+ Просто обгортка над tkinter. Зроблено на колінках, але працює.
6
+
7
+
8
+
9
+ \## Встановлення
10
+
11
+ pip install opentkinter
12
+
13
+
14
+
15
+ \## Використання
16
+
17
+ python
18
+
19
+ from opentkinter import OpenTkinter
20
+
21
+
22
+
23
+ app = OpenTkinter.App(title="OpenTkinter")
24
+
25
+ btn = OpenTkinter.Button(app, text="Тиць")
26
+
27
+ btn.pack()
28
+
29
+ app.mainloop()
30
+
31
+ Автор
32
+
33
+ Poowo1101
34
+
@@ -0,0 +1,7 @@
1
+ from .core import OpenTkinter
2
+ from .widgets import Button, Entry, Label, Frame
3
+ from .themes import ThemeManager
4
+ from .animations import Animation
5
+
6
+ __version__ = "1.0.0"
7
+ __author__ = "Poowo1101"
@@ -0,0 +1,37 @@
1
+ import threading
2
+ import time
3
+
4
+ class Animation:
5
+ @staticmethod
6
+ def fade_in(widget, duration=0.3):
7
+ def animate():
8
+ alpha = 0.0
9
+ step = 0.05
10
+ while alpha <= 1.0:
11
+ try:
12
+ widget.attributes("-alpha", alpha)
13
+ except:
14
+ pass
15
+ alpha += step
16
+ time.sleep(duration / 20)
17
+ try:
18
+ widget.attributes("-alpha", 1.0)
19
+ except:
20
+ pass
21
+ threading.Thread(target=animate, daemon=True).start()
22
+
23
+ @staticmethod
24
+ def fade_out(widget, duration=0.3, callback=None):
25
+ def animate():
26
+ alpha = 1.0
27
+ step = 0.05
28
+ while alpha >= 0.0:
29
+ try:
30
+ widget.attributes("-alpha", alpha)
31
+ except:
32
+ pass
33
+ alpha -= step
34
+ time.sleep(duration / 20)
35
+ if callback:
36
+ callback()
37
+ threading.Thread(target=animate, daemon=True).start()
@@ -0,0 +1,35 @@
1
+ import tkinter as tk
2
+ from tkinter import messagebox, filedialog, colorchooser
3
+
4
+ class OpenTkinter:
5
+ class App(tk.Tk):
6
+ def __init__(self, title="OpenTkinter", size="800x600"):
7
+ super().__init__()
8
+ self.title(title)
9
+ self.geometry(size)
10
+ self.configure(bg="#1e1e1e")
11
+ self.center()
12
+
13
+ def center(self):
14
+ self.update_idletasks()
15
+ x = (self.winfo_screenwidth() - self.winfo_width()) // 2
16
+ y = (self.winfo_screenheight() - self.winfo_height()) // 2
17
+ self.geometry(f"+{x}+{y}")
18
+
19
+ def message(self, title, text, type="info"):
20
+ types = {
21
+ "info": messagebox.showinfo,
22
+ "error": messagebox.showerror,
23
+ "warning": messagebox.showwarning,
24
+ "question": messagebox.askyesno
25
+ }
26
+ return types.get(type, messagebox.showinfo)(title, text)
27
+
28
+ def ask_file(self, filetypes=[("All files", "*.*")]):
29
+ return filedialog.askopenfilename(filetypes=filetypes)
30
+
31
+ def ask_save_file(self, filetypes=[("All files", "*.*")]):
32
+ return filedialog.asksaveasfilename(filetypes=filetypes)
33
+
34
+ def ask_color(self):
35
+ return colorchooser.askcolor()[1]
@@ -0,0 +1,27 @@
1
+ class ThemeManager:
2
+ themes = {
3
+ "dark": {
4
+ "bg": "#1e1e1e",
5
+ "fg": "#ffffff",
6
+ "button": "#0078D7",
7
+ "button_hover": "#005a9e",
8
+ "entry": "#2d2d2d"
9
+ },
10
+ "light": {
11
+ "bg": "#f0f0f0",
12
+ "fg": "#000000",
13
+ "button": "#0078D7",
14
+ "button_hover": "#005a9e",
15
+ "entry": "#ffffff"
16
+ }
17
+ }
18
+
19
+ @classmethod
20
+ def get(cls, name):
21
+ return cls.themes.get(name, cls.themes["dark"])
22
+
23
+ @classmethod
24
+ def apply(cls, widget, theme_name):
25
+ theme = cls.get(theme_name)
26
+ widget.configure(bg=theme["bg"])
27
+ return theme
@@ -0,0 +1,15 @@
1
+ def center_window(window, width, height):
2
+ screen_width = window.winfo_screenwidth()
3
+ screen_height = window.winfo_screenheight()
4
+ x = (screen_width - width) // 2
5
+ y = (screen_height - height) // 2
6
+ window.geometry(f"{width}x{height}+{x}+{y}")
7
+
8
+ def get_screen_size():
9
+ import tkinter as tk
10
+ root = tk.Tk()
11
+ root.withdraw()
12
+ width = root.winfo_screenwidth()
13
+ height = root.winfo_screenheight()
14
+ root.destroy()
15
+ return width, height
@@ -0,0 +1,67 @@
1
+ import tkinter as tk
2
+
3
+ class Button(tk.Canvas):
4
+ def __init__(self, parent, text="", command=None, bg="#0078D7", fg="white",
5
+ hover_bg="#005a9e", width=120, height=35):
6
+ super().__init__(parent, width=width, height=height, highlightthickness=0, bg=parent.cget("bg"))
7
+ self.command = command
8
+ self.bg = bg
9
+ self.hover_bg = hover_bg
10
+ self.text = text
11
+ self.width = width
12
+ self.height = height
13
+
14
+ self.bind("<Enter>", self._on_enter)
15
+ self.bind("<Leave>", self._on_leave)
16
+ self.bind("<Button-1>", self._on_click)
17
+
18
+ self._draw(bg)
19
+
20
+ def _draw(self, color):
21
+ self.delete("all")
22
+ self.create_rectangle(0, 0, self.width, self.height, fill=color, outline="")
23
+ self.create_text(self.width//2, self.height//2, text=self.text, fill="white",
24
+ font=("Segoe UI", 10, "bold"))
25
+
26
+ def _on_enter(self, e):
27
+ self._draw(self.hover_bg)
28
+ self.config(cursor="hand2")
29
+
30
+ def _on_leave(self, e):
31
+ self._draw(self.bg)
32
+
33
+ def _on_click(self, e):
34
+ if self.command:
35
+ self.command()
36
+
37
+ class Entry(tk.Frame):
38
+ def __init__(self, parent, label="", placeholder="", show=None, width=30):
39
+ super().__init__(parent, bg=parent.cget("bg"))
40
+ self.label = tk.Label(self, text=label, font=("Segoe UI", 9), bg=self.cget("bg"), fg="#888888")
41
+ self.label.pack(anchor="w")
42
+
43
+ self.entry = tk.Entry(self, font=("Segoe UI", 10), bg="#2d2d2d", fg="white",
44
+ insertbackground="white", relief="flat", width=width, show=show)
45
+ self.entry.pack(fill="x", pady=(2, 5))
46
+
47
+ if placeholder:
48
+ self.entry.insert(0, placeholder)
49
+ self.entry.config(fg="#666666")
50
+ self.entry.bind("<FocusIn>", lambda e: self.entry.delete(0, tk.END) if self.entry.get() == placeholder else None)
51
+
52
+ def get(self):
53
+ return self.entry.get()
54
+
55
+ def set(self, value):
56
+ self.entry.delete(0, tk.END)
57
+ self.entry.insert(0, value)
58
+
59
+ class Label(tk.Label):
60
+ def __init__(self, parent, text="", font_size=10, bold=False, color="white"):
61
+ font = ("Segoe UI", font_size, "bold" if bold else "normal")
62
+ super().__init__(parent, text=text, font=font, fg=color, bg=parent.cget("bg"))
63
+
64
+ class Frame(tk.Frame):
65
+ def __init__(self, parent, bg=None, padding=10):
66
+ super().__init__(parent, bg=bg or parent.cget("bg"))
67
+ self.pack(fill="both", expand=True, padx=padding, pady=padding)
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: opentkinter
3
+ Version: 1.0.0
4
+ Summary: OpenTkinter — обгортка над tkinter
5
+ Author: Poowo1101
6
+ Requires-Python: >=3.6
7
+ Requires-Dist: pillow>=9.0.0
8
+ Dynamic: author
9
+ Dynamic: requires-dist
10
+ Dynamic: requires-python
11
+ Dynamic: summary
@@ -0,0 +1,13 @@
1
+ README.md
2
+ setup.py
3
+ opentkinter/__init__.py
4
+ opentkinter/animations.py
5
+ opentkinter/core.py
6
+ opentkinter/themes.py
7
+ opentkinter/utils.py
8
+ opentkinter/widgets.py
9
+ opentkinter.egg-info/PKG-INFO
10
+ opentkinter.egg-info/SOURCES.txt
11
+ opentkinter.egg-info/dependency_links.txt
12
+ opentkinter.egg-info/requires.txt
13
+ opentkinter.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ pillow>=9.0.0
@@ -0,0 +1 @@
1
+ opentkinter
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="opentkinter",
5
+ version="1.0.0",
6
+ author="Poowo1101",
7
+ description="OpenTkinter — обгортка над tkinter",
8
+ packages=find_packages(),
9
+ python_requires=">=3.6",
10
+ install_requires=[
11
+ "pillow>=9.0.0",
12
+ ],
13
+ )