From a49bbd28346cc09f7bea4842078caa373888f545 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 14 Dec 2018 12:29:31 -0500 Subject: [PATCH 1/2] NEW Paned Element --- PySimpleGUI.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index edc8efe4..f439a4c4 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -240,6 +240,7 @@ ELEM_TYPE_TREE = 'tree' ELEM_TYPE_ERROR = 'error' ELEM_TYPE_SEPARATOR = 'separator' ELEM_TYPE_STATUSBAR = 'statusbar' +ELEM_TYPE_PANE = 'pane' # ------------------------- Popup Buttons Types ------------------------- # POPUP_BUTTONS_YES_NO = 1 @@ -2413,7 +2414,7 @@ class Column(Element): self.Layout(layout) - super().__init__(ELEM_TYPE_COLUMN, background_color=background_color, size=size, pad=pad, key=key, visible=visible) + super().__init__(ELEM_TYPE_COLUMN, background_color=bg, size=size, pad=pad, key=key, visible=visible) return def AddRow(self, *args): @@ -2459,6 +2460,43 @@ class Column(Element): super().__del__() +# ---------------------------------------------------------------------- # +# Pane # +# ---------------------------------------------------------------------- # +class Pane(Element): + def __init__(self, pane_list, background_color=None, size=(None, None), pad=None, orientation='vertical', key=None, visible=True): + ''' + Container for elements that are stacked into rows + :param layout: + :param background_color: + :param size: + :param pad: + :param scrollable: + :param vertical_scroll_only: + :param key: + ''' + self.UseDictionary = False + self.ReturnValues = None + self.ReturnValuesList = [] + self.ReturnValuesDictionary = {} + self.DictionaryKeyCounter = 0 + self.ParentWindow = None + self.Rows = [] + self.TKFrame = None + self.TKColFrame = None + self.Orientation = orientation + self.PaneList = pane_list + + bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR + + + super().__init__(ELEM_TYPE_PANE, background_color=bg, size=size, pad=pad, key=key, visible=visible) + return + + + + + # ---------------------------------------------------------------------- # # Calendar # # ---------------------------------------------------------------------- # @@ -4328,6 +4366,26 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None: col_frame.configure(background=element.BackgroundColor, highlightbackground=element.BackgroundColor, highlightcolor=element.BackgroundColor) + + # ------------------------- Pane element ------------------------- # + if element_type == ELEM_TYPE_PANE: + element.PanedWindow = tk.PanedWindow(tk_row_frame, + orient=tk.VERTICAL if element.Orientation.startswith('v') else tk.HORIZONTAL, + relief=tk.RAISED) + + for pane in element.PaneList: + col_frame = tk.Frame(element.PanedWindow) + PackFormIntoFrame(pane, col_frame, toplevel_form) + element.PanedWindow.add(col_frame) + if pane.BackgroundColor != COLOR_SYSTEM_DEFAULT and pane.BackgroundColor is not None: + col_frame.configure(background=pane.BackgroundColor, highlightbackground=pane.BackgroundColor, + highlightcolor=pane.BackgroundColor) + + element.PanedWindow.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') + if element.Visible is False: + element.PanedWindow.pack_forget() + + # ------------------------- TEXT element ------------------------- # elif element_type == ELEM_TYPE_TEXT: # auto_size_text = element.AutoSizeText @@ -6824,7 +6882,7 @@ def main(): Frame('Binary Choice Group', frame3, title_color='purple'), Frame('Variable Choice Group', frame4, title_color='blue')], [Frame('Structured Data Group', frame5, title_color='red'), ], - [Frame('Graphing Group', frame6)], + # [Frame('Graphing Group', frame6)], [TabGroup([[tab1, tab2]])], [ProgressBar(max_value=800, size=(60, 25), key='+PROGRESS+'), Button('Button'), Button('Exit')], ] From a845a6778b08938dcc878991582509c4d0a85028 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 14 Dec 2018 13:32:19 -0500 Subject: [PATCH 2/2] Window.BringToFront() implemented. Fix for element Update that uses colors --- PySimpleGUIQt/PySimpleGUIQt.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PySimpleGUIQt/PySimpleGUIQt.py b/PySimpleGUIQt/PySimpleGUIQt.py index 859a5387..2cfefc39 100644 --- a/PySimpleGUIQt/PySimpleGUIQt.py +++ b/PySimpleGUIQt/PySimpleGUIQt.py @@ -456,13 +456,18 @@ class Element(): def Update(self, widget, background_color=None, text_color=None, font=None, visible=None): style = str(widget.styleSheet()) + add_brace = False + if len(style) != 0 and style[-1] == '}': + style = style[:-1] + add_brace = True if font is not None: style += create_style_from_font(font) if text_color is not None: - style += 'color: %s;' % text_color + style += ' color: %s;' % text_color if background_color is not None: style += 'background-color: %s;' % background_color - # print(style) + if add_brace: + style += '}' widget.setStyleSheet(style) set_widget_visiblity(widget, visible) @@ -3505,10 +3510,7 @@ class Window: def BringToFront(self): self.QTMainWindow.activateWindow(self.QT_QMainWindow) self.QTMainWindow.raise_(self.QT_QMainWindow) - # try: - # self.TKroot.lift() - # except: - # pass + def CurrentLocation(self): location = self.QT_QMainWindow.geometry()