def MkFileBox(w): msg = Tix.Message(w, font='-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*', relief=Tix.FLAT, width=240, anchor=Tix.N, text='The TixFileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.') box = Tix.FileSelectBox(w) msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3) box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
def __init__(self, master): # control panel conf = tix.Frame(master, bg="lightblue", width=300, padx=1, pady=1) conf.grid(row=0, column=0, sticky="nw") conf.pack(fill="both", expand=1, side="left") # file list window self.files = tix.FileSelectBox(conf, bg='white', width=300, height=760, command=self.dispfile) self.files.grid(row=1, column=1, sticky="nw") self.files.pack(fill='both', expand=1, side="bottom") # text window textw = tix.Frame(master, bg="lightblue", width=900, height=960, padx=5, pady=1) textw.grid(row=0, column=1, columnspan=2, sticky="ne") textw.pack(fill='both', expand=1, side="right") self.edit = tix.ScrolledText(textw, bg='lightblue', width=900, height=960) self.edit.pack() # Menu menu = tix.Menu(master) root.config(menu=menu) # file menu filemenu = tix.Menu(menu, tearoff=0) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=self.new_text) filemenu.add_command(label="Open", command=self.file_open) filemenu.add_command(label="SaveAs", command=self.file_saveas) filemenu.add_separator() filemenu.add_command(label="Exit", command=self.do_exit) # start with cursor in the editor area self.edit.focus()
import Tix as Tk root = Tk.Tk() def command_print(): print box.cget("value") box = Tk.FileSelectBox(root) box.config(directory="c:\\") box.pack() Tk.Button(root, text="print", command=command_print).pack() root.mainloop()
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-