Mass update for Window Layout Change
This commit is contained in:
parent
a87a5d0529
commit
03e6310834
|
@ -1180,7 +1180,6 @@ class Text(Element):
|
|||
:param key:
|
||||
:param right_click_menu:
|
||||
:param tooltip:
|
||||
:param tooltip:
|
||||
:param visible:
|
||||
'''
|
||||
self.DisplayText = str(text)
|
||||
|
@ -3499,7 +3498,7 @@ class Window:
|
|||
animated_popup_dict = {}
|
||||
container_element_counter = 0 # used to get a number of Container Elements (Frame, Column, Tab)
|
||||
|
||||
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
def __init__(self, title, layout=None, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None), element_padding=None, margins=(None, None), button_color=None, font=None,
|
||||
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
|
||||
auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, force_toplevel=False,
|
||||
|
@ -3591,7 +3590,8 @@ class Window:
|
|||
self.RightClickMenu = right_click_menu
|
||||
self.Margins = margins if margins != (None, None) else DEFAULT_MARGINS
|
||||
self.ContainerElemementNumber = Window.GetAContainerNumber()
|
||||
|
||||
if layout is not None:
|
||||
self.Layout(layout)
|
||||
|
||||
@classmethod
|
||||
def GetAContainerNumber(cls):
|
||||
|
|
|
@ -53,7 +53,6 @@ g_time_end = 0
|
|||
g_time_delta = 0
|
||||
|
||||
|
||||
|
||||
def TimerStart():
|
||||
global g_time_start
|
||||
|
||||
|
@ -619,7 +618,7 @@ class InputText(Element):
|
|||
# ------------------------- INPUT TEXT Element lazy functions ------------------------- #
|
||||
In = InputText
|
||||
Input = InputText
|
||||
|
||||
I = InputText
|
||||
|
||||
# ---------------------------------------------------------------------- #
|
||||
# Combo #
|
||||
|
@ -1494,7 +1493,7 @@ class Button(Element):
|
|||
self.FileTypes = file_types
|
||||
self.TKButton = None
|
||||
self.Target = target
|
||||
self.ButtonText = button_text
|
||||
self.ButtonText = str(button_text)
|
||||
if sys.platform == 'darwin' and button_color is not None:
|
||||
print('Button *** WARNING - Button colors are not supported on the Mac ***')
|
||||
self.ButtonColor = button_color if button_color else DEFAULT_BUTTON_COLOR
|
||||
|
@ -1714,6 +1713,10 @@ class Button(Element):
|
|||
super().__del__()
|
||||
|
||||
|
||||
# ------------------------- Button lazy functions ------------------------- #
|
||||
B = Button
|
||||
Btn = Button
|
||||
Butt = Button
|
||||
|
||||
# ---------------------------------------------------------------------- #
|
||||
# ButtonMenu Class #
|
||||
|
@ -1889,7 +1892,7 @@ class Image(Element):
|
|||
self.CurrentFrameNumber = 0
|
||||
self.TotalAnimatedFrames = 0
|
||||
self.LastFrameTime = 0
|
||||
self.Source = filename or data
|
||||
self.Source = filename if filename is not None else data
|
||||
|
||||
super().__init__(ELEM_TYPE_IMAGE, size=size, background_color=background_color, pad=pad, key=key,
|
||||
tooltip=tooltip, visible=visible)
|
||||
|
@ -3508,7 +3511,7 @@ class Window(object):
|
|||
animated_popup_dict = {}
|
||||
container_element_counter = 0 # used to get a number of Container Elements (Frame, Column, Tab)
|
||||
|
||||
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
def __init__(self, title, layout=None, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None), element_padding=None, margins=(None, None), button_color=None, font=None,
|
||||
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
|
||||
auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, force_toplevel=False,
|
||||
|
@ -3600,7 +3603,8 @@ class Window(object):
|
|||
self.RightClickMenu = right_click_menu
|
||||
self.Margins = margins if margins != (None, None) else DEFAULT_MARGINS
|
||||
self.ContainerElemementNumber = Window.GetAContainerNumber()
|
||||
|
||||
if layout is not None:
|
||||
self.Layout(layout)
|
||||
|
||||
@classmethod
|
||||
def GetAContainerNumber(cls):
|
||||
|
@ -4699,6 +4703,10 @@ def _FindElementWithFocusInSubForm(form):
|
|||
if element.TKText is not None:
|
||||
if element.TKText is element.TKText.focus_get():
|
||||
return element
|
||||
if element.Type == ELEM_TYPE_BUTTON:
|
||||
if element.TKButton is not None:
|
||||
if element.TKButton is element.TKButton.focus_get():
|
||||
return element
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
def AddMenuItem(top_menu, sub_menu_info, element, is_sub_menu=False, skip=False):
|
||||
|
@ -6001,6 +6009,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
|||
|
||||
|
||||
def ConvertFlexToTK(MyFlexForm):
|
||||
MyFlexForm # type: Window
|
||||
master = MyFlexForm.TKroot
|
||||
master.title(MyFlexForm.Title)
|
||||
InitializeResults(MyFlexForm)
|
||||
|
|
|
@ -3082,7 +3082,7 @@ class Window:
|
|||
active_popups = {}
|
||||
|
||||
|
||||
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
def __init__(self, title, layout=None, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None), element_padding=None, button_color=None, font=None,
|
||||
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
|
||||
auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, force_toplevel=False,
|
||||
|
@ -3174,7 +3174,8 @@ class Window:
|
|||
self.BackgroundImage = background_image
|
||||
self.XFound = False
|
||||
self.DisableMinimize = disable_minimize
|
||||
|
||||
if layout is not None:
|
||||
self.Layout(layout)
|
||||
|
||||
@classmethod
|
||||
def IncrementOpenCount(self):
|
||||
|
|
|
@ -2646,7 +2646,7 @@ class Window:
|
|||
active_windows = [ ] # type: Window []
|
||||
App = None # type: remi.App
|
||||
|
||||
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
def __init__(self, title, layout=None, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None),
|
||||
element_padding=None, button_color=None, font=None,
|
||||
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
|
||||
|
@ -2757,6 +2757,9 @@ class Window:
|
|||
self.MessageQueue = Queue()
|
||||
self.master_widget = None # type: remi.gui.VBox
|
||||
|
||||
if layout is not None:
|
||||
self.Layout(layout)
|
||||
|
||||
@classmethod
|
||||
def IncrementOpenCount(self):
|
||||
self.NumOpenWindows += 1
|
||||
|
|
|
@ -2948,7 +2948,7 @@ class Window:
|
|||
stdout_is_rerouted = False
|
||||
stdout_location = None
|
||||
|
||||
def __init__(self, title, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
def __init__(self, title, layout=None, default_element_size=DEFAULT_ELEMENT_SIZE, default_button_element_size=(None, None),
|
||||
auto_size_text=None, auto_size_buttons=None, location=(None, None), size=(None, None), element_padding=None, button_color=None, font=None,
|
||||
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
|
||||
auto_close_duration=None, icon=DEFAULT_BASE64_ICON, force_toplevel=False,
|
||||
|
@ -3044,7 +3044,8 @@ class Window:
|
|||
self.MasterFrame = None # type: wx.Frame
|
||||
self.MasterPanel = None # type: wx.Panel
|
||||
self.IgnoreClose = False
|
||||
|
||||
if layout is not None:
|
||||
self.Layout(layout)
|
||||
|
||||
@classmethod
|
||||
def IncrementOpenCount(self):
|
||||
|
|
|
@ -68,12 +68,13 @@ Some of the more advanced programs operate with the window remaining visible on
|
|||
|
||||
This code will present a window and will print values until the user clicks the exit button or closes window using an X.
|
||||
|
||||
Note the `do_not_clear` parameter that is described in the next design pattern.
|
||||
|
||||
```python
|
||||
import PySimpleGUI as sg
|
||||
|
||||
layout = [[sg.Text('Persistent window')],
|
||||
[sg.Input()],
|
||||
[sg.Input(do_not_clear=True)],
|
||||
[sg.Button('Read'), sg.Exit()]]
|
||||
|
||||
window = sg.Window('Window that stays open').Layout(layout)
|
||||
|
@ -97,7 +98,7 @@ This is a slightly more complex, but maybe more realistic version that reads inp
|
|||
|
||||
Do not worry yet what all of these statements mean. Just copy it so you can begin to play with it, make some changes. Experiment to see how thing work.
|
||||
|
||||
A final note... the parameter `do_not_clear` in the input call determines the action of the input field after a button event. If this value is True, the input value remains visible following button clicks. If False, then the input field is CLEARED of whatever was input. The default is True, which means whatever is input remains visible after buttons are clicked. If your Window is more of a "form" then you will likely want to set this parameter to False.
|
||||
A final note... the parameter `do_not_clear` in the input call determines the action of the input field after a button event. If this value is True, the input value remains visible following button clicks. If False, then the input field is CLEARED of whatever was input. If you are building a "Form" type of window with data entry, you likely want False, the default setting (you can remove the parameter completely).
|
||||
|
||||
```python
|
||||
import sys
|
||||
|
@ -107,7 +108,7 @@ else:
|
|||
import PySimpleGUI27 as sg
|
||||
|
||||
layout = [[sg.Text('Your typed chars appear here:'), sg.Text('', key='_OUTPUT_') ],
|
||||
[sg.Input(key='_IN_')],
|
||||
[sg.Input(do_not_clear=True, key='_IN_')],
|
||||
[sg.Button('Show'), sg.Button('Exit')]]
|
||||
|
||||
window = sg.Window('Window Title').Layout(layout)
|
||||
|
@ -124,7 +125,7 @@ while True: # Event Loop
|
|||
window.Close()
|
||||
```
|
||||
|
||||
<iframe height="800px" width="100%" src="https://repl.it/@PySimpleGUI/Cookbook-Design-Pattern-2B-on-tkinter?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>
|
||||
<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
|
||||
|
@ -580,7 +581,7 @@ CHROME = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
|
|||
|
||||
|
||||
layout = [ [sg.Text('Text area', key='_TEXT_')],
|
||||
[sg.Input(key='_URL_')],
|
||||
[sg.Input(do_not_clear=True, key='_URL_')],
|
||||
[sg.Button('Chrome'), sg.Button('Exit')]]
|
||||
|
||||
window = sg.Window('Window Title').Layout(layout)
|
||||
|
@ -809,7 +810,7 @@ import PySimpleGUI as sg
|
|||
# Design pattern 1 - First window does not remain active
|
||||
|
||||
layout = [[ sg.Text('Window 1'),],
|
||||
[sg.Input()],
|
||||
[sg.Input(do_not_clear=True)],
|
||||
[sg.Text('', key='_OUTPUT_')],
|
||||
[sg.Button('Launch 2')]]
|
||||
|
||||
|
@ -925,6 +926,7 @@ There are a number of features used in this Recipe including:
|
|||
* Button
|
||||
* Dictionary Return values
|
||||
* Update of Elements in window (Input, Text)
|
||||
* do_not_clear of Input Elements
|
||||
|
||||
|
||||
![keypad 2](https://user-images.githubusercontent.com/13696193/44640891-57504d80-a992-11e8-93f4-4e97e586505e.jpg)
|
||||
|
@ -939,10 +941,10 @@ There are a number of features used in this Recipe including:
|
|||
# Button
|
||||
# Dictionary return values
|
||||
# Update of elements in window (Text, Input)
|
||||
|
||||
# do_not_clear of Input elements
|
||||
|
||||
layout = [[sg.Text('Enter Your Passcode')],
|
||||
[sg.Input(size=(10, 1), justification='right', key='input')],
|
||||
[sg.Input(size=(10, 1), do_not_clear=True, justification='right', key='input')],
|
||||
[sg.Button('1'), sg.Button('2'), sg.Button('3')],
|
||||
[sg.Button('4'), sg.Button('5'), sg.Button('6')],
|
||||
[sg.Button('7'), sg.Button('8'), sg.Button('9')],
|
||||
|
@ -1549,9 +1551,8 @@ That's all... Run your `my_program.exe` file on the Windows machine of your choo
|
|||
|
||||
Your EXE file should run without creating a "shell window". Only the GUI window should show up on your taskbar.
|
||||
<!--stackedit_data:
|
||||
eyJoaXN0b3J5IjpbNjIxOTUxNDYzLC0xODA5NzIxMjMxLC0xMz
|
||||
U3OTY1MjU1LC05NDI3Njg4MzcsLTM1MDcwNjgxOCwtMTk4MzIw
|
||||
MzYzMCwtMTAwMDI3Njk1NCwtMTQwMjg0MDk4Niw2Njg3ODk3ND
|
||||
ksLTExNzQ3OTk4OTIsNzE3MDQ5NjYwLC02Nzk1NDk2NzUsLTMz
|
||||
OTM3MTM1Ml19
|
||||
eyJoaXN0b3J5IjpbLTEzNTc5NjUyNTUsLTk0Mjc2ODgzNywtMz
|
||||
UwNzA2ODE4LC0xOTgzMjAzNjMwLC0xMDAwMjc2OTU0LC0xNDAy
|
||||
ODQwOTg2LDY2ODc4OTc0OSwtMTE3NDc5OTg5Miw3MTcwNDk2Nj
|
||||
AsLTY3OTU0OTY3NSwtMzM5MzcxMzUyXX0=
|
||||
-->
|
|
@ -33,15 +33,15 @@
|
|||
|
||||
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.27.0-red.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.28.0-red.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.27.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.28.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_Version-0.23.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_Version-0.26.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWx_version-0.9.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWx_version-0.11.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWeb_Version-0.18.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWeb_Version-0.22.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
|
||||
|
||||
|
@ -4916,6 +4916,14 @@ Mixup.... 3.26 changes don't appear to have been correctly released so releasing
|
|||
* PopupAnimated - image_source can be a filename or bytes (base64)
|
||||
* Option Menu can now have values updated
|
||||
|
||||
## 3.28.0 11-Apr-2019 PySimpleGUI
|
||||
|
||||
* NEW Window Parameter - layout - second parameter. Can pass in layout directly now!
|
||||
* New shortcuts
|
||||
* I = InputText
|
||||
* B = Btn = Butt = Button
|
||||
* Convert button text to string when creating buttons
|
||||
* Buttons are returned now as well as input fields when searching for element with focus
|
||||
|
||||
|
||||
### Upcoming
|
||||
|
@ -4961,17 +4969,13 @@ This is a language feature that is featured **heavily** in all of the API calls
|
|||
**tkinter**
|
||||
tkinter is the "official" GUI that Python supports. It runs on Windows, Linux, and Mac. It was chosen as the first target GUI framework due to its ***ubiquity***. Nearly all Python installations, with the exception of Ubuntu Linux, come pre-loaded with tkinter. It is the "simplest" of the GUI frameworks to get up an running (among Qt, WxPython, Kivy, etc).
|
||||
|
||||
From the start of the PSG project, tkinter was not meant to be the only underlying GUI framework for PySimpleGUI. It is merely a starting point. All journeys begin with one step forward and choosing tkinter was the first of many steps for PySimpleGUI.
|
||||
From the start of the PSG project, tkinter was not meant to be the only underlying GUI framework for PySimpleGUI. It is merely a starting point. All journeys begin with one step forward and choosing tkinter was the first of many steps for PySimpleGUI. Now there are 4 ports up and running - tkinter, WxPython, Qt and Remi (web support)
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
MikeB
|
||||
|
||||
## Demo Code Contributors
|
||||
|
||||
[JorjMcKie](https://github.com/JorjMcKie) - PDF and image viewers (plus a number of code suggestions)
|
||||
[Otherion](https://github.com/Otherion) - Table Demos Panda & CSV. Loads of suggestions to the core APIs
|
||||
|
||||
## License
|
||||
|
||||
|
|
24
readme.md
24
readme.md
|
@ -33,15 +33,15 @@
|
|||
|
||||
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.27.0-red.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_3.x_Version-3.28.0-red.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.27.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUI_For_Python_2.7_Version-1.28.0-blue.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_Version-0.23.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIQt_Version-0.26.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWx_version-0.9.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWx_version-0.11.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWeb_Version-0.18.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
![Python Version](https://img.shields.io/badge/PySimpleGUIWeb_Version-0.22.0-orange.svg?longCache=true&style=for-the-badge)
|
||||
|
||||
[Announcements of Latest Developments](https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/142)
|
||||
|
||||
|
@ -4916,6 +4916,14 @@ Mixup.... 3.26 changes don't appear to have been correctly released so releasing
|
|||
* PopupAnimated - image_source can be a filename or bytes (base64)
|
||||
* Option Menu can now have values updated
|
||||
|
||||
## 3.28.0 11-Apr-2019 PySimpleGUI
|
||||
|
||||
* NEW Window Parameter - layout - second parameter. Can pass in layout directly now!
|
||||
* New shortcuts
|
||||
* I = InputText
|
||||
* B = Btn = Butt = Button
|
||||
* Convert button text to string when creating buttons
|
||||
* Buttons are returned now as well as input fields when searching for element with focus
|
||||
|
||||
|
||||
### Upcoming
|
||||
|
@ -4961,17 +4969,13 @@ This is a language feature that is featured **heavily** in all of the API calls
|
|||
**tkinter**
|
||||
tkinter is the "official" GUI that Python supports. It runs on Windows, Linux, and Mac. It was chosen as the first target GUI framework due to its ***ubiquity***. Nearly all Python installations, with the exception of Ubuntu Linux, come pre-loaded with tkinter. It is the "simplest" of the GUI frameworks to get up an running (among Qt, WxPython, Kivy, etc).
|
||||
|
||||
From the start of the PSG project, tkinter was not meant to be the only underlying GUI framework for PySimpleGUI. It is merely a starting point. All journeys begin with one step forward and choosing tkinter was the first of many steps for PySimpleGUI.
|
||||
From the start of the PSG project, tkinter was not meant to be the only underlying GUI framework for PySimpleGUI. It is merely a starting point. All journeys begin with one step forward and choosing tkinter was the first of many steps for PySimpleGUI. Now there are 4 ports up and running - tkinter, WxPython, Qt and Remi (web support)
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
MikeB
|
||||
|
||||
## Demo Code Contributors
|
||||
|
||||
[JorjMcKie](https://github.com/JorjMcKie) - PDF and image viewers (plus a number of code suggestions)
|
||||
[Otherion](https://github.com/Otherion) - Table Demos Panda & CSV. Loads of suggestions to the core APIs
|
||||
|
||||
## License
|
||||
|
||||
|
|
Loading…
Reference in New Issue