Skip to main content

The Engineering Pre-Relase Wx version of PySimpleGUI. PySimpleGUI SDK Launched in 2018 Actively developed and supported. Super-simple to create custom GUI's. Now supports tkinter, Qt, and soon WxPython

Project description

pysimplegui_logo

Downloads

Awesome Meter

Python Version

Python Version

PySimpleGUIWx

The WxPython port of PySimpleGUI

The Engineering Pre-Release Version 0.3.0

Announcements of Latest Developments

SystemTray

This is the only fully functioning feature of PySimpleGUIWx. Previously only the Qt port supported the System Tray.

Now it's possible to "tack on" the System Tray to your PySimpleGUI application.

If you're unable to upgrade to Qt but want the System Tray feature, then adding PySimpleGUIWx to your project may be the way to go.

You can mix your System Tray's event loop with your normal Window event loop by adding a timeout to both your Window.Read call and your SystemTray.Read call.

Source code compatibility

PySimpleGUIWx's System Tray feature has been tested against the same PySimpleGUIQt feature. As long as you don't use features that are not yet supported you'll find your source code will run on either PySimpleGUIQt or PySimpleGUIWx by simply changing the import statement.

Source code compatibility and easy of migration between frameworks is a major design goal for PySimpleGUI.

System Tray Design Pattern

Here is a design pattern you can use to get a jump-start.

This program will create a system tray icon and perform a blocking Read.

import PySimpleGUIWx as sg

tray = sg.SystemTray(menu= ['menu',['Open', ['&Save::KEY', '---', 'Issues', '!Disabled'], 'E&xit']],
                     filename=r'C:\Python\PycharmProjects\GooeyGUI\default_icon.ico')
tray.ShowMessage('My Message', 'The tray icon is up and runnning!')
while True:
    event = tray.Read()
    print(event)
    if event == 'Exit':
        break

Limitations

This is the first relase of this feature and it has some limitations.

  • Timeouts must be None (completely blocking) or non-zero. A value of 0 is invalid at the moment
  • Base64 and in-ram icon images are not yet supported

Menu Definitions

See the original, full documentation for PySimpleGUI to get an understanding of how menus are defined.

SystemTray Methods

Read - Read the context menu or check for events

def Read(timeout=None)
    '''  
 Reads the context menu  
 :param timeout: Optional.  Any value other than None indicates a non-blocking read
 :return:   String representing meny item chosen. None if nothing read.  
    '''

The timeout parameter specifies how long to wait for an event to take place. If nothing happens within the timeout period, then a "timeout event" is returned. These types of reads make it possible to run asynchronously. To run non-blocked, specify timeout=0on the Read call (not yet supported).

Read returns the menu text, complete with key, for the menu item chosen. If you specified Open::key as the menu entry, and the user clicked on Open, then you will receive the string Open::key upon completion of the Read.

Read special return values

In addition to Menu Items, the Read call can return several special values. They include:

EVENT_SYSTEM_TRAY_ICON_DOUBLE_CLICKED - Tray icon was double clicked EVENT_SYSTEM_TRAY_ICON_ACTIVATED - Tray icon was single clicked EVENT_SYSTEM_TRAY_MESSAGE_CLICKED - a message balloon was clicked TIMEOUT_KEY is returned if no events are available if the timeout value is set in the Read call

ShowMessage

Just like Qt, you can create a pop-up message. Unlike Qt, you cannot set your own custom icon in the message, at least you can't at the moment.

The preset messageicon values are:

SYSTEM_TRAY_MESSAGE_ICON_INFORMATION 
SYSTEM_TRAY_MESSAGE_ICON_WARNING
SYSTEM_TRAY_MESSAGE_ICON_CRITICAL 
SYSTEM_TRAY_MESSAGE_ICON_NOICON
ShowMessage(title, message, filename=None, data=None, data_base64=None, messageicon=None, time=10000):  
    '''  
 Shows a balloon above icon in system tray  
 :param title:  Title shown in balloon  
 :param message: Message to be displayed  
 :param filename: Optional icon filename  
 :param data: Optional in-ram icon  
 :param data_base64: Optional base64 icon  
 :param time: How long to display message in milliseconds  :return:  
 '''

Update

You can update any of these items within a SystemTray object

  • Menu definition
  • Icon (not working yet)
  • Tooltip

Change them all or just 1.

Update(menu=None, tooltip=None,filename=None, data=None, data_base64=None,)
    '''  
 Updates the menu, tooltip or icon  
 :param menu: menu defintion  
 :param tooltip: string representing tooltip  
 :param filename:  icon filename  
 :param data:  icon raw image  
 :param data_base64: icon base 64 image  
 :return:  
 '''

Menus with Keys

You can add a key to your menu items. To do so, you add :: and the key value to the end of your menu definition.

menu_def = ['File', ['Hide::key', '&Open::key', '&Save',['1', '2', ['a','b']], '&Properties', 'E&xit']]

The menu definition adds a key "key" to the menu entries Hide and Open.

If you want to change the separator characters from :: top something else,change the variable MENU_KEY_SEPARATOR

When a menu item has a key and it is chosen, then entire string is returned. If Hide were selected, then Hide::key would be returned from the Read. Note that the shortcut character & is NOT returned from Reads.

Release Notes:

0.1.0 - 25-Dec-2018

  • Support for SystemTray
    • Read, with or without a timeout
    • Catch single click, double click events
    • Source code compatiable with Qt

0.2.0 - 26-Dec-2018

  • Correctly handling base64 images
  • Support for clicking message balloon
  • Can Hide and UnHide the icon

0.3.0 - 27-Dec-2018

  • Hooked up buttons!
  • Browse file button is only file/folder button that works
  • Text, Input and Button elements are the only working elements
  • SystemTray can take any kind of image as icon
  • Read with Timeout (non-zero) works
  • Popups

Design

Author

Mike B.

License

GNU Lesser General Public License (LGPL 3) +

Acknowledgments

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

PySimpleGUIWx-0.3.0.tar.gz (55.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PySimpleGUIWx-0.3.0-py3-none-any.whl (53.2 kB view details)

Uploaded Python 3

File details

Details for the file PySimpleGUIWx-0.3.0.tar.gz.

File metadata

  • Download URL: PySimpleGUIWx-0.3.0.tar.gz
  • Upload date:
  • Size: 55.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.19.2 CPython/3.6.2

File hashes

Hashes for PySimpleGUIWx-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8cbf6642a4bf1f56c3f64933a159c53e746d3e1dc15916f6d6ffd5e52eb10af0
MD5 01f8eca51c44d5b4cb5f30dcd0ca8fd1
BLAKE2b-256 24e5a128f03fd1408bd595fc80e65f4130c4489865e2e8d9fce48789d71db70b

See more details on using hashes here.

File details

Details for the file PySimpleGUIWx-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: PySimpleGUIWx-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 53.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.19.2 CPython/3.6.2

File hashes

Hashes for PySimpleGUIWx-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1705e0fe6919d9ed0c3527d1426f390459e9b172c4021d4c5f04a13fbd1d3c16
MD5 c67989707b7baa97765098c5ad79d061
BLAKE2b-256 da63022ca0c692a68edc135eba67e89b50344fb764bfc52361a5b7c86e3c2f34

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