Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
If you're looking for the latest documentation:
Release 2.30 - Sept 6th. NEW FEATURES
Some Demos changed that rely on features only found in 2.30 so be sure and do yet another pip install to pick up 2.30.
These features you can only get from the GitHub branches. Pip install won't give you these, only GitHub will
This one is seriously cool! You can expect a healthy dose of borderless windows in the upcoming demos.
By setting the flag no_titlebar in your call to FlexForm, you too can work with windows that have no ugly titlebar on them.
The way you move these windows is the lazy way, by clicking anywhere on the window and dragging your mouse.
Be sure and make an "exit" button or you'll be running task manager to close your windows.
Your Python programs never looked this good before!
Buttons can target Text Elements & Buttons can have keys / data
Previously the "Browse" buttons had a "target" that was an Input Element. You can now target Text Elements too so that the value is a read-only one.
If you Target a Text Element or if you don't have any target, then you must get the value from the button itself. So.... buttons can have values now, if they have a key. You must have a key for this to work.
This layout will return 2 button values:
layout = [ [sg.FileBrowse(key='button key')], [sg.Text('File goes here', ), sg.FileBrowse(key='second button')], [sg.Ok(), sg.Cancel()] ]
The first button has no target so the only way to get the browsed data is to look at the key. The second one has a text target. The only way to get that value is also the button's key.
Calendar Button Element
A new Element! The Calendar Button Element is a new type of element. When you click the button, it will open a calendar date chooser. The date chosen is stored in the button itself. You can read the entered date using the key associated with the button
import PySimpleGUI as sg layout = [[sg.T('Calendar Test')], [sg.CalendarButton('Choose Date', key='date')], [sg.Ok(key=1)]] form = sg.FlexForm('Calendar') b,v = form.LayoutAndRead(layout) sg.Popup(v['date'])
Have you ever want a way to "save settings" in a form?
Now you can easily do it for your entire form using the form.SaveToDisk method. This enables you to easily create a way to quickly load previously saved form values.
Still working on a good demo script for this one. Plan is to combine with a Combo Element that has change_submits set. This enables showing a list of previously saved setting that can be chosen and then loaded. Saving the settings is easy too.
SEPT 4, 2018 - RELEASE 2.20
Released a large set of changes including:
- Renaming of the MsgBox functions to Popup
- Renaming GetFile, etc, to PopupGetFile
- High-level windowing capabilities start with Popup
- PopupNoWait/PopupNonblocking, PopupNoButtons
- default icon added
- change_submits option for Listbox/Combobox/Slider/Spin/
- New OptionMenu element
- updating elements after shown
- system default color option for progress bars
- new button type (Dummy Button) that only closes a window
- SCROLLABLE Columns!! (yea, playing in the Big League now)
- LayoutAndShow function removed form
- Fill - bulk updates to forms
- no longer use grid packing for row elements (a potentially huge change)
- FindElement - find element based on key value (ALL elements have keys now
- scrolled text box sizing changed
- new look and feel themes (Dark, Dark2, Black, Tan, TanBlue, DarkTanBlue, DarkAmber, DarkBlue, Reds, Green)
More information on some of the notable features....
Popup - The new name for
MsgBox EVERYONE STOP USING MsgBox or your code will soon break!
Going forward, you should not be using the MsgBox call, instead replace with a call to Popup.
There have been a series of name changes recently. This was done in an effort to make the package more consistent in the overall naming as well as an attempt to find terms that are easier to remember or understand. MsgBox or "message box" is a term that a programmer that has used a GUI will immediately recognize, but a beginner is less likely to be able to guess that MsgBox means.
However, the term "popup" in the context of windows, everyone knows. Everyone knows what a "popup window" is.
As a result, there are a number of new function calls with the word "Popup" which include:
Popup,PopupOk PopupYesNo PopupCancel PopupOkCancel PopupError PopupTimed, PopupAutoClose
These functions look like this when called:
There are also a number of input dialog boxes with popup in the name. These calls are the high-level input calls that include:
PopupGetString- get a single line of text
PopupGetFile- get a filename
PopupGetFolder- get a folder name
This is one great little debugging aid! You can display a message in a pop-up window without blocking.
Be careful however as the order you close the windows matters. When you have no windows open at all and you create a window, the other windows created after that first window will be tied to the first window. Close that initial window and it will also close other windows.
sg.PopupNoWait('My valiables include', x, y , z)
One place it's particularly handy for is when you're going to be creating a window/form based on some variables. It can be advantageous to have their values visible on the screen even before you open your main window.
Notice how in the above screenshots the typical bland tkinter icon is gone, instead replaced by the PySimpleGUI icon. Don't like the PySimpleGUI icon? Then replace it. This package is meant to be customized.
Option Menu Element
Discovered a cool tkinter widget that I didn't know existed. It's like a combo-box, but has a slightly different look.
This is a big damned deal, particularly for applications needing to display tables that are larger than 1 screen. Use the new
scrollable option when you create the Column Element. The size is specified in Pixels.
Fill in Form - Bulk Fill Operation
New feature - "Bulk initialize" operation. This enables you to set all or some of the form's values. Use it to load your form's values. Access by calling
This was a user request.... so speak up if you need something that is not yet in PySimpleGUI. It may not be in there today, but it could be in there tomorrow if the idea is good enough.
Some Elements have a new capability added to them.... the ability to immediately report changes back to the caller. These are incredibly powerful capabilities as it enables one graphic element to affect another in a real-time manner.
Sliders, spinners, and listboxes all support the
change_submits Boolean parameter.
When an Element that has
change_submits set to True will cause a form to immediately return back to the caller as soon as its value changes. The form.Read() function call will return with the button value equal to
''. Note this is different than if a button return value is
None which indicates a form has closed.
The "browser" demos such as Matplotlib and Cookbook, both use a listbox that immediately reacts to use input.
See the file Demo_Font_Sizer.py for a demonstration of a slider and spinbox element interacting with each other.
Note - is you previously used the parameter
return_submits when creating a Listbox, you need to change this parameter to
change_submits. Sorry about that!
Look and Feel Themes
Added several new look and feel themes.
Dark is a new one that's particularly nice. New ones to try include:
Dark Black Tan TanBlue DarkTanBlue DarkAmber DarkBlue Reds Green
Reminder on how to change themes... to change to dark theme:
form.FindElement - Looking Up Elements By Key
Sometimes things come together just right.... by accident....
The keys used to define the dictionary of return values can be used to update elements.
In the past, if an element's value was to be updated by the form after the element had been placed into a form, then a copy of the element needed to be kept so that it can be modified. Now instead of retaining a copy of the element, it can be easily looked up using the key. This works for "output" elements too like Text Elements because all Elements can now have a key associated with them.
The effect was that the code compressed as these variables used to hold elements were no longer needed. Here's how code using this new variable looks:
form.FindElement('text').Update('this is the new value')