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

Uploaded Source

File details

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

File metadata

  • Download URL: EventSimpleGUI-0.1.8.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.8.tar.gz
Algorithm Hash digest
SHA256 21e15581042cf442bfe0793ae289a11fb82d3c839c84226e826280e4043b76c3
MD5 0cd9b5353039f9f9e3fbe5f29fe7de2e
BLAKE2b-256 c2361f053d62e9b53c2e7ec96114de1acec5a55a7773a5035f81622f8c64aa9f

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