def create_widgets(self): self.create_line(13, 13, 25, 13, fill="white", smooth=True) self.create_rectangle(13, 14, 24, 22, fill=rgb_to_hex(64, 20, 107), outline='white') self.create_line(9, 16, 21, 16, fill="white", smooth=True) self.create_rectangle(9, 17, 20, 25, fill=rgb_to_hex(64, 20, 107), outline='white')
def textEvent(self, event): """timerText回调事件""" self.tag_configure("current_line", background=rgb_to_hex(0, 120, 215), foreground="white") self.tag_remove("current_line", 1.0, "end") self.tag_add("current_line", "current linestart", "current lineend")
def create_max_widgets(self): self.create_line(10, 14, 27, 14, width=2, fill='white', tags="max") # 如果27改为26的话,则线和矩阵的右边对不齐 self.create_rectangle(10, 14, 26, 24, fill=rgb_to_hex(64, 20, 107), outline='white', tags="max")
def __init__(self, master): tk.Canvas.__init__(self, master) # highlightthickness: get rid of the light grey border of the canvas widgets self.config(width=34, height=36, bd=0, bg=rgb_to_hex(64, 20, 107), highlightthickness=0) self.pack(side=tk.RIGHT, expand=tk.NO, padx=1) self.bind("<Enter>", self.on_enter) self.bind("<Leave>", self.on_leave)
def create_widget(self): # make a frame for the title bar self.title_bar = tk.Frame(self, height=40, bg=rgb_to_hex(64, 20, 107), relief='flat', bd=0) # title name self.title_name = tk.Label(self.title_bar, text="极星量化", width=12, bg=rgb_to_hex(64, 20, 107), relief='flat', fg=rgb_to_hex(255, 255, 255), font=("微软雅黑", "-14", 'normal'), anchor=tk.CENTER, padx=-16) self.title_name.pack(side=tk.LEFT, expand=tk.NO) # put the close, maximize and minimize button on the title bar close_button = CloseCanvas(self.title_bar) mixed_button = MixedCancas(self.title_bar) minimize_button = MinimizeCanvas(self.title_bar) # bind event self.title_bar.bind('<B1-Motion>', self.move_window) # a canvas for the main area of the window window = tk.Canvas(self, bg=rgb_to_hex(227, 230, 233)) # pack the widgets self.title_bar.pack(side=tk.TOP, fill=tk.X, expand=tk.NO) window.pack(padx=2, pady=2, side=tk.TOP, expand=1, fill=tk.BOTH) # Quant window self.quant_app = QuantApplication(window, self.control) self.quant_app.create_window()
def __init__(self, master, control): tk.Toplevel.__init__(self, master) self.control = control self.master = master self.overrideredirect(1) # self.attributes('-topmost', 1) # window in front(no need) # set the Quant window's size and location width = self.master.winfo_screenwidth() * 0.8 height = self.master.winfo_screenheight() * 0.8 self.geometry('%dx%d+%d+%d' % (width, height, width * 0.1, height * 0.1)) self.config(background=rgb_to_hex(64, 20, 107)) self.create_widget()
def on_leave(self, event): self.config(bg=rgb_to_hex(64, 20, 107))
def on_enter(self, event): self.config(bg=rgb_to_hex(84, 26, 131))