Python Forum
[Tkinter] ttk.barprogress - root.mainloop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] ttk.barprogress - root.mainloop
#9
(Apr-08-2019, 06:10 PM)Larz60+ Wrote: All of the tools needed have been pointed out to you. You need to make an attempt to write the progress bar code. When you run into trouble, show us where you are having an issue, and we will be glad to help.
class ProgressBar:
    def  __init__(self):
        self.root = tk.Tk()
        self.root.geometry('540x540')
        self.root.title('                                                 PROGRAMA PRINCIPAL')
 
        self.step = tk.DoubleVar()
        self.progbar1 = ttk.Progressbar
        self.progbar2 = ttk.Progressbar
        self.progbar3 = ttk.Progressbar
 
        self.frame = tk.Frame()
        self.frame.grid()
        
        imagetest = PhotoImage(file="word.png")
        button_qwer = tk.Button(image = imagetest, command=self.start_progbar1)
        button_qwer.grid(row=1, column=2)

        imagetest1 = PhotoImage(file="powerpoint.png")
        button_qwer = tk.Button(image = imagetest1, command=self.start_progbar2)
        button_qwer.grid(row=1, column=3)

        imagetest2 = PhotoImage(file="excel.png")
        button_qwer = tk.Button(image = imagetest2, command=self.start_progbar3)
        button_qwer.grid(row=1, column=4)
        
        self.root.mainloop()
 
    def start_progbar1(self):
        self.progbar1 = ttk.Progressbar(orient=tk.HORIZONTAL, mode='determinate', variable=self.step)
        self.progbar1.grid(columnspan=3)

        for x in range(1,120):
          self.step.set(x)
          time.sleep(0.1)
          self.root.update()
        self.progbar1.destroy()
        if True:
          word()

    def start_progbar2(self):
        self.progbar2 = ttk.Progressbar(orient=tk.HORIZONTAL, mode='determinate', variable=self.step)
        self.progbar2.grid(columnspan=3)

        for x in range(1,120):
          self.step.set(x)
          time.sleep(0.1)
          self.root.update()
        self.progbar2.destroy()
        if True:
            powerpoint()

    def start_progbar3(self):
      if True:
        self.progbar3 = ttk.Progressbar(orient=tk.HORIZONTAL, mode='determinate', variable=self.step)
        self.progbar3.grid(columnspan=3)

      for x in range(1,120):
        self.step.set(x)
        time.sleep(0.1)
        self.root.update()
      self.progbar3.destroy()
      if True:
        excel()

def word():
  path = "C:/Program Files (x86)/Microsoft Office/root/Office16/"
  os.chdir(path)
  subprocess.run(["WINWORD.exe"])

def powerpoint():
  path = "C:/Program Files (x86)/Microsoft Office/root/Office16/"
  os.chdir(path)
  subprocess.run(["POWERPNT.exe"])
            
def excel():
  path = "C:/Program Files (x86)/Microsoft Office/root/Office16/"
  os.chdir(path)
  subprocess.run(["EXCEL.exe"])
  

if __name__ == '__main__':
    ProgressBar()
I have done what you ask, it is working, but the problem i have is i can't place the "loading bar" anywhere else, i tried all the codes, but the ones that allow me to place the bar in the bottom, makes my buttons move to the right when the "loading bar appears" and if i don't use "self.progbar.destroy()",, when i pressed another button, a second, a third bar appears and so on (all of them loading).

Resuming:
move the loading bar to the bottom - without moving the buttons
don't allow another bars to popup, just the same - keep the bar visible at all times
Can you provide assistance for this?
Reply


Messages In This Thread
RE: ttk.barprogress - root.mainloop - by Larz60+ - Apr-08-2019, 06:10 PM
RE: ttk.barprogress - root.mainloop - by francisco_neves2020 - Apr-08-2019, 08:22 PM
RE: ttk.barprogress - root.mainloop - by metulburr - Apr-08-2019, 09:29 PM
RE: add loading bar - press button - by Larz60+ - Apr-07-2019, 10:28 PM
RE: ttk.barprogress - root.mainloop - by Larz60+ - Apr-08-2019, 05:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TKinter restarting the mainloop when button pressed zazas321 7 16,448 Jan-26-2021, 06:38 AM
Last Post: zazas321
  [Tkinter] Is mainloop() necessary? escape_freedom13 2 12,752 Sep-01-2019, 02:49 PM
Last Post: escape_freedom13
  [Tkinter] sleep(n) not working inside tkinter mainloop roger31415 2 5,216 Jul-14-2019, 06:57 PM
Last Post: wuf
  [split] What is a GUI's mainloop ? kom2 1 2,787 May-04-2019, 01:58 PM
Last Post: Yoriz
  [Tkinter] How to update the gui in a loop without blocking the gui mainloop Qnuba 2 65,664 Nov-12-2016, 04:33 PM
Last Post: Qnuba

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020