ttkps6 0.0.1__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.
- ttkps6-0.0.1/LICENSE +19 -0
- ttkps6-0.0.1/PKG-INFO +9 -0
- ttkps6-0.0.1/README.md +18 -0
- ttkps6-0.0.1/pyproject.toml +15 -0
- ttkps6-0.0.1/setup.cfg +4 -0
- ttkps6-0.0.1/src/ttkps6/BaseTkinterWidget.py +356 -0
- ttkps6-0.0.1/src/ttkps6/PySide6Widget/LCDNumber.py +72 -0
- ttkps6-0.0.1/src/ttkps6/Windows.py +171 -0
- ttkps6-0.0.1/src/ttkps6/__init__.py +43 -0
- ttkps6-0.0.1/src/ttkps6/other.py +36 -0
- ttkps6-0.0.1/src/ttkps6/ttk.py +0 -0
- ttkps6-0.0.1/src/ttkps6.egg-info/PKG-INFO +9 -0
- ttkps6-0.0.1/src/ttkps6.egg-info/SOURCES.txt +14 -0
- ttkps6-0.0.1/src/ttkps6.egg-info/dependency_links.txt +1 -0
- ttkps6-0.0.1/src/ttkps6.egg-info/requires.txt +1 -0
- ttkps6-0.0.1/src/ttkps6.egg-info/top_level.txt +1 -0
ttkps6-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2026 engineergipbili
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
ttkps6-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ttkps6
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: This library simplifies PySide6 and extends the functionality of Tkinter. You can write code in the Tkinter style to create native PySide6 GUI windows, allowing you to avoid the default appearance of Tkinter.
|
|
5
|
+
Author-email: gwood <engineergipbili@163.com>
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: pyside6
|
|
9
|
+
Dynamic: license-file
|
ttkps6-0.0.1/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
\# ttkps6
|
|
2
|
+
|
|
3
|
+
This library simplifies PySide6 and extends the functionality of Tkinter.
|
|
4
|
+
|
|
5
|
+
You can write code in the Tkinter style to create native PySide6 GUI windows,
|
|
6
|
+
|
|
7
|
+
allowing you to avoid the default appearance of Tkinter.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
\## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
|
|
15
|
+
pip install ttkps6
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ttkps6"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="gwood", email="engineergipbili@163.com" }
|
|
10
|
+
]
|
|
11
|
+
description = "This library simplifies PySide6 and extends the functionality of Tkinter. You can write code in the Tkinter style to create native PySide6 GUI windows, allowing you to avoid the default appearance of Tkinter."
|
|
12
|
+
requires-python = ">=3.7"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"pyside6"
|
|
15
|
+
]
|
ttkps6-0.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
from PySide6.QtWidgets import QLabel,QLineEdit,QPushButton,QListWidget, QListWidgetItem
|
|
2
|
+
from PySide6.QtGui import QFont
|
|
3
|
+
|
|
4
|
+
class Label(QLabel):
|
|
5
|
+
def __init__(self,master=None,text="",textvariable=None,width=3,height=1,font=('',17),bg=None,fg=None):
|
|
6
|
+
super().__init__(master)
|
|
7
|
+
self.master=master
|
|
8
|
+
self._text=text
|
|
9
|
+
self._char_width=width
|
|
10
|
+
self._char_height=height
|
|
11
|
+
self._css=''
|
|
12
|
+
self._font_pt = 24
|
|
13
|
+
self.setText(text)
|
|
14
|
+
if font is not None:
|
|
15
|
+
f=QFont(font[0])
|
|
16
|
+
f.setPointSize(font[1])
|
|
17
|
+
self.setFont(f)
|
|
18
|
+
self._font_pt = font[1]
|
|
19
|
+
self._update_size()
|
|
20
|
+
if bg is not None:
|
|
21
|
+
if type(bg) == str:
|
|
22
|
+
self._css += f'background-color:'+bg+';\n'
|
|
23
|
+
elif type(bg) == tuple or type(bg) == list:
|
|
24
|
+
self._css += 'background-color:rgb'+str(bg)+';\n'
|
|
25
|
+
else:
|
|
26
|
+
pass
|
|
27
|
+
if fg is not None:
|
|
28
|
+
if type(fg) == str:
|
|
29
|
+
self._css += 'color: '+fg+';\n'
|
|
30
|
+
elif type(fg) == tuple or type(fg) == list:
|
|
31
|
+
self._css += 'color: rgb'+str(fg)+';\n'
|
|
32
|
+
else:
|
|
33
|
+
pass
|
|
34
|
+
if textvariable is not None:
|
|
35
|
+
textvariable._input_widget(self,'text')
|
|
36
|
+
self.setStyleSheet(self._css)
|
|
37
|
+
self._update_size()
|
|
38
|
+
|
|
39
|
+
def _update_size(self):
|
|
40
|
+
w = self._char_width * self._font_pt/2
|
|
41
|
+
h = self._char_height * self._font_pt * 2/2
|
|
42
|
+
self.resize(w, h)
|
|
43
|
+
|
|
44
|
+
def __getitem__(self,key):
|
|
45
|
+
if key=="text":
|
|
46
|
+
return self._text
|
|
47
|
+
if key=="width":
|
|
48
|
+
return self._char_width
|
|
49
|
+
if key=="height":
|
|
50
|
+
return self._char_height
|
|
51
|
+
raise KeyError(key)
|
|
52
|
+
|
|
53
|
+
def __setitem__(self,key,value):
|
|
54
|
+
if key=="text":
|
|
55
|
+
self._text=value
|
|
56
|
+
self.setText(value)
|
|
57
|
+
elif key=="width":
|
|
58
|
+
self._char_width=value
|
|
59
|
+
self._update_size()
|
|
60
|
+
elif key=="height":
|
|
61
|
+
self._char_height=value
|
|
62
|
+
self._update_size()
|
|
63
|
+
elif key=="bg":
|
|
64
|
+
if type(key) == str:
|
|
65
|
+
self._css += f'background-color:'+key+';\n'
|
|
66
|
+
elif type(key) == tuple or type(key) == list:
|
|
67
|
+
self._css += 'background-color:rgb'+str(key)+';\n'
|
|
68
|
+
self.setStyleSheet(self._css)
|
|
69
|
+
elif key=="fg":
|
|
70
|
+
if type(key) == str:
|
|
71
|
+
self._css += 'color: '+key+';\n'
|
|
72
|
+
elif type(key) == tuple or type(key) == list:
|
|
73
|
+
self._css += 'color: rgb'+str(key)+';\n'
|
|
74
|
+
else:
|
|
75
|
+
pass
|
|
76
|
+
self.setStyleSheet(self._css)
|
|
77
|
+
elif key=="font":
|
|
78
|
+
f=QFont(key[0])
|
|
79
|
+
f.setPointSize(key[1])
|
|
80
|
+
self.setFont(f)
|
|
81
|
+
self._font_pt = key[1]
|
|
82
|
+
self._update_size()
|
|
83
|
+
else:
|
|
84
|
+
raise KeyError(key)
|
|
85
|
+
|
|
86
|
+
def place(self,x,y,width=None,height=None):
|
|
87
|
+
self.move(x,y)
|
|
88
|
+
if width is not None:
|
|
89
|
+
self.resize(int(width),self.geometry().height())
|
|
90
|
+
if height is not None:
|
|
91
|
+
self.resize(self.geometry().width(),int(height))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class Entry(QLineEdit):
|
|
95
|
+
def __init__(self,master=None,text="",textvariable=None,width=9,height=1,font=('',17),bg=None,fg=None):
|
|
96
|
+
super().__init__(master)
|
|
97
|
+
self.master=master
|
|
98
|
+
self._text=text
|
|
99
|
+
self._char_width=width
|
|
100
|
+
self._char_height=height
|
|
101
|
+
self._css=''
|
|
102
|
+
self._font_pt = 24
|
|
103
|
+
self.setText(text)
|
|
104
|
+
|
|
105
|
+
f=QFont(font[0])
|
|
106
|
+
f.setPointSize(font[1])
|
|
107
|
+
self.setFont(f)
|
|
108
|
+
self._font_pt = font[1]
|
|
109
|
+
self._update_size()
|
|
110
|
+
if bg is not None:
|
|
111
|
+
if type(bg) == str:
|
|
112
|
+
self._css += f'background-color:'+bg+';\n'
|
|
113
|
+
elif type(bg) == tuple or type(bg) == list:
|
|
114
|
+
self._css += 'background-color:rgb'+str(bg)+';\n'
|
|
115
|
+
else:
|
|
116
|
+
pass
|
|
117
|
+
if fg is not None:
|
|
118
|
+
if type(fg) == str:
|
|
119
|
+
self._css += 'color: '+fg+';\n'
|
|
120
|
+
elif type(fg) == tuple or type(fg) == list:
|
|
121
|
+
self._css += 'color: rgb'+str(fg)+';\n'
|
|
122
|
+
else:
|
|
123
|
+
pass
|
|
124
|
+
self.setStyleSheet(self._css)
|
|
125
|
+
self._update_size()
|
|
126
|
+
|
|
127
|
+
def _update_size(self):
|
|
128
|
+
w = self._char_width * self._font_pt
|
|
129
|
+
h = self._char_height * self._font_pt * 2
|
|
130
|
+
self.resize(w, h)
|
|
131
|
+
|
|
132
|
+
def __getitem__(self,key):
|
|
133
|
+
if key=="text":
|
|
134
|
+
return self._text
|
|
135
|
+
if key=="width":
|
|
136
|
+
return self._char_width
|
|
137
|
+
if key=="height":
|
|
138
|
+
return self._char_height
|
|
139
|
+
raise KeyError(key)
|
|
140
|
+
|
|
141
|
+
def __setitem__(self,key,value):
|
|
142
|
+
if key=="text":
|
|
143
|
+
self._text=value
|
|
144
|
+
self.setText(value)
|
|
145
|
+
elif key=="width":
|
|
146
|
+
self._char_width=value
|
|
147
|
+
self._update_size()
|
|
148
|
+
elif key=="height":
|
|
149
|
+
self._char_height=value
|
|
150
|
+
self._update_size()
|
|
151
|
+
elif key=="bg":
|
|
152
|
+
if type(key) == str:
|
|
153
|
+
self._css += f'background-color:'+key+';\n'
|
|
154
|
+
elif type(key) == tuple or type(key) == list:
|
|
155
|
+
self._css += 'background-color:rgb'+str(key)+';\n'
|
|
156
|
+
self.setStyleSheet(self._css)
|
|
157
|
+
elif key=="fg":
|
|
158
|
+
if type(key) == str:
|
|
159
|
+
self._css += 'color: '+key+';\n'
|
|
160
|
+
elif type(key) == tuple or type(key) == list:
|
|
161
|
+
self._css += 'color: rgb'+str(key)+';\n'
|
|
162
|
+
else:
|
|
163
|
+
pass
|
|
164
|
+
self.setStyleSheet(self._css)
|
|
165
|
+
elif key=="font":
|
|
166
|
+
f=QFont(key[0])
|
|
167
|
+
f.setPointSize(key[1])
|
|
168
|
+
self.setFont(f)
|
|
169
|
+
self._font_pt = key[1]
|
|
170
|
+
self._update_size()
|
|
171
|
+
else:
|
|
172
|
+
raise KeyError(key)
|
|
173
|
+
def get(self):
|
|
174
|
+
return self.text()
|
|
175
|
+
def place(self,x,y,width=None,height=None):
|
|
176
|
+
self.move(x,y)
|
|
177
|
+
if width is not None:
|
|
178
|
+
self.resize(int(width),self.geometry().height())
|
|
179
|
+
if height is not None:
|
|
180
|
+
self.resize(self.geometry().width(),int(height))
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class Button(QPushButton):
|
|
184
|
+
def __init__(self,master=None,text="",textvariable=None,width=4,height=1,font=('',17),bg=None,fg=None,command=None):
|
|
185
|
+
super().__init__(master)
|
|
186
|
+
self.master=master
|
|
187
|
+
self._text=text
|
|
188
|
+
self._char_width=width
|
|
189
|
+
self._char_height=height
|
|
190
|
+
self._css=''
|
|
191
|
+
self._font_pt = 24
|
|
192
|
+
self.setText(text)
|
|
193
|
+
f=QFont(font[0])
|
|
194
|
+
f.setPointSize(font[1])
|
|
195
|
+
self.setFont(f)
|
|
196
|
+
self._font_pt = font[1]
|
|
197
|
+
self._update_size()
|
|
198
|
+
if bg is not None:
|
|
199
|
+
if type(bg) == str:
|
|
200
|
+
self._css += f'background-color:'+bg+';\n'
|
|
201
|
+
elif type(bg) == tuple or type(bg) == list:
|
|
202
|
+
self._css += 'background-color:rgb'+str(bg)+';\n'
|
|
203
|
+
else:
|
|
204
|
+
pass
|
|
205
|
+
if fg is not None:
|
|
206
|
+
if type(fg) == str:
|
|
207
|
+
self._css += 'color: '+fg+';\n'
|
|
208
|
+
elif type(fg) == tuple or type(fg) == list:
|
|
209
|
+
self._css += 'color: rgb'+str(fg)+';\n'
|
|
210
|
+
else:
|
|
211
|
+
pass
|
|
212
|
+
if command is not None:
|
|
213
|
+
self.clicked.connect(command)
|
|
214
|
+
self.setStyleSheet(self._css)
|
|
215
|
+
self._update_size()
|
|
216
|
+
|
|
217
|
+
def _update_size(self):
|
|
218
|
+
w = self._char_width * self._font_pt
|
|
219
|
+
h = self._char_height * self._font_pt * 2
|
|
220
|
+
self.resize(w, h)
|
|
221
|
+
|
|
222
|
+
def __getitem__(self,key):
|
|
223
|
+
if key=="text":
|
|
224
|
+
return self._text
|
|
225
|
+
if key=="width":
|
|
226
|
+
return self._char_width
|
|
227
|
+
if key=="height":
|
|
228
|
+
return self._char_height
|
|
229
|
+
raise KeyError(key)
|
|
230
|
+
|
|
231
|
+
def __setitem__(self,key,value):
|
|
232
|
+
if key=="text":
|
|
233
|
+
self._text=value
|
|
234
|
+
self.setText(value)
|
|
235
|
+
elif key=="width":
|
|
236
|
+
self._char_width=value
|
|
237
|
+
self._update_size()
|
|
238
|
+
elif key=="height":
|
|
239
|
+
self._char_height=value
|
|
240
|
+
self._update_size()
|
|
241
|
+
elif key=="bg":
|
|
242
|
+
if type(key) == str:
|
|
243
|
+
self._css += f'background-color:'+key+';\n'
|
|
244
|
+
elif type(key) == tuple or type(key) == list:
|
|
245
|
+
self._css += 'background-color:rgb'+str(key)+';\n'
|
|
246
|
+
self.setStyleSheet(self._css)
|
|
247
|
+
elif key=="fg":
|
|
248
|
+
if type(key) == str:
|
|
249
|
+
self._css += 'color: '+key+';\n'
|
|
250
|
+
elif type(key) == tuple or type(key) == list:
|
|
251
|
+
self._css += 'color: rgb'+str(key)+';\n'
|
|
252
|
+
else:
|
|
253
|
+
pass
|
|
254
|
+
self.setStyleSheet(self._css)
|
|
255
|
+
elif key=="font":
|
|
256
|
+
f=QFont(key[0])
|
|
257
|
+
f.setPointSize(key[1])
|
|
258
|
+
self.setFont(f)
|
|
259
|
+
self._font_pt = key[1]
|
|
260
|
+
self._update_size()
|
|
261
|
+
else:
|
|
262
|
+
raise KeyError(key)
|
|
263
|
+
|
|
264
|
+
def place(self,x,y,width=None,height=None):
|
|
265
|
+
self.move(x,y)
|
|
266
|
+
if width is not None:
|
|
267
|
+
self.resize(int(width),self.geometry().height())
|
|
268
|
+
if height is not None:
|
|
269
|
+
self.resize(self.geometry().width(),int(height))
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class Listbox(QListWidget):
|
|
276
|
+
def __init__(self, master, font=('',15), width=10, height=2, css=''):
|
|
277
|
+
super().__init__(master)
|
|
278
|
+
self.master = master
|
|
279
|
+
self._char_width = width
|
|
280
|
+
self._char_height = height
|
|
281
|
+
self._css = css
|
|
282
|
+
f=QFont(font[0])
|
|
283
|
+
f.setPointSize(font[1])
|
|
284
|
+
self.setFont(f)
|
|
285
|
+
self._font_pt = font[1]
|
|
286
|
+
self._update_size()
|
|
287
|
+
self.setStyleSheet(css)
|
|
288
|
+
self._update_size()
|
|
289
|
+
|
|
290
|
+
def _update_size(self):
|
|
291
|
+
w = self._char_width * self._font_pt
|
|
292
|
+
h = self._char_height * self._font_pt * 2
|
|
293
|
+
self.resize(w, h)
|
|
294
|
+
def __setitem__(self, key, value):
|
|
295
|
+
if key == "width":
|
|
296
|
+
self._char_width = value
|
|
297
|
+
self._update_size()
|
|
298
|
+
elif key == "height":
|
|
299
|
+
self._char_height = value
|
|
300
|
+
self._update_size()
|
|
301
|
+
elif key == "css":
|
|
302
|
+
self._css = value
|
|
303
|
+
self.setStyleSheet(value)
|
|
304
|
+
else:
|
|
305
|
+
raise KeyError(key)
|
|
306
|
+
|
|
307
|
+
def __getitem__(self, key):
|
|
308
|
+
if key == "width":
|
|
309
|
+
return self._char_width
|
|
310
|
+
if key == "height":
|
|
311
|
+
return self._char_height
|
|
312
|
+
if key == "css":
|
|
313
|
+
return self._css
|
|
314
|
+
raise KeyError(key)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def insert(self, index, *values):
|
|
318
|
+
if str(index).upper() == "END":
|
|
319
|
+
index = int(self.count())
|
|
320
|
+
for v in values:
|
|
321
|
+
item = QListWidgetItem(str(v))
|
|
322
|
+
self.insertItem(index, item)
|
|
323
|
+
index += 1
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def get(self, index):
|
|
327
|
+
item = self.item(index)
|
|
328
|
+
if item is None:
|
|
329
|
+
return ""
|
|
330
|
+
return item.text()
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def curselection(self):
|
|
334
|
+
return tuple(i.row() for i in self.selectedIndexes())
|
|
335
|
+
|
|
336
|
+
def delete(self, first, last=None):
|
|
337
|
+
if last is None:
|
|
338
|
+
self.takeItem(first)
|
|
339
|
+
else:
|
|
340
|
+
for i in range(last, first-1, -1):
|
|
341
|
+
self.takeItem(i)
|
|
342
|
+
def getchoice(self):
|
|
343
|
+
|
|
344
|
+
sel = self.curselection()
|
|
345
|
+
if not sel:
|
|
346
|
+
return None
|
|
347
|
+
|
|
348
|
+
return self.get(sel[0])
|
|
349
|
+
def place(self, x, y, width=None, height=None):
|
|
350
|
+
self.move(x,y)
|
|
351
|
+
if width is not None:
|
|
352
|
+
self.resize(int(width),self.geometry().height())
|
|
353
|
+
if height is not None:
|
|
354
|
+
self.resize(self.geometry().width(),int(height))
|
|
355
|
+
|
|
356
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from PySide6.QtWidgets import QLCDNumber
|
|
2
|
+
from PySide6.QtGui import QFont
|
|
3
|
+
|
|
4
|
+
class LcdNumber(QLCDNumber):
|
|
5
|
+
def __init__(self, master, value=0, digits=5, font=("",8), width=8, height=2, command=None, css=""):
|
|
6
|
+
super().__init__(digits, master)
|
|
7
|
+
self.master = master
|
|
8
|
+
self._numCount = digits
|
|
9
|
+
self._char_width = width
|
|
10
|
+
self._char_height = height
|
|
11
|
+
self._css = css
|
|
12
|
+
|
|
13
|
+
f = QFont(font[0])
|
|
14
|
+
f.setPointSize(font[1])
|
|
15
|
+
self.setFont(f)
|
|
16
|
+
self._font_pt = font[1]
|
|
17
|
+
|
|
18
|
+
self.setDigitCount(self._numCount)
|
|
19
|
+
self.display(value)
|
|
20
|
+
if command is not None:
|
|
21
|
+
self.overflow.connect(command)
|
|
22
|
+
self.setStyleSheet(css)
|
|
23
|
+
self._update_size()
|
|
24
|
+
|
|
25
|
+
def _update_size(self):
|
|
26
|
+
# 和你其他组件统一:字符数量 × 字体像素
|
|
27
|
+
w = self._char_width * self._font_pt
|
|
28
|
+
h = self._char_height * self._font_pt * 2
|
|
29
|
+
self.resize(w, h)
|
|
30
|
+
|
|
31
|
+
def place(self, x, y, width=None, height=None):
|
|
32
|
+
if width is None:
|
|
33
|
+
w = self._char_width * self._font_pt
|
|
34
|
+
else:
|
|
35
|
+
w = width
|
|
36
|
+
if height is None:
|
|
37
|
+
h = self._char_height * self._font_pt * 2
|
|
38
|
+
else:
|
|
39
|
+
h = height
|
|
40
|
+
self.setGeometry(x, y, w, h)
|
|
41
|
+
self.show()
|
|
42
|
+
|
|
43
|
+
def __setitem__(self, key, value):
|
|
44
|
+
if key == "numCount":
|
|
45
|
+
self._numCount = value
|
|
46
|
+
self.setDigitCount(value)
|
|
47
|
+
elif key == "width":
|
|
48
|
+
self._char_width = value
|
|
49
|
+
self._update_size()
|
|
50
|
+
elif key == "height":
|
|
51
|
+
self._char_height = value
|
|
52
|
+
self._update_size()
|
|
53
|
+
elif key == "value":
|
|
54
|
+
self.display(value)
|
|
55
|
+
elif key == "css":
|
|
56
|
+
self._css = value
|
|
57
|
+
self.setStyleSheet(value)
|
|
58
|
+
else:
|
|
59
|
+
raise KeyError(key)
|
|
60
|
+
|
|
61
|
+
def __getitem__(self, key):
|
|
62
|
+
if key == "numCount":
|
|
63
|
+
return self._numCount
|
|
64
|
+
if key == "width":
|
|
65
|
+
return self._char_width
|
|
66
|
+
if key == "height":
|
|
67
|
+
return self._char_height
|
|
68
|
+
if key == "value":
|
|
69
|
+
return self.value()
|
|
70
|
+
if key == "css":
|
|
71
|
+
return self._css
|
|
72
|
+
raise KeyError(key)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
from PySide6.QtWidgets import QApplication, QMainWindow
|
|
2
|
+
from PySide6.QtCore import Qt,QCoreApplication,QTimer
|
|
3
|
+
from PySide6.QtGui import QIcon
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
class Tk(QMainWindow):
|
|
7
|
+
def __init__(self):
|
|
8
|
+
self.app = QApplication(sys.argv)
|
|
9
|
+
super().__init__()
|
|
10
|
+
self.title('tk')
|
|
11
|
+
self.geometry('400x200')
|
|
12
|
+
self._timer_pool = dict()
|
|
13
|
+
self._next_timer_id = 1
|
|
14
|
+
def title(self, s):
|
|
15
|
+
self.setWindowTitle(s)
|
|
16
|
+
|
|
17
|
+
def geometry(self, s):
|
|
18
|
+
if '+' in s:
|
|
19
|
+
size, pos = s.split('+',1)
|
|
20
|
+
w, h = size.split('x')
|
|
21
|
+
x, y = pos.split('+')
|
|
22
|
+
self.setGeometry(int(x), int(y), int(w), int(h))
|
|
23
|
+
else:
|
|
24
|
+
w, h = s.split('x')
|
|
25
|
+
self.resize(int(w), int(h))
|
|
26
|
+
|
|
27
|
+
def attributes(self, key, val=True):
|
|
28
|
+
if key == "-topmost":
|
|
29
|
+
flag = self.windowFlags()
|
|
30
|
+
if val:
|
|
31
|
+
flag |= Qt.WindowStaysOnTopHint
|
|
32
|
+
else:
|
|
33
|
+
flag &= ~Qt.WindowStaysOnTopHint
|
|
34
|
+
self.setWindowFlags(flag)
|
|
35
|
+
elif key == "-alpha":
|
|
36
|
+
self.setWindowOpacity(val)
|
|
37
|
+
elif key == "-fullscreen":
|
|
38
|
+
f = self.windowFlags()
|
|
39
|
+
if val:
|
|
40
|
+
f |= Qt.WindowFullScreen
|
|
41
|
+
else:
|
|
42
|
+
f &= ~Qt.WindowFullScreen
|
|
43
|
+
self.setWindowFlags(f)
|
|
44
|
+
elif key == "-toolwindow":
|
|
45
|
+
f = self.windowFlags()
|
|
46
|
+
if val:
|
|
47
|
+
f |= Qt.Tool
|
|
48
|
+
else:
|
|
49
|
+
f &= ~Qt.Tool
|
|
50
|
+
self.setWindowFlags(f)
|
|
51
|
+
elif key == "-disabled":
|
|
52
|
+
self.setEnabled(not val)
|
|
53
|
+
if val:
|
|
54
|
+
self.setStyleSheet("background-color:#cccccc;")
|
|
55
|
+
else:
|
|
56
|
+
self.setStyleSheet("")
|
|
57
|
+
elif key == "-dismoved":
|
|
58
|
+
f = self.windowFlags()
|
|
59
|
+
if val:
|
|
60
|
+
f |= Qt.FramelessWindowHint
|
|
61
|
+
else:
|
|
62
|
+
f &= ~Qt.FramelessWindowHint
|
|
63
|
+
self.setWindowFlags(f)
|
|
64
|
+
else:
|
|
65
|
+
pass
|
|
66
|
+
def mainloop(self):
|
|
67
|
+
self.show()
|
|
68
|
+
sys.exit(self.app.exec())
|
|
69
|
+
def after(self, ms, func, *args):
|
|
70
|
+
timer_id = self._next_timer_id
|
|
71
|
+
self._next_timer_id += 1
|
|
72
|
+
timer = QTimer(self)
|
|
73
|
+
timer.setSingleShot(True)
|
|
74
|
+
def callback():
|
|
75
|
+
del self._timer_pool[timer_id]
|
|
76
|
+
func(*args)
|
|
77
|
+
timer.timeout.connect(callback)
|
|
78
|
+
timer.start(ms)
|
|
79
|
+
self._timer_pool[timer_id] = timer
|
|
80
|
+
return timer_id
|
|
81
|
+
|
|
82
|
+
def after_cancel(self, timer_id):
|
|
83
|
+
if timer_id in self._timer_pool:
|
|
84
|
+
t = self._timer_pool.pop(timer_id)
|
|
85
|
+
t.stop()
|
|
86
|
+
def update(self):
|
|
87
|
+
QCoreApplication.processEvents()
|
|
88
|
+
def iconbitmap(self,icon):
|
|
89
|
+
self.setWindowIcon(QIcon(icon))
|
|
90
|
+
class Toplevel(QMainWindow):
|
|
91
|
+
def __init__(self):
|
|
92
|
+
super().__init__()
|
|
93
|
+
self.title('toplevel')
|
|
94
|
+
self.geometry('400x200')
|
|
95
|
+
def title(self, s):
|
|
96
|
+
self.setWindowTitle(s)
|
|
97
|
+
|
|
98
|
+
def geometry(self, s):
|
|
99
|
+
if '+' in s:
|
|
100
|
+
size, pos = s.split('+',1)
|
|
101
|
+
w, h = size.split('x')
|
|
102
|
+
x, y = pos.split('+')
|
|
103
|
+
self.setGeometry(int(x), int(y), int(w), int(h))
|
|
104
|
+
else:
|
|
105
|
+
w, h = s.split('x')
|
|
106
|
+
self.resize(int(w), int(h))
|
|
107
|
+
|
|
108
|
+
def attributes(self, key, val=True):
|
|
109
|
+
if key == "-topmost":
|
|
110
|
+
flag = self.windowFlags()
|
|
111
|
+
if val:
|
|
112
|
+
flag |= Qt.WindowStaysOnTopHint
|
|
113
|
+
else:
|
|
114
|
+
flag &= ~Qt.WindowStaysOnTopHint
|
|
115
|
+
self.setWindowFlags(flag)
|
|
116
|
+
elif key == "-alpha":
|
|
117
|
+
self.setWindowOpacity(val)
|
|
118
|
+
elif key == "-fullscreen":
|
|
119
|
+
f = self.windowFlags()
|
|
120
|
+
if val:
|
|
121
|
+
f |= Qt.WindowFullScreen
|
|
122
|
+
else:
|
|
123
|
+
f &= ~Qt.WindowFullScreen
|
|
124
|
+
self.setWindowFlags(f)
|
|
125
|
+
elif key == "-toolwindow":
|
|
126
|
+
f = self.windowFlags()
|
|
127
|
+
if val:
|
|
128
|
+
f |= Qt.Tool
|
|
129
|
+
else:
|
|
130
|
+
f &= ~Qt.Tool
|
|
131
|
+
self.setWindowFlags(f)
|
|
132
|
+
elif key == "-disabled":
|
|
133
|
+
self.setEnabled(not val)
|
|
134
|
+
if val:
|
|
135
|
+
self.setStyleSheet("background-color:#cccccc;")
|
|
136
|
+
else:
|
|
137
|
+
self.setStyleSheet("")
|
|
138
|
+
elif key == "-dismoved":
|
|
139
|
+
f = self.windowFlags()
|
|
140
|
+
if val:
|
|
141
|
+
f |= Qt.FramelessWindowHint
|
|
142
|
+
else:
|
|
143
|
+
f &= ~Qt.FramelessWindowHint
|
|
144
|
+
self.setWindowFlags(f)
|
|
145
|
+
else:
|
|
146
|
+
pass
|
|
147
|
+
|
|
148
|
+
def mainloop(self):
|
|
149
|
+
self.show()
|
|
150
|
+
def after(self, ms, func, *args):
|
|
151
|
+
timer_id = self._next_timer_id
|
|
152
|
+
self._next_timer_id += 1
|
|
153
|
+
|
|
154
|
+
timer = QTimer(self)
|
|
155
|
+
timer.setSingleShot(True) # 只执行一次,和tkinter after一致
|
|
156
|
+
def callback():
|
|
157
|
+
del self._timer_pool[timer_id]
|
|
158
|
+
func(*args)
|
|
159
|
+
timer.timeout.connect(callback)
|
|
160
|
+
timer.start(ms)
|
|
161
|
+
self._timer_pool[timer_id] = timer
|
|
162
|
+
return timer_id
|
|
163
|
+
|
|
164
|
+
def after_cancel(self, timer_id):
|
|
165
|
+
if timer_id in self._timer_pool:
|
|
166
|
+
t = self._timer_pool.pop(timer_id)
|
|
167
|
+
t.stop()
|
|
168
|
+
def update(self):
|
|
169
|
+
QCoreApplication.processEvents()
|
|
170
|
+
def iconbitmap(self,icon):
|
|
171
|
+
self.setWindowIcon(QIcon(icon))
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
try:
|
|
2
|
+
from .BaseTkinterWidget import *
|
|
3
|
+
from .Windows import *
|
|
4
|
+
from .other import *
|
|
5
|
+
from .PySide6Widget.LCDNumber import *
|
|
6
|
+
except:
|
|
7
|
+
from BaseTkinterWidget import *
|
|
8
|
+
from Windows import *
|
|
9
|
+
from other import *
|
|
10
|
+
from PySide6Widget.LCDNumber import *
|
|
11
|
+
if __name__=="__main__":
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
root = Tk()
|
|
14
|
+
root.title("窗口")
|
|
15
|
+
root.geometry("400x400")
|
|
16
|
+
root.attributes("-topmost",True)
|
|
17
|
+
v=StringVar()
|
|
18
|
+
a=Label(root,textvariable=v,bg=(1,255,255))
|
|
19
|
+
a.place(x=45,y=1)
|
|
20
|
+
|
|
21
|
+
e=Entry(root,text='',bg=(1,255,255),font=('bauhaus 93',17))
|
|
22
|
+
e.place(x=0,y=50)
|
|
23
|
+
def changelabel():
|
|
24
|
+
v.set(l.getchoice())
|
|
25
|
+
b=Button(root,text='修改',font=('',17),command=changelabel)
|
|
26
|
+
b.place(x=10,y=130)
|
|
27
|
+
lcd = LcdNumber(root, digits=8, font=('',5), width=12, height=3.5)
|
|
28
|
+
lcd.place(10,86)
|
|
29
|
+
|
|
30
|
+
def update_clock():
|
|
31
|
+
now = datetime.now()
|
|
32
|
+
time_str = now.strftime("%H:%M:%S")
|
|
33
|
+
lcd["value"] = time_str
|
|
34
|
+
# 用你库里面的after,和tkinter一样的after
|
|
35
|
+
root.after(1000, update_clock)
|
|
36
|
+
|
|
37
|
+
update_clock()
|
|
38
|
+
l=Listbox(root,height=13)
|
|
39
|
+
l.place(x=156,y=10)
|
|
40
|
+
ll=list('qwertytuhdyurtdycj')
|
|
41
|
+
for i in ll:
|
|
42
|
+
l.insert('end',i)
|
|
43
|
+
root.mainloop()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
class StringVar:
|
|
2
|
+
def __init__(self, initial_value=''):
|
|
3
|
+
self._value = str(initial_value)
|
|
4
|
+
self._bind_widgets = []
|
|
5
|
+
|
|
6
|
+
def _input_widget(self, widget, key):
|
|
7
|
+
item = (widget, key)
|
|
8
|
+
if item not in self._bind_widgets:
|
|
9
|
+
self._bind_widgets.append(item)
|
|
10
|
+
for w, k in self._bind_widgets:
|
|
11
|
+
w[k] = self._value
|
|
12
|
+
def set(self, new_val=''):
|
|
13
|
+
self._value = str(new_val)
|
|
14
|
+
for w, k in self._bind_widgets:
|
|
15
|
+
w[k] = self._value
|
|
16
|
+
def get(self):
|
|
17
|
+
return self._value
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class IntVar:
|
|
21
|
+
def __init__(self, initial_value=0):
|
|
22
|
+
self._value = int(initial_value)
|
|
23
|
+
self._bind_widgets = []
|
|
24
|
+
|
|
25
|
+
def _input_widget(self, widget, key):
|
|
26
|
+
item = (widget, key)
|
|
27
|
+
if item not in self._bind_widgets:
|
|
28
|
+
self._bind_widgets.append(item)
|
|
29
|
+
for w, k in self._bind_widgets:
|
|
30
|
+
w[k] = self._value
|
|
31
|
+
def set(self, new_val=0):
|
|
32
|
+
self._value = int(new_val)
|
|
33
|
+
for w, k in self._bind_widgets:
|
|
34
|
+
w[k] = self._value
|
|
35
|
+
def get(self):
|
|
36
|
+
return self._value
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ttkps6
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: This library simplifies PySide6 and extends the functionality of Tkinter. You can write code in the Tkinter style to create native PySide6 GUI windows, allowing you to avoid the default appearance of Tkinter.
|
|
5
|
+
Author-email: gwood <engineergipbili@163.com>
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: pyside6
|
|
9
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/ttkps6/BaseTkinterWidget.py
|
|
5
|
+
src/ttkps6/Windows.py
|
|
6
|
+
src/ttkps6/__init__.py
|
|
7
|
+
src/ttkps6/other.py
|
|
8
|
+
src/ttkps6/ttk.py
|
|
9
|
+
src/ttkps6.egg-info/PKG-INFO
|
|
10
|
+
src/ttkps6.egg-info/SOURCES.txt
|
|
11
|
+
src/ttkps6.egg-info/dependency_links.txt
|
|
12
|
+
src/ttkps6.egg-info/requires.txt
|
|
13
|
+
src/ttkps6.egg-info/top_level.txt
|
|
14
|
+
src/ttkps6/PySide6Widget/LCDNumber.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyside6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ttkps6
|