Quantcast
Viewing all articles
Browse latest Browse all 14069

how to disable a button after being clicked once in pysimplegui?

I want to disable the Start update button in my code

code :

import PySimpleGUI as sgimport timemylist = ["task 1", "task 2", "task 3", "task 4"]progressbar = [    [sg.ProgressBar(len(mylist), orientation='h', size=(51, 10), key='progressbar')]]outputwin = [    [sg.Output(size=(78,20))]]layout = [    [sg.Frame('Progress',layout= progressbar)],    [sg.Frame('Output', layout = outputwin)],    [sg.Submit('Start update'),sg.Cancel()]]window = sg.Window('Assistant updater', layout)progress_bar = window['progressbar']while True:    event, values = window.read(timeout=10)    if event == 'Cancel'  or event is None:        break    elif event == 'Start update':        for i,item in enumerate(mylist):            print(item)            if item=="Reading files from the internet":                print('New line started')            time.sleep(1)            progress_bar.UpdateBar(i + 1)

Can anyone please help me so that I can disable the button after the Start update button so it won't be clicked twice


Viewing all articles
Browse latest Browse all 14069

Trending Articles