Can anyone help me figure out how to thread my animate.py program through my GUI when the "Change Background" button is pressed?

Viewed 7

I've been trying to figure out how to run the animate.py / thread the program through when my "Change Background" button is pressed, I want it to execute the program while leaving the GUI window open. If anyone knows how to do this and can show me that'd be very helpful.

Here is my code:

# Main Window Layout (will include empty keys and variables until the main source code is finished)

layout = [[sg.Text('Gif Background Changer', justification='center', relief='flat', size=(40, 10))],
          [sg.Text('Select This Button Once You Have Selected Your Preferred Background: ', size= (30, 1))],
          [sg.Button('Change Background', enable_events=True, key='bkgrnd')],
          [sg.Button('Run the Program in Background', enable_events=True, key='rn')],
          ]

# Create Window

win = sg.Window('Gif Background Changer', layout, resizable=True, grab_anywhere=True)

# While running loop

running = True


while running:
    event, values = win.read(timeout=1000, timeout_key='__TIMEOUT__', close=False)

# Closes the window once the X button is clicked.

    if event == sg.WINDOW_CLOSED:
        break

# When the button is pressed, this elif statement allows the window to run in the background once the button is pressed.
    elif event == 'rn':
        win.alpha_channel = 0

win.close()
0 Answers
Related