Merge pull request #166 from MikeTheWatchGuy/Dev-latest

Dev latest
This commit is contained in:
MikeTheWatchGuy 2018-09-08 01:13:16 -04:00 committed by GitHub
commit fdd67f9be6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 11 deletions

View File

@ -1674,17 +1674,18 @@ def main():
list_of_colors = [c for c in colors] list_of_colors = [c for c in colors]
printable = '\n'.join(map(str, list_of_colors)) printable = '\n'.join(map(str, list_of_colors))
# show_all_colors_on_buttons() # show_all_colors_on_buttons()
sg.SetOptions(element_padding=(0,0))
while True: while True:
# ------- Form show ------- # # ------- Form show ------- #
layout = [[sg.Text('Find color')], layout = [[sg.Text('Find color')],
[sg.Text('Demonstration of colors')], [sg.Text('Demonstration of colors')],
[sg.Text('Enter a color name in text or hex #RRGGBB format')], [sg.Text('Enter a color name in text or hex #RRGGBB format')],
[sg.InputText()], [sg.InputText(key='hex')],
[sg.Listbox(list_of_colors, size=(20, 30)), sg.T('Or choose from list')], [sg.Listbox(list_of_colors, size=(20, 30), key='listbox'), sg.T('Or choose from list')],
[sg.Submit(), sg.Quit(), sg.SimpleButton('Show me lots of colors!', button_color=('white', '#0e6251'))], [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))]] # [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 ------- # # ------- OUTPUT results portion ------- #
if button == '' or button == 'Quit' or button is None: if button == '' or button == 'Quit' or button is None:
@ -1692,13 +1693,16 @@ def main():
elif button == 'Show me lots of colors!': elif button == 'Show me lots of colors!':
show_all_colors_on_buttons() 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] == '#': if hex_input is not '' and hex_input[0] == '#':
color_hex = hex_input.upper() color_hex = hex_input.upper()
color_name = get_name_from_hex(hex_input) color_name = get_name_from_hex(hex_input)
else: elif drop_down_value is not None:
color_name = drop_down_value color_name = drop_down_value[0]
color_hex = get_hex_from_name(color_name) color_hex = get_hex_from_name(color_name)
complementary_hex = get_complementary_hex(color_hex) complementary_hex = get_complementary_hex(color_hex)

View File

@ -14,10 +14,11 @@ def TableSimulation():
for i in range(20): 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.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) 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) form.Layout(layout)
while True: while True:

View File

@ -861,6 +861,7 @@ class Button(Element):
self.TKStringVar.set(file_name) self.TKStringVar.set(file_name)
elif self.BType == BUTTON_TYPE_COLOR_CHOOSER: elif self.BType == BUTTON_TYPE_COLOR_CHOOSER:
color = tk.colorchooser.askcolor() # show the 'get file' dialog box color = tk.colorchooser.askcolor() # show the 'get file' dialog box
color = color[1] # save only the #RRGGBB portion
strvar.set(color) strvar.set(color)
self.TKStringVar.set(color) self.TKStringVar.set(color)
elif self.BType == BUTTON_TYPE_BROWSE_FILES: elif self.BType == BUTTON_TYPE_BROWSE_FILES:
@ -2028,8 +2029,8 @@ def BuildResultsForSubform(form, initialize_only, top_level_form):
element.Type!= ELEM_TYPE_COLUMN: element.Type!= ELEM_TYPE_COLUMN:
AddToReturnList(form, value) AddToReturnList(form, value)
AddToReturnDictionary(top_level_form, element, value) AddToReturnDictionary(top_level_form, element, value)
elif (element.Type == ELEM_TYPE_BUTTON and element.BType == BUTTON_TYPE_CALENDAR_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) 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))): (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) AddToReturnList(form, value)
AddToReturnDictionary(top_level_form, element, 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 # ATTENTION: this applies the new style 'combostyle' to all ttk.Combobox
combostyle.theme_use('combostyle') combostyle.theme_use('combostyle')
element.TKCombo = ttk.Combobox(tk_row_frame, width=width, textvariable=element.TKStringVar,font=font ) 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['state']='readonly'
element.TKCombo['values'] = element.Values element.TKCombo['values'] = element.Values
if element.InitializeAsDisabled: if element.InitializeAsDisabled: