From 8712c09e0863a1b2436a68cf15256deed4aa8811 Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Sat, 8 Sep 2018 01:12:43 -0400 Subject: [PATCH] Added correct sizing to ComboBoxes - how height matches user requested height --- Demo_Table_Simulation.py | 5 +++-- PySimpleGUI.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Demo_Table_Simulation.py b/Demo_Table_Simulation.py index 66f208c6..a96ef955 100644 --- a/Demo_Table_Simulation.py +++ b/Demo_Table_Simulation.py @@ -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: diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 33368996..eb5d899f 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -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: