Python Forum
[Tkinter] ttk.barprogress - root.mainloop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] ttk.barprogress - root.mainloop
#5
Please, the only thing left is just a load bar - i want to add it, i have found thousands of information about ttk.progressbar, but i don't know where to put each part inside the code. Want to add the loading bar at the bottom, when someone press it, the bar loads until 100 and then stop, after that execute the command itself(open word.exe, open browser), if person returns to tkinter window the bar should reset to 0, so it repeat again when another button is pressed.

import os
import sys
import tkinter as tk
from tkinter import *
import subprocess
import idlelib
import urllib.request
import ctypes
import functools
from tkinter import PhotoImage
import webbrowser
from tkinter import messagebox
 
def base():

    def word():
        if True:
            path = "C:/Program Files (x86)/Microsoft Office/root/Office16/"
            os.chdir(path)
            subprocess.run(["WINWORD.exe"])
        else:
            return
 
    imagetest = PhotoImage(file="word.png")
 
    button_qwer = tk.Button(root, image=imagetest, command=word)
    button_qwer.grid(row=1, column=1)
 
 
 
    def excel():
        if True:
            path = "C:/Program Files (x86)/Microsoft Office/root/Office16/"
            os.chdir(path)
            subprocess.run(["EXCEL.exe"])
        else:
            return
 
    imagetest2 = PhotoImage(file="excel.png")
 
    button_qwer2 = tk.Button(root, image=imagetest2, command=excel)
    button_qwer2.grid(row=1, column=2)
 
 
 
    def powerpoint():
        if True:
            path = "C:/Program Files (x86)/Microsoft Office/root/Office16/"
            os.chdir(path)
            subprocess.run(["POWERPNT.exe"])
        else:
            return
 
    imagetest3 = PhotoImage(file="powerpoint.png")
 
    button_qwer3 = tk.Button(root, image=imagetest3, command=powerpoint)
    button_qwer3.grid(row=1, column=3)
 
 
    def publisher():
        if True:
            path = "C:/Program Files (x86)/Microsoft Office/root/Office16/"
            os.chdir(path)
            subprocess.run(["MSPUB.exe"])
        else:
            return
 
    imagetest4 = PhotoImage(file="publisher.png")
 
    button_qwer4 = tk.Button(root, image=imagetest4, command=publisher)
    button_qwer4.grid(row=1, column=4)
 
 
    def outlook():
        if True:
            webbrowser.open('https://login.live.com/')
        else:
            return
 
    imagetest5 = PhotoImage(file="outlook.png")
 
    button_qwer5 = tk.Button(root, image=imagetest5, command=outlook)
    button_qwer5.grid(row=2, column=1)
 
 
 
    def gmail():
        if True:
            webbrowser.open('https://accounts.google.com/ServiceLogin/identifier?hl=pt-PT&passive=true&continue=https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dgooglw%26ie%3D%26oe%3D&flowName=GlifWebSignIn&flowEntry=AddSession')
        else:
            return
 
    imagetest6 = PhotoImage(file="gmail.png")
 
    button_qwer6 = tk.Button(root, image=imagetest6, command=gmail)
    button_qwer6.grid(row=2, column=2)
 
 
 
    def notepad():
        if True:
            path = "C:/WINDOWS/system32/"
            os.chdir(path)
            subprocess.run(["notepad.exe"])
        else:
            return
 
    imagetest7 = PhotoImage(file="notepad.png")
 
    button_qwer7 = tk.Button(root, image=imagetest7, command=notepad)
    button_qwer7.grid(row=2, column=3)
 
 
 
    def meteorologia():
        if True:
            webbrowser.open('https://www.google.com/search?q=meteorologia&ie=&oe=')
        else:
            return
 
    imagetest8 = PhotoImage(file="meteorologia.png")
 
    button_qwer8 = tk.Button(root, image=imagetest8, command=meteorologia)
    button_qwer8.grid(row=2, column=4)
 
 
 
    def google():
        if True:
            webbrowser.open('https://www.google.pt/')
        else:
            return
 
    imagetest9 = PhotoImage(file="google.png")
 
    button_qwer9 = tk.Button(root, image=imagetest9, command=google)
    button_qwer9.grid(row=3, column=1)
 
 
 
    def olx():
        if True:
            webbrowser.open('https://www.olx.pt/')
        else:
            return
 
    imagetest10 = PhotoImage(file="olx.png")
 
    button_qwer10 = tk.Button(root, image=imagetest10, command=olx)
    button_qwer10.grid(row=3, column=2)
 
 
 
    def facebook():
        if True:
            webbrowser.open('https://www.facebook.com/')
        else:
            return
 
    imagetest11 = PhotoImage(file="facebook.png")
 
    button_qwer11 = tk.Button(root, image=imagetest11, command=facebook)
    button_qwer11.grid(row=3, column=3)
 
 
 
    def idealista():
        if True:
            webbrowser.open('https://www.idealista.pt/comprar-casas/seixal/amora/')
        else:
            return
 
    imagetest12 = PhotoImage(file="idealista.png")
 
    button_qwer12 = tk.Button(root, image=imagetest12, command=idealista)
    button_qwer12.grid(row=3, column=4)
 
 
 
    def shutdown():
        import subprocess
        cmdCommand = "shutdown -s -t 0"
        process = subprocess.Popen(cmdCommand.split(), stdout=subprocess.PIPE)
 
 
    imagetest13 = PhotoImage(file="shutdown.png")
 
    button_qwer13 = tk.Button(root, image=imagetest13, command=shutdown)
    button_qwer13.grid(row=5, column=4)
 
 
    root.mainloop()
 
def main():
    base()
 
if __name__== ("__main__"):
    main()
[Image: 2SVGMd4]
Reply


Messages In This Thread
RE: ttk.barprogress - root.mainloop - by Larz60+ - Apr-08-2019, 06:10 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
ttk.barprogress - root.mainloop - by francisco_neves2020 - Apr-08-2019, 01:42 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,455 Jan-26-2021, 06:38 AM
Last Post: zazas321
  [Tkinter] Is mainloop() necessary? escape_freedom13 2 12,757 Sep-01-2019, 02:49 PM
Last Post: escape_freedom13
  [Tkinter] sleep(n) not working inside tkinter mainloop roger31415 2 5,218 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,671 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