1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
class WidgetPersonnal(tk.Frame) :
def __init__(self, master, name, channel, width = 300, height = 70) :
super(WidgetPersonnal, self).__init__(width = width, height = height)
self.Button_Name = tk.Button(self, text = name, command = self.command_detail)
self.channel_name = tk.Label(self, text = channel)
self.MPVar = tk.StringVar()
self.MPEntry = tk.Entry(self, textvariable = self.MPVar)
self.MPButton = tk.Button(self, text = "SEND")
self.isVisible = False
def grid(self, row = 0, rowspan = 1, column = 0, columnspan = 1) :
super(WidgetPersonnal,self).grid(row = row, column = column, rowspan = rowspan, columnspan = columnspan)
self.grid_propagate(0)
self.Button_Name.grid(row =1, columnspan = 2, column = 0)
def command_normal(self, evt) :
mousex = evt.x_root ; mousey = evt.y_root
debt_fenx = self.winfo_rootx() ; debt_feny = self.winfo_rooty()
fen_width = self.winfo_width() ; fen_height = self.winfo_height()
if not (mousex >= debt_fenx and mousex <= (debt_fenx +fen_width) and mousey >=debt_feny and mousey <=(debt_feny+fen_height)) :
self.Button_Name.config(state = tk.NORMAL)
self.isVisible = False
self.unbind_all("<Button-1>")
self.channel_name.grid_forget()
self.MPButton.grid_forget()
self.MPEntry.grid_forget()
self.Button_Name.grid(row = 0, column = 1, rowspan = 2,columnspan = 3)
def command_detail(self) :
if not self.isVisible :
self.Button_Name.config(state = tk.DISABLED)
self.Button_Name.grid_forget()
self.channel_name.grid(row = 0, rowspan = 1, column = 0, columnspan = 3)
self.MPEntry.grid(row = 1, rowspan = 1, column = 0, columnspan = 2)
self.MPButton.grid(row = 1, rowspan = 1, column = 2, columnspan = 1)
self.isVisible = True
self.bind_all("<Button-1>", self.command_normal) |
Partager