Python Forum
Need help setting up a PySimpleGUI progress bar that I can maually update in script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help setting up a PySimpleGUI progress bar that I can maually update in script
#2
Figured it out

just leave everything as a single line, not a definition

heres an example to help others

#this Script will create a Progress Bar
#The Progress will be Manually Updated using the format listed below
#progress_bar.UpdateBar(Value of Bar, Maximum Bar Value)
#the Window uses a .Finalize Function to make the window Persistent

#Import the PySimpleGUI Library
import PySimpleGUI as sg
#Import the Time Library for use in this script
import time

#this is for the Layout Design of the Window
layout = [[sg.Text('Custom Text')],
              [sg.ProgressBar(1, orientation='h', size=(20, 20), key='progress')],
          ]
#This Creates the Physical Window
window = sg.Window('Window Title', layout).Finalize()
progress_bar = window.FindElement('progress')

#This Updates the Window
#progress_bar.UpdateBar(Current Value to show, Maximum Value to show)
progress_bar.UpdateBar(0, 5)
#adding time.sleep(length in Seconds) has been used to Simulate adding your script in between Bar Updates
time.sleep(.5)

progress_bar.UpdateBar(1, 5)
time.sleep(.5)

progress_bar.UpdateBar(2, 5)
time.sleep(.5)

progress_bar.UpdateBar(3, 5)
time.sleep(.5)

progress_bar.UpdateBar(4, 5)
time.sleep(.5)

progress_bar.UpdateBar(5, 5)
time.sleep(.5)
#I paused for 3 seconds at the end to give you time to see it has completed before closing the window
time.sleep(3)

#This will Close The Window
window.Close()

#Thanks for Using PySimpleGUI
Reply


Messages In This Thread
RE: Need help setting up a PySimpleGUI progress bar that I can maually update in script - by Soundtechscott - Jun-10-2019, 06:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PysimpleGUI window update dynamically SamLiu 6 4,031 Apr-05-2023, 02:32 PM
Last Post: SamLiu
Photo PySimpleGUI FilesBrowse enable event to update value in combo SamLiu 2 4,594 Mar-15-2023, 12:49 PM
Last Post: SamLiu
  Want to dynamically update numbers using tkinter in pygame script k0gane 0 2,072 Feb-09-2020, 09:01 AM
Last Post: k0gane
  How can I measure progress and display it in the progress bar in the interface? Matgaret 2 5,926 Dec-11-2019, 03:30 PM
Last Post: Denni
  [Tkinter] Progress Bar While Sending an Email maxtimbo 3 4,093 Oct-09-2019, 09:13 PM
Last Post: woooee
  Progress Bar While Sending an Email maxtimbo 0 2,115 Oct-08-2019, 02:13 PM
Last Post: maxtimbo
  [PySimpleGUI] update listbox not working zappfinger 2 12,090 Nov-12-2018, 08:33 PM
Last Post: zappfinger
  GUI Progress Bar Anysja 6 6,607 Aug-29-2018, 02:34 PM
Last Post: swetanjali
  [PyQt] cant import progress bar from another py file swipis 7 8,596 Dec-18-2016, 10:41 AM
Last Post: swipis

Forum Jump:

User Panel Messages

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