|
| 1 | +import random |
| 2 | +from tkinter import * |
| 3 | +from tkinter.ttk import * |
| 4 | + |
| 5 | +class WinGUI(Tk): |
| 6 | + def __init__(self): |
| 7 | + super().__init__() |
| 8 | + self.__win() |
| 9 | + self.tk_text_m27qkagn = self.__tk_text_m27qkagn(self) |
| 10 | + self.tk_button_m27qm1i7 = self.__tk_button_m27qm1i7(self) |
| 11 | + self.tk_label_m27qqav2 = self.__tk_label_m27qqav2(self) |
| 12 | + |
| 13 | + def __win(self): |
| 14 | + self.title("微信多开助手") |
| 15 | + # 设置窗口大小、居中 |
| 16 | + width = 320 |
| 17 | + height = 80 |
| 18 | + screenwidth = self.winfo_screenwidth() |
| 19 | + screenheight = self.winfo_screenheight() |
| 20 | + geometry = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2) |
| 21 | + self.geometry(geometry) |
| 22 | + |
| 23 | + self.resizable(width=False, height=False) |
| 24 | + |
| 25 | + def scrollbar_autohide(self,vbar, hbar, widget): |
| 26 | + """自动隐藏滚动条""" |
| 27 | + def show(): |
| 28 | + if vbar: vbar.lift(widget) |
| 29 | + if hbar: hbar.lift(widget) |
| 30 | + def hide(): |
| 31 | + if vbar: vbar.lower(widget) |
| 32 | + if hbar: hbar.lower(widget) |
| 33 | + hide() |
| 34 | + widget.bind("<Enter>", lambda e: show()) |
| 35 | + if vbar: vbar.bind("<Enter>", lambda e: show()) |
| 36 | + if vbar: vbar.bind("<Leave>", lambda e: hide()) |
| 37 | + if hbar: hbar.bind("<Enter>", lambda e: show()) |
| 38 | + if hbar: hbar.bind("<Leave>", lambda e: hide()) |
| 39 | + widget.bind("<Leave>", lambda e: hide()) |
| 40 | + |
| 41 | + def v_scrollbar(self,vbar, widget, x, y, w, h, pw, ph): |
| 42 | + widget.configure(yscrollcommand=vbar.set) |
| 43 | + vbar.config(command=widget.yview) |
| 44 | + vbar.place(relx=(w + x) / pw, rely=y / ph, relheight=h / ph, anchor='ne') |
| 45 | + |
| 46 | + def h_scrollbar(self,hbar, widget, x, y, w, h, pw, ph): |
| 47 | + widget.configure(xscrollcommand=hbar.set) |
| 48 | + hbar.config(command=widget.xview) |
| 49 | + hbar.place(relx=x / pw, rely=(y + h) / ph, relwidth=w / pw, anchor='sw') |
| 50 | + |
| 51 | + def create_bar(self,master, widget,is_vbar,is_hbar, x, y, w, h, pw, ph): |
| 52 | + vbar, hbar = None, None |
| 53 | + if is_vbar: |
| 54 | + vbar = Scrollbar(master) |
| 55 | + self.v_scrollbar(vbar, widget, x, y, w, h, pw, ph) |
| 56 | + if is_hbar: |
| 57 | + hbar = Scrollbar(master, orient="horizontal") |
| 58 | + self.h_scrollbar(hbar, widget, x, y, w, h, pw, ph) |
| 59 | + self.scrollbar_autohide(vbar, hbar, widget) |
| 60 | + |
| 61 | + def __tk_text_m27qkagn(self,parent): |
| 62 | + text = Text(parent) |
| 63 | + text.place(x=100, y=16, width=116, height=50) |
| 64 | + return text |
| 65 | + |
| 66 | + def __tk_button_m27qm1i7(self,parent): |
| 67 | + btn = Button(parent, text="打开", takefocus=False,) |
| 68 | + btn.place(x=226, y=16, width=80, height=50) |
| 69 | + return btn |
| 70 | + |
| 71 | + def __tk_label_m27qqav2(self,parent): |
| 72 | + label = Label(parent,text="数量",anchor="center", ) |
| 73 | + label.place(x=10, y=16, width=85, height=50) |
| 74 | + return label |
| 75 | + |
| 76 | +class Win(WinGUI): |
| 77 | + def __init__(self, controller): |
| 78 | + self.ctl = controller |
| 79 | + super().__init__() |
| 80 | + self.__event_bind() |
| 81 | + self.__style_config() |
| 82 | + self.ctl.init(self) |
| 83 | + |
| 84 | + def __event_bind(self): |
| 85 | + self.tk_button_m27qm1i7.bind('<Button>',self.ctl.open_wechat) |
| 86 | + pass |
| 87 | + |
| 88 | + def __style_config(self): |
| 89 | + pass |
0 commit comments