Merge pull request #927 from MikeTheWatchGuy/Dev-latest

Ability to make Columns within Panes visible and invisible.  Support …
This commit is contained in:
MikeTheWatchGuy 2018-12-14 17:07:39 -05:00 committed by GitHub
commit f8f7613aa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 22 deletions

View File

@ -2413,6 +2413,7 @@ class Column(Element):
self.ReturnValuesDictionary = {} self.ReturnValuesDictionary = {}
self.DictionaryKeyCounter = 0 self.DictionaryKeyCounter = 0
self.ParentWindow = None self.ParentWindow = None
self.ParentPanedWindow = None
self.Rows = [] self.Rows = []
self.TKFrame = None self.TKFrame = None
self.TKColFrame = None self.TKColFrame = None
@ -2452,9 +2453,15 @@ class Column(Element):
def Update(self, visible=None): def Update(self, visible=None):
if visible is False: if visible is False:
if self.TKColFrame:
self.TKColFrame.pack_forget() self.TKColFrame.pack_forget()
if self.ParentPanedWindow:
self.ParentPanedWindow.remove(self.TKColFrame)
elif visible is True: elif visible is True:
if self.TKColFrame:
self.TKColFrame.pack() self.TKColFrame.pack()
if self.ParentPanedWindow:
self.ParentPanedWindow.add(self.TKColFrame)
def __del__(self): def __del__(self):
@ -2472,7 +2479,7 @@ class Column(Element):
# Pane # # Pane #
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
class Pane(Element): class Pane(Element):
def __init__(self, pane_list, background_color=None, size=(None, None), pad=None, orientation='vertical', show_handle=True, relief=RELIEF_RAISED ,key=None, visible=True): def __init__(self, pane_list, background_color=None, size=(None, None), pad=None, orientation='vertical', show_handle=True, relief=RELIEF_RAISED, handle_size=None, key=None, visible=True):
''' '''
Container for elements that are stacked into rows Container for elements that are stacked into rows
:param layout: :param layout:
@ -2496,6 +2503,7 @@ class Pane(Element):
self.PaneList = pane_list self.PaneList = pane_list
self.ShowHandle = show_handle self.ShowHandle = show_handle
self.Relief = relief self.Relief = relief
self.HandleSize = handle_size or 8
bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
@ -4373,30 +4381,30 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# ------------------------- COLUMN element ------------------------- # # ------------------------- COLUMN element ------------------------- #
if element_type == ELEM_TYPE_COLUMN: if element_type == ELEM_TYPE_COLUMN:
if element.Scrollable: if element.Scrollable:
col_frame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly) # do not use yet! not working pane.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly) # do not use yet! not working
PackFormIntoFrame(element, col_frame.TKFrame, toplevel_form) PackFormIntoFrame(element, pane.TKColFrame.TKFrame, toplevel_form)
col_frame.TKFrame.update() pane.TKColFrame.TKFrame.update()
if element.Size == (None, None): # if no size specified, use column width x column height/2 if element.Size == (None, None): # if no size specified, use column width x column height/2
col_frame.canvas.config(width=col_frame.TKFrame.winfo_reqwidth(), pane.TKColFrame.canvas.config(width=pane.TKColFrame.TKFrame.winfo_reqwidth(),
height=col_frame.TKFrame.winfo_reqheight() / 2) height=pane.TKColFrame.TKFrame.winfo_reqheight() / 2)
else: else:
col_frame.canvas.config(width=element.Size[0], height=element.Size[1]) pane.TKColFrame.canvas.config(width=element.Size[0], height=element.Size[1])
if not element.BackgroundColor in (None, COLOR_SYSTEM_DEFAULT): if not element.BackgroundColor in (None, COLOR_SYSTEM_DEFAULT):
col_frame.canvas.config(background=element.BackgroundColor) pane.TKColFrame.canvas.config(background=element.BackgroundColor)
col_frame.TKFrame.config(background=element.BackgroundColor, borderwidth=0, pane.TKColFrame.TKFrame.config(background=element.BackgroundColor, borderwidth=0,
highlightthickness=0) highlightthickness=0)
col_frame.config(background=element.BackgroundColor, borderwidth=0, highlightthickness=0) pane.TKColFrame.config(background=element.BackgroundColor, borderwidth=0, highlightthickness=0)
else: else:
col_frame = tk.Frame(tk_row_frame) pane.TKColFrame = tk.Frame(tk_row_frame)
PackFormIntoFrame(element, col_frame, toplevel_form) PackFormIntoFrame(element, pane.TKColFrame, toplevel_form)
col_frame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') pane.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:
col_frame.pack_forget() pane.TKColFrame.pack_forget()
element.TKColFrame = col_frame element.TKColFrame = pane.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:
col_frame.configure(background=element.BackgroundColor, highlightbackground=element.BackgroundColor, pane.TKColFrame.configure(background=element.BackgroundColor, highlightbackground=element.BackgroundColor,
highlightcolor=element.BackgroundColor) highlightcolor=element.BackgroundColor)
# ------------------------- Pane element ------------------------- # # ------------------------- Pane element ------------------------- #
@ -4407,6 +4415,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
) )
if element.Relief is not None: if element.Relief is not None:
element.PanedWindow.configure(relief=element.Relief) element.PanedWindow.configure(relief=element.Relief)
element.PanedWindow.configure(handlesize=element.HandleSize)
if element.ShowHandle: if element.ShowHandle:
element.PanedWindow.config(showhandle=True) element.PanedWindow.config(showhandle=True)
if element.Size != (None, None): if element.Size != (None, None):
@ -4414,11 +4423,12 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
element.PanedWindow.configure(background=element.BackgroundColor) element.PanedWindow.configure(background=element.BackgroundColor)
for pane in element.PaneList: for pane in element.PaneList:
col_frame = tk.Frame(element.PanedWindow) pane.TKColFrame = tk.Frame(element.PanedWindow)
PackFormIntoFrame(pane, col_frame, toplevel_form) pane.ParentPanedWindow = element.PanedWindow
element.PanedWindow.add(col_frame) PackFormIntoFrame(pane, pane.TKColFrame, toplevel_form)
element.PanedWindow.add(pane.TKColFrame)
if pane.BackgroundColor != COLOR_SYSTEM_DEFAULT and pane.BackgroundColor is not None: if pane.BackgroundColor != COLOR_SYSTEM_DEFAULT and pane.BackgroundColor is not None:
col_frame.configure(background=pane.BackgroundColor, highlightbackground=pane.BackgroundColor, pane.TKColFrame.configure(background=pane.BackgroundColor, highlightbackground=pane.BackgroundColor,
highlightcolor=pane.BackgroundColor) highlightcolor=pane.BackgroundColor)
element.PanedWindow.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both') element.PanedWindow.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=True, fill='both')