pygui_simple 0.5.2__tar.gz → 0.5.3__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.
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/PKG-INFO +1 -1
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/pyproject.toml +1 -1
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/tkscrollpicker.py +53 -13
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/tkslideswitch.py +1 -4
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/tkwin.py +9 -14
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/LICENSE +0 -0
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/README.md +0 -0
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/__init__.py +0 -0
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/py.typed +0 -0
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/tkcalendar.py +0 -0
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/tkcontrol.py +0 -0
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/tkmatplot.py +0 -0
- {pygui_simple-0.5.2 → pygui_simple-0.5.3}/src/pygui_simple/winbasic.py +0 -0
|
@@ -115,17 +115,19 @@ class ScrollPicker(tk.Frame, Generic[T]):
|
|
|
115
115
|
_ = self._data_label.bind("<Enter>", self._on_enter)
|
|
116
116
|
_ = self._data_label.bind("<Leave>", self._on_leave)
|
|
117
117
|
|
|
118
|
-
def _on_enter(self, event: tk.Event[tk.Label]) -> None:
|
|
118
|
+
def _on_enter(self, event: tk.Event[tk.Label]) -> None:
|
|
119
119
|
""" 鼠标进入时的样式变化"""
|
|
120
120
|
if hasattr(event.widget, 'config'):
|
|
121
121
|
_ = event.widget.config(bg="#e0f0ff")
|
|
122
122
|
|
|
123
|
-
def _on_leave(self, event: tk.Event[tk.Label]) -> None:
|
|
123
|
+
def _on_leave(self, event: tk.Event[tk.Label]) -> None:
|
|
124
124
|
""" 鼠标离开时的样式恢复"""
|
|
125
125
|
if hasattr(event.widget, 'config'):
|
|
126
126
|
_ = event.widget.config(bg="white")
|
|
127
127
|
|
|
128
|
-
def _update_previews(self) -> None:
|
|
128
|
+
def _update_previews(self) -> None:
|
|
129
|
+
self._data_label["text"] = self._selected_data
|
|
130
|
+
|
|
129
131
|
""" 更新上下预览内容"""
|
|
130
132
|
# 上方预览(+1和+2,受限于上限)
|
|
131
133
|
up1 = self._get_data(self._index + 1)
|
|
@@ -140,7 +142,7 @@ class ScrollPicker(tk.Frame, Generic[T]):
|
|
|
140
142
|
_ = self._data_down1.config(text=str(down1))
|
|
141
143
|
_ = self._data_down2.config(text=str(down2))
|
|
142
144
|
|
|
143
|
-
def _on_data_scroll(self, event: tk.Event) -> None:
|
|
145
|
+
def _on_data_scroll(self, event: tk.Event) -> None:
|
|
144
146
|
""" 处理滚动"""
|
|
145
147
|
if event.delta > 0 or getattr(event, 'num', 0) == 4: # 上滚增加
|
|
146
148
|
self._selected_data = self._get_data(self._index + 1, True)
|
|
@@ -166,6 +168,8 @@ class ScrollPicker(tk.Frame, Generic[T]):
|
|
|
166
168
|
|
|
167
169
|
def update_data(self, data: T):
|
|
168
170
|
self._selected_data = data
|
|
171
|
+
print(f"data = {data}")
|
|
172
|
+
self._index = self._val_list.index(self._selected_data)
|
|
169
173
|
self._update_previews()
|
|
170
174
|
|
|
171
175
|
def update_val_list(self, val_list: list[T]):
|
|
@@ -359,36 +363,54 @@ class DateScrollPickerDialog:
|
|
|
359
363
|
|
|
360
364
|
class TimeScrollPickerCtrl(tkControl):
|
|
361
365
|
def __init__(self, parent: tk.Misc, owner: Container, idself: str,
|
|
362
|
-
width: int, height: int,
|
|
366
|
+
width: int, height: int, *,
|
|
367
|
+
stp: int = 0,
|
|
363
368
|
background: str = "white",
|
|
364
369
|
title: str = "", initial: str = ""):
|
|
365
370
|
self._master: tk.Misc = parent
|
|
366
371
|
self._owner: Container = owner
|
|
372
|
+
self._stp: int = stp
|
|
373
|
+
|
|
374
|
+
self._selected_hour: int = 0
|
|
375
|
+
self._selected_minute: int = 0
|
|
367
376
|
|
|
368
377
|
self._frame: tk.Frame = tk.Frame(self._master,
|
|
369
378
|
background=background,
|
|
370
379
|
width=width, height=height)
|
|
371
380
|
super().__init__(parent, "", idself, self._frame)
|
|
372
381
|
|
|
373
|
-
#
|
|
382
|
+
# self.set_initial(initial)
|
|
374
383
|
if not initial:
|
|
375
384
|
now: datetime.datetime = datetime.datetime.now()
|
|
376
|
-
self._selected_hour
|
|
377
|
-
self._selected_minute
|
|
385
|
+
self._selected_hour = now.hour
|
|
386
|
+
self._selected_minute = now.minute
|
|
378
387
|
else:
|
|
379
388
|
now_list = initial.split(":")
|
|
380
389
|
self._selected_hour = int(now_list[0])
|
|
381
390
|
self._selected_minute = int(now_list[1])
|
|
382
391
|
|
|
383
|
-
|
|
384
|
-
|
|
392
|
+
stp_hour, stp_minute = divmod(stp, 60)
|
|
393
|
+
|
|
394
|
+
print(f"step: {stp_hour} {stp_minute}")
|
|
395
|
+
|
|
396
|
+
if stp_hour:
|
|
397
|
+
hour_list = list(range(0, 24, stp_hour))
|
|
398
|
+
self._selected_hour = (self._selected_hour // stp_hour) * stp_hour
|
|
399
|
+
else:
|
|
400
|
+
hour_list = list(range(0, 24))
|
|
401
|
+
print(f"hour_list :{hour_list}")
|
|
385
402
|
self._hour_scrollpicker: ScrollPicker[int] = ScrollPicker[int](self._frame,
|
|
386
403
|
hour_list, self._selected_hour,
|
|
387
404
|
self._on_hour_change,
|
|
388
405
|
background=background
|
|
389
406
|
)
|
|
390
407
|
|
|
391
|
-
|
|
408
|
+
if stp_minute:
|
|
409
|
+
minute_list = list(range(0, 60, stp_minute))
|
|
410
|
+
self._selected_minute = (self._selected_minute // stp_minute) * stp_minute
|
|
411
|
+
else:
|
|
412
|
+
minute_list = list(range(0, 60))
|
|
413
|
+
print(f"minute_list :{minute_list}")
|
|
392
414
|
self._minute_scrollpicker: ScrollPicker[int] = ScrollPicker(self._frame,
|
|
393
415
|
minute_list, self._selected_minute,
|
|
394
416
|
self._on_minute_change,
|
|
@@ -433,6 +455,23 @@ class TimeScrollPickerCtrl(tkControl):
|
|
|
433
455
|
formatted_time: str = f"{self._selected_hour:02d}:{self._selected_minute:02d}"
|
|
434
456
|
self._result_var.set(f"当前选择: {formatted_time}")
|
|
435
457
|
|
|
458
|
+
def set_initial(self, initial: str = ""):
|
|
459
|
+
if not initial:
|
|
460
|
+
now: datetime.datetime = datetime.datetime.now()
|
|
461
|
+
self._selected_hour = now.hour
|
|
462
|
+
self._selected_minute = now.minute
|
|
463
|
+
else:
|
|
464
|
+
now_list = initial.split(":")
|
|
465
|
+
self._selected_hour = int(now_list[0])
|
|
466
|
+
self._selected_minute = int(now_list[1])
|
|
467
|
+
stp_hour, stp_minute = divmod(self._stp, 60)
|
|
468
|
+
if stp_hour:
|
|
469
|
+
self._selected_hour = (self._selected_hour // stp_hour) * stp_hour
|
|
470
|
+
if stp_minute:
|
|
471
|
+
self._selected_minute = (self._selected_minute // stp_minute) * stp_minute
|
|
472
|
+
self._hour_scrollpicker.update_data(self._selected_hour)
|
|
473
|
+
self._minute_scrollpicker.update_data(self._selected_minute)
|
|
474
|
+
|
|
436
475
|
def get_time(self):
|
|
437
476
|
""" 获取当前选择的时间"""
|
|
438
477
|
return datetime.time(self._selected_hour, self._selected_minute)
|
|
@@ -443,7 +482,7 @@ class TimeScrollPickerCtrl(tkControl):
|
|
|
443
482
|
|
|
444
483
|
|
|
445
484
|
class TimeScrollPickerDialog(Container):
|
|
446
|
-
def __init__(self, point: tuple[int, int] | None = None,
|
|
485
|
+
def __init__(self, point: tuple[int, int] | None = None, *, stp: int = 0,
|
|
447
486
|
title: str = "", initial: str = ""):
|
|
448
487
|
super().__init__()
|
|
449
488
|
|
|
@@ -469,6 +508,7 @@ class TimeScrollPickerDialog(Container):
|
|
|
469
508
|
self._time_scrollpicker_ctrl: TimeScrollPickerCtrl = TimeScrollPickerCtrl(self._frame, self,
|
|
470
509
|
"tspSelectTime",
|
|
471
510
|
100, 50,
|
|
511
|
+
stp=stp,
|
|
472
512
|
initial=f"{selected_hour}:{selected_minute}"
|
|
473
513
|
)
|
|
474
514
|
self._time_scrollpicker_ctrl.control.pack(pady=5)
|
|
@@ -612,7 +652,7 @@ if __name__ == "__main__":
|
|
|
612
652
|
self._var_time.set(res)
|
|
613
653
|
|
|
614
654
|
def ask_time(self, x: int, y: int):
|
|
615
|
-
scrollpicker = TimeScrollPickerDialog((x, y), "wahaha")
|
|
655
|
+
scrollpicker = TimeScrollPickerDialog((x, y), title="wahaha")
|
|
616
656
|
return scrollpicker.get_timestr()
|
|
617
657
|
|
|
618
658
|
|
|
@@ -289,8 +289,6 @@ class SlideSwitchCtrl(tkControl):
|
|
|
289
289
|
if abs(distance) < 1:
|
|
290
290
|
self._current_slider_x = target_x
|
|
291
291
|
self._redraw_all()
|
|
292
|
-
|
|
293
|
-
self._on_state_changed(target_state)
|
|
294
292
|
return
|
|
295
293
|
|
|
296
294
|
# Calculate animation step (smooth movement over 10 frames)
|
|
@@ -306,7 +304,6 @@ class SlideSwitchCtrl(tkControl):
|
|
|
306
304
|
(step < 0 and self._current_slider_x <= target_x)):
|
|
307
305
|
self._current_slider_x = target_x
|
|
308
306
|
|
|
309
|
-
self._on_state_changed(target_state)
|
|
310
307
|
self._redraw_all()
|
|
311
308
|
return
|
|
312
309
|
|
|
@@ -354,7 +351,7 @@ class SlideSwitchCtrl(tkControl):
|
|
|
354
351
|
self._current_slider_x = float(self.__slider_on_x) if state else float(self.__slider_off_x)
|
|
355
352
|
self._redraw_all()
|
|
356
353
|
|
|
357
|
-
|
|
354
|
+
self._on_state_changed(state)
|
|
358
355
|
|
|
359
356
|
def _on_state_changed(self, state: bool):
|
|
360
357
|
# self._state = state
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# !/usr/bin/python3
|
|
2
2
|
# -*- coding: UTF-8 -*-
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
import builtins as __builtin__
|
|
5
4
|
# from _typeshed import SupportsWrite
|
|
6
5
|
import sys
|
|
7
6
|
import os
|
|
@@ -979,15 +978,7 @@ class DialogCtrl(Dialog):
|
|
|
979
978
|
|
|
980
979
|
_T_contra = TypeVar("_T_contra", contravariant=True)
|
|
981
980
|
class SupportsWrite(Protocol[_T_contra]):
|
|
982
|
-
|
|
983
|
-
def write(self, s: str) -> object: ...
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
# class Root(tkControl):
|
|
987
|
-
# def __init__(self):
|
|
988
|
-
# self._win: tk.Tk = tk.Tk()
|
|
989
|
-
# super().__init__(self._win, "", "", self._win)
|
|
990
|
-
|
|
981
|
+
def write(self, s: _T_contra, /) -> object: ...
|
|
991
982
|
|
|
992
983
|
class tkWin(WinBasic):
|
|
993
984
|
def __init__(self, cur_path: str, xmlfile: str):
|
|
@@ -1064,9 +1055,13 @@ class tkWin(WinBasic):
|
|
|
1064
1055
|
def path(self):
|
|
1065
1056
|
return self._cur_path
|
|
1066
1057
|
|
|
1067
|
-
def debug_print(self, *
|
|
1058
|
+
def debug_print(self, *values: object,
|
|
1059
|
+
sep: str | None = " ",
|
|
1060
|
+
end: str | None = "\n",
|
|
1061
|
+
file: SupportsWrite[str] | None = None,
|
|
1062
|
+
flush: Literal[False] = False):
|
|
1068
1063
|
if self._is_debug:
|
|
1069
|
-
|
|
1064
|
+
print(*values, sep, end, file, flush)
|
|
1070
1065
|
|
|
1071
1066
|
def _center_window(self, width: int, hight: int):
|
|
1072
1067
|
"""设置窗口居中和宽高
|
|
@@ -1305,8 +1300,8 @@ class tkWin(WinBasic):
|
|
|
1305
1300
|
# pe(ctrl_type)
|
|
1306
1301
|
if ctrl_type in [tk.Menu, DialogCtrl]:
|
|
1307
1302
|
return
|
|
1308
|
-
elif ctrl_type in [tk.Canvas,
|
|
1309
|
-
ttk.Style, tk.Scrollbar]:
|
|
1303
|
+
elif ctrl_type in [tk.Canvas, scrolledtext.ScrolledText, tk.Spinbox, \
|
|
1304
|
+
ttk.Style, tk.Scrollbar, MultiStatusBar]:
|
|
1310
1305
|
widget = cast(tk.Widget, ctrl)
|
|
1311
1306
|
elif ctrl_type is ScrollableFrameCtrl:
|
|
1312
1307
|
widget = cast(ScrollableFrameCtrl, ctrl).outter
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|