Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to register button presses in pysimpleGUI

import PySimpleGUI as sg

def func(message):
    print(message)

layout = [[sg.Button('1'), sg.Button('2'), sg.Exit()] ]

window = sg.Window('ORIGINAL').Layout(layout)

while True:             # Event Loop
    event, values = window.Read()
    if event in (None, 'Exit'):
        break
    if event == '1':
        func('Pressed button 1')
    elif event == '2':
        func('Pressed button 2')
window.Close()
Comment

PREVIOUS NEXT
Code Example
Python :: representation of multidimensional array in data structure 
Python :: how to search over a notebook in python 
Python :: dictionary changed size during iteration after pop function 
Python :: asyncio RuntimeError: Event loop is closed 
Python :: how to convert array value to integer in python 
Python :: anagram game 
Python :: Scope, Global Variables and Global Keyword 
Python :: ladnha; 
Python :: create image tkinter set active background 
Python :: python plot auc 95% confidence intervals stackoverflow 
Python :: get false positives from confusoin matrix 
Python :: check if number is divisible without remainder python 
Python :: struct is not defined python 
Python :: how to remove no data times plotly 
Python :: filter dataframe site:stackoverflow.com 
Python :: caqch làm app chatbot python 
Python :: python check if dictionary empty 
Python :: loops with variables that count 
Python :: unction which takes in a list of integers and returns a dictionary of the five number summary.. 
Python :: nlargest of each group 
Python :: socket python how to check if server alive 
Python :: what is python virtual environment 
Python :: how to get rid of an instance variable python 
Python :: algorithme pour afficher table de multiplication python 
Python :: n largest python 
Python :: python open application windows 
Python :: rotate list python 
Python :: python code to press a key 
Python :: append multiple elements python 
Python :: true in python 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =