Renamed Treeview to be Table,the offoical Table Element. Created New function name PrepareForUpdate that is same as ReadNonBlocking

This commit is contained in:
MikeTheWatchGuy 2018-09-13 00:27:33 -04:00
parent bb990fca05
commit 473430f6dc
1 changed files with 26 additions and 23 deletions

View File

@ -95,10 +95,10 @@ LISTBOX_SELECT_MODE_EXTENDED = 'extended'
SELECT_MODE_SINGLE = tk.SINGLE SELECT_MODE_SINGLE = tk.SINGLE
LISTBOX_SELECT_MODE_SINGLE = 'single' LISTBOX_SELECT_MODE_SINGLE = 'single'
TREEVIEW_SELECT_MODE_NONE = tk.NONE TABLE_SELECT_MODE_NONE = tk.NONE
TREEVIEW_SELECT_MODE_BROWSE = tk.BROWSE TABLE_SELECT_MODE_BROWSE = tk.BROWSE
TREEVIEW_SELECT_MODE_EXTENDED = tk.EXTENDED TABLE_SELECT_MODE_EXTENDED = tk.EXTENDED
DEFAULT_TREEVIEW_SECECT_MODE = TREEVIEW_SELECT_MODE_EXTENDED DEFAULT_TABLE_SECECT_MODE = TABLE_SELECT_MODE_EXTENDED
@ -170,7 +170,7 @@ ELEM_TYPE_COLUMN = 555
ELEM_TYPE_MENUBAR = 600 ELEM_TYPE_MENUBAR = 600
ELEM_TYPE_PROGRESS_BAR = 200 ELEM_TYPE_PROGRESS_BAR = 200
ELEM_TYPE_BLANK = 100 ELEM_TYPE_BLANK = 100
ELEM_TYPE_TREEVIEW = 700 ELEM_TYPE_TABLE = 700
# ------------------------- MsgBox Buttons Types ------------------------- # # ------------------------- MsgBox Buttons Types ------------------------- #
MSG_BOX_YES_NO = 1 MSG_BOX_YES_NO = 1
@ -1514,26 +1514,20 @@ class Menu(Element):
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
# TreeView # # TreeView #
# ---------------------------------------------------------------------- # # ---------------------------------------------------------------------- #
class Treeview(Element): class Table(Element):
def __init__(self, values, column_headings=None, display_columns=None, show=None, tags=None, label=None, image=None, readonly=None, disabled=False, select_mode=None, children_hidden=False, font=None, justification='left', text_color=None, background_color=None, scale=(None, None), size=(None, None), pad=None, key=None): def __init__(self, values, headings=None, visible_column_map=None, select_mode=None, scrollable=None, font=None, justification='left', text_color=None, background_color=None, scale=(None, None), size=(None, None), pad=None, key=None):
self.Values = values self.Values = values
self.ColumnHeadings = column_headings self.ColumnHeadings = headings
self.ColumnsToDisplay = display_columns self.ColumnsToDisplay = visible_column_map
self.Show = show
self.ChildrenHidden = children_hidden
self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
self.TextColor = text_color self.TextColor = text_color
self.Disabled = disabled
self.ReadOnly = readonly
self.Image = image
self.Label = label
self.Tags = tags
self.Justification = justification self.Justification = justification
self.Scrollable = scrollable
self.InitialState = None self.InitialState = None
self.SelectMode = select_mode self.SelectMode = select_mode
self.TKTreeview = None self.TKTreeview = None
super().__init__(ELEM_TYPE_TREEVIEW, text_color=text_color, background_color=background_color, scale=scale, font=font, size=size, pad=pad, key=key) super().__init__(ELEM_TYPE_TABLE, text_color=text_color, background_color=background_color, scale=scale, font=font, size=size, pad=pad, key=key)
return return
@ -1550,8 +1544,6 @@ class TreeviewItem(object):
self.Tags = tags self.Tags = tags
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
# FlexForm CLASS # # FlexForm CLASS #
# ------------------------------------------------------------------------- # # ------------------------------------------------------------------------- #
@ -1732,6 +1724,10 @@ class FlexForm:
# return None, None # return None, None
return BuildResults(self, False, self) return BuildResults(self, False, self)
# Another name for ReadNonBlocking.
PrepareForUpdate = ReadNonBlocking
def Refresh(self): def Refresh(self):
if self.TKrootDestroyed: if self.TKrootDestroyed:
return return
@ -2693,19 +2689,26 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
tkscale.configure(fg=text_color) tkscale.configure(fg=text_color)
tkscale.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1]) tkscale.pack(side=tk.LEFT, padx=element.Pad[0],pady=element.Pad[1])
element.TKScale = tkscale element.TKScale = tkscale
# ------------------------- Treeview element ------------------------- # # ------------------------- TABLE element ------------------------- #
elif element_type == ELEM_TYPE_TREEVIEW: elif element_type == ELEM_TYPE_TABLE:
width, height = element_size width, height = element_size
anchor = tk.W if element.Justification == 'left' else tk.E anchor = tk.W if element.Justification == 'left' else tk.E
if element.ColumnsToDisplay is None:
displaycolumns = element.ColumnHeadings
else:
displaycolumns = []
for i, should_display in enumerate(element.ColumnsToDisplay):
if should_display:
displaycolumns.append(element.ColumnHeadings[i])
element.TKTreeview = ttk.Treeview(tk_row_frame, columns=element.ColumnHeadings, element.TKTreeview = ttk.Treeview(tk_row_frame, columns=element.ColumnHeadings,
displaycolumns=element.ColumnsToDisplay, show=element.Show, height=height, selectmode=element.SelectMode) displaycolumns=displaycolumns, show='headings', height=height, selectmode=element.SelectMode)
treeview = element.TKTreeview treeview = element.TKTreeview
for heading in element.ColumnHeadings: for heading in element.ColumnHeadings:
treeview.heading(heading, text=heading) treeview.heading(heading, text=heading)
treeview.column(heading, width=width*CharWidthInPixels(), anchor=anchor) treeview.column(heading, width=width*CharWidthInPixels(), anchor=anchor)
for value in element.Values: for value in element.Values:
id = treeview.insert('', 'end', text=value, values=value) id = treeview.insert('', 'end', text=value, values=value)
print(id) # print(id)
for i in range(5): for i in range(5):
treeview.insert(id, 'end', text=value, values=i) treeview.insert(id, 'end', text=value, values=i)
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: