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

Uploaded Source

File details

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

File metadata

  • Download URL: EventSimpleGUI-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 5b7f7df0818009177d8e10a76395d08bdd6210cf2a3bda0f32d9ea9d5df7175c
MD5 cd1021ac19a79889c464cbf2b2790427
BLAKE2b-256 0eaa92336d2d3a043f90368ad238e3c2fa4023b3b5c43f28ebf8e892c36d79a1

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