Python Forum
[Tkinter] ttk.barprogress - root.mainloop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] ttk.barprogress - root.mainloop
#11
(Apr-08-2019, 09:29 PM)metulburr Wrote: I havent done tkinter in a long time. So i am very rusty with placement. But you are assinging the same widget to the same cell pushing the buttons to the right. I would explicitly state row and column for each. Such as

        imagetest = PhotoImage(file="house.png")
        button_qwer = tk.Button(image = imagetest, command=self.start_progbar1)
        button_qwer.grid(row=1, column=2)
 
        imagetest1 = PhotoImage(file="house.png")
        button_qwer = tk.Button(image = imagetest1, command=self.start_progbar2)
        button_qwer.grid(row=1, column=3)
 
        imagetest2 = PhotoImage(file="house.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(row=2, column=5)
 
        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(row=3, column=5)
 
        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(row=4, column=5)
If you wanted to move it down to the bottom, i would suspect you would put it in a frame (just the progressbars and not the buttons) and assign that to the bottom. You can assign empty frames to use as a spacer to get to the bottom until your actually put something in the middle. (if i recall correctly). I would also split up your class. Because buttons are not progressbars and hence if you want to the move the class to the bottom, you would then be moving the buttons as well.
This is the close i got, not the final project i wanted, but is working. Many thanks mettulbur, i will take your advice in consideration and when possible try to execute it. Right now i have to finalize the program, because this is for people that have difficulty using computers, it will provide help to them, everything in one place, on a button click.

Attached Files

Thumbnail(s)
   
Reply
#12
The python project i wanted finally realized the way it is. Lots of errors and failures, probably not the most perfect one, but for a beginner is good. If you want to take some tips from my code, there it is.

import tkinter   
from tkinter import ttk
from tkinter import *
import tkinter as tk
import time
import sys
import os
import subprocess
import idlelib
import urllib.request
import ctypes
import functools
from tkinter import PhotoImage
import webbrowser
from tkinter import messagebox

###################################
master = Tk()
master.configure(background='blue')
master.minsize(500,300)
master.geometry("500x300")
###################################

def start1(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            webbrowser.open('https://mail.google.com/mail/u/0/#inbox')

def start2(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            path = "C:/Program Files (x86)/Microsoft Office/Office12/"
            os.chdir(path)
            subprocess.run(["POWERPNT.exe"])

def start3(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            webbrowser.open('https://www.imovirtual.com/comprar/amora-seixal/')

def start4(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            webbrowser.open('https://www.youtube.com/')

def start5(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            webbrowser.open('https://www.google.com/search?q=meteorologia&ie=&oe=')

def start6(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            path = "C:/Program Files (x86)/Microsoft Office/Office12/"
            os.chdir(path)
            subprocess.run(["WINWORD.exe"])
                
def start7(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            path = "C:/Program Files (x86)/Microsoft Office/Office12/"
            os.chdir(path)
            subprocess.run(["EXCEL.exe"])

def start8(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            webbrowser.open('https://www.facebook.com/')

def start9(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            webbrowser.open('https://www.olx.pt/')

def start10(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            webbrowser.open('https://www.google.pt/')

def start11(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.04)
            master.update()
            progress_var.set(0)

    if True:
            import subprocess
            cmdCommand = "shutdown -s -t 0"
            process = subprocess.Popen(cmdCommand.split(), stdout=subprocess.PIPE)

    
progress_var = tkinter.IntVar()
pb = ttk.Progressbar(master, orient="horizontal", length=200, maximum=100, mode="determinate", var=progress_var)

pb.grid(padx=100, pady=250)

#########################################################################################

photo1=PhotoImage(file="gmail.png")
b1 = Button(master,image=photo1, command=start1, height=100, width=100, compound=LEFT)
b1.place(x = 0, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo2=PhotoImage(file="powerpoint.png")
b2 = Button(master,image=photo2, command=start2, height=100, width=100, compound=LEFT)
b2.place(x = 100, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo3=PhotoImage(file="imovirtual.png")
b3 = Button(master,image=photo3, command=start3, height=100, width=100, compound=LEFT)
b3.place(x = 200, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo4=PhotoImage(file="youtube.png")
b4 = Button(master,image=photo4, command=start4, height=100, width=100, compound=LEFT)
b4.place(x = 300, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo5=PhotoImage(file="meteorologia.png")
b5 = Button(master,image=photo5, command=start5, height=100, width=100, compound=LEFT)
b5.place(x = 400, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo6=PhotoImage(file="word.png")
b6 = Button(master,image=photo6, command=start6, height=100, width=100, compound=LEFT)
b6.place(x = 0, y = 100)# x = mexe na horizontal e y = mexe na vertical

photo7=PhotoImage(file="excel.png")
b7 = Button(master,image=photo7, command=start7, height=100, width=100, compound=LEFT)
b7.place(x = 100, y = 100)# x = mexe na horizontal e y = mexe na vertical

photo8=PhotoImage(file="facebook.png")
b8 = Button(master,image=photo8, command=start8, height=100, width=100, compound=LEFT)
b8.place(x = 200, y = 100)# x = mexe na horizontal e y = mexe na vertical

photo9=PhotoImage(file="olx.png")
b9 = Button(master,image=photo9, command=start9, height=100, width=100, compound=LEFT)
b9.place(x = 300, y = 100)# x = mexe na horizontal e y = mexe na vertical

photo10=PhotoImage(file="google.png")
b10 = Button(master,image=photo10, command=start10, height=100, width=100, compound=LEFT)
b10.place(x = 400, y = 100)# x = mexe na horizontal e y = mexe na vertical

photo11=PhotoImage(file="shutdown.png")
b11 = Button(master,image=photo11, command=start11, height=100, width=100, compound=LEFT)
b11.place(x = 400, y = 200)# x = mexe na horizontal e y = mexe na vertical

####################################    
master.resizable(False, False) 
master.mainloop()
####################################

Attached Files

Thumbnail(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TKinter restarting the mainloop when button pressed zazas321 7 16,327 Jan-26-2021, 06:38 AM
Last Post: zazas321
  [Tkinter] Is mainloop() necessary? escape_freedom13 2 12,715 Sep-01-2019, 02:49 PM
Last Post: escape_freedom13
  [Tkinter] sleep(n) not working inside tkinter mainloop roger31415 2 5,193 Jul-14-2019, 06:57 PM
Last Post: wuf
  [split] What is a GUI's mainloop ? kom2 1 2,767 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,601 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