Text wrapping - the FINAL FIX! Update a Disabled multiline works now (enables, changes, disables)

This commit is contained in:
MikeTheWatchGuy 2019-06-08 14:26:02 -04:00
parent b37a83074a
commit 1fc718b325
1 changed files with 8 additions and 4 deletions

View File

@ -1149,12 +1149,16 @@ class Multiline(Element):
if autoscroll is not None: if autoscroll is not None:
self.Autoscroll = autoscroll self.Autoscroll = autoscroll
if value is not None: if value is not None:
if self.Disabled:
self.TKText.configure(state='normal')
try: try:
if not append: if not append:
self.TKText.delete('1.0', tk.END) self.TKText.delete('1.0', tk.END)
self.TKText.insert(tk.END, value) self.TKText.insert(tk.END, value)
except: except:
pass pass
if self.Disabled:
self.TKText.configure(state='disabled')
self.DefaultText = value self.DefaultText = value
if self.Autoscroll: if self.Autoscroll:
self.TKText.see(tk.END) self.TKText.see(tk.END)
@ -5183,11 +5187,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width, tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width,
height=height, justify=justify, bd=border_depth, font=font) height=height, 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 = 0 wraplen = tktext_label.winfo_reqwidth() # width of widget in Pixels
if not auto_size_text and height == 1: if not auto_size_text and height == 1: # if just 1 line high, ensure no wrap happens
wraplen = 0 wraplen = 0
elif not auto_size_text: # print(f'Text wraplen = {wraplen} wxh = {width} x {height}')
wraplen = tktext_label.winfo_reqwidth() - 10 # width of widget in Pixels # print(f'Len = {len(display_text)} Text = {str(display_text)}')
tktext_label.configure(anchor=anchor, wraplen=wraplen) # set wrap to width of widget tktext_label.configure(anchor=anchor, wraplen=wraplen) # set wrap to width of widget
if element.Relief is not None: if element.Relief is not None:
tktext_label.configure(relief=element.Relief) tktext_label.configure(relief=element.Relief)