Python Tix/TkInter,FolderDialog赢得';单击时不要保持打开状态

Python Tix/TkInter,FolderDialog赢得';单击时不要保持打开状态,python,tkinter,tix,Python,Tkinter,Tix,我意识到第一个建议是“停止使用Tix”,但我喜欢一些小部件,尽管它们自08年以来就没有维护过。我注意到的一件事是,一些对话框无法保持打开状态。例如,我正在笔记本小部件中的LabelFrame小部件中使用FileEntry小部件。文件对话框如下所示 当您单击“文件”对话框按钮时,您会得到: 红色箭头显示该过滤器中文件的下拉列表,但单击它时不会发生任何变化。你可以看到一个短暂的闪光(以毫秒为单位),比如检查了一个事件循环,或者什么都没有。与FileEntry上的其他按钮相同 有关此的完整代码,您

我意识到第一个建议是“停止使用Tix”,但我喜欢一些小部件,尽管它们自08年以来就没有维护过。我注意到的一件事是,一些对话框无法保持打开状态。例如,我正在笔记本小部件中的LabelFrame小部件中使用FileEntry小部件。文件对话框如下所示

当您单击“文件”对话框按钮时,您会得到:

红色箭头显示该过滤器中文件的下拉列表,但单击它时不会发生任何变化。你可以看到一个短暂的闪光(以毫秒为单位),比如检查了一个事件循环,或者什么都没有。与FileEntry上的其他按钮相同

有关此的完整代码,您可以看到

我认为有关的部分是:

import os, os.path, sys, Tix
from Tkconstants import *
import tkFileDialog
import traceback, tkMessageBox
from Tkinter import *

class pyigblast_gui():
    def __init__(self,root):
            #Initialization
            self.root = root 
            self.exit = -1
            self.dir = None

            self.argument_dict = {'query':''}

            #local
            _program_name = sys.argv[0]
            _directory_name = os.path.dirname(_program_name)

    def MainMenu(self):
            main_menu = Tix.Frame(self.root,bd=2,relief=RAISED)
            return main_menu

    def TabNotebook(self):
            notebook_frame = self.root
            notebook = Tix.NoteBook(notebook_frame, ipadx=5, ipady=5, bg='black')
            notebook.add('f_and_d', label="Files and Databases", underline=0,
                    createcmd=lambda self=self,nb=notebook,name='f_and_d': self.files_and_directories(nb,name))
            notebook.add('readme', label="Usage", underline=0,
                    createcmd=lambda self=self,nb=notebook,name='readme': self.readme(nb,name) )
            return notebook

    def files_and_directories(self,nb,name):
            f_and_d_page = nb.page(name)
            options = "label.padX4"
            self.input_frame = Tix.LabelFrame(f_and_d_page,options=options)
            self.input_frame.pack(side=TOP,expand=0,fill=BOTH)
            self.make_fasta_entry()

            #self.input_frame.grid(in_=f_and_d_page,row=0,column=0,columnspan=2)

    def make_fasta_entry(self):
            message = Tix.Message(self.input_frame,relief=Tix.FLAT, width=500, anchor=W,
                                                            text='Enter the entry FASTA file here',font=('Arial',16))
            self.fasta_entry = Tix.FileEntry(self.input_frame, label="Select a FASTA file:",selectmode="normal")
            message.pack(side=TOP,expand=1,fill=BOTH,padx=3,pady=3)
            self.fasta_entry.pack(side=TOP,fill=X,padx=3,pady=3)

    def build(self):
            window_info = self.root.winfo_toplevel()
            window_info.wm_title('PyIgBLAST - GUI')
            #if window_info <= 800:
            window_info.geometry('1500x900+10+10')
            frame1 = self.MainMenu()
            frame1.pack(side=BOTTOM, fill=X)
            frame2 = self.TabNotebook()
            frame2.pack(side=TOP,expand=1,fill=BOTH,padx=5,pady=5)
            window_info.wm_protocol("WM_DELETE_WINDOW", lambda self=self:self.quitcmd())


    def loop(self):
            while self.exit < 0:
                    # There are 2 whiles here. The outer one lets you continue
                    # after a ^C interrupt.
                    try:
                            # This is the replacement for _tkinter mainloop()
                            # It blocks waiting for the next Tcl event using select.
                            while self.exit < 0:
                                    self.root.tk.dooneevent(0)
                    except SystemExit:
                            # Tkinter uses SystemExit to exit
                            self.exit = 1
                            return
                    except KeyboardInterrupt:
                            if tkMessageBox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
                                    # self.tk.eval('exit')
                                    self.exit = 1
                                    return
                            continue
                    except:
                            # Otherwise it's some other error - be nice and say why
                            t, v, tb = sys.exc_info()
                            text = ""
                            for line in traceback.format_exception(t,v,tb):
                                    text += line + '\n'
                            try: tkMessageBox.showerror ('Error', text)
                            except: pass
                            self.exit = 1
                            raise SystemExit, 1
    def destroy(self):
            self.root.destroy()
 if __name__ == '__main__':
    root = Tix.Tk()
    pyigblast_class = pyigblast_gui(root)
    pyigblast_class.build()
    pyigblast_class.loop()
    pyigblast_class.destroy()
如果有人能告诉我,我需要用Tix更改什么以保持对话框打开和/或为什么它说我正在使用两个几何体管理器,我将不胜感激

谢谢, 好的,把那声音照亮

ttk解决方案更干净,更可定制。下面是一个非常优雅的解决方案,它概括了这个精确的文件对话框,但是使用ttk更简洁

(TixForm) Error:Trying to use more than one geometry
      manager for the same master window.
      Giving up after 50 iterations.