python - Show Progress Bar during a system call in tkinter -


i try input user. make system call , pass input argument on button press (next in case). during time add indeterminate progress bar widget in current window until system call return , gets next function. somehow progress bars doesn't shows , see next window itself. below code same.

from tkinter import * import ttk  class app:       def __init__(self, master):              #copy root         self.master = master                  #label root         self.title_frame = frame(self.master)         self.title_label= label(self.title_frame, text="my application")          #position title label         self.title_frame.pack(fill=x)         self.title_label.pack()           #create frame containing details         self.detail_frame1 = frame(self.master)              self.detail_frame2 = frame(self.master)          #create entry input details         self.input1 = entry(self.detail_frame1)          self.function()      def function(self):                       #copy root window         master = self.master          #copy body frame         detail_frame = self.detail_frame1          #position details frame         detail_frame.pack()          #create labels displayed in details frame         input1_label = label(detail_frame, text="input:")                 #button enter next window         next = button(detail_frame, text="next", width=26,height=2, command= lambda: self.function1())          input1_label.grid(row=0, sticky=e, padx=10, pady=10)         self.input1.grid(row=0, column=2, sticky=w, pady=10)          next.grid(row=3, column=3, pady=5, padx=5)      def function1(self):         pb = ttk.progressbar(self.detail_frame1, orient='horizontal', mode='indeterminate')         pb.pack()         pb.start(1)          #get paper code of paper checked         input1 = self.input1.get()                                                # system call based on value of input1         call("")         #          self.function2()      def function2(self):         self.detail_frame1.pack_forget()         self.detail_frame2.pack()  def main(): #create root window  root = tk()      root.resizable(width=false, height=false) app = app(root) root.mainloop()       if __name__=='__main__':     main() 

i tried create new window on next button press , add progress bar in window. did not work. new window never appeared , directly transferred next window.

i want see progress bar on button press until system call executed , next window. progress bar can in current window or new window. if new window should closed when next step.

i able solve progress bar freezing on applications multithreading "call" function. in code, like:

import time import threading class app:     def function1(self):         pb = ttk.progressbar(self.detail_frame1, orient='horizontal', mode='indeterminate')     pb.pack()     pb.start(1)      #get paper code of paper checked     input1 = self.input1.get()      # system call based on value of input1     t = threading.thread(target=call, args="")     t.start()      self.function2()      def function2(self):         self.detail_frame1.pack_forget()         self.detail_frame2.pack() def call():     time.sleep(2) 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -