A simple tool to create events to PySimpleGUI
Project description
Events For SimpleGui
Status of project: in progress...
This project has the intention to make easier, scalable and readable events on PySimpleGUI
Download
$pip install EventSimpleGUI
Demonstration
Creating an event function
Using the decorator event to run an event, you can pass the element key as an argument for decorator, when the event is called, function is going to be called two
from pysimpleevent import EventSimpleGUI
import PySimpleGUI as sg
app = EventSimpleGUI()
@app.event('_click')
def when_btn_was_clicked(event: str, values: dict, window: sg.Window):
print('Just a normal event')
layout = [[sg.B('Just a button', key='_click')]]
window = sg.Window('Just a Window.', layout)
if __name__ == '__main__':
app.run_window(window)
Events can be passed as an argument of run window like in the exemple
from pysimpleevent import EventSimpleGUI
import PySimpleGUI as sg
app = EventSimpleGUI()
def when_btn_was_clicked(event: str, values: dict, window: sg.Window):
if event == '_click':
print('Just a normal event')
layout = [[sg.B('Just a button', key='_click')]]
window = sg.Window('Just a Window.', layout)
if __name__ == '__main__':
app.run_window(window, when_btn_was_clicked)
And can also pass an event using add_event
from pysimpleevent import EventSimpleGUI
import PySimpleGUI as sg
app = EventSimpleGUI()
def when_btn_was_clicked(event: str, values: dict, window: sg.Window):
if event == '_click':
print('Just a normal event')
app.add_event(when_btn_was_clicked)
layout = [[sg.B('Just a button', key='_click')]]
window = sg.Window('Just a Window.', layout)
if __name__ == '__main__':
app.run_window(window)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
EventSimpleGUI-0.2.1.tar.gz
(3.5 kB
view hashes)