Merge pull request #1223 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2019-03-16 17:13:53 -04:00 committed by GitHub
commit d1cc208c77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 212 deletions

View File

@ -3479,7 +3479,7 @@ class ErrorElement(Element):
Stretch = ErrorElement Stretch = ErrorElement
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
# Window CLASS # # Window CLASS #
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
class Window: class Window:
NumOpenWindows = 0 NumOpenWindows = 0
@ -7410,7 +7410,7 @@ def PopupGetFolder(message, title=None, default_path='', no_window=False, size=(
[InputText(default_text=default_path, size=size), FolderBrowse(initial_folder=initial_folder)], [InputText(default_text=default_path, size=size), FolderBrowse(initial_folder=initial_folder)],
[CloseButton('Ok', size=(5, 1), bind_return_key=True), CloseButton('Cancel', size=(5, 1))]] [CloseButton('Ok', size=(5, 1), bind_return_key=True), CloseButton('Cancel', size=(5, 1))]]
window = Window(title=title, icon=icon, auto_size_text=True, button_color=button_color, window = Window(title=title or message, icon=icon, auto_size_text=True, button_color=button_color,
background_color=background_color, background_color=background_color,
font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
location=location) location=location)
@ -7540,7 +7540,10 @@ def PopupAnimated(image_source, message=None, background_color=None, text_color=
return return
if image_source not in Window.animated_popup_dict: if image_source not in Window.animated_popup_dict:
layout = [[Image(data=image_source, background_color=background_color, key='_IMAGE_',)],] if type(image_source) is bytes:
layout = [[Image(data=image_source, background_color=background_color, key='_IMAGE_',)],]
else:
layout = [[Image(filename=image_source, background_color=background_color, key='_IMAGE_',)],]
if message: if message:
layout.append([Text(message, background_color=background_color, text_color=text_color, font=font)]) layout.append([Text(message, background_color=background_color, text_color=text_color, font=font)])

View File

@ -16,7 +16,7 @@
![Python Version](https://img.shields.io/badge/Python-3.x-yellow.svg) ![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.23.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" "Qt without the ugly"
## The Alpha Release Version 0.23.0 ## The Alpha Release Version 0.18.0
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142) [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. 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 ## 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: Notable MISSING features at the moment include:
* Graphs Element Methods - erasing, draw arc, etc * 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: There are a number of new features that are only available in PySimpleGUIQt. These include:
* ButtonMenu Element * ButtonMenu Element
* Dial Element * Dial Element
* Stretcher Element * Stretcher Element
* SystemTray feature * SystemTray feature
* "Dynamic" windows that grow and shrink (uses invisible elements)
## SystemTray ## SystemTray
@ -219,7 +218,7 @@ You will find 3 parameters used to specify these 3 options on both the initializ
## Menu Definition ## Menu Definition
```python ```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: 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 * keyboard shortcut
* key * 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 An entry without a key and keyboard shortcut is a simple string
`'Menu Item'` `'Menu Item'`
@ -244,10 +243,6 @@ The first entry can be ignored.`'BLANK`' was chosen for this example. It's this
**Separators** **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. 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 ## 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. 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: # Release Notes:
### 0.12.0 - 20-Nov-2018 ### 0.12.0 - 20-Nov-2018
@ -503,155 +486,6 @@ Window - Get screen dimensions
Slider - disable Slider - disable
Dial - 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
### 0.23.0 PySimpleGUIQt
* Fixed crash that was happening with latest pyside2 release!!!!
* Huge update to OneLineProgressMeter
* Debug window got title and do-not-reroute-std-out option
* Popups get a title option
* PopupScrolled getr non-blocking option
* Default logo included in Base64 Format
* Changed Chars to pixels scaling. Went from (10,25) to (10,35)
* Changed pixel to chars cutoff from 10 to 12
* Change progress bar default size to 200 from 250
* Reworked the _my_windows global variable / class to use Window class variables
* Change in how Elements / Widgets are updated. Need to use {} correctly
* InputText supports drag and drop
* Support for Checkbox.Get()
* Support for strings in spinbox
* Added Update method to Output element
* Changed Button default file_types from *.* to *
* Support for Tab enable_events so they now generate events
* Table.Update can change the number of rows of table
* Window class now manages the list of active popups, user defined icon, QTApplication, num open windows
* Window resizable parameter default changed from False to True
* Window new parameter - disable_minimize
* Window.GetScreenDimensions added
* Window.Move added
* Window.Minimize added
* Window.Maximize added
* Window.Disable added
* Window.Enable added
* Window.BringToFront added
* Window.CurrentLocation added
* TabGroup now returns which tab is selected in the return values
* Completely new Style generation class and functions (I hope it works!!!!)
* Style reworked for Column, Text, Button, Input, Combobox, Listbox, Input Multiline, Output Multiline, Progress Bar, Spinbox, Output,
* Progress Bar colors are now correct
* Events generated when tabs are changed
* "Better" Table support. Uses num_rows now and styles the scrollbar
* Tree element can support multiple types of icons including base64
* Fixed tree element scroll bar
* Icon ccan be set using SetOptions
* main for PySimpleGUIQt.py gets a nice test harness that shows lots of Elements
# Design # Design
## Author ## Author
Mike B. Mike B.

View File

@ -20,12 +20,6 @@ There is a short section in the Readme with instruction on installing PySimpleGU
If you like this Cookbook, then you'll LOVE the 100+ sample programs that are just like these. You'll find them in the GitHub at http://www.PySimpleGUI.com. These Recipes are simply several of those programs displayed in document format. If you like this Cookbook, then you'll LOVE the 100+ sample programs that are just like these. You'll find them in the GitHub at http://www.PySimpleGUI.com. These Recipes are simply several of those programs displayed in document format.
# Experimental repl.it Embedded Windows
You'll find a few of these Recipes are running in your browser window using PySimpleGUIWeb. They are included so that you can immediately play around with the SDK before installing one of the PySimpleGUI variants on your computer.
This is a new capability for PySimpleGUI that has only very recently been started. Only a few of the elements are operational using PySimpleGUIWeb. So, be prepared for some bugs. It's got a ways to go, but still seemed valuable to include.
# Copy these design patterns! # Copy these design patterns!
All of your PySimpleGUI programs will utilize one of these 2 design patterns depending on the type of window you're implementing. The two types of windows are: All of your PySimpleGUI programs will utilize one of these 2 design patterns depending on the type of window you're implementing. The two types of windows are:
@ -47,7 +41,7 @@ This will be the most common pattern you'll follow if you are not using an "even
import PySimpleGUI as sg import PySimpleGUI as sg
layout = [[sg.Text('My one-shot window.')], layout = [[sg.Text('My one-shot window.')],
[sg.InputText()], [sg.InputText(), sg.FileBrowse()],
[sg.Submit(), sg.Cancel()]] [sg.Submit(), sg.Cancel()]]
window = sg.Window('Window Title').Layout(layout) window = sg.Window('Window Title').Layout(layout)
@ -55,12 +49,9 @@ window = sg.Window('Window Title').Layout(layout)
event, values = window.Read() event, values = window.Read()
window.Close() window.Close()
text_input = values[0] source_filename = values[0]
print(text_input)
``` ```
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Design-Pattern-1-One-shot-Window?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
## Pattern 2 A - Persistent window (multiple reads using an event loop) ## Pattern 2 A - Persistent window (multiple reads using an event loop)
@ -88,10 +79,6 @@ while True:
window.Close() window.Close()
``` ```
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Design-Pattern-2A-Persistent-Window?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
## Pattern 2 B - Persistent window (multiple reads using an event loop + updates data in window) ## Pattern 2 B - Persistent window (multiple reads using an event loop + updates data in window)
This is a slightly more complex, but maybe more realistic version that reads input from the user and displays that input as text in the window. Your program is likely to be doing both of those activities so this will give you a big jump-start. This is a slightly more complex, but maybe more realistic version that reads input from the user and displays that input as text in the window. Your program is likely to be doing both of those activities so this will give you a big jump-start.
@ -125,7 +112,7 @@ while True: # Event Loop
window.Close() window.Close()
``` ```
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Design-Pattern-2B-Persistent-Window-with-Updates?lite=false" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
# Simple Data Entry - Return Values As List # Simple Data Entry - Return Values As List
@ -152,8 +139,6 @@ Same GUI screen except the return values are in a list instead of a dictionary a
print(event, values[0], values[1], values[2]) print(event, values[0], values[1], values[2])
``` ```
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Cookbook-Return-Values-as-List?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
# Simple data entry - Return Values As Dictionary # Simple data entry - Return Values As Dictionary
A simple GUI with default values. Results returned in a dictionary. A simple GUI with default values. Results returned in a dictionary.
@ -180,11 +165,7 @@ A simple GUI with default values. Results returned in a dictionary.
print(event, values['_NAME_'], values['_ADDRESS_'], values['_PHONE_']) print(event, values['_NAME_'], values['_ADDRESS_'], values['_PHONE_'])
``` ```
---------------------
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Cookbook-Return-Values-As-Dictionary?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
-------
@ -346,7 +327,6 @@ while True:
window.FindElement('_OUTPUT_').Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100)) window.FindElement('_OUTPUT_').Update('{:02d}:{:02d}.{:02d}'.format((i // 100) // 60, (i // 100) % 60, i % 100))
``` ```
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Cookbook-Timer?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
-------- --------
@ -795,8 +775,6 @@ while True: # Event Loop
window.Close() window.Close()
``` ```
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Cookbook-Compound-Element?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
## Multiple Windows ## Multiple Windows
This recipe is a design pattern for multiple windows where the first window is not active while the second window is showing. The first window is hidden to discourage continued interaction. This recipe is a design pattern for multiple windows where the first window is not active while the second window is showing. The first window is hidden to discourage continued interaction.
@ -972,9 +950,6 @@ There are a number of features used in this Recipe including:
window.FindElement('input').Update(keys_entered) # change the window to reflect current key string window.FindElement('input').Update(keys_entered) # change the window to reflect current key string
``` ```
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Cookbook-Keypad-Touchscreen-Entry?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>
## Animated Matplotlib Graph ## Animated Matplotlib Graph
Use the Canvas Element to create an animated graph. The code is a bit tricky to follow, but if you know Matplotlib then this recipe shouldn't be too difficult to copy and modify. Use the Canvas Element to create an animated graph. The code is a bit tricky to follow, but if you know Matplotlib then this recipe shouldn't be too difficult to copy and modify.
@ -1550,9 +1525,3 @@ That's all... Run your `my_program.exe` file on the Windows machine of your choo
(famous last words that screw up just about anything being referenced) (famous last words that screw up just about anything being referenced)
Your EXE file should run without creating a "shell window". Only the GUI window should show up on your taskbar. Your EXE file should run without creating a "shell window". Only the GUI window should show up on your taskbar.
<!--stackedit_data:
eyJoaXN0b3J5IjpbLTEzNTc5NjUyNTUsLTk0Mjc2ODgzNywtMz
UwNzA2ODE4LC0xOTgzMjAzNjMwLC0xMDAwMjc2OTU0LC0xNDAy
ODQwOTg2LDY2ODc4OTc0OSwtMTE3NDc5OTg5Miw3MTcwNDk2Nj
AsLTY3OTU0OTY3NSwtMzM5MzcxMzUyXX0=
-->