Apr-07-2019, 08:38 PM
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(): root = tk.Tk() root.geometry("540x540") messagebox.showinfo(" INFORMAÇÃO","PROGRAMA DE ACESSO RÁPIDO\n\nBASTA CLICAR EM *OK*") 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()My goal is to add a loading bar. When the user press the button, the bar will get to 100 and then it will open the exe command or the web browser, also, how to apply the bar on the bottom left corner
Tkinter Window Image