Merge pull request #1854 from PySimpleGUI/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2019-08-21 18:35:38 -04:00 committed by GitHub
commit f5e4410b14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 3 deletions

View File

@ -541,6 +541,8 @@ class Element():
self.TKRightClickMenu = None self.TKRightClickMenu = None
self.Widget = None # Set when creating window. Has the main tkinter widget for element self.Widget = None # Set when creating window. Has the main tkinter widget for element
self.Tearoff = False self.Tearoff = False
self.ParentRowFrame = None # type tk.Frame
def _RightClickMenuCallback(self, event): def _RightClickMenuCallback(self, event):
""" """
@ -7245,6 +7247,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
tk_row_frame = tk.Frame(containing_frame) tk_row_frame = tk.Frame(containing_frame)
row_should_expand = False row_should_expand = False
for col_num, element in enumerate(flex_row): for col_num, element in enumerate(flex_row):
element.ParentRowFrame = tk_row_frame
element.ParentForm = toplevel_form # save the button's parent form object element.ParentForm = toplevel_form # save the button's parent form object
if toplevel_form.Font and (element.Font == DEFAULT_FONT or not element.Font): if toplevel_form.Font and (element.Font == DEFAULT_FONT or not element.Font):
font = toplevel_form.Font font = toplevel_form.Font
@ -7322,7 +7325,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKColFrame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') element.TKColFrame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both')
if element.Visible is False: if element.Visible is False:
element.TKColFrame.pack_forget() element.TKColFrame.pack_forget()
# element.TKColFrame = element.TKColFrame # element.TKColFrame = element.TKColFrame
# if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: # if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None:
# element.TKColFrame.configure(background=element.BackgroundColor, # element.TKColFrame.configure(background=element.BackgroundColor,

View File

@ -484,6 +484,20 @@ class Element():
set_widget_visiblity(widget, visible) set_widget_visiblity(widget, visible)
def __call__(self, *args, **kwargs):
"""
Makes it possible to "call" an already existing element. When you do make the "call", it actually calls
the Update method for the element.
Example: If this text element was in yoiur layout:
sg.Text('foo', key='T')
Then you can call the Update method for that element by writing:
window.FindElement('T')('new text value')
:param args:
:param kwargs:
:return:
"""
return self.Update(*args, **kwargs)
def __del__(self): def __del__(self):
try: try:
@ -3159,7 +3173,7 @@ class Window:
progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False, 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, auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=DEFAULT_WINDOW_ICON, force_toplevel=False,
alpha_channel=1, return_keyboard_events=False, use_default_focus=True, text_justification=None, alpha_channel=1, return_keyboard_events=False, use_default_focus=True, text_justification=None,
no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=True, disable_close=False, disable_minimize=False, background_image=None): no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=True, disable_close=False, disable_minimize=False, background_image=None, finalize=False):
''' '''
:param title: :param title:
@ -3250,6 +3264,8 @@ class Window:
if layout is not None: if layout is not None:
self.Layout(layout) self.Layout(layout)
if finalize:
self.Finalize()
@classmethod @classmethod
def IncrementOpenCount(self): def IncrementOpenCount(self):
@ -3835,6 +3851,36 @@ class Window:
for element in row: for element in row:
element.__del__() element.__del__()
add_row = AddRow
add_rows = AddRows
alpha_channel = AlphaChannel
bring_to_front = BringToFront
close = Close
current_location = CurrentLocation
disable = Disable
disappear = Disappear
element = Element
enable = Enable
fill = Fill
finalize = Finalize
find_element = FindElement
find_element_with_focus = FindElementWithFocus
get_screen_dimensions = GetScreenDimensions
hide = Hide
layout = Layout
load_from_disk = LoadFromDisk
maximize = Maximize
minimize = Minimize
move = Move
read = Read
reappear = Reappear
refresh = Refresh
save_to_disk = SaveToDisk
set_alpha = SetAlpha
set_icon = SetIcon
size = Size
un_hide = UnHide
visibility_changed = VisibilityChanged
FlexForm = Window FlexForm = Window
@ -5071,6 +5117,7 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
qt_row_layout.addWidget(element.QT_TextEdit) qt_row_layout.addWidget(element.QT_TextEdit)
# ------------------------- OUTPUT MULTI LINE element ------------------------- # # ------------------------- OUTPUT MULTI LINE element ------------------------- #
elif element_type == ELEM_TYPE_MULTILINE_OUTPUT: elif element_type == ELEM_TYPE_MULTILINE_OUTPUT:
element = element # type: MultilineOutput
default_text = element.DefaultText default_text = element.DefaultText
width, height = element_size width, height = element_size
element.Widget = element.QT_TextBrowser = QTextBrowser() element.Widget = element.QT_TextBrowser = QTextBrowser()
@ -5102,6 +5149,7 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
qt_row_layout.addWidget(element.QT_TextBrowser) qt_row_layout.addWidget(element.QT_TextBrowser)
# ------------------------- INPUT CHECKBOX element ------------------------- # # ------------------------- INPUT CHECKBOX element ------------------------- #
elif element_type == ELEM_TYPE_INPUT_CHECKBOX: elif element_type == ELEM_TYPE_INPUT_CHECKBOX:
element = element # type: Checkbox
element.QT_Checkbox = QCheckBox(element.Text) element.QT_Checkbox = QCheckBox(element.Text)
element.QT_Checkbox.setChecked(element.InitialState) element.QT_Checkbox.setChecked(element.InitialState)
if element.Disabled: if element.Disabled:

View File

@ -501,6 +501,23 @@ class Element():
elif visible is True: elif visible is True:
del(widget.attributes['hidden']) del(widget.attributes['hidden'])
def __call__(self, *args, **kwargs):
"""
Makes it possible to "call" an already existing element. When you do make the "call", it actually calls
the Update method for the element.
Example: If this text element was in yoiur layout:
sg.Text('foo', key='T')
Then you can call the Update method for that element by writing:
window.FindElement('T')('new text value')
:param args:
:param kwargs:
:return:
"""
return self.Update(*args, **kwargs)
def __del__(self): def __del__(self):
pass pass
@ -2883,7 +2900,7 @@ class Window:
auto_close_duration=None, icon=DEFAULT_BASE64_ICON, force_toplevel=False, auto_close_duration=None, icon=DEFAULT_BASE64_ICON, force_toplevel=False,
alpha_channel=1, return_keyboard_events=False, return_key_down_events=False, use_default_focus=True, text_justification=None, alpha_channel=1, return_keyboard_events=False, return_key_down_events=False, use_default_focus=True, text_justification=None,
no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=True, disable_close=False, no_titlebar=False, grab_anywhere=False, keep_on_top=False, resizable=True, disable_close=False,
disable_minimize=False, background_image=None, disable_minimize=False, background_image=None, finalize=False,
web_debug=False, web_ip='0.0.0.0', web_port=0, web_start_browser=True, web_update_interval=.0000001, web_multiple_instance=False ): web_debug=False, web_ip='0.0.0.0', web_port=0, web_start_browser=True, web_update_interval=.0000001, web_multiple_instance=False ):
''' '''
@ -2992,6 +3009,8 @@ class Window:
if layout is not None: if layout is not None:
self.Layout(layout) self.Layout(layout)
if finalize:
self.Finalize()
@classmethod @classmethod
def IncrementOpenCount(self): def IncrementOpenCount(self):