Saturday, 15 September 2012

function - tkinter python create child window -



function - tkinter python create child window -

hi trying create tool browses time machine image tkinter in python. plan on using code here: http://code.google.com/p/python-ttk/source/browse/trunk/pyttk-samples/dirbrowser.py?r=21 directory browser. have written start menu , upon clicking on 'browse' button want directory browser open user can select file , path passed label (i need add together not in directory browser code yet). below code start menu:

#!/usr/bin/python tkinter import * import ttk class app: def __init__(self,master): frame = frame(master) frame.pack() self.label = label(frame, text="please come in file path or browse file") self.label.pack(side=top) self.button = button(frame, text="ok", command=messagewindow) self.button.pack(side=bottom) self.hi_there = button(frame, text="browse") self.hi_there.pack(side=bottom) self.entry = entry(frame, width = 30) self.entry.pack(side=left) root = tk() app = app(root) root.mainloop()

i have read cannot have 2 root frames @ 1 time tkinter struggling find alternative directory browser has root frame. not sure if doing right on button browse have added:

self.hi_there = button(frame, text="browse", command=dir)

i have set directory browser code within of class , called dir. thinking should calling entire class? error stating name dir not defined. ways can go getting right?

i don't quite understand mean "a time machine image", i've got few things might help you: don't utilize variable name dir, that's builtin keyword , you're bound run problems. if you're having problem finding method called dir within class, create sure you're telling within class.

def sayhello(): print "hello!" class person: def sayhello(): print "hello person" a_person = person() sayhello() ##"hello" a_person.sayhello() ## "hello person"

calling printhello , class_instance.printhello 2 different functions, , you'll want pass class_instance.dir button.

i'm sure know them, there premade file dialogs help getting filepaths, filenames etc.

another thing don't want new root instance, you're looking new toplevel instance, same thing new root, not quite.

python function tkinter

No comments:

Post a Comment