Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 特金特忘记完成这个功能了_Python 2.7_Tkinter - Fatal编程技术网

Python 2.7 特金特忘记完成这个功能了

Python 2.7 特金特忘记完成这个功能了,python-2.7,tkinter,Python 2.7,Tkinter,我再次问一个关于progressbar项目的问题;虽然这只是一个澄清问题 我的代码导致创建progressbar以跟踪文件的创建。用户选择要创建的文件类型,然后点击“go”,这将导致文件开始更改并显示progressbar。Progressbar工作得很好。文件写入/操作非常有效 问题:当用户选择几个要操作的文件时,尽管progressbars创建正确,但它们不会正确更新。起初,我认为多次单击按钮会导致tkinter忘记以前执行的root.after()函数,但在使用(更简单的)示例代码后,我意

我再次问一个关于progressbar项目的问题;虽然这只是一个澄清问题

我的代码导致创建progressbar以跟踪文件的创建。用户选择要创建的文件类型,然后点击“go”,这将导致文件开始更改并显示progressbar。Progressbar工作得很好。文件写入/操作非常有效

问题:当用户选择几个要操作的文件时,尽管progressbars创建正确,但它们不会正确更新。起初,我认为多次单击按钮会导致tkinter忘记以前执行的root.after()函数,但在使用(更简单的)示例代码后,我意识到情况并非如此。 问题:如何确保tkinter不会停止实现第一个函数,即使使用不同的参数重新启动同一个函数

下面是我的代码的一部分来描述我在做什么

progbarlock = False # start with the prograssbar marked as not occupied

class guibuild:
    def __init__(self):
        self.root = root
        guibuild.progbarlock = False
        global theframe
        theframe = Frame(root)

        job_name = e.get()
        label = Label(theframe,text = job_name).pack(side=LEFT,padx =2)

        self.progbar = Meter(theframe) #makes the progressbar object
        self.progbar.set(0.0) #sets the initial value to 0
        self.progbar.pack(side=LEFT)
        self.counter = 0
        self.i = float(0) #i is the value set to the progressbar

    def stop_progbar(self):
        self.progbar.stop()

    def begin(self):
        self.interval()
        self.Status_bar()
        theframe.pack(anchor="s")

    def interval(self):
        if guibuild.progbarlock == False:

        guibuild.progbarlock = True


        def update(self):

            the_file = open('running_file.json')
            data = json.load(the_file)
            curr = data["current_line"]
            total = data["total_lines"]

            if self.i == 1.0:
                self.stop_progbar
                rint "100% - process is done"
                self.root.after_cancel(self.interval)
            elif curr == self.counter:
                 self.root.after(5000, self.interval)
            elif curr == self.counter+1:
                 self.i += 1.0/total
                 self.progbar.set(self.i) #apply the new value of i to the progressbar
                 self.counter += 1
                 self.stop_progbar
                 self.root.after(5000, self.interval)
            elif curr > self.counter+1:
                 self.i += 1.0/total*(curr-self.counter)
                 self.progbar.set(self.i) #apply the new value of i to the progressbar
                 self.counter = curr
                 self.stop_progbar
                 self.root.after(5000, self.interval)

            else:
                 print "something is wrong - running.json is not available"
                 self.root.after(5000, self.interval)


            guibuild.progbarlock = False



def start_process():
    makeRequest() #this is defined much earlier in the code and includes all the file creation and manipulation
    guibuild().begin()

button4 = Button(root,text="GO", command = start_process).pack()

注意:
makeRequest()
完全取决于用户输入,每次按下“go”时,用户输入都会更改

具有不同参数的函数如果不使用共享/全局变量,则不应停止前一个函数。但您必须更清楚地描述您的问题。请修复缩进,使代码可读。@ebarr我为格式问题道歉,我没有意识到复制缩进时缩进发生了变化。@furas所有问题都是全局变量造成的。非常感谢你的建议!