DfGUI 0.1.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.
- DfGUI/__init__.py +169 -0
- dfgui-0.1.0.dist-info/METADATA +96 -0
- dfgui-0.1.0.dist-info/RECORD +6 -0
- dfgui-0.1.0.dist-info/WHEEL +5 -0
- dfgui-0.1.0.dist-info/licenses/LICENSE +21 -0
- dfgui-0.1.0.dist-info/top_level.txt +1 -0
DfGUI/__init__.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DfGUI - простая библиотека для создания графических интерфейсов.
|
|
3
|
+
Основана на tkinter, автоматически подстраивается под DPI экрана.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import tkinter as tk
|
|
7
|
+
from tkinter import ttk, messagebox, filedialog
|
|
8
|
+
import ctypes
|
|
9
|
+
|
|
10
|
+
def DPI(scale_factor=None):
|
|
11
|
+
"""
|
|
12
|
+
Настраивает масштабирование интерфейса под DPI экрана.
|
|
13
|
+
Если scale_factor указан (например, 1.5), принудительно задаёт множитель.
|
|
14
|
+
"""
|
|
15
|
+
try:
|
|
16
|
+
ctypes.windll.shcore.SetProcessDpiAwareness(1)
|
|
17
|
+
if scale_factor is None:
|
|
18
|
+
hwnd = ctypes.windll.user32.GetDesktopWindow()
|
|
19
|
+
dpi = ctypes.windll.user32.GetDpiForWindow(hwnd)
|
|
20
|
+
scale_factor = dpi / 96.0
|
|
21
|
+
except:
|
|
22
|
+
scale_factor = scale_factor or 1.0
|
|
23
|
+
|
|
24
|
+
root = tk.Tk()
|
|
25
|
+
root.tk.call('tk', 'scaling', scale_factor)
|
|
26
|
+
root.destroy()
|
|
27
|
+
return scale_factor
|
|
28
|
+
|
|
29
|
+
class Window:
|
|
30
|
+
"""Главное окно приложения."""
|
|
31
|
+
def __init__(self, title="DfGUI App", width=800, height=600, resizable=(True, True)):
|
|
32
|
+
self.root = tk.Tk()
|
|
33
|
+
self.root.title(title)
|
|
34
|
+
self.root.geometry(f"{width}x{height}")
|
|
35
|
+
self.root.resizable(*resizable)
|
|
36
|
+
self.children = []
|
|
37
|
+
|
|
38
|
+
def add(self, widget):
|
|
39
|
+
widget.pack()
|
|
40
|
+
self.children.append(widget)
|
|
41
|
+
|
|
42
|
+
def run(self):
|
|
43
|
+
self.root.mainloop()
|
|
44
|
+
|
|
45
|
+
def close(self):
|
|
46
|
+
self.root.quit()
|
|
47
|
+
|
|
48
|
+
class Widget:
|
|
49
|
+
"""Базовый класс для всех виджетов."""
|
|
50
|
+
def __init__(self, parent):
|
|
51
|
+
self.parent = parent
|
|
52
|
+
self.widget = None
|
|
53
|
+
|
|
54
|
+
def pack(self):
|
|
55
|
+
if self.widget:
|
|
56
|
+
self.widget.pack(pady=5, padx=5)
|
|
57
|
+
|
|
58
|
+
class Label(Widget):
|
|
59
|
+
def __init__(self, parent, text="", font=("Arial", 12), fg="black", bg=None):
|
|
60
|
+
super().__init__(parent)
|
|
61
|
+
self.widget = tk.Label(parent.root, text=text, font=font, fg=fg, bg=bg)
|
|
62
|
+
|
|
63
|
+
class Button(Widget):
|
|
64
|
+
def __init__(self, parent, text="", command=None, bg="lightgray", fg="black"):
|
|
65
|
+
super().__init__(parent)
|
|
66
|
+
self.widget = tk.Button(parent.root, text=text, command=command, bg=bg, fg=fg)
|
|
67
|
+
|
|
68
|
+
class Entry(Widget):
|
|
69
|
+
def __init__(self, parent, width=30, font=("Arial", 12)):
|
|
70
|
+
super().__init__(parent)
|
|
71
|
+
self.widget = tk.Entry(parent.root, width=width, font=font)
|
|
72
|
+
|
|
73
|
+
def get(self):
|
|
74
|
+
return self.widget.get()
|
|
75
|
+
|
|
76
|
+
def set(self, value):
|
|
77
|
+
self.widget.delete(0, tk.END)
|
|
78
|
+
self.widget.insert(0, value)
|
|
79
|
+
|
|
80
|
+
class Checkbox(Widget):
|
|
81
|
+
def __init__(self, parent, text="", variable=None):
|
|
82
|
+
super().__init__(parent)
|
|
83
|
+
if variable is None:
|
|
84
|
+
variable = tk.BooleanVar()
|
|
85
|
+
self.widget = tk.Checkbutton(parent.root, text=text, variable=variable)
|
|
86
|
+
|
|
87
|
+
class Radio(Widget):
|
|
88
|
+
def __init__(self, parent, text="", variable=None, value=0):
|
|
89
|
+
super().__init__(parent)
|
|
90
|
+
self.widget = tk.Radiobutton(parent.root, text=text, variable=variable, value=value)
|
|
91
|
+
|
|
92
|
+
class Combo(Widget):
|
|
93
|
+
def __init__(self, parent, values=[], width=20):
|
|
94
|
+
super().__init__(parent)
|
|
95
|
+
self.widget = ttk.Combobox(parent.root, values=values, width=width)
|
|
96
|
+
|
|
97
|
+
class Listbox(Widget):
|
|
98
|
+
def __init__(self, parent, height=5, width=30):
|
|
99
|
+
super().__init__(parent)
|
|
100
|
+
self.widget = tk.Listbox(parent.root, height=height, width=width)
|
|
101
|
+
|
|
102
|
+
def insert(self, index, *items):
|
|
103
|
+
for item in items:
|
|
104
|
+
self.widget.insert(index, item)
|
|
105
|
+
|
|
106
|
+
def get_selected(self):
|
|
107
|
+
selection = self.widget.curselection()
|
|
108
|
+
if selection:
|
|
109
|
+
return self.widget.get(selection[0])
|
|
110
|
+
return None
|
|
111
|
+
|
|
112
|
+
class TextArea(Widget):
|
|
113
|
+
def __init__(self, parent, height=10, width=50):
|
|
114
|
+
super().__init__(parent)
|
|
115
|
+
self.widget = tk.Text(parent.root, height=height, width=width)
|
|
116
|
+
|
|
117
|
+
def insert(self, text):
|
|
118
|
+
self.widget.insert(tk.END, text)
|
|
119
|
+
|
|
120
|
+
def get(self):
|
|
121
|
+
return self.widget.get(1.0, tk.END)
|
|
122
|
+
|
|
123
|
+
class Frame(Widget):
|
|
124
|
+
def __init__(self, parent, relief=tk.FLAT, borderwidth=0):
|
|
125
|
+
super().__init__(parent)
|
|
126
|
+
self.widget = tk.Frame(parent.root, relief=relief, borderwidth=borderwidth)
|
|
127
|
+
self.children = []
|
|
128
|
+
|
|
129
|
+
def add(self, widget):
|
|
130
|
+
widget.pack()
|
|
131
|
+
self.children.append(widget)
|
|
132
|
+
|
|
133
|
+
def message_box(title, message, type="info"):
|
|
134
|
+
if type == "info":
|
|
135
|
+
messagebox.showinfo(title, message)
|
|
136
|
+
elif type == "warning":
|
|
137
|
+
messagebox.showwarning(title, message)
|
|
138
|
+
elif type == "error":
|
|
139
|
+
messagebox.showerror(title, message)
|
|
140
|
+
elif type == "yesno":
|
|
141
|
+
return messagebox.askyesno(title, message)
|
|
142
|
+
return None
|
|
143
|
+
|
|
144
|
+
def open_file(title="Выберите файл", filetypes=[("All files", "*.*")]):
|
|
145
|
+
return filedialog.askopenfilename(title=title, filetypes=filetypes)
|
|
146
|
+
|
|
147
|
+
def save_file(title="Сохранить файл", filetypes=[("All files", "*.*")]):
|
|
148
|
+
return filedialog.asksaveasfilename(title=title, filetypes=filetypes)
|
|
149
|
+
|
|
150
|
+
def select_folder(title="Выберите папку"):
|
|
151
|
+
return filedialog.askdirectory(title=title)
|
|
152
|
+
|
|
153
|
+
__all__ = [
|
|
154
|
+
'DPI',
|
|
155
|
+
'Window',
|
|
156
|
+
'Label',
|
|
157
|
+
'Button',
|
|
158
|
+
'Entry',
|
|
159
|
+
'Checkbox',
|
|
160
|
+
'Radio',
|
|
161
|
+
'Combo',
|
|
162
|
+
'Listbox',
|
|
163
|
+
'TextArea',
|
|
164
|
+
'Frame',
|
|
165
|
+
'message_box',
|
|
166
|
+
'open_file',
|
|
167
|
+
'save_file',
|
|
168
|
+
'select_folder'
|
|
169
|
+
]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: DfGUI
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Простая GUI библиотека на tkinter
|
|
5
|
+
Author: Team_S1S_TopTools
|
|
6
|
+
Author-email: hereiop@vk.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.1
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: author-email
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# RU:
|
|
23
|
+
# DfGUI – простая библиотека для GUI на Python
|
|
24
|
+
|
|
25
|
+
Основана на tkinter, автоматически подстраивается под DPI экрана.
|
|
26
|
+
|
|
27
|
+
## Установка
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install DfGUI
|
|
31
|
+
Пример
|
|
32
|
+
python
|
|
33
|
+
import DfGUI as dg
|
|
34
|
+
|
|
35
|
+
dg.DPI()
|
|
36
|
+
win = dg.Window("Моя программа")
|
|
37
|
+
win.add(dg.Label(win, text="Привет!"))
|
|
38
|
+
win.run()
|
|
39
|
+
text
|
|
40
|
+
|
|
41
|
+
### 5. Создайте `LICENSE`
|
|
42
|
+
|
|
43
|
+
Выберите лицензию, например MIT. Файл можно создать с текстом лицензии (скопируйте с https://opensource.org/licenses/MIT).
|
|
44
|
+
|
|
45
|
+
### 6. Установите пакет локально
|
|
46
|
+
|
|
47
|
+
В командной строке перейдите в корневую папку `DfGUI/` и выполните:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install .
|
|
51
|
+
Эта команда установит вашу библиотеку в текущее окружение Python. После этого вы сможете импортировать её из любого скрипта:
|
|
52
|
+
|
|
53
|
+
python
|
|
54
|
+
import DfGUI as dg
|
|
55
|
+
dg.DPI()
|
|
56
|
+
win = dg.Window()
|
|
57
|
+
...
|
|
58
|
+
|
|
59
|
+
# --------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
# USA# DfGUI – simple GUI library in Python
|
|
62
|
+
|
|
63
|
+
Based on tkinter, automatically adjusts to the DPI of the screen.
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install DfGUI
|
|
69
|
+
Example
|
|
70
|
+
python
|
|
71
|
+
import DfGUI as dg
|
|
72
|
+
|
|
73
|
+
dg.DPI()
|
|
74
|
+
win = dg.Window("My program")
|
|
75
|
+
win.add(dg.Label(win, text="Hello!"))
|
|
76
|
+
win.run()
|
|
77
|
+
text
|
|
78
|
+
|
|
79
|
+
### 5. Create a `LICENSE`
|
|
80
|
+
|
|
81
|
+
Select a license, such as MIT. You can create a file with the license text (copy from https://opensource.org/licenses/MIT).
|
|
82
|
+
|
|
83
|
+
### 6. Install the package locally
|
|
84
|
+
|
|
85
|
+
In the command line, navigate to the root folder of `DfGUI/` and run:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
pip install .
|
|
89
|
+
This command will install your library in the current Python environment. After that, you can import it from any script:
|
|
90
|
+
|
|
91
|
+
python
|
|
92
|
+
import DfGUI as dg
|
|
93
|
+
dg.DPI()
|
|
94
|
+
win = dg.Window()
|
|
95
|
+
...
|
|
96
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
DfGUI/__init__.py,sha256=xDTC0EKsKsTt74WpteG21fyqV_jxKSTN8VXKWQmE0Mw,5509
|
|
2
|
+
dfgui-0.1.0.dist-info/licenses/LICENSE,sha256=LyRuxvGszP4IWHotD03A24J69wT2zAQ7XFIUMcjFFKs,1093
|
|
3
|
+
dfgui-0.1.0.dist-info/METADATA,sha256=S7gvzd6Dtd2AZGUi2oXR8MIZraAp3WRpz4AtFOMPTtE,2585
|
|
4
|
+
dfgui-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
dfgui-0.1.0.dist-info/top_level.txt,sha256=A7yyzDLnEsC08GFNfFByx-5vuL869PWTTWjQmhzKoTY,6
|
|
6
|
+
dfgui-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Team S1S TopTools
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DfGUI
|