2017-02-25 5 views
0

Ich weiß nicht warum, aber Knopf zeigt nicht - wahrscheinlich ein einfacher Fehler, aber ich sehe es nicht. Bitte helfenIn tkinter Knopf zeigt nicht

Ich benutze Python 3, wenn es

from tkinter import Tk, Label, Button, Entry, IntVar, END, W, E, filedialog, BOTH, Frame, LEFT 

class Resizer(Frame): 

    def __init__(self, master): 
     Frame.__init__(self, master) 
     self.master = master 
     master.title("Resizer") 

     def askdir(): 
      self.dir_opt = options = {} 
      options['initialdir'] = '~/' 
      options['mustexist'] = False 
      options['parent'] = root 
      options['title'] = 'This is a title' 
      filedialog.askdirectory(**self.dir_opt) 

     Button(self, text='askopenfile', command=askdir).pack() 

root = Tk() 
my_gui = Resizer(root) 
root.mainloop() 

Antwort

0

Der Knopf hilft, ist nicht sichtbar, weil es Eltern (my_gui) ist nicht sichtbar. Sie müssen pack, place oder grid auf my_gui verwenden, um es sichtbar zu machen. Zum Beispiel:

my_gui = Resizer(root) 
my_gui.pack(fill="both", expand=True)