如何以正确的方式纠正执行tkinter代码的顺序?

时间:2017-03-13 07:59:21

标签: python tkinter execution

func1()调用了func2(),但func2()的调用在func1()完全完成后开始。如何在func2()完全完成后立即执行func1()? 我的代码:

def func1(self):
    self.path='1'
    self.func2()
    print self.path   #I want to get correct path, not '1'

def func2(self):
    self.openFileBut = Button(self, text="Open image", command=self.openFileBut)
    self.openFileBut.pack(side=LEFT, fill=None)

def openFileBut(self):
    ftypes = [('All files', '*')]
    dlg = tkFileDialog.Open(self, filetypes=ftypes)
    f = dlg.show()
    self.path = f
    if self.path != '':
        self.createCanv(self.path)

0 个答案:

没有答案