commit
fdd67f9be6
|
@ -1674,17 +1674,18 @@ def main():
|
|||
list_of_colors = [c for c in colors]
|
||||
printable = '\n'.join(map(str, list_of_colors))
|
||||
# show_all_colors_on_buttons()
|
||||
sg.SetOptions(element_padding=(0,0))
|
||||
while True:
|
||||
# ------- Form show ------- #
|
||||
layout = [[sg.Text('Find color')],
|
||||
[sg.Text('Demonstration of colors')],
|
||||
[sg.Text('Enter a color name in text or hex #RRGGBB format')],
|
||||
[sg.InputText()],
|
||||
[sg.Listbox(list_of_colors, size=(20, 30)), sg.T('Or choose from list')],
|
||||
[sg.Submit(), sg.Quit(), sg.SimpleButton('Show me lots of colors!', button_color=('white', '#0e6251'))],
|
||||
[sg.InputText(key='hex')],
|
||||
[sg.Listbox(list_of_colors, size=(20, 30), key='listbox'), sg.T('Or choose from list')],
|
||||
[sg.Submit(), sg.SimpleButton('Many buttons', button_color=('white', '#0e6251')), sg.ColorChooserButton( 'Chooser', target=(3,0)), sg.Quit(),],
|
||||
]
|
||||
# [g.Multiline(DefaultText=str(printable), Size=(30,20))]]
|
||||
(button, (hex_input, drop_down_value)) = sg.FlexForm('Color Demo', auto_size_text=True, icon=MY_WINDOW_ICON).LayoutAndRead(layout)
|
||||
button, values = sg.FlexForm('Color Demo', auto_size_buttons=False).LayoutAndRead(layout)
|
||||
|
||||
# ------- OUTPUT results portion ------- #
|
||||
if button == '' or button == 'Quit' or button is None:
|
||||
|
@ -1692,13 +1693,16 @@ def main():
|
|||
elif button == 'Show me lots of colors!':
|
||||
show_all_colors_on_buttons()
|
||||
|
||||
drop_down_value = drop_down_value[0]
|
||||
drop_down_value = values['listbox']
|
||||
hex_input = values['hex']
|
||||
if hex_input == '' and len(drop_down_value) == 0:
|
||||
continue
|
||||
|
||||
if hex_input is not '' and hex_input[0] == '#':
|
||||
color_hex = hex_input.upper()
|
||||
color_name = get_name_from_hex(hex_input)
|
||||
else:
|
||||
color_name = drop_down_value
|
||||
elif drop_down_value is not None:
|
||||
color_name = drop_down_value[0]
|
||||
color_hex = get_hex_from_name(color_name)
|
||||
|
||||
complementary_hex = get_complementary_hex(color_hex)
|
||||
|
|
|
@ -14,10 +14,11 @@ def TableSimulation():
|
|||
|
||||
for i in range(20):
|
||||
inputs = [sg.In('{}{}'.format(i,j), size=(8, 1), pad=(1, 1), justification='right', key=(i,j), do_not_clear=True) for j in range(10)]
|
||||
inputs = [sg.Combo(('Customer ID', 'Customer Name', 'Customer Info')), *inputs]
|
||||
line = [sg.Combo(('Customer ID', 'Customer Name', 'Customer Info'))]
|
||||
line.append(inputs)
|
||||
layout.append(inputs)
|
||||
|
||||
form = sg.FlexForm('Table', return_keyboard_events=True)
|
||||
form = sg.FlexForm('Table', return_keyboard_events=True, grab_anywhere=False)
|
||||
form.Layout(layout)
|
||||
|
||||
while True:
|
||||
|
|
|
@ -861,6 +861,7 @@ class Button(Element):
|
|||
self.TKStringVar.set(file_name)
|
||||
elif self.BType == BUTTON_TYPE_COLOR_CHOOSER:
|
||||
color = tk.colorchooser.askcolor() # show the 'get file' dialog box
|
||||
color = color[1] # save only the #RRGGBB portion
|
||||
strvar.set(color)
|
||||
self.TKStringVar.set(color)
|
||||
elif self.BType == BUTTON_TYPE_BROWSE_FILES:
|
||||
|
@ -2028,8 +2029,8 @@ def BuildResultsForSubform(form, initialize_only, top_level_form):
|
|||
element.Type!= ELEM_TYPE_COLUMN:
|
||||
AddToReturnList(form, value)
|
||||
AddToReturnDictionary(top_level_form, element, value)
|
||||
elif (element.Type == ELEM_TYPE_BUTTON and element.BType == BUTTON_TYPE_CALENDAR_CHOOSER) or \
|
||||
(element.Type == ELEM_TYPE_BUTTON and element.BType == BUTTON_TYPE_COLOR_CHOOSER) or \
|
||||
elif (element.Type == ELEM_TYPE_BUTTON and element.BType == BUTTON_TYPE_CALENDAR_CHOOSER and element.Target == (None,None)) or \
|
||||
(element.Type == ELEM_TYPE_BUTTON and element.BType == BUTTON_TYPE_COLOR_CHOOSER and element.Target == (None,None)) or \
|
||||
(element.Type == ELEM_TYPE_BUTTON and element.Key is not None and (element.BType in (BUTTON_TYPE_SAVEAS_FILE, BUTTON_TYPE_BROWSE_FILE, BUTTON_TYPE_BROWSE_FILES, BUTTON_TYPE_BROWSE_FOLDER))):
|
||||
AddToReturnList(form, value)
|
||||
AddToReturnDictionary(top_level_form, element, value)
|
||||
|
@ -2320,6 +2321,8 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
|
|||
# ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox
|
||||
combostyle.theme_use('combostyle')
|
||||
element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font )
|
||||
if element.Size[1] != 1 and element.Size[1] is not None:
|
||||
element.TKCombo.configure(height=element.Size[1])
|
||||
# element.TKCombo['state']='readonly'
|
||||
element.TKCombo['values'] = element.Values
|
||||
if element.InitializeAsDisabled:
|
||||
|
|
Loading…
Reference in New Issue