magictk/debug.py

136 lines
6.1 KiB
Python
Raw Permalink Normal View History

2024-03-24 18:16:29 +08:00
import magictk
2024-04-07 21:39:09 +08:00
import random
from multiprocessing import Process
2024-03-24 18:16:29 +08:00
if __name__ == "__main__":
2024-04-27 13:39:33 +08:00
win = magictk.Window(h=400)
2024-04-26 09:00:26 +08:00
# win = magictk.Container(mwin, h=10000, container_h=500)
2024-04-07 21:39:09 +08:00
frame = magictk.Frame(win)
magictk.Button(frame, text="Default",
func=lambda s: print("Btn 1")).pack(side='left')
magictk.ButtonFill(frame, text="Primary",
func=lambda s: print("Btn 2")).pack(side='left')
magictk.ButtonFill(frame, color_type="success", text="Success",
func=lambda s: print("Btn 3")).pack(side='left')
magictk.ButtonFill(frame, color_type="info", text="Info",
func=lambda s: print("Btn 4")).pack(side='left')
magictk.ButtonFill(frame, color_type="warning", text="Warning",
func=lambda s: print("Btn 5")).pack(side='left')
magictk.ButtonFill(frame, color_type="danger", text="Danger",
func=lambda s: print("Btn 6")).pack(side='left')
frame.pack()
2024-04-27 13:39:33 +08:00
frame10 = magictk.Frame(win)
magictk.ButtonLight(frame10, text="Plain",
func=lambda s: print("Btn 2")).pack(side='left')
magictk.ButtonLight(frame10, color_type="primary", text="Primary",
func=lambda s: print("Btn 2")).pack(side='left')
magictk.ButtonLight(frame10, color_type="success", text="Success",
func=lambda s: print("Btn 3")).pack(side='left')
magictk.ButtonLight(frame10, color_type="info", text="Info",
func=lambda s: print("Btn 4")).pack(side='left')
magictk.ButtonLight(frame10, color_type="warning", text="Warning",
func=lambda s: print("Btn 5")).pack(side='left')
magictk.ButtonLight(frame10, color_type="danger", text="Danger",
func=lambda s: print("Btn 6")).pack(side='left')
frame10.pack()
2024-04-07 21:39:09 +08:00
frame2 = magictk.Frame(win)
magictk.Select(frame2, text="Select", items=[
f"Option {i}" for i in range(1, 6)]).pack(side='left')
magictk.Select(frame2, text="Select(1000 items)", items=[
f"Option {i}" for i in range(1, 1001)]).pack(side='left')
obj1 = magictk.MenuObjs()
for i in range(1, 10):
obj1.addmenu(f"Option {i}", lambda s, t: print(i))
magictk.Button(frame2, text="Menu",
2024-04-26 09:00:26 +08:00
func=lambda s: magictk.Menu(win, menuobj=obj1), w=60).pack()
2024-04-07 21:39:09 +08:00
frame2.pack()
frame3 = magictk.Frame(win)
groups = magictk.RadioGroup()
magictk.Checkbox(frame3, text="Radio 1", w=100,
group=groups).pack(side='left')
magictk.Checkbox(frame3, text="Radio 2", w=100,
group=groups).pack(side='left')
magictk.Checkbox(frame3, text="Radio 3", w=100,
group=groups).pack(side='left')
magictk.Checkbox(frame3, text="Radio 4", w=100,
group=groups).pack(side='left')
frame3.pack()
2024-04-26 09:00:26 +08:00
frame5 = magictk.Frame(win)
magictk.Checkbox(frame5, text="Option 1", w=100).pack(side='left')
magictk.Checkbox(frame5, text="Option 2", w=100).pack(side='left')
frame5.pack()
2024-04-07 21:39:09 +08:00
frame4 = magictk.Frame(win)
2024-04-26 09:00:26 +08:00
magictk.Icon(frame4, size=12).pack(side='left')
magictk.Icon(frame4, size=16).pack(side='left')
magictk.Icon(frame4, size=32).pack(side='left')
magictk.Icon(frame4, size=48).pack(side='left')
magictk.Button(frame4,
func=lambda s: print("Icon Btn 1"), iconname="apple", iconsize=16, w=32).pack(side='left')
magictk.ButtonFill(frame4, color_type="primary",
func=lambda s: print("Icon Btn 2"), iconname="apple", iconsize=16, w=32).pack(side='left')
2024-04-29 21:10:39 +08:00
magictk.ButtonLight(frame4,
func=lambda s: print("Icon Btn 3"), iconname="apple", iconsize=16, w=32).pack(side='left')
2024-04-07 21:39:09 +08:00
frame4.pack()
2024-04-26 09:00:26 +08:00
frame6 = magictk.Frame(win)
pb = magictk.ProgressBar(frame6)
2024-04-07 21:39:09 +08:00
pb.pack(side='left')
2024-04-26 09:00:26 +08:00
magictk.Button(frame6, text="+",
2024-04-07 21:39:09 +08:00
func=lambda s: pb.add_progress(0.1), w=30).pack(side='left')
2024-04-26 09:00:26 +08:00
magictk.Button(frame6, text="-",
2024-04-07 21:39:09 +08:00
func=lambda s: pb.add_progress(-0.1), w=30).pack(side='left')
2024-04-26 09:00:26 +08:00
magictk.Button(frame6, text="++",
2024-04-07 21:39:09 +08:00
func=lambda s: pb.add_progress(0.3), w=40).pack(side='left')
2024-04-26 09:00:26 +08:00
magictk.Button(frame6, text="--",
2024-04-07 21:39:09 +08:00
func=lambda s: pb.add_progress(-0.3), w=40).pack(side='left')
2024-04-26 09:00:26 +08:00
frame6.pack()
2024-04-07 21:39:09 +08:00
2024-04-26 09:00:26 +08:00
frame7 = magictk.Frame(win)
2024-04-07 21:39:09 +08:00
def kaoji():
def test(*args):
p = []
size = 10000000
for i in range(1, size):
if (i % 100000 == 0):
print(f"make data... {i*100//size}%")
p.append(random.randint(1, size))
print("sort...")
p.sort()
print("finish!")
del p
ts = Process(target=test)
ts.start()
2024-04-26 09:00:26 +08:00
magictk.Button(frame7, text="Performance Test",
2024-04-07 21:39:09 +08:00
func=lambda s: kaoji(), w=130).pack(side='left')
2024-04-12 22:01:51 +08:00
frame7.pack()
2024-03-24 18:16:29 +08:00
2024-04-26 09:00:26 +08:00
frame8 = magictk.Frame(win)
magictk.Entry(frame8, w=200).pack(side='left')
frame8.pack()
frame9 = magictk.Container(win, h=200, container_h=30*6*5)
for i in range(5):
2024-04-26 09:00:26 +08:00
magictk.Button(frame9, text="Default",
func=lambda s: print("Btn 1")).pack()
2024-04-26 09:00:26 +08:00
magictk.ButtonFill(frame9, text="Primary",
func=lambda s: print("Btn 2")).pack()
2024-04-26 09:00:26 +08:00
magictk.ButtonFill(frame9, color_type="success", text="Success",
func=lambda s: print("Btn 3")).pack()
2024-04-26 09:00:26 +08:00
magictk.ButtonFill(frame9, color_type="info", text="Info",
func=lambda s: print("Btn 4")).pack()
2024-04-26 09:00:26 +08:00
magictk.ButtonFill(frame9, color_type="warning", text="Warning",
func=lambda s: print("Btn 5")).pack()
2024-04-26 09:00:26 +08:00
magictk.ButtonFill(frame9, color_type="danger", text="Danger",
func=lambda s: print("Btn 6")).pack()
2024-04-26 09:00:26 +08:00
frame9.pack(expand=True, fill="x")
2024-04-21 18:04:20 +08:00
2024-04-26 09:00:26 +08:00
# win.pack(expand=True, fill="x", anchor="n")
2024-04-26 09:00:26 +08:00
win.mainloop()