本文整理汇总了Python中ttk.Label.pack_forget方法的典型用法代码示例。如果您正苦于以下问题:Python Label.pack_forget方法的具体用法?Python Label.pack_forget怎么用?Python Label.pack_forget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk.Label
的用法示例。
在下文中一共展示了Label.pack_forget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GraphFrame
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack_forget [as 别名]
class GraphFrame(Frame):
def __init__(self, parent, paned_window, **kwargs):
Frame.__init__(self, paned_window)
self.parent = parent
self.df_column_frame = ScrolledFrame(self, vertflex='expand')
self.graph_frame = ScrolledFrame(self, horizflex='expand', vertflex='expand')
self.plot_figure = kwargs['plot'] if 'plot' in kwargs else None
self.plot_title = kwargs['plot_title'] if 'plot_title' in kwargs else 'Line Plot'
self.y_label = kwargs['y_label'] if 'y_label' in kwargs else 'y'
self.df = kwargs['df'] if 'df' in kwargs else DataFrame() # If the dataframe wasn't passed in, then create an empty dataframe
plot_selected_avg = ModelRunnerPlots.get_avg_plot(self.plot_title, self.y_label, self.df, None)
self.plot_figure = plot_selected_avg
self.graph_canvas = FigureCanvasTkAgg(plot_selected_avg, master=self.graph_frame.interior())
self.col_list = list()
for col in self.df.columns:
if col != 'year' and 'Average' not in col:
col_var = IntVar()
col_var.set(0)
col_checkbox = Checkbutton(self.df_column_frame.interior(), text=col, variable=col_var, command=self.on_col_check)
self.col_list.append([col_var, col_checkbox, col])
avg_dataframe, dataframe = ModelRunnerPlots.find_avg_dataframe(self.df)
for col in avg_dataframe.columns:
if col != 'year':
col_var = IntVar()
col_var.set(0)
col_checkbox = Checkbutton(self.df_column_frame.interior(), text=col, variable=col_var, command=self.on_col_check)
self.col_list.append([col_var, col_checkbox, col])
self.log_filename_frame = Frame(self)
self.log_label = Label(self.log_filename_frame, text='Logfile: ' + kwargs['log_filename']) if 'log_filename' in kwargs else None
self.button_frame = Frame(self)
self.close_button = Button(self.button_frame, text='Close', command=self.on_close)
self.save_button = Button(self.button_frame, text='Save', command=self.on_save)
def set_grid(self):
#print 'Resizing graph frame'
#self.grid(padx=4, pady=4)
self.pack(padx=4, pady=4, expand=True, fill=Tkinter.BOTH)
#self.rowconfigure(0, minsize=600)
#self.columnconfigure(0, minsize=100)
#self.columnconfigure(1, minsize=600)
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=5)
self.rowconfigure(0, weight=1)
self.df_column_frame.grid(row=0, column=0, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)
#self.df_column_frame.pack(side=Tkinter.LEFT, expand=True, fill=Tkinter.BOTH)
row_index = 0
for col in self.col_list:
checkButton = col[1]
checkButton.grid(sticky=Tkinter.E + Tkinter.W)
row_index += 1
self.graph_frame.grid(row=0, column=1, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)
#self.graph_frame.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.BOTH)
try:
self.graph_canvas.get_tk_widget().grid(row=0, column=0, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)
#self.graph_canvas.get_tk_widget().pack(expand=True, fill=Tkinter.BOTH)
except AttributeError:
pass
self.log_filename_frame.grid(row=1, column=0, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)
if self.log_label != None:
self.log_label.pack(side=Tkinter.LEFT)
self.button_frame.grid(row=1, column=1, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W)
#self.button_frame.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)
self.close_button.pack(side=Tkinter.RIGHT)
self.save_button.pack(side=Tkinter.RIGHT)
def unset_grid(self):
self.pack_forget()
self.df_column_frame.grid_forget()
self.graph_frame.grid_forget()
try:
self.graph_canvas.get_tk_widget().grid_forget()
except AttributeError:
pass
self.log_filename_frame.grid_forget()
if self.log_label != None:
self.log_label.pack_forget()
self.button_frame.grid_forget()
self.close_button.pack_forget()
self.save_button.pack_forget()
def on_col_check(self):
# Based upon what is checked, a new plot should be created
value_vars = list()
for col in self.col_list:
if col[0].get() == 1:
#print col[2] + ' is checked'
value_vars.append(col[2])
#.........这里部分代码省略.........
示例2: setCard
# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import pack_forget [as 别名]
def setCard(self,cardnum,row,col):
dodel = False
if cardnum == -1:
dodel = True
cardnum = 1
card = Card(cardnum)
f = Frame(self, height = card.height, width = card.width)
if (row == 2 and self.client.player == 'p1') or (row == 3 and self.client.player == 'p2'):
f.config(height = card.height+20)
if self.client.player == 'p1':
f.grid(row=row+1, column=col)
else:
f.grid(row=6-row, column=NUM_COLS-col)
f.pack_propagate(0)
self.fgrid[row][col] = f
pic = Label(f)
if row <= 2:
card.flip()
if self.client.player == 'p2':
card.flip()
pic.config(image=card.img)
pic.image = card.img
pic.row = row
pic.col = col
pic.card = card
def clicked(pic,ins,card):
if ins.state == 'taking' and not pic.isNone:
if pic.card.number == ins.activeCard:
endTime = time.time()
ins.delta = round(endTime-self.startTime,2)
print(ins.delta)
print("Got in "+str(ins.delta))
ins.client.sendMessage('took,'+str(ins.delta)+','+str(ins.faultCount))
if not ins.multiplayer:
ins.client.oppSendMessage('p2,took,20,0')
ins.changeState('waiting')
pic.pack_forget()
ins.model[pic.row][pic.col].isNone = True
elif ins.activeCardRow == -1 or not (pic.row <= 2) == (ins.activeCardRow <= 2):
ins.faults[int(pic.row <= 2)] = 1
ins.faultCount = sum(ins.faults)
elif ins.state == 'move-select-start':
ins.movingPic = (pic.row, pic.col)
print('moving card:')
print(ins.movingPic)
if (((self.client.player == 'p1' and pic.row > 2) or (self.client.player == 'p2' and pic.row <= 2))\
and not pic.isNone) or not ins.multiplayer:
ins.infoLabel.config(text="Card chosen. Select destination.")
ins.changeState('move-select-stop')
else:
ins.infoLabel.config(text="Can't move that. Select a different card to move.")
ins.moveButton.config(text="Cancel")
elif ins.state == 'move-select-stop':
print('to:')
print((pic.row, pic.col))
if ((self.client.player == 'p1' and pic.row <= 2) or (self.client.player == 'p2' and pic.row > 2))\
and not pic.isNone:
ins.infoLabel.config(text="Illegal move. Select a different card to move.")
else:
ins.swapCards(self.movingPic,(pic.row, pic.col))
ins.infoLabel.config(text="Move completed. Select next card.")
ins.changeState('move-select-start')
f.bind("<Button-1>",lambda e,pic=pic,self=self,card=card:clicked(pic,self,card))
pic.bind("<Button-1>",lambda e,pic=pic,self=self,card=card:clicked(pic,self,card))
pic.pack(fill=BOTH)
self.model[row][col] = pic
if dodel:
pic.pack_forget()
self.model[row][col].isNone = True
else:
self.model[row][col].isNone = False