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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for EventSimpleGUI-0.2.4.tar.gz
Algorithm Hash digest
SHA256 cb18fec89033b03f65b8f23e7f3b9020c699c241813dc5226a4430be49a14b54
MD5 cc90157266f4d7c9536d74860817a74f
BLAKE2b-256 fb4d629e5cd989b6ca7b1c2b80809aa56317bef5053f1f06b8a0103db3bcfb1b

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