New Element level method - SetToolTip. Made a new element.Widget property

This commit is contained in:
MikeTheWatchGuy 2019-05-14 09:28:33 -04:00
parent c5080b8d42
commit abd0caa631
1 changed files with 39 additions and 33 deletions

View File

@ -382,6 +382,7 @@ class Element():
self.TooltipObject = None self.TooltipObject = None
self.Visible = visible self.Visible = visible
self.TKRightClickMenu = None self.TKRightClickMenu = None
self.Widget = None # Set when creating window. Has the main tkinter widget for element
def RightClickMenuCallback(self, event): def RightClickMenuCallback(self, event):
self.TKRightClickMenu.tk_popup(event.x_root, event.y_root, 0) self.TKRightClickMenu.tk_popup(event.x_root, event.y_root, 0)
@ -502,6 +503,9 @@ class Element():
if self.ParentForm.CurrentlyRunningMainloop: if self.ParentForm.CurrentlyRunningMainloop:
self.ParentForm.TKroot.quit() self.ParentForm.TKroot.quit()
def SetTooltip(self,tooltip_text):
self.TooltipObject = ToolTip(self.Widget, text=tooltip_text, timeout=DEFAULT_TOOLTIP_TIME)
def __del__(self): def __del__(self):
try: try:
@ -4955,7 +4959,7 @@ 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:
element.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly) # do not use yet! not working element.TKColFrame = element.Widget = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly) # do not use yet! not working
PackFormIntoFrame(element, element.TKColFrame.TKFrame, toplevel_form) PackFormIntoFrame(element, element.TKColFrame.TKFrame, toplevel_form)
element.TKColFrame.TKFrame.update() element.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
@ -4999,7 +5003,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# ------------------------- Pane element ------------------------- # # ------------------------- Pane element ------------------------- #
if element_type == ELEM_TYPE_PANE: if element_type == ELEM_TYPE_PANE:
bd = element.BorderDepth if element.BorderDepth is not None else border_depth bd = element.BorderDepth if element.BorderDepth is not None else border_depth
element.PanedWindow = tk.PanedWindow(tk_row_frame, element.PanedWindow = element.Widget = tk.PanedWindow(tk_row_frame,
orient=tk.VERTICAL if element.Orientation.startswith('v') else tk.HORIZONTAL, orient=tk.VERTICAL if element.Orientation.startswith('v') else tk.HORIZONTAL,
borderwidth=bd, borderwidth=bd,
bd=bd, bd=bd,
@ -5058,7 +5062,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE
# tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, # tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height,
# justify=justify, bd=border_depth, font=font) # justify=justify, bd=border_depth, font=font)
tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height,
justify=justify, bd=border_depth, font=font) justify=justify, bd=border_depth, font=font)
# Set wrap-length for text (in PIXELS) == PAIN IN THE ASS # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS
wraplen = tktext_label.winfo_reqwidth() + 40 # width of widget in Pixels wraplen = tktext_label.winfo_reqwidth() + 40 # width of widget in Pixels
@ -5110,10 +5114,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
bc = DEFAULT_BUTTON_COLOR bc = DEFAULT_BUTTON_COLOR
border_depth = element.BorderWidth border_depth = element.BorderWidth
if btype != BUTTON_TYPE_REALTIME: if btype != BUTTON_TYPE_REALTIME:
tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, tkbutton = element.Widget = tk.Button(tk_row_frame, text=btext, width=width, height=height,
command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth, font=font) command=element.ButtonCallBack, justify=tk.LEFT, bd=border_depth, font=font)
else: else:
tkbutton = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, tkbutton = element.Widget = tk.Button(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT,
bd=border_depth, font=font) bd=border_depth, font=font)
tkbutton.bind('<ButtonRelease-1>', element.ButtonReleaseCallBack) tkbutton.bind('<ButtonRelease-1>', element.ButtonReleaseCallBack)
tkbutton.bind('<ButtonPress-1>', element.ButtonPressCallBack) tkbutton.bind('<ButtonPress-1>', element.ButtonPressCallBack)
@ -5185,7 +5189,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
else: else:
bc = DEFAULT_BUTTON_COLOR bc = DEFAULT_BUTTON_COLOR
border_depth = element.BorderWidth border_depth = element.BorderWidth
tkbutton = tk.Menubutton(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth, font=font) tkbutton = element.Widget = tk.Menubutton(tk_row_frame, text=btext, width=width, height=height, justify=tk.LEFT, bd=border_depth, font=font)
element.TKButtonMenu = tkbutton element.TKButtonMenu = tkbutton
if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT and bc[1] != COLOR_SYSTEM_DEFAULT: if bc != (None, None) and bc != COLOR_SYSTEM_DEFAULT and bc[1] != COLOR_SYSTEM_DEFAULT:
tkbutton.config(foreground=bc[0], background=bc[1], activebackground=bc[1]) tkbutton.config(foreground=bc[0], background=bc[1], activebackground=bc[1])
@ -5251,7 +5255,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
justification = DEFAULT_TEXT_JUSTIFICATION justification = DEFAULT_TEXT_JUSTIFICATION
justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT
# anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE # anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE
element.TKEntry = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, element.TKEntry = element.Widget = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar,
bd=border_depth, font=font, show=show, justify=justify) bd=border_depth, font=font, show=show, justify=justify)
if element.ChangeSubmits: if element.ChangeSubmits:
element.TKEntry.bind('<Key>', element.KeyboardHandler) element.TKEntry.bind('<Key>', element.KeyboardHandler)
@ -5325,7 +5329,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
combostyle.configure(style_name, fieldbackground=element.BackgroundColor) combostyle.configure(style_name, fieldbackground=element.BackgroundColor)
combostyle.configure(style_name, selectforeground=element.TextColor) combostyle.configure(style_name, selectforeground=element.TextColor)
element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar, font=font, style=style_name) element.TKCombo = element.Widget = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar, font=font, style=style_name)
if element.Size[1] != 1 and element.Size[1] is not None: if element.Size[1] != 1 and element.Size[1] is not None:
element.TKCombo.configure(height=element.Size[1]) element.TKCombo.configure(height=element.Size[1])
element.TKCombo['values'] = element.Values element.TKCombo['values'] = element.Values
@ -5358,7 +5362,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKStringVar = tk.StringVar() element.TKStringVar = tk.StringVar()
default = element.DefaultValue if element.DefaultValue else element.Values[0] default = element.DefaultValue if element.DefaultValue else element.Values[0]
element.TKStringVar.set(default) element.TKStringVar.set(default)
element.TKOptionMenu = tk.OptionMenu(tk_row_frame, element.TKStringVar, *element.Values) element.TKOptionMenu = element.Widget = tk.OptionMenu(tk_row_frame, element.TKStringVar, *element.Values)
element.TKOptionMenu.config(highlightthickness=0, font=font, width=width) element.TKOptionMenu.config(highlightthickness=0, font=font, width=width)
element.TKOptionMenu.config(borderwidth=border_depth) element.TKOptionMenu.config(borderwidth=border_depth)
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
@ -5382,7 +5386,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
width = max_line_len width = max_line_len
listbox_frame = tk.Frame(tk_row_frame) listbox_frame = tk.Frame(tk_row_frame)
element.TKStringVar = tk.StringVar() element.TKStringVar = tk.StringVar()
element.TKListbox = tk.Listbox(listbox_frame, height=element_size[1], width=width, element.TKListbox = element.Widget = tk.Listbox(listbox_frame, height=element_size[1], width=width,
selectmode=element.SelectMode, font=font, exportselection=False) selectmode=element.SelectMode, font=font, exportselection=False)
for index, item in enumerate(element.Values): for index, item in enumerate(element.Values):
element.TKListbox.insert(tk.END, item) element.TKListbox.insert(tk.END, item)
@ -5420,7 +5424,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element = element # type: Multiline element = element # type: Multiline
default_text = element.DefaultText default_text = element.DefaultText
width, height = element_size width, height = element_size
element.TKText = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word', element.TKText = element.Widget = tk.scrolledtext.ScrolledText(tk_row_frame, width=width, height=height, wrap='word',
bd=border_depth, font=font, relief=tk.FLAT) bd=border_depth, font=font, relief=tk.FLAT)
element.TKText.insert(1.0, default_text) # set the default text element.TKText.insert(1.0, default_text) # set the default text
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
@ -5455,11 +5459,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKIntVar = tk.IntVar() element.TKIntVar = tk.IntVar()
element.TKIntVar.set(default_value if default_value is not None else 0) element.TKIntVar.set(default_value if default_value is not None else 0)
if element.ChangeSubmits: if element.ChangeSubmits:
element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, element.TKCheckbutton = element.Widget = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width,
variable=element.TKIntVar, bd=border_depth, font=font, variable=element.TKIntVar, bd=border_depth, font=font,
command=element.CheckboxHandler) command=element.CheckboxHandler)
else: else:
element.TKCheckbutton = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, element.TKCheckbutton = element.Widget = tk.Checkbutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width,
variable=element.TKIntVar, bd=border_depth, font=font) variable=element.TKIntVar, bd=border_depth, font=font)
if default_value is None or element.Disabled: if default_value is None or element.Disabled:
element.TKCheckbutton.configure(state='disable') element.TKCheckbutton.configure(state='disable')
@ -5495,6 +5499,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) element.TKProgressBar.TKProgressBarForReal.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
if element.Visible is False: if element.Visible is False:
element.TKProgressBar.TKProgressBarForReal.pack_forget() element.TKProgressBar.TKProgressBarForReal.pack_forget()
element.Widget = element.TKProgressBar.TKProgressBarForReal
# ------------------------- RADIO BUTTON element ------------------------- # # ------------------------- RADIO BUTTON element ------------------------- #
elif element_type == ELEM_TYPE_INPUT_RADIO: elif element_type == ELEM_TYPE_INPUT_RADIO:
element = element # type: Radio element = element # type: Radio
@ -5513,11 +5518,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if default_value: # if this radio is the one selected, set RadVar to match if default_value: # if this radio is the one selected, set RadVar to match
element.TKIntVar.set(value) element.TKIntVar.set(value)
if element.ChangeSubmits: if element.ChangeSubmits:
element.TKRadio = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, element.TKRadio = element.Widget = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width,
variable=element.TKIntVar, value=value, bd=border_depth, font=font, variable=element.TKIntVar, value=value, bd=border_depth, font=font,
command=element.RadioHandler) command=element.RadioHandler)
else: else:
element.TKRadio = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width, element.TKRadio = element.Widget = tk.Radiobutton(tk_row_frame, anchor=tk.NW, text=element.Text, width=width,
variable=element.TKIntVar, value=value, bd=border_depth, font=font) variable=element.TKIntVar, value=value, bd=border_depth, font=font)
if not element.BackgroundColor in (None, COLOR_SYSTEM_DEFAULT): if not element.BackgroundColor in (None, COLOR_SYSTEM_DEFAULT):
element.TKRadio.configure(background=element.BackgroundColor) element.TKRadio.configure(background=element.BackgroundColor)
@ -5536,7 +5541,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
width, height = element_size width, height = element_size
width = 0 if auto_size_text else element_size[0] width = 0 if auto_size_text else element_size[0]
element.TKStringVar = tk.StringVar() element.TKStringVar = tk.StringVar()
element.TKSpinBox = tk.Spinbox(tk_row_frame, values=element.Values, textvariable=element.TKStringVar, element.TKSpinBox = element.Widget = tk.Spinbox(tk_row_frame, values=element.Values, textvariable=element.TKStringVar,
width=width, bd=border_depth) width=width, bd=border_depth)
element.TKStringVar.set(element.DefaultValue) element.TKStringVar.set(element.DefaultValue)
element.TKSpinBox.configure(font=font) # set wrap to width of widget element.TKSpinBox.configure(font=font) # set wrap to width of widget
@ -5557,7 +5562,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# ------------------------- OUTPUT element ------------------------- # # ------------------------- OUTPUT element ------------------------- #
elif element_type == ELEM_TYPE_OUTPUT: elif element_type == ELEM_TYPE_OUTPUT:
width, height = element_size width, height = element_size
element._TKOut = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth, element._TKOut = element.Widget = TKOutput(tk_row_frame, width=width, height=height, bd=border_depth,
background_color=element.BackgroundColor, text_color=text_color, font=font, background_color=element.BackgroundColor, text_color=text_color, font=font,
pad=elementpad) pad=elementpad)
element._TKOut.output.configure(takefocus=0) # make it so that Output does not get focus element._TKOut.output.configure(takefocus=0) # make it so that Output does not get focus
@ -5589,10 +5594,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
else: else:
width, height = element_size width, height = element_size
if photo is not None: if photo is not None:
element.tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, element.tktext_label = element.Widget = tk.Label(tk_row_frame, image=photo, width=width, height=height,
bd=border_depth) bd=border_depth)
else: else:
element.tktext_label = tk.Label(tk_row_frame, width=width, height=height, bd=border_depth) element.tktext_label = element.Widget = tk.Label(tk_row_frame, width=width, height=height, bd=border_depth)
if element.BackgroundColor is not None: if element.BackgroundColor is not None:
element.tktext_label.config(background=element.BackgroundColor) element.tktext_label.config(background=element.BackgroundColor)
@ -5616,7 +5621,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
elif element_type == ELEM_TYPE_CANVAS: elif element_type == ELEM_TYPE_CANVAS:
width, height = element_size width, height = element_size
if element._TKCanvas is None: if element._TKCanvas is None:
element._TKCanvas = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth) element._TKCanvas = element.Widget = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth)
else: else:
element._TKCanvas.master = tk_row_frame element._TKCanvas.master = tk_row_frame
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
@ -5642,7 +5647,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# element._TKCanvas = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth) # element._TKCanvas = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth)
# else: # else:
# element._TKCanvas.master = tk_row_frame # element._TKCanvas.master = tk_row_frame
element._TKCanvas2 = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth) element._TKCanvas2 = element.Widget = tk.Canvas(tk_row_frame, width=width, height=height, bd=border_depth)
element._TKCanvas2.pack(side=tk.LEFT) element._TKCanvas2.pack(side=tk.LEFT)
element._TKCanvas2.addtag_all('mytag') element._TKCanvas2.addtag_all('mytag')
if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT: if element.BackgroundColor is not None and element.BackgroundColor != COLOR_SYSTEM_DEFAULT:
@ -5669,7 +5674,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# ------------------------- MENUBAR element ------------------------- # # ------------------------- MENUBAR element ------------------------- #
elif element_type == ELEM_TYPE_MENUBAR: elif element_type == ELEM_TYPE_MENUBAR:
menu_def = element.MenuDefinition menu_def = element.MenuDefinition
element.TKMenu = tk.Menu(toplevel_form.TKroot, tearoff=element.Tearoff) # create the menubar element.TKMenu = element.Widget = tk.Menu(toplevel_form.TKroot, tearoff=element.Tearoff) # create the menubar
menubar = element.TKMenu menubar = element.TKMenu
for menu_entry in menu_def: for menu_entry in menu_def:
# print(f'Adding a Menubar ENTRY {menu_entry}') # print(f'Adding a Menubar ENTRY {menu_entry}')
@ -5690,7 +5695,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
toplevel_form.TKroot.configure(menu=element.TKMenu) toplevel_form.TKroot.configure(menu=element.TKMenu)
# ------------------------- Frame element ------------------------- # # ------------------------- Frame element ------------------------- #
elif element_type == ELEM_TYPE_FRAME: elif element_type == ELEM_TYPE_FRAME:
labeled_frame = tk.LabelFrame(tk_row_frame, text=element.Title, relief=element.Relief) labeled_frame = element.Widget = tk.LabelFrame(tk_row_frame, text=element.Title, relief=element.Relief)
element.TKFrame = labeled_frame element.TKFrame = labeled_frame
PackFormIntoFrame(element, labeled_frame, toplevel_form) PackFormIntoFrame(element, labeled_frame, toplevel_form)
labeled_frame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1]) labeled_frame.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1])
@ -5718,7 +5723,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
labeled_frame.bind('<Button-3>', element.RightClickMenuCallback) labeled_frame.bind('<Button-3>', element.RightClickMenuCallback)
# ------------------------- Tab element ------------------------- # # ------------------------- Tab element ------------------------- #
elif element_type == ELEM_TYPE_TAB: elif element_type == ELEM_TYPE_TAB:
element.TKFrame = tk.Frame(form.TKNotebook) element.TKFrame = element.Widget = tk.Frame(form.TKNotebook)
PackFormIntoFrame(element, element.TKFrame, toplevel_form) PackFormIntoFrame(element, element.TKFrame, toplevel_form)
if element.Disabled: if element.Disabled:
form.TKNotebook.add(element.TKFrame, text=element.Title, state='disabled') form.TKNotebook.add(element.TKFrame, text=element.Title, state='disabled')
@ -5785,7 +5790,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
style.configure(custom_style + '.Tab', foreground=element.TextColor) style.configure(custom_style + '.Tab', foreground=element.TextColor)
# style.configure(custom_style, background='blue', foreground='yellow') # style.configure(custom_style, background='blue', foreground='yellow')
element.TKNotebook = ttk.Notebook(tk_row_frame, style=custom_style) element.TKNotebook = element.Widget = ttk.Notebook(tk_row_frame, style=custom_style)
PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form) PackFormIntoFrame(element, toplevel_form.TKroot, toplevel_form)
@ -5810,13 +5815,13 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
range_from = element.Range[0] range_from = element.Range[0]
range_to = element.Range[1] range_to = element.Range[1]
if element.ChangeSubmits: if element.ChangeSubmits:
tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, tkscale = element.Widget = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar,
from_=range_from, to_=range_to, resolution=element.Resolution, from_=range_from, to_=range_to, resolution=element.Resolution,
length=slider_length, width=slider_width, bd=element.BorderWidth, length=slider_length, width=slider_width, bd=element.BorderWidth,
relief=element.Relief, font=font, tickinterval=element.TickInterval, relief=element.Relief, font=font, tickinterval=element.TickInterval,
command=element.SliderChangedHandler) command=element.SliderChangedHandler)
else: else:
tkscale = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar, tkscale = element.Widget = tk.Scale(tk_row_frame, orient=element.Orientation, variable=element.TKIntVar,
from_=range_from, to_=range_to, resolution=element.Resolution, from_=range_from, to_=range_to, resolution=element.Resolution,
length=slider_length, width=slider_width, bd=element.BorderWidth, length=slider_length, width=slider_width, bd=element.BorderWidth,
relief=element.Relief, font=font, tickinterval=element.TickInterval) relief=element.Relief, font=font, tickinterval=element.TickInterval)
@ -5869,7 +5874,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
if element.DisplayRowNumbers: # if display row number, tack on the numbers to front of columns if element.DisplayRowNumbers: # if display row number, tack on the numbers to front of columns
displaycolumns = [element.RowHeaderText, ] + displaycolumns displaycolumns = [element.RowHeaderText, ] + displaycolumns
column_headings = [element.RowHeaderText, ] + element.ColumnHeadings column_headings = [element.RowHeaderText, ] + element.ColumnHeadings
element.TKTreeview = ttk.Treeview(frame, columns=column_headings, element.TKTreeview = element.Widget = ttk.Treeview(frame, columns=column_headings,
displaycolumns=displaycolumns, show='headings', height=height, displaycolumns=displaycolumns, show='headings', height=height,
selectmode=element.SelectMode,) selectmode=element.SelectMode,)
treeview = element.TKTreeview treeview = element.TKTreeview
@ -5966,7 +5971,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
displaycolumns.append(element.ColumnHeadings[i]) displaycolumns.append(element.ColumnHeadings[i])
column_headings = element.ColumnHeadings column_headings = element.ColumnHeadings
# ------------- GET THE TREEVIEW WIDGET ------------- # ------------- GET THE TREEVIEW WIDGET -------------
element.TKTreeview = ttk.Treeview(frame, columns=column_headings, element.TKTreeview = element.Widget = ttk.Treeview(frame, columns=column_headings,
displaycolumns=displaycolumns, show='tree headings', height=height, displaycolumns=displaycolumns, show='tree headings', height=height,
selectmode=element.SelectMode) selectmode=element.SelectMode)
treeview = element.TKTreeview treeview = element.TKTreeview
@ -6029,7 +6034,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
# ------------------------- Separator element ------------------------- # # ------------------------- Separator element ------------------------- #
elif element_type == ELEM_TYPE_SEPARATOR: elif element_type == ELEM_TYPE_SEPARATOR:
element = element # type: VerticalSeparator element = element # type: VerticalSeparator
separator = ttk.Separator(tk_row_frame, orient=element.Orientation, ) separator = element.Widget = ttk.Separator(tk_row_frame, orient=element.Orientation, )
separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill='both', expand=True) separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill='both', expand=True)
# ------------------------- StatusBar element ------------------------- # # ------------------------- StatusBar element ------------------------- #
elif element_type == ELEM_TYPE_STATUSBAR: elif element_type == ELEM_TYPE_STATUSBAR:
@ -6062,7 +6067,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE
# tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, # tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height,
# justify=justify, bd=border_depth, font=font) # justify=justify, bd=border_depth, font=font)
tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height,
justify=justify, bd=border_depth, font=font) justify=justify, bd=border_depth, font=font)
# Set wrap-length for text (in PIXELS) == PAIN IN THE ASS # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS
wraplen = tktext_label.winfo_reqwidth() + 40 # width of widget in Pixels wraplen = tktext_label.winfo_reqwidth() + 40 # width of widget in Pixels
@ -7757,12 +7762,12 @@ def main():
layout1 = [ layout1 = [
[Menu(menu_def)], [Menu(menu_def)],
[Text('You are running the PySimpleGUI.py file itself', font='ANY 15', tooltip='My tooltip')], [Text('You are running the PySimpleGUI.py file itself', font='ANY 15', tooltip='My tooltip', key='_TEXT1_')],
[Text('You should be importing it rather than running it', font='ANY 15')], [Text('You should be importing it rather than running it', font='ANY 15')],
[Frame('Input Text Group', frame1, title_color='red'), [Frame('Input Text Group', frame1, title_color='red'),
Image(data=DEFAULT_BASE64_LOADING_GIF, key='_IMAGE_')], Image(data=DEFAULT_BASE64_LOADING_GIF, key='_IMAGE_')],
[Frame('Multiple Choice Group', frame2, title_color='green'), [Frame('Multiple Choice Group', frame2, title_color='green'),
Frame('Binary Choice Group', frame3, title_color='purple'), Frame('Binary Choice Group', frame3, title_color='purple', tooltip='Binary Choice'),
Frame('Variable Choice Group', frame4, title_color='blue')], Frame('Variable Choice Group', frame4, title_color='blue')],
[Frame('Structured Data Group', frame5, title_color='red'), ], [Frame('Structured Data Group', frame5, title_color='red'), ],
# [Frame('Graphing Group', frame6)], # [Frame('Graphing Group', frame6)],
@ -7796,6 +7801,7 @@ def main():
i += 1 i += 1
if event == 'Button': if event == 'Button':
print(window.AllKeysDict) print(window.AllKeysDict)
window.Element('_TEXT1_').SetTooltip('NEW TEXT')
# TimerStop() # TimerStop()
window.Close() window.Close()