Skip to main content

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


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.1.5.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file EventSimpleGUI-0.1.5.tar.gz.

File metadata

  • Download URL: EventSimpleGUI-0.1.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for EventSimpleGUI-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f959314b797e0707b30f52c1c499f859dc7a722cf51612c015196558068bd46d
MD5 3ca5ab9cbc3897db948674d55f93eca9
BLAKE2b-256 3c8e0e3515c51fb699ccf7a03c1e18a26bb3214ac50cf3c566a7da501d4ae9df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page