本文整理汇总了Python中tkinter.Frame.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.destroy方法的具体用法?Python Frame.destroy怎么用?Python Frame.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.destroy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import destroy [as 别名]
class Widget_:
def __init__(self, parent_frame, row, column, width=50, height=50):
self.widget_frame = Frame(parent_frame, width=width, height=height)
self.widget_frame.grid(row=row, column=column)
self.width, self.height = width, height
return
def add_tag(self, tag_library, string):
tag_library[string] = self
def delete_widget(self):
for child in self.widget_frame.winfo_children():
child.destroy()
self.widget_frame.destroy()
def hide_widget(self):
self.widget_frame.grid_forget()
def get_info(self):
return
def set_field(self):
return
pass
示例2: ChoosePlayerDialog
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import destroy [as 别名]
class ChoosePlayerDialog(Toplevel):
"""Dialog used to prompt the user to choose a player."""
def __init__(self, program: GUIProgram):
super(ChoosePlayerDialog, self).__init__(program.app)
self.title('Choose Player')
self.program = program
self.body = Frame(self)
self.initial_focus = self.body
self.body.pack()
self.create_widgets()
self.initial_focus.focus_set()
# If this window is closed, terminate the application.
self.wm_protocol('WM_DELETE_WINDOW', self.on_close)
def create_widgets(self):
"""Generate the label and buttons to prompt the user for a player."""
Label(self.body, text='Choose your player:').pack()
for player in Player:
Button(self.body, text=player,
command=partial(self.click_handler, player),
**GUIProgram.standard_button_dimensions).pack()
def click_handler(self, player: Player):
"""Callback used to call back into the main program to handle the
player choice. Once complete, the dialog is closed.
"""
self.program.handle_player_choice(player)
self.body.destroy()
self.destroy()
def on_close(self):
"""Callback used to terminate the application if closed."""
self.program.window.quit()
示例3: go_action
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import destroy [as 别名]
def go_action(self, actions):
"""
execute the action script
:param actions:
:return:
"""
# hide the menu and show a delay screen
self.hide_top()
delay = Frame(self, bg="#2d89ef")
delay.pack(fill=TkC.BOTH, expand=1)
label = Label(delay, text="Executing...", fg="white", bg="#2d89ef", font="Sans 30")
label.pack(fill=TkC.BOTH, expand=1)
self.parent.update()
# excute shell script
subprocess.call([self.path + '/pimenu.sh'] + actions)
# remove delay screen and show menu again
delay.destroy()
self.destroy_all()
self.show_top()
示例4: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import destroy [as 别名]
class SaveGui:
__name = None
def __init__(self, main_controller, window):
self.__main_controller = main_controller
self.__window = window
self.__menu = None
def show(self):
self.__menu = Frame(self.__window)
self.__menu.configure(padx=10, pady=20)
self.__menu.pack(fill=BOTH, expand=True)
line1 = Frame(self.__menu)
line1.pack(fill=X)
self.__name = StringVar()
self.__name.set("my_game_at_"+strftime("%H:%M")+"-"+strftime("%d.%m.%Y"))
name_input = Entry(line1)
name_input.configure(textvariable=self.__name)
name_input.pack(fill=X)
line2 = Frame(self.__menu)
line2.pack(fill=X, pady=20)
save_btn = Button(line2)
save_btn.configure(text="Save Game", command=self.save)
save_btn.pack(fill=X)
def remove(self):
if self.__menu is not None:
self.__menu.destroy()
self.__memu = None
def save(self):
if self.__name is not None:
self.__main_controller.save_game(self.__name.get())
self.remove()
self.__main_controller.show_game()
self.__main_controller.toggle_game()
self.__main_controller.toggle_game()
示例5: TrendProg
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import destroy [as 别名]
class TrendProg(Frame):
def __init__(self, parent):
Frame.__init__(self, parent, background='white')
# saved reference to parent widget. "Tk root window"
self.parent = parent
self._workbook = None
self._file_path = None
self._folder_path = None
# set properties of buttons
self.frame_1 = Frame(self, relief=RAISED)
self.run_button = Button(self, text='Run', width=10,
command=self.run_program)
self.file_button = Button(self.frame_1, text='Select File',
width=15, command=self.get_file)
self.folder_button = Button(self.frame_1, text='Select Folder',
width=15, command=self.get_folder)
self.close_button = Button(self, text='Close', width=10,
command=self.quit)
self.init_gui()
def init_gui(self):
self.parent.title('Trending Analysis')
# fill frame to take up whole of root window
self.pack(fill=BOTH, expand=True)
self.frame_1.pack(fill=BOTH, expand=True)
# put buttons on GUI
self.folder_button.pack(side=RIGHT, padx=5)
self.file_button.pack(side=LEFT, padx=5, pady=5)
self.close_button.pack(side=RIGHT, padx=5, pady=5)
self.run_button.pack(side=RIGHT, pady=5)
def get_file(self):
self._file_path = filedialog.askopenfilename()
if self._file_path != '':
self.file_button.config(text='File Selected!')
self.file_button.pack(fill=BOTH, expand=True, padx=5, pady=5)
self.folder_button.destroy()
def get_folder(self):
self._folder_path = filedialog.askdirectory()
if self._folder_path != '':
self.folder_button.config(text='Folder Selected!')
self.folder_button.pack(fill=BOTH, expand=True, padx=5, pady=5)
self.file_button.destroy()
def run_program(self):
workbook = 'Draft_Detail_Findings.xlsx'
worksheet = 'Template'
# user selected one CAPA
print('=' * 75)
if self._folder_path == '' or self._folder_path is None:
self._file_path = self.convert_to_docx(self._file_path)
docx_to_xlsx.main(self._file_path, workbook, worksheet)
print('=' * 75)
# user selected a folder of CAPA's
elif self._file_path == '' or self._file_path is None:
for f in os.listdir(self._folder_path):
# get full path name
file_name = str(self._folder_path + '/' + f)
file_name = self.convert_to_docx(file_name)
docx_to_xlsx.main(file_name, workbook, worksheet)
print('=' * 75)
# get ready to end the program
# pd = project_data.TrendData(workbook, worksheet)
print('Done.')
self.frame_1.destroy()
self.run_button.destroy()
self.close_button.config(text='Done.')
self.close_button.pack(fill=BOTH, expand=True, padx=10, pady=10)
@classmethod
def convert_to_docx(cls, file_selected):
""" Check that file(s) selected is .docx NOT .doc and convert if needed. """
if str(file_selected).endswith('.docx'):
return file_selected
else:
new_file_name = re.sub('.doc', '.docx', file_selected)
# full path to wordconv.exe
word_conv = r'C:\Program Files (x86)\Microsoft Office\Office12\wordconv.exe'
commands = ['wordconv.exe', '-oice', '-nme', file_selected, new_file_name]
try:
print('CONVERTING {}'.format(file_selected))
subprocess.Popen(commands, executable=word_conv)
# wait for converted file to be created
while not os.path.exists(new_file_name):
time.sleep(1.5)
print('REMOVING old .doc file ...')
os.remove(file_selected)
return new_file_name
except OSError:
print('FAILED to convert file. Check to see if it exists.')
示例6: EguanaGUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import destroy [as 别名]
class EguanaGUI(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
# if not EguanaInit.eguana_root_dir_exists():
# EguanaInit.create_eguana_root_dir()
def initUI(self):
self.parent.title("EGUANA")
self.style = ttk.Style()
self.style.theme_use("alt")
self.photoName = "eguana.gif"
self.frame = Frame(self, relief=FLAT, borderwidth=10,bg='#FADC46')
self.frame.pack(fill=BOTH, expand=True)
self.pack(fill=BOTH, expand=True)
self.setupMenuBar()
self.setupTopBar()
def setupMenuBar(self):
self.menubar = EguanaMenu(self.parent,self)
self.parent.config(menu=self.menubar)
def setupTopBar(self):
self.supportedDevices = []
for fileName in [name for name in os.listdir('./machineConfig') if os.path.isfile('./machineConfig/' + name) and not name == 'eguanaMachineConfig.py' and name.endswith('.py')]:
# try:{
components = fileName.split('.')
fileName = components[0]
className = fileName[0].upper() + fileName[1:]
try:
module = __import__("machineConfig."+fileName,fromlist=["machineConfig."])
classVar = getattr(module,className)
except:
continue
self.supportedDevices.append(classVar())
# except:
# pass
self.selectMachineFrame = Frame(self.frame,relief=FLAT,bg='#FADC46')
self.selectMachineFrame.pack(fill=BOTH,expand=True)
self.setupSelectMachineButtons()
def setupSelectMachineButtons(self):
numDevices = len(self.supportedDevices)
numColumns = 3
numRows = math.ceil((numDevices+1)/3)
self.photo = PhotoImage(file="eguana.gif")
self.photo = self.photo.subsample(2);
self.photo_label = Label(self.selectMachineFrame,image=self.photo,borderwidth=0,highlightthickness=0)
self.photo_label.configure(bg='#FADC46')
self.photo_label.grid(row=int(numRows/2),column=1, sticky=N+S+E+W,padx=2,pady =2)
self.photo_label.image = self.photo
index = 0
for i in range(numRows):
for j in range(numColumns):
if not(j == 1 and i == int(numRows/2)) and (index < numDevices):
device = self.supportedDevices[index]
b = Button(self.selectMachineFrame,text=device.name,relief=RAISED, command=lambda device=device :self.machineButtonPressed(device))
b.grid(row=i,column=j, sticky=N+S+E+W,padx=2,pady =2)
index += 1
for i in range(numRows):
self.selectMachineFrame.rowconfigure(i,weight=1)
for i in range(numColumns):
self.selectMachineFrame.columnconfigure(i,weight=1)
def machineButtonPressed(self,inputDevice):
dirStr = filedialog.askdirectory()
if len(dirStr) and inputDevice.isDirectoryValid(dirStr):
inputDevice.setDirPath(dirStr)
EguanaModel().machine = inputDevice
self.selectMachineFrame.destroy()
self.menubar.inputSelected()
self.photo_label.destroy()
dirStr = 'Input Path : '+dirStr
#.........这里部分代码省略.........
示例7: QueryBrowserUI
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import destroy [as 别名]
#.........这里部分代码省略.........
#-- Buttons Panel
pnlBtns = Frame(pnlSQL)
pnlBtns.grid(row=2, column=2)
Button(pnlBtns, text='INSERT', width = 12, command=lambda cmd='QUERY',query='INSERT': self.onCommand(cmd,query=query)).grid(row=1, column=1)
Button(pnlBtns, text='SELECT', width = 12, command=lambda cmd='QUERY',query='SELECT': self.onCommand(cmd,query=query)).grid(row=1, column=2)
Button(pnlBtns, text='UPDATE', width = 12, command=lambda cmd='QUERY',query='UPDATE': self.onCommand(cmd,query=query)).grid(row=1, column=3)
Button(pnlBtns, text='DELETE', width = 12, command=lambda cmd='QUERY',query='DELETE': self.onCommand(cmd,query=query)).grid(row=1, column=4)
#-- Result Panel:
self.pnlResult = Frame(self.pnlQuery)
self.pnlResult.pack(side="top", fill="both", expand=True, pady=10, padx=10)
self.resultGrid = TextResult(self.pnlResult)
self.resultGrid.pack(side="top", fill="both", expand=True)
#Table List Panel: ---------------------------------------
self.pnlTables = Frame(self)
self.pnlTables.pack(side="left", fill="both", pady=10, padx=10)
#---Tables Buttons Panel:
self.pnlTableList = Frame(self.pnlTables)
self.pnlTableList.pack(side="top", fill="both", pady=10)
#---Panel Nueva: Button
pnlNewTable = Frame(self.pnlTables)
pnlNewTable.pack(side="bottom", pady=10, padx=10)
Button(pnlNewTable, text=_("New Table"), command=lambda cmd='QUERY',query='CREATE': self.onCommand(cmd,query=query,table='<table>')).grid(row=1, column=2, padx=5)
def tableContextMenu(self, event, table=''):
popup = Menu(self, tearoff=0)
popup.add_command(label=_("Add Column"), command=lambda cmd='QUERY',query='ADD', table=table: self.onCommand(cmd,query=query,table=table))
popup.add_command(label=_("Rename Table"), command=lambda cmd='QUERY',query='RENAME', table=table: self.onCommand(cmd,query=query,table=table))
popup.add_command(label=_("Drop Table"), command=lambda cmd='QUERY',query='DROP', table=table: self.onCommand(cmd,query=query,table=table))
popup.post(event.x_root, event.y_root)
def showTables(self):
tables = self.app.getTables()
self.pnlTableList.destroy()
self.pnlTableList = Frame(self.pnlTables)
self.pnlTableList.pack(side="top", fill="both", pady=10)
self.btnTables = {}
Label(self.pnlTableList, text=_('Tables')).grid(row=0, column=1)
for n,table in enumerate(tables):
self.btnTables[table] = Button(self.pnlTableList, text=table,width=20, command=lambda cmd='QUERY',query='SELECT',table=table: self.onCommand(cmd,query=query,table=table))
self.btnTables[table].grid(row=n+1, column=1)
self.btnTables[table].bind("<Button-3>", lambda event, table=table:self.tableContextMenu(event, table))
if table == self.selectedTable:
self.markTable(table)
def onCommand(self, comando, **args):
comandos = {
'NEW':self.newDataBaseFile,
'OPEN':self.openDataBaseFile,
'EXIT':self.exitApp,
'ABOUT':self.about,
'QUERY':self.showQuery,
'RUN':self.run,
'TABLES_RL': self.showTablesAtRightOrLeft
}
try:
comandos[comando](**args)
except KeyError:
showerror(_('Error'), _('Unknown command: ')+ comando)
def exitApp(self):
self.destroy()
def about(self):
showinfo(_('About...'), self.appName+'\n'+_('Desarrollado por:')+'\n'+_('Martín Nicolás Carbone')+'\n'+_('Agosto 2014'))