119 lines
5.1 KiB
Python
119 lines
5.1 KiB
Python
import magictk
|
|
import random
|
|
from multiprocessing import Process
|
|
if __name__ == "__main__":
|
|
win = magictk.Window()
|
|
# win = magictk.Container(mwin, h=10000, container_h=500)
|
|
|
|
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()
|
|
|
|
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",
|
|
func=lambda s: magictk.Menu(win, menuobj=obj1), w=60).pack()
|
|
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()
|
|
|
|
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()
|
|
|
|
frame4 = magictk.Frame(win)
|
|
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')
|
|
frame4.pack()
|
|
|
|
frame6 = magictk.Frame(win)
|
|
pb = magictk.ProgressBar(frame6)
|
|
pb.pack(side='left')
|
|
magictk.Button(frame6, text="+",
|
|
func=lambda s: pb.add_progress(0.1), w=30).pack(side='left')
|
|
magictk.Button(frame6, text="-",
|
|
func=lambda s: pb.add_progress(-0.1), w=30).pack(side='left')
|
|
magictk.Button(frame6, text="++",
|
|
func=lambda s: pb.add_progress(0.3), w=40).pack(side='left')
|
|
magictk.Button(frame6, text="--",
|
|
func=lambda s: pb.add_progress(-0.3), w=40).pack(side='left')
|
|
frame6.pack()
|
|
|
|
frame7 = magictk.Frame(win)
|
|
|
|
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()
|
|
magictk.Button(frame7, text="Performance Test",
|
|
func=lambda s: kaoji(), w=130).pack(side='left')
|
|
frame7.pack()
|
|
|
|
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):
|
|
magictk.Button(frame9, text="Default",
|
|
func=lambda s: print("Btn 1")).pack()
|
|
magictk.ButtonFill(frame9, text="Primary",
|
|
func=lambda s: print("Btn 2")).pack()
|
|
magictk.ButtonFill(frame9, color_type="success", text="Success",
|
|
func=lambda s: print("Btn 3")).pack()
|
|
magictk.ButtonFill(frame9, color_type="info", text="Info",
|
|
func=lambda s: print("Btn 4")).pack()
|
|
magictk.ButtonFill(frame9, color_type="warning", text="Warning",
|
|
func=lambda s: print("Btn 5")).pack()
|
|
magictk.ButtonFill(frame9, color_type="danger", text="Danger",
|
|
func=lambda s: print("Btn 6")).pack()
|
|
frame9.pack(expand=True, fill="x")
|
|
|
|
# win.pack(expand=True, fill="x", anchor="n")
|
|
|
|
win.mainloop()
|