Fill form function working! New Look and Feel settings
This commit is contained in:
parent
38dd2732e4
commit
60a93a54ae
|
@ -273,7 +273,10 @@ class InputText(Element):
|
||||||
|
|
||||||
|
|
||||||
def Update(self, new_value):
|
def Update(self, new_value):
|
||||||
|
try:
|
||||||
self.TKStringVar.set(new_value)
|
self.TKStringVar.set(new_value)
|
||||||
|
except: pass
|
||||||
|
self.DefaultText = new_value
|
||||||
|
|
||||||
def Get(self):
|
def Get(self):
|
||||||
return self.TKStringVar.get()
|
return self.TKStringVar.get()
|
||||||
|
@ -285,8 +288,7 @@ class InputText(Element):
|
||||||
# Combo #
|
# Combo #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class InputCombo(Element):
|
class InputCombo(Element):
|
||||||
|
def __init__(self, values, default_value=None, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None, pad=None):
|
||||||
def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None, pad=None):
|
|
||||||
'''
|
'''
|
||||||
Input Combo Box Element (also called Dropdown box)
|
Input Combo Box Element (also called Dropdown box)
|
||||||
:param values:
|
:param values:
|
||||||
|
@ -296,6 +298,7 @@ class InputCombo(Element):
|
||||||
:param background_color: Color for Element. Text or RGB Hex
|
:param background_color: Color for Element. Text or RGB Hex
|
||||||
'''
|
'''
|
||||||
self.Values = values
|
self.Values = values
|
||||||
|
self.DefaultValue = default_value
|
||||||
self.TKComboBox = None
|
self.TKComboBox = None
|
||||||
bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR
|
bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR
|
||||||
fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
|
fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
|
||||||
|
@ -305,7 +308,10 @@ class InputCombo(Element):
|
||||||
def Update(self, value):
|
def Update(self, value):
|
||||||
for index, v in enumerate(self.Values):
|
for index, v in enumerate(self.Values):
|
||||||
if v == value:
|
if v == value:
|
||||||
|
try:
|
||||||
self.TKCombo.current(index)
|
self.TKCombo.current(index)
|
||||||
|
except: pass
|
||||||
|
self.DefaultValue = value
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
@ -321,8 +327,7 @@ class InputCombo(Element):
|
||||||
# Option Menu #
|
# Option Menu #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class InputOptionMenu(Element):
|
class InputOptionMenu(Element):
|
||||||
|
def __init__(self, values, default_value=None, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None, pad=None):
|
||||||
def __init__(self, values, scale=(None, None), size=(None, None), auto_size_text=None, background_color=None, text_color=None, key=None, pad=None):
|
|
||||||
'''
|
'''
|
||||||
Input Combo Box Element (also called Dropdown box)
|
Input Combo Box Element (also called Dropdown box)
|
||||||
:param values:
|
:param values:
|
||||||
|
@ -332,6 +337,7 @@ class InputOptionMenu(Element):
|
||||||
:param background_color: Color for Element. Text or RGB Hex
|
:param background_color: Color for Element. Text or RGB Hex
|
||||||
'''
|
'''
|
||||||
self.Values = values
|
self.Values = values
|
||||||
|
self.DefaultValue = default_value
|
||||||
self.TKOptionMenu = None
|
self.TKOptionMenu = None
|
||||||
bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR
|
bg = background_color if background_color else DEFAULT_INPUT_ELEMENTS_COLOR
|
||||||
fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
|
fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
|
||||||
|
@ -341,7 +347,10 @@ class InputOptionMenu(Element):
|
||||||
def Update(self, value):
|
def Update(self, value):
|
||||||
for index, v in enumerate(self.Values):
|
for index, v in enumerate(self.Values):
|
||||||
if v == value:
|
if v == value:
|
||||||
|
try:
|
||||||
self.TKStringVar.set(value)
|
self.TKStringVar.set(value)
|
||||||
|
except: pass
|
||||||
|
self.DefaultValue = value
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
@ -356,7 +365,7 @@ class InputOptionMenu(Element):
|
||||||
# Listbox #
|
# Listbox #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
class Listbox(Element):
|
class Listbox(Element):
|
||||||
def __init__(self, values, select_mode=None, select_submits=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None, pad=None):
|
def __init__(self, values, default_values=None, select_mode=None, select_submits=False, scale=(None, None), size=(None, None), auto_size_text=None, font=None, background_color=None, text_color=None, key=None, pad=None):
|
||||||
'''
|
'''
|
||||||
Listbox Element
|
Listbox Element
|
||||||
:param values:
|
:param values:
|
||||||
|
@ -367,6 +376,7 @@ class Listbox(Element):
|
||||||
:param auto_size_text: True if should shrink field to fit the default text
|
:param auto_size_text: True if should shrink field to fit the default text
|
||||||
:param background_color: Color for Element. Text or RGB Hex '''
|
:param background_color: Color for Element. Text or RGB Hex '''
|
||||||
self.Values = values
|
self.Values = values
|
||||||
|
self.DefaultValues = default_values
|
||||||
self.TKListbox = None
|
self.TKListbox = None
|
||||||
self.SelectSubmits = select_submits
|
self.SelectSubmits = select_submits
|
||||||
if select_mode == LISTBOX_SELECT_MODE_BROWSE:
|
if select_mode == LISTBOX_SELECT_MODE_BROWSE:
|
||||||
|
@ -390,12 +400,15 @@ class Listbox(Element):
|
||||||
self.TKListbox.insert(tk.END, item)
|
self.TKListbox.insert(tk.END, item)
|
||||||
self.TKListbox.selection_set(0, 0)
|
self.TKListbox.selection_set(0, 0)
|
||||||
|
|
||||||
def SetValue(self, value):
|
def SetValue(self, values):
|
||||||
for index, item in enumerate(self.Values):
|
for index, item in enumerate(self.Values):
|
||||||
if item in value:
|
try:
|
||||||
|
if item in values:
|
||||||
self.TKListbox.selection_set(index)
|
self.TKListbox.selection_set(index)
|
||||||
else:
|
else:
|
||||||
self.TKListbox.selection_clear(index)
|
self.TKListbox.selection_clear(index)
|
||||||
|
except: pass
|
||||||
|
self.DefaultValues = values
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -435,7 +448,10 @@ class Radio(Element):
|
||||||
if not value:
|
if not value:
|
||||||
return
|
return
|
||||||
location = EncodeRadioRowCol(self.Position[0], self.Position[1])
|
location = EncodeRadioRowCol(self.Position[0], self.Position[1])
|
||||||
|
try:
|
||||||
self.TKIntVar.set(location)
|
self.TKIntVar.set(location)
|
||||||
|
except: pass
|
||||||
|
self.InitialState = value
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -471,11 +487,14 @@ class Checkbox(Element):
|
||||||
return self.TKIntVar.get()
|
return self.TKIntVar.get()
|
||||||
|
|
||||||
def Update(self, value):
|
def Update(self, value):
|
||||||
|
try:
|
||||||
if value is None:
|
if value is None:
|
||||||
self.TKCheckbutton.configure(state='disabled')
|
self.TKCheckbutton.configure(state='disabled')
|
||||||
else:
|
else:
|
||||||
self.TKCheckbutton.configure(state='normal')
|
self.TKCheckbutton.configure(state='normal')
|
||||||
self.TKIntVar.set(value)
|
self.TKIntVar.set(value)
|
||||||
|
except: pass
|
||||||
|
self.InitialState = value
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
@ -510,7 +529,10 @@ class Spin(Element):
|
||||||
return
|
return
|
||||||
|
|
||||||
def Update(self, new_value):
|
def Update(self, new_value):
|
||||||
|
try:
|
||||||
self.TKStringVar.set(new_value)
|
self.TKStringVar.set(new_value)
|
||||||
|
except: pass
|
||||||
|
self.DefaultValue = new_value
|
||||||
|
|
||||||
def SpinChangedHandler(self, event):
|
def SpinChangedHandler(self, event):
|
||||||
# first, get the results table built
|
# first, get the results table built
|
||||||
|
@ -550,9 +572,12 @@ class Multiline(Element):
|
||||||
super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key, pad=pad)
|
super().__init__(ELEM_TYPE_INPUT_MULTILINE, scale=scale, size=size, auto_size_text=auto_size_text, background_color=bg, text_color=fg, key=key, pad=pad)
|
||||||
return
|
return
|
||||||
|
|
||||||
def Update(self, NewValue):
|
def Update(self, new_value):
|
||||||
|
try:
|
||||||
self.TKText.delete('1.0', tk.END)
|
self.TKText.delete('1.0', tk.END)
|
||||||
self.TKText.insert(1.0, NewValue)
|
self.TKText.insert(1.0, new_value)
|
||||||
|
except: pass
|
||||||
|
self.DefaultText = new_value
|
||||||
|
|
||||||
def Get(self):
|
def Get(self):
|
||||||
return self.TKText.get(1.0, tk.END)
|
return self.TKText.get(1.0, tk.END)
|
||||||
|
@ -1005,9 +1030,12 @@ class Slider(Element):
|
||||||
return
|
return
|
||||||
|
|
||||||
def Update(self, value, range=(None, None)):
|
def Update(self, value, range=(None, None)):
|
||||||
|
try:
|
||||||
self.TKIntVar.set(value)
|
self.TKIntVar.set(value)
|
||||||
if range != (None, None):
|
if range != (None, None):
|
||||||
self.TKScale.config(from_ = range[0], to_ = range[1])
|
self.TKScale.config(from_ = range[0], to_ = range[1])
|
||||||
|
except: pass
|
||||||
|
self.DefaultValue = value
|
||||||
|
|
||||||
def SliderChangedHandler(self, event):
|
def SliderChangedHandler(self, event):
|
||||||
# first, get the results table built
|
# first, get the results table built
|
||||||
|
@ -1663,7 +1691,6 @@ def FillSubformWithValues(form, values_dict):
|
||||||
value = values_dict[element.Key]
|
value = values_dict[element.Key]
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if element.Type == ELEM_TYPE_INPUT_TEXT:
|
if element.Type == ELEM_TYPE_INPUT_TEXT:
|
||||||
element.Update(value)
|
element.Update(value)
|
||||||
elif element.Type == ELEM_TYPE_INPUT_CHECKBOX:
|
elif element.Type == ELEM_TYPE_INPUT_CHECKBOX:
|
||||||
|
@ -1887,12 +1914,19 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
# if element.BackgroundColor is not None:
|
# if element.BackgroundColor is not None:
|
||||||
# element.TKCombo.configure(background=element.BackgroundColor)
|
# element.TKCombo.configure(background=element.BackgroundColor)
|
||||||
element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1])
|
element.TKCombo.pack(side=tk.LEFT,padx=element.Pad[0], pady=element.Pad[1])
|
||||||
|
if element.DefaultValue:
|
||||||
|
for i, v in enumerate(element.Values):
|
||||||
|
if v == element.DefaultValue:
|
||||||
|
element.TKCombo.current(i)
|
||||||
|
break
|
||||||
|
else:
|
||||||
element.TKCombo.current(0)
|
element.TKCombo.current(0)
|
||||||
# ------------------------- OPTION MENU (Like ComboBox but different) element ------------------------- #
|
# ------------------------- OPTION MENU (Like ComboBox but different) element ------------------------- #
|
||||||
elif element_type == ELEM_TYPE_INPUT_OPTION_MENU:
|
elif element_type == ELEM_TYPE_INPUT_OPTION_MENU:
|
||||||
max_line_len = max([len(str(l)) for l in element.Values])
|
max_line_len = max([len(str(l)) for l in element.Values])
|
||||||
element.TKStringVar = tk.StringVar()
|
element.TKStringVar = tk.StringVar()
|
||||||
element.TKStringVar.set(element.Values[0])
|
default = element.DefaultValue if element.DefaultValue else element.Values[0]
|
||||||
|
element.TKStringVar.set(default)
|
||||||
element.TKOptionMenu = tk.OptionMenu(tk_row_frame, element.TKStringVar ,*element.Values )
|
element.TKOptionMenu = tk.OptionMenu(tk_row_frame, element.TKStringVar ,*element.Values )
|
||||||
element.TKOptionMenu.config(highlightthickness=0, font=font)
|
element.TKOptionMenu.config(highlightthickness=0, font=font)
|
||||||
element.TKOptionMenu.config(borderwidth=border_depth)
|
element.TKOptionMenu.config(borderwidth=border_depth)
|
||||||
|
@ -1909,9 +1943,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
||||||
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, selectmode=element.SelectMode, font=font)
|
element.TKListbox= tk.Listbox(listbox_frame, height=element_size[1], width=width, selectmode=element.SelectMode, font=font)
|
||||||
for item in element.Values:
|
for index, item in enumerate(element.Values):
|
||||||
element.TKListbox.insert(tk.END, item)
|
element.TKListbox.insert(tk.END, item)
|
||||||
element.TKListbox.selection_set(0,0)
|
if element.DefaultValues is not None and item in element.DefaultValues:
|
||||||
|
element.TKListbox.selection_set(index)
|
||||||
|
# element.TKListbox.selection_set(0,0)
|
||||||
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.TKListbox.configure(background=element.BackgroundColor)
|
element.TKListbox.configure(background=element.BackgroundColor)
|
||||||
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
|
if text_color is not None and text_color != COLOR_SYSTEM_DEFAULT:
|
||||||
|
@ -3046,6 +3082,26 @@ def ChangeLookAndFeel(index):
|
||||||
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
||||||
'PROGRESS_DEPTH': 0},
|
'PROGRESS_DEPTH': 0},
|
||||||
|
|
||||||
|
'Tan': {'BACKGROUND': '#fdf6e3', 'TEXT': '#268bd1', 'INPUT': '#eee8d5',
|
||||||
|
'TEXT_INPUT': '#6c71c3', 'SCROLL': '#eee8d5', 'BUTTON': ('white', '#063542'),
|
||||||
|
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
||||||
|
'PROGRESS_DEPTH': 0},
|
||||||
|
|
||||||
|
'TanBlue': {'BACKGROUND': '#e5dece', 'TEXT': '#063289', 'INPUT': '#f9f8f4',
|
||||||
|
'TEXT_INPUT': '#242834', 'SCROLL': '#eee8d5', 'BUTTON': ('white', '#063289'),
|
||||||
|
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
||||||
|
'PROGRESS_DEPTH': 0},
|
||||||
|
|
||||||
|
'DarkTanBlue': {'BACKGROUND': '#242834', 'TEXT': '#dfe6f8', 'INPUT': '#4f5764',
|
||||||
|
'TEXT_INPUT': 'white', 'SCROLL': '#a9afbb', 'BUTTON': ('white', '#063289'),
|
||||||
|
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
||||||
|
'PROGRESS_DEPTH': 0},
|
||||||
|
|
||||||
|
'DarkBlue': {'BACKGROUND': '#1a2835', 'TEXT': '#d1ecff', 'INPUT': '#335267',
|
||||||
|
'TEXT_INPUT': '#acc2d0', 'SCROLL': '#1b6497', 'BUTTON': ('black', '#fafaf8'),
|
||||||
|
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
||||||
|
'PROGRESS_DEPTH': 0},
|
||||||
|
|
||||||
'Reds': {'BACKGROUND': '#280001', 'TEXT': 'white', 'INPUT': '#d8d584',
|
'Reds': {'BACKGROUND': '#280001', 'TEXT': 'white', 'INPUT': '#d8d584',
|
||||||
'TEXT_INPUT': 'black', 'SCROLL': '#763e00', 'BUTTON': ('black', '#daad28'),
|
'TEXT_INPUT': 'black', 'SCROLL': '#763e00', 'BUTTON': ('black', '#daad28'),
|
||||||
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
'PROGRESS': DEFAULT_PROGRESS_BAR_COLOR, 'BORDER': 1, 'SLIDER_DEPTH': 0,
|
||||||
|
|
Loading…
Reference in New Issue