opentkinter 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.
- opentkinter/__init__.py +7 -0
- opentkinter/animations.py +37 -0
- opentkinter/core.py +35 -0
- opentkinter/themes.py +27 -0
- opentkinter/utils.py +15 -0
- opentkinter/widgets.py +67 -0
- opentkinter-1.0.0.dist-info/METADATA +11 -0
- opentkinter-1.0.0.dist-info/RECORD +10 -0
- opentkinter-1.0.0.dist-info/WHEEL +5 -0
- opentkinter-1.0.0.dist-info/top_level.txt +1 -0
opentkinter/__init__.py
ADDED
|
@@ -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()
|
opentkinter/core.py
ADDED
|
@@ -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]
|
opentkinter/themes.py
ADDED
|
@@ -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
|
opentkinter/utils.py
ADDED
|
@@ -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
|
opentkinter/widgets.py
ADDED
|
@@ -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,10 @@
|
|
|
1
|
+
opentkinter/__init__.py,sha256=AZ_wlBIfE8M0QODEta2KnVSRmW0Y-kCrTpyWZg-Rkdc,199
|
|
2
|
+
opentkinter/animations.py,sha256=cGfSs1S8YYmPgQQG7ugjPgnwfC3a67Fc0imKpQaxOvc,1100
|
|
3
|
+
opentkinter/core.py,sha256=RbGsw8BkPxv76DRfphYmLQ7MczYtH5gOqPPUlrVGBGQ,1353
|
|
4
|
+
opentkinter/themes.py,sha256=6Cpw16Bb2-yUTXvmo_XCk-MU-wgipp8rkH8uV9wBe_Q,708
|
|
5
|
+
opentkinter/utils.py,sha256=daeHgMB_ewJLCfJ8sYO95IjMl0qW-aKmie3tph-Cazo,480
|
|
6
|
+
opentkinter/widgets.py,sha256=aMBOYnZKdeco1rN4cFX0MV8jVUvi7epJT2Ms-LwXRNo,2653
|
|
7
|
+
opentkinter-1.0.0.dist-info/METADATA,sha256=9k0qhQgLa9FNaVAPvVobWNOwPnteuQk3xcsWM6boIbc,274
|
|
8
|
+
opentkinter-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
9
|
+
opentkinter-1.0.0.dist-info/top_level.txt,sha256=kbj8FaN9-XvrxOyTzcJDbZolUZzwFr5PQ0vRz513vRE,12
|
|
10
|
+
opentkinter-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
opentkinter
|