Release 3.21
This commit is contained in:
parent
ae819cb969
commit
3748454b7d
|
@ -16,7 +16,7 @@
|
|||
|
||||
![Python Version](https://img.shields.io/badge/Python-3.x-yellow.svg)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_For_Python_3.x_Version-00.21.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_For_Python_3.x_Version-00.19.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
|||
"Qt without the ugly"
|
||||
|
||||
|
||||
## The Alpha Release Version 0.21.0
|
||||
## The Alpha Release Version 0.18.0
|
||||
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ Welcome to the Alpha Release of PySimpleGUI for Qt!
|
|||
|
||||
You can use the exact same code that you are running on the older, tkinter, version of PySimpleGUI.
|
||||
|
||||
PySimpleGUIQt uses **PySide2** OR **PyQt5** for access to Qt. **PyQt5 has been having a number of problems recently however so tread lightly.**
|
||||
PySimpleGUIQt uses **PySide2** OR **PyQt5** for access to Qt. PyQt5 has been having a number of problems recently however so tread lightly.
|
||||
|
||||
## Porting your PySimpleGUI code to PySimpleGUIQt
|
||||
|
||||
|
@ -153,14 +153,13 @@ These Elements are "complete" (a relative term... more are more complete than ot
|
|||
Notable MISSING features at the moment include:
|
||||
* Graphs Element Methods - erasing, draw arc, etc
|
||||
|
||||
# New PySimpleGUI Features only in Qt (or first introduced in Qt)
|
||||
# New PySimpleGUI Features only in Qt
|
||||
|
||||
There are a number of new features that are only available in PySimpleGUIQt. These include:
|
||||
* ButtonMenu Element
|
||||
* Dial Element
|
||||
* Stretcher Element
|
||||
* SystemTray feature
|
||||
* "Dynamic" windows that grow and shrink (uses invisible elements)
|
||||
|
||||
## SystemTray
|
||||
|
||||
|
@ -219,7 +218,7 @@ You will find 3 parameters used to specify these 3 options on both the initializ
|
|||
|
||||
## Menu Definition
|
||||
```python
|
||||
menu_def = ['BLANK', ['&Open', '&Save', ['1', '2', ['a', 'b']], '!&Properties', 'E&xit']]
|
||||
menu_def = ['BLANK', ['&Open', '&Save', ['1', '2', ['a', 'b']], '&Properties', 'E&xit']]
|
||||
```
|
||||
|
||||
A menu is defined using a list. A "Menu entry" is a string that specifies:
|
||||
|
@ -227,7 +226,7 @@ A menu is defined using a list. A "Menu entry" is a string that specifies:
|
|||
* keyboard shortcut
|
||||
* key
|
||||
|
||||
See section on Menu Keys for more information on using keys with menus.
|
||||
See section on Menu Keys for more informatoin on using keys with menus.
|
||||
|
||||
An entry without a key and keyboard shortcut is a simple string
|
||||
`'Menu Item'`
|
||||
|
@ -244,10 +243,6 @@ The first entry can be ignored.`'BLANK`' was chosen for this example. It's this
|
|||
**Separators**
|
||||
If you want a separator between 2 items, add the entry `'---'` and it will add a separator item at that place in your menu.
|
||||
|
||||
**Disabled menu entries**
|
||||
|
||||
If you want to disable a menu entry, place a `!` before the menu entry
|
||||
|
||||
|
||||
## SystemTray Methods
|
||||
|
||||
|
@ -365,18 +360,6 @@ If you want to change the separator characters from :: top something else,change
|
|||
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.
|
||||
|
||||
|
||||
## Dynamic Windows (Element Visibility)
|
||||
|
||||
Finally, the ability to grow and shrink has been added as of release 0.20.0
|
||||
|
||||
While the window **appears** to be dynamic, the reality is that the elements are created up front, when you define the window layout. You will create these "extra" elements with the flag `visible=False`. Then, when you wish to show those elements, call the element's `Update` method setting `visible=True`.
|
||||
|
||||
After you call the `Update` method, it's important to call `window.VisibilityChanged()` so that your window can change sizes. Without that call your window will not shrink. It will grow properly, but it will not shrink. While this could have been done by PySimpleGUI on the user's behalf, the thought was that perhaps the user wants the window size to remain the same and the element simply appears and disappears, leaving a blank spot. If the window automatically grew and shrank, this would not be possible. Just buck-up and make the call to `VisibilityChanged`.
|
||||
|
||||
## `enable_events` Parameter
|
||||
|
||||
All elements that are capable of producing events now have a parameter `enable_events`. This is *identical* to the old parameter `change_submits` or `click_submits`. The idea is to standardize on 1 name that all elements use. The old parameters will continue to work, but the documentation and sample programs will steer you away from them and towards enable_events.
|
||||
|
||||
# Release Notes:
|
||||
|
||||
### 0.12.0 - 20-Nov-2018
|
||||
|
@ -503,111 +486,6 @@ Window - Get screen dimensions
|
|||
Slider - disable
|
||||
Dial - disable
|
||||
|
||||
### 0.20.0 6-Dec-2018
|
||||
|
||||
* Ability to change calculations between characters and pixels
|
||||
* size_px added to ALL elements that have a size parameter
|
||||
* General Element.Update(widget, background_color, text_color, font, visible)
|
||||
* visible parameter added to ALL elements
|
||||
* enable_events flag
|
||||
* Input text - enable events, visibility, size_px
|
||||
* Input text update added capabilities
|
||||
* ability to highlight the input string
|
||||
* background, text colors and font
|
||||
* Combo - enable events, visibility, size_px
|
||||
* Combo - auto complete feature
|
||||
* Combo - added to Update - background color, text color, font, visible
|
||||
* Listbox - enable events, visibility, size_px
|
||||
* Listbox - better scaling from characters to pixels
|
||||
* Listbox - ability to Update with set to index, text color, font, visibility
|
||||
* Radio - enable events, visibility, size_px
|
||||
* Radio - Update additions - background_color, text_color, font, visibility
|
||||
* Checkbox - enable events, visibility, size_px
|
||||
* Checkbox - Update additions - background_color, text_color, font, visibility
|
||||
* Spin - enable events, visibility, size_px
|
||||
* Spin - Update additions - background_color, text_color, font, visibility
|
||||
* Multiline input - enable events, visibility, size_px
|
||||
* Multiline input - Update additions - background_color, text_color, font, visibility
|
||||
* Multiline input better character to pixel scaling
|
||||
* Multiline output - enable events, visibility, size_px
|
||||
* Multiline output - Update additions - background_color, text_color, visibility
|
||||
* Text - enable events, size in pixels
|
||||
* Text - Update addition of visibility
|
||||
* Output - visible, size_px
|
||||
* Output - added update capability with new value, background_color, text_color, font, visibility
|
||||
* Button - enable events, visible, size_px
|
||||
* Button - Color Chooser feature completed
|
||||
* Button - Color Chooser can target (None, None) which will store the value to be returned with the values from Read()
|
||||
* Button - fixed bug in SaveAs button code. Bad filter variable
|
||||
* Button - Updated added font, visibility
|
||||
* Button - new SetFocus() method will set the focus onto the button
|
||||
* ButtonMenu - Update method implemented that includes menu definition changes, text, button color, font, visibility
|
||||
* ProgressBar - added visibility, size_px
|
||||
* ProgressBar - added Update method for changing the visibility
|
||||
* Images - events, size_pix, visibility
|
||||
* Images - can now get click events for images!
|
||||
* Images - Update added visibility
|
||||
* Graph - visibility, size_px
|
||||
* Graph - Update method for changing visibility
|
||||
* Frame - visibility, size_px
|
||||
* Frame - Update method added that controls visibility
|
||||
* ALL elements inside of a Frame that's invisible will also be invisible
|
||||
* Tab - visible parameter added, however not yet functional!
|
||||
* TabGroup - enable events, visibility
|
||||
* TabGroup - Update for controlling visibility
|
||||
* Slider - enable events, size_px
|
||||
* Slider - Update method now includes visibility
|
||||
* Dial - enable events, size_px, visibility
|
||||
* Dial - Update method added visibilty control
|
||||
* Column - visibility added
|
||||
* Column - Added Update method to control visibility
|
||||
* ALL elements inside of an invisible Column Element will also be invisible
|
||||
* MenuBar - added visibility
|
||||
* MenuBar - Update can now change menu definitions at runtime, and control visibility
|
||||
* Table - enable events, size_px, visibility
|
||||
* Table - Update method can control visibility
|
||||
* Tree - enable events, size_px, visibility
|
||||
* Tree - Update method can control visibility
|
||||
* VisibilityChanged() function that must be called when using Qt so that the window will shrink or grow
|
||||
* window.GetScreenDimensions can now be called prior to window creation
|
||||
* window.Size property
|
||||
* enable_events added to all of the shortcut buttons and browse buttons
|
||||
* Ability to set a button image from a file
|
||||
* Combo - ability to set a default value
|
||||
* Combo - Read only setting. Allows for user editing of value
|
||||
* Menus - Ability to disable / enable any part of a menu by adding a ! before the entry name
|
||||
* Tabs - ability to set tab text color, background color, background color of selected tab
|
||||
* Tabs - ability to set widget area's background color
|
||||
* Sliders - paging works properly (using page-up page-down or slider slider area to advance slider)
|
||||
* Tree - Setting number of visible rows implemented
|
||||
* Added 5 pixels to every window. Have been having issues with text being cutoff on the right side
|
||||
* SetOptions - ability to change default error button color for popups
|
||||
|
||||
### 0.21.0 - 9-Dec-2018
|
||||
|
||||
* Removed use of global variabels - using static class variabels instead
|
||||
* Listbox.Get() will return current listbox value
|
||||
* Progressbar now has color support
|
||||
* Progressbar can be vertical now
|
||||
* Can change bar or back and background color
|
||||
* (barcolor, background color - None if use default)
|
||||
* Table num_rows parameter implemented
|
||||
* Table.Update - can change number of visible rows
|
||||
* Window resizable parm - implemented, default changed from False to True
|
||||
* Window.Move - implemented
|
||||
* Window.Minimize - implemented
|
||||
* Window.Disable - implemented
|
||||
* Window.Enable - implemented
|
||||
* Window.CurrentLocation - implemented
|
||||
* Fixed too small scrollbar in Combobox
|
||||
* Fixed too small scrollbar in Listbox
|
||||
* Changed "text" window to a complex one for quick regression testing (try running PySimpleGUIQt.py by itself)
|
||||
|
||||
### 0.22.0 - 9-Dec-2018
|
||||
|
||||
* Spin.Get method - get the current spinner value
|
||||
|
||||
|
||||
# Design
|
||||
## Author
|
||||
Mike B.
|
||||
|
|
250
docs/index.md
250
docs/index.md
|
@ -23,20 +23,22 @@
|
|||
# PySimpleGUI
|
||||
|
||||
|
||||
# NEW for NOV 2018 - Run Qt using PySimpleGUI!
|
||||
|
||||
## Supports both Python 2.7 & 3 when using tkinter
|
||||
## Supports both PySide2 and PyQt5 (limited support)
|
||||
## PySimpleGUI source code can run either on Qt or tkinter by changing only the import
|
||||
## PySimpleGUI source code can run either on Qt, tkinter, WxPython by changing only the import statement
|
||||
|
||||
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.20.0-red.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.21.0-red.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.20.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.21.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_For_Python_3.x_Version-0.22.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWx_For_Python_3.x_Version-0.3.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
|
||||
|
||||
[ReadTheDocs](http://pysimplegui.readthedocs.io/)
|
||||
|
@ -74,11 +76,17 @@ Here is a summary of the Qt Elements
|
|||
Are there enough things on there to cover your GUI solution?
|
||||
|
||||
|
||||
### Source code compatibility
|
||||
## Source code compatibility
|
||||
Your source code is completely portable from one platform to another by simply changing the import statement.
|
||||
|
||||
# WxPython Version
|
||||
|
||||
### Platforms
|
||||
Started in late December 2018 PySimpleGUIWx started with the SystemTray Icon feature. This enabled the package to have one fully functioning feature that can be used along with tkinter to provide a complete program.
|
||||
|
||||
The Windowing code is coming together with Reads now operational which means Popups work. It's very early in the port however with MANY more Elements left to implement. 3 down, 20-something to go.
|
||||
|
||||
|
||||
# Platforms
|
||||
|
||||
It's surprising that Python GUI code is completely cross platform from Windows to Mac to Linux. No source code changes. This is true for both PySimpleGUI and PySimpleGUIQt.
|
||||
|
||||
|
@ -88,10 +96,12 @@ However, **Macs** suck. They suck on tkinter in particular. The "Look and feel
|
|||
|
||||
|
||||
Looking for a GUI package? Are you
|
||||
|
||||
* looking to take your Python code from the world of command lines and into the convenience of a GUI? *
|
||||
* sitting on a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK?
|
||||
* into Machine Learning and are sick of the command line?
|
||||
* wanting to distribute your Python code to Windows users as a single .EXE file that launches straight into a GUI, much like a WinForms app?
|
||||
* would like to run a program in the system tray?
|
||||
* a teacher wanting to teach your students how to program using a GUI?
|
||||
* a student that wants to put a GUI onto their project?
|
||||
* looking for an active project?
|
||||
|
@ -116,12 +126,16 @@ Or how about a ***custom GUI*** in 1 line of code?
|
|||
|
||||
|
||||
Build beautiful customized windows that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve your real problems. Look through the Cookbook, find a matching recipe, copy, paste, run within minutes. This is the process PySimpleGUI was designed to facilitate.
|
||||
|
||||
Your windows don't have to look like "boring" old windows. Add a few custom graphics to your windows to polish things up.
|
||||
|
||||
![batterup2](https://user-images.githubusercontent.com/13696193/50378902-6aa2bb00-060a-11e9-8f2f-d746694fa4ee.gif)
|
||||
|
||||
|
||||
![uno_final](https://user-images.githubusercontent.com/13696193/49945232-67952580-feba-11e8-90c8-7dc31c5f7c67.gif)
|
||||
|
||||
![borderless grayed buttons](https://user-images.githubusercontent.com/13696193/45168664-d848e980-b1c9-11e8-886e-63279ae4017f.jpg)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PySimpleGUI wraps tkinter or Qt so that you get all the same widgets as you would tkinter/Qt, but you interact with them in a more friendly way. It does the layout and boilerplate code for you and presents you with a simple, efficient interface.
|
||||
|
||||
|
||||
|
@ -3337,6 +3351,196 @@ This call sets all of the different color options.
|
|||
progress_meter_color = ('green', 'blue')
|
||||
button_color=('white','#475841'))
|
||||
|
||||
# SystemTray
|
||||
|
||||
This is a PySimpleGUIQt and PySimpleGUIWx only feature. Don't know of a way to do it using tkinter. Your source code for SystemTray is identical for the Qt and Wx implementations. You can switch frameworks by simply changing your import statement.
|
||||
|
||||
In addition to running normal windows, it's now also possible to have an icon down in the system tray that you can read to get menu events. There is a new SystemTray object that is used much like a Window object. You first get one, then you perform Reads in order to get events.
|
||||
|
||||
Here is the definition of the SystemTray object.
|
||||
|
||||
```python
|
||||
SystemTray(menu=None, filename=None, data=None, data_base64=None, tooltip=None):
|
||||
'''
|
||||
SystemTray - create an icon in the system tray
|
||||
:param menu: Menu definition
|
||||
:param filename: filename for icon
|
||||
:param data: in-ram image for icon
|
||||
:param data_base64: basee-64 data for icon
|
||||
:param tooltip: tooltip string '''
|
||||
```
|
||||
|
||||
You'll notice that there are 3 different ways to specify the icon image. The base-64 parameter allows you to define a variable in your .py code that is the encoded image so that you do not need any additional files. Very handy feature.
|
||||
|
||||
## 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. If the item "Open" is chosen from the system tray, then a popup is shown.
|
||||
|
||||
```python
|
||||
import PySimpleGUIQt as sg
|
||||
|
||||
menu_def = ['BLANK', ['&Open', '---', '&Save', ['1', '2', ['a', 'b']], '&Properties', 'E&xit']]
|
||||
|
||||
tray = sg.SystemTray(menu=menu_def, filename=r'default_icon.ico')
|
||||
|
||||
while True: # The event loop
|
||||
menu_item = tray.Read()
|
||||
print(menu_item)
|
||||
if menu_item == 'Exit':
|
||||
break
|
||||
elif menu_item == 'Open':
|
||||
sg.Popup('Menu item chosen', menu_item)
|
||||
|
||||
```
|
||||
The design pattern creates an icon that will display this menu:
|
||||
![snag-0293](https://user-images.githubusercontent.com/13696193/49057441-8bbfe980-f1cd-11e8-93e7-1aeda9ccd173.jpg)
|
||||
|
||||
### Icons
|
||||
|
||||
When specifying "icons", you can use 3 different formats.
|
||||
* `filename`- filename
|
||||
* `data_base64` - base64 byte string
|
||||
* '`data` - in-ram bitmap or other "raw" image
|
||||
|
||||
You will find 3 parameters used to specify these 3 options on both the initialize statement and on the Update method.
|
||||
|
||||
## Menu Definition
|
||||
```python
|
||||
menu_def = ['BLANK', ['&Open', '&Save', ['1', '2', ['a', 'b']], '!&Properties', 'E&xit']]
|
||||
```
|
||||
|
||||
A menu is defined using a list. A "Menu entry" is a string that specifies:
|
||||
* text shown
|
||||
* keyboard shortcut
|
||||
* key
|
||||
|
||||
See section on Menu Keys for more information on using keys with menus.
|
||||
|
||||
An entry without a key and keyboard shortcut is a simple string
|
||||
`'Menu Item'`
|
||||
|
||||
If you want to make the "M" be a keyboard shortcut, place an `&` in front of the letter that is the shortcut.
|
||||
`'&Menu Item'`
|
||||
|
||||
You can add "keys" to make menu items unique or as another way of identifying a menu item than the text shown. The key is added to the text portion by placing `::` after the text.
|
||||
|
||||
`'Menu Item::key'`
|
||||
|
||||
The first entry can be ignored.`'BLANK`' was chosen for this example. It's this way because normally you would specify these menus under some heading on a menu-bar. But here there is no heading so it's filled in with any value you want.
|
||||
|
||||
**Separators**
|
||||
If you want a separator between 2 items, add the entry `'---'` and it will add a separator item at that place in your menu.
|
||||
|
||||
**Disabled menu entries**
|
||||
|
||||
If you want to disable a menu entry, place a `!` before the menu entry
|
||||
|
||||
|
||||
## SystemTray Methods
|
||||
|
||||
### Read - Read the context menu or check for events
|
||||
|
||||
```python
|
||||
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=0`on the Read call.
|
||||
|
||||
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
|
||||
|
||||
|
||||
### Hide
|
||||
|
||||
Hides the icon. Note that no message balloons are shown while an icon is hidden.
|
||||
|
||||
```python
|
||||
def Hide()
|
||||
```
|
||||
|
||||
### Close
|
||||
|
||||
Does the same thing as hide
|
||||
```python
|
||||
def Close()
|
||||
```
|
||||
|
||||
|
||||
### UnHide
|
||||
|
||||
Shows a previously hidden icon
|
||||
|
||||
```python
|
||||
def UnHide()
|
||||
```
|
||||
|
||||
### ShowMessage
|
||||
|
||||
Shows a balloon above the icon in the system tray area. You can specify your own icon to be shown in the balloon, or you can set `messageicon` to one of the preset values.
|
||||
|
||||
This message has a custom icon.
|
||||
|
||||
![snag-0286](https://user-images.githubusercontent.com/13696193/49057459-a85c2180-f1cd-11e8-9a66-aa331d7e034c.jpg)
|
||||
|
||||
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
|
||||
|
||||
```python
|
||||
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:
|
||||
'''
|
||||
```
|
||||
Note, on windows it may be necessary to make a registry change to enable message balloons to be seen. To fix this, you must create the DWORD you see in this screenshot.
|
||||
|
||||
![snag-0285](https://user-images.githubusercontent.com/13696193/49056144-6381bc00-f1c8-11e8-9f44-199394823369.jpg)
|
||||
|
||||
|
||||
### Update
|
||||
|
||||
You can update any of these items within a SystemTray object
|
||||
* Menu definition
|
||||
* Icon
|
||||
* Tooltip
|
||||
|
||||
Change them all or just 1.
|
||||
|
||||
```python
|
||||
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:
|
||||
'''
|
||||
```
|
||||
|
||||
|
||||
# Global Settings
|
||||
|
@ -4567,6 +4771,32 @@ Emergency patch release... going out same day as previous release
|
|||
* Can set title for PopupScrolled window
|
||||
|
||||
|
||||
## 3.21.0 & 1.21.0 28-Dec-2018
|
||||
|
||||
* ButtonMenu Element
|
||||
* Embedded base64 default icon
|
||||
* Input Text Right click menu
|
||||
* Disabled Input Text are now 'readonly' instead of disabled
|
||||
* Listbox right click menu
|
||||
* Multiline right click menu
|
||||
* Text right click menu
|
||||
* Output right click menu
|
||||
* Image right click menu
|
||||
* Canvas right click menu
|
||||
* Graph right click menu
|
||||
* Frame right click menu
|
||||
* Tab, tabgroup right click menu (unsure if works correctly)
|
||||
* Column right click menu
|
||||
* Table right click menu
|
||||
* Tree right click menu
|
||||
* Window level right click menu
|
||||
* Window icon can be filename or bytes (Base64 string)
|
||||
* Window.Maximize method
|
||||
* Attempted to use Styles better with Combobox
|
||||
* Fixed bug blocking setting bar colors in OneLineProgressMeter
|
||||
|
||||
|
||||
|
||||
### Upcoming
|
||||
Make suggestions people! Future release features
|
||||
|
||||
|
|
250
readme.md
250
readme.md
|
@ -23,20 +23,22 @@
|
|||
# PySimpleGUI
|
||||
|
||||
|
||||
# NEW for NOV 2018 - Run Qt using PySimpleGUI!
|
||||
|
||||
## Supports both Python 2.7 & 3 when using tkinter
|
||||
## Supports both PySide2 and PyQt5 (limited support)
|
||||
## PySimpleGUI source code can run either on Qt or tkinter by changing only the import
|
||||
## PySimpleGUI source code can run either on Qt, tkinter, WxPython by changing only the import statement
|
||||
|
||||
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.20.0-red.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.21.0-red.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.20.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.21.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_For_Python_3.x_Version-0.22.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWx_For_Python_3.x_Version-0.3.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
|
||||
|
||||
[ReadTheDocs](http://pysimplegui.readthedocs.io/)
|
||||
|
@ -74,11 +76,17 @@ Here is a summary of the Qt Elements
|
|||
Are there enough things on there to cover your GUI solution?
|
||||
|
||||
|
||||
### Source code compatibility
|
||||
## Source code compatibility
|
||||
Your source code is completely portable from one platform to another by simply changing the import statement.
|
||||
|
||||
# WxPython Version
|
||||
|
||||
### Platforms
|
||||
Started in late December 2018 PySimpleGUIWx started with the SystemTray Icon feature. This enabled the package to have one fully functioning feature that can be used along with tkinter to provide a complete program.
|
||||
|
||||
The Windowing code is coming together with Reads now operational which means Popups work. It's very early in the port however with MANY more Elements left to implement. 3 down, 20-something to go.
|
||||
|
||||
|
||||
# Platforms
|
||||
|
||||
It's surprising that Python GUI code is completely cross platform from Windows to Mac to Linux. No source code changes. This is true for both PySimpleGUI and PySimpleGUIQt.
|
||||
|
||||
|
@ -88,10 +96,12 @@ However, **Macs** suck. They suck on tkinter in particular. The "Look and feel
|
|||
|
||||
|
||||
Looking for a GUI package? Are you
|
||||
|
||||
* looking to take your Python code from the world of command lines and into the convenience of a GUI? *
|
||||
* sitting on a Raspberry **Pi** with a touchscreen that's going to waste because you don't have the time to learn a GUI SDK?
|
||||
* into Machine Learning and are sick of the command line?
|
||||
* wanting to distribute your Python code to Windows users as a single .EXE file that launches straight into a GUI, much like a WinForms app?
|
||||
* would like to run a program in the system tray?
|
||||
* a teacher wanting to teach your students how to program using a GUI?
|
||||
* a student that wants to put a GUI onto their project?
|
||||
* looking for an active project?
|
||||
|
@ -116,12 +126,16 @@ Or how about a ***custom GUI*** in 1 line of code?
|
|||
|
||||
|
||||
Build beautiful customized windows that fit your specific problem. Let PySimpleGUI solve your GUI problem while you solve your real problems. Look through the Cookbook, find a matching recipe, copy, paste, run within minutes. This is the process PySimpleGUI was designed to facilitate.
|
||||
|
||||
Your windows don't have to look like "boring" old windows. Add a few custom graphics to your windows to polish things up.
|
||||
|
||||
![batterup2](https://user-images.githubusercontent.com/13696193/50378902-6aa2bb00-060a-11e9-8f2f-d746694fa4ee.gif)
|
||||
|
||||
|
||||
![uno_final](https://user-images.githubusercontent.com/13696193/49945232-67952580-feba-11e8-90c8-7dc31c5f7c67.gif)
|
||||
|
||||
![borderless grayed buttons](https://user-images.githubusercontent.com/13696193/45168664-d848e980-b1c9-11e8-886e-63279ae4017f.jpg)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PySimpleGUI wraps tkinter or Qt so that you get all the same widgets as you would tkinter/Qt, but you interact with them in a more friendly way. It does the layout and boilerplate code for you and presents you with a simple, efficient interface.
|
||||
|
||||
|
||||
|
@ -3337,6 +3351,196 @@ This call sets all of the different color options.
|
|||
progress_meter_color = ('green', 'blue')
|
||||
button_color=('white','#475841'))
|
||||
|
||||
# SystemTray
|
||||
|
||||
This is a PySimpleGUIQt and PySimpleGUIWx only feature. Don't know of a way to do it using tkinter. Your source code for SystemTray is identical for the Qt and Wx implementations. You can switch frameworks by simply changing your import statement.
|
||||
|
||||
In addition to running normal windows, it's now also possible to have an icon down in the system tray that you can read to get menu events. There is a new SystemTray object that is used much like a Window object. You first get one, then you perform Reads in order to get events.
|
||||
|
||||
Here is the definition of the SystemTray object.
|
||||
|
||||
```python
|
||||
SystemTray(menu=None, filename=None, data=None, data_base64=None, tooltip=None):
|
||||
'''
|
||||
SystemTray - create an icon in the system tray
|
||||
:param menu: Menu definition
|
||||
:param filename: filename for icon
|
||||
:param data: in-ram image for icon
|
||||
:param data_base64: basee-64 data for icon
|
||||
:param tooltip: tooltip string '''
|
||||
```
|
||||
|
||||
You'll notice that there are 3 different ways to specify the icon image. The base-64 parameter allows you to define a variable in your .py code that is the encoded image so that you do not need any additional files. Very handy feature.
|
||||
|
||||
## 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. If the item "Open" is chosen from the system tray, then a popup is shown.
|
||||
|
||||
```python
|
||||
import PySimpleGUIQt as sg
|
||||
|
||||
menu_def = ['BLANK', ['&Open', '---', '&Save', ['1', '2', ['a', 'b']], '&Properties', 'E&xit']]
|
||||
|
||||
tray = sg.SystemTray(menu=menu_def, filename=r'default_icon.ico')
|
||||
|
||||
while True: # The event loop
|
||||
menu_item = tray.Read()
|
||||
print(menu_item)
|
||||
if menu_item == 'Exit':
|
||||
break
|
||||
elif menu_item == 'Open':
|
||||
sg.Popup('Menu item chosen', menu_item)
|
||||
|
||||
```
|
||||
The design pattern creates an icon that will display this menu:
|
||||
![snag-0293](https://user-images.githubusercontent.com/13696193/49057441-8bbfe980-f1cd-11e8-93e7-1aeda9ccd173.jpg)
|
||||
|
||||
### Icons
|
||||
|
||||
When specifying "icons", you can use 3 different formats.
|
||||
* `filename`- filename
|
||||
* `data_base64` - base64 byte string
|
||||
* '`data` - in-ram bitmap or other "raw" image
|
||||
|
||||
You will find 3 parameters used to specify these 3 options on both the initialize statement and on the Update method.
|
||||
|
||||
## Menu Definition
|
||||
```python
|
||||
menu_def = ['BLANK', ['&Open', '&Save', ['1', '2', ['a', 'b']], '!&Properties', 'E&xit']]
|
||||
```
|
||||
|
||||
A menu is defined using a list. A "Menu entry" is a string that specifies:
|
||||
* text shown
|
||||
* keyboard shortcut
|
||||
* key
|
||||
|
||||
See section on Menu Keys for more information on using keys with menus.
|
||||
|
||||
An entry without a key and keyboard shortcut is a simple string
|
||||
`'Menu Item'`
|
||||
|
||||
If you want to make the "M" be a keyboard shortcut, place an `&` in front of the letter that is the shortcut.
|
||||
`'&Menu Item'`
|
||||
|
||||
You can add "keys" to make menu items unique or as another way of identifying a menu item than the text shown. The key is added to the text portion by placing `::` after the text.
|
||||
|
||||
`'Menu Item::key'`
|
||||
|
||||
The first entry can be ignored.`'BLANK`' was chosen for this example. It's this way because normally you would specify these menus under some heading on a menu-bar. But here there is no heading so it's filled in with any value you want.
|
||||
|
||||
**Separators**
|
||||
If you want a separator between 2 items, add the entry `'---'` and it will add a separator item at that place in your menu.
|
||||
|
||||
**Disabled menu entries**
|
||||
|
||||
If you want to disable a menu entry, place a `!` before the menu entry
|
||||
|
||||
|
||||
## SystemTray Methods
|
||||
|
||||
### Read - Read the context menu or check for events
|
||||
|
||||
```python
|
||||
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=0`on the Read call.
|
||||
|
||||
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
|
||||
|
||||
|
||||
### Hide
|
||||
|
||||
Hides the icon. Note that no message balloons are shown while an icon is hidden.
|
||||
|
||||
```python
|
||||
def Hide()
|
||||
```
|
||||
|
||||
### Close
|
||||
|
||||
Does the same thing as hide
|
||||
```python
|
||||
def Close()
|
||||
```
|
||||
|
||||
|
||||
### UnHide
|
||||
|
||||
Shows a previously hidden icon
|
||||
|
||||
```python
|
||||
def UnHide()
|
||||
```
|
||||
|
||||
### ShowMessage
|
||||
|
||||
Shows a balloon above the icon in the system tray area. You can specify your own icon to be shown in the balloon, or you can set `messageicon` to one of the preset values.
|
||||
|
||||
This message has a custom icon.
|
||||
|
||||
![snag-0286](https://user-images.githubusercontent.com/13696193/49057459-a85c2180-f1cd-11e8-9a66-aa331d7e034c.jpg)
|
||||
|
||||
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
|
||||
|
||||
```python
|
||||
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:
|
||||
'''
|
||||
```
|
||||
Note, on windows it may be necessary to make a registry change to enable message balloons to be seen. To fix this, you must create the DWORD you see in this screenshot.
|
||||
|
||||
![snag-0285](https://user-images.githubusercontent.com/13696193/49056144-6381bc00-f1c8-11e8-9f44-199394823369.jpg)
|
||||
|
||||
|
||||
### Update
|
||||
|
||||
You can update any of these items within a SystemTray object
|
||||
* Menu definition
|
||||
* Icon
|
||||
* Tooltip
|
||||
|
||||
Change them all or just 1.
|
||||
|
||||
```python
|
||||
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:
|
||||
'''
|
||||
```
|
||||
|
||||
|
||||
# Global Settings
|
||||
|
@ -4567,6 +4771,32 @@ Emergency patch release... going out same day as previous release
|
|||
* Can set title for PopupScrolled window
|
||||
|
||||
|
||||
## 3.21.0 & 1.21.0 28-Dec-2018
|
||||
|
||||
* ButtonMenu Element
|
||||
* Embedded base64 default icon
|
||||
* Input Text Right click menu
|
||||
* Disabled Input Text are now 'readonly' instead of disabled
|
||||
* Listbox right click menu
|
||||
* Multiline right click menu
|
||||
* Text right click menu
|
||||
* Output right click menu
|
||||
* Image right click menu
|
||||
* Canvas right click menu
|
||||
* Graph right click menu
|
||||
* Frame right click menu
|
||||
* Tab, tabgroup right click menu (unsure if works correctly)
|
||||
* Column right click menu
|
||||
* Table right click menu
|
||||
* Tree right click menu
|
||||
* Window level right click menu
|
||||
* Window icon can be filename or bytes (Base64 string)
|
||||
* Window.Maximize method
|
||||
* Attempted to use Styles better with Combobox
|
||||
* Fixed bug blocking setting bar colors in OneLineProgressMeter
|
||||
|
||||
|
||||
|
||||
### Upcoming
|
||||
Make suggestions people! Future release features
|
||||
|
||||
|
|
Loading…
Reference in New Issue