From 6d163bb085a74d114558ca25dff46f9646055695 Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Thu, 2 Jun 2022 17:17:05 -0400 Subject: [PATCH 1/2] Better error handling for newly added column justification feature for Table element. Explicitly checks for "center" now instead of assuming not left and not right means center --- PySimpleGUI.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index c350ea2a..f6dd46a3 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -version = __version__ = "4.60.0.21 Unreleased" +version = __version__ = "4.60.0.22 Unreleased" _change_log = """ Changelog since 4.60.0 released to PyPI on 8-May-2022 @@ -54,6 +54,8 @@ _change_log = """ Fix for bind_return_key - if a button has been disabled, then the event shouldn't be generated for the return key being pressed 4.60.0.21 Added cols_justification for Table element - list or tuple of strings that indicates how each column should be justified + 4.60.0.22 + Better error handling for table element's new justification list. If a bad value is found, will use the default value """ __version__ = version.split()[0] # For PEP 396 and PEP 345 @@ -16388,8 +16390,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form): col_anchor = tk.W elif element.cols_justification[i].startswith('r'): col_anchor = tk.E - else: + elif element.cols_justification[i].startswith('c'): col_anchor = tk.CENTER + else: + col_anchor = anchor + except: # likely didn't specify enough entries (must be one per col) col_anchor = anchor else: @@ -25066,4 +25071,4 @@ if __name__ == '__main__': exit(0) main() exit(0) -def get_signature(): return b"\x81\xbfU'\xa1*\x8f\xc3\x04\xb5i\xafE|m \xdcK\x08\xdf\x0f\xe9\xb7/\x9e\xadW\x03j\x82\x88\xa5\x81f\xfc\xe2/]u\xbd\x9e\x8d\xb3\xcc]\xa5>=y\xc8d\n\x184\xb3\x9f\x15\x1b^,\xdc\xa3\x8aH\x8ama#\xfc\xbb\x88\xf2\x8b\xd4\x05o'\xf1w$-t\xbb\xedj\x93\xc1C\xdb\xc9\xa9&\x00\xeef\xa2Xu[\x94\x8dA\x1ey\x83\x0f>\xfd\xec\xad\x9a\x83\xbf\x1c\x99\xd7\x80\xc9|@6\x08\xcf\r\x00\x05$1" \ No newline at end of file +def get_signature(): return b'\x1e\x94j\x0b\xe5Mi\xe0\x00$\x12s\x93\x88\xf7\x95K\xec\xa3\xcd\xaa\x84\x89M\xe9\xdbiQ2\x018_\xf34W\xfd\x0c\x98q\x12Q\x96\xc2\xa8\x12t\xd8\xc2\xf8\xf6Y\xc3\xd6\x7fYJ\x0eA\xd0\xf9\xb2pk\xa4\xce\x86\xa3A\xe3\xf4\xb4H\x0f(\xad\xfeD\xd0\x97p\x05\x06\xb0Wo\xbd\xc0,K\x01\xa5Z\x1e\xb3\xf5\x07V Date: Thu, 2 Jun 2022 17:17:54 -0400 Subject: [PATCH 2/2] Fixed "double" operation. Was including the header. Demonstrate that cols_justification can have illegal values --- DemoPrograms/Demo_Table_Element.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DemoPrograms/Demo_Table_Element.py b/DemoPrograms/Demo_Table_Element.py index 13d75ff8..8ec56c9e 100644 --- a/DemoPrograms/Demo_Table_Element.py +++ b/DemoPrograms/Demo_Table_Element.py @@ -30,9 +30,9 @@ headings = [str(data[0][x])+' ..' for x in range(len(data[0]))] # ------ Window Layout ------ layout = [[sg.Table(values=data[1:][:], headings=headings, max_col_width=25, auto_size_columns=True, - # cols_justification=('l','c','r','c', 'r', 'r'), # Added on GitHub only as of June 2022 + # cols_justification=('left','center','right','c', 'l', 'bad'), # Added on GitHub only as of June 2022 display_row_numbers=True, - justification='right', + justification='center', num_rows=20, alternating_row_color='lightblue', key='-TABLE-', @@ -62,9 +62,9 @@ while True: if event == sg.WIN_CLOSED: break if event == 'Double': - for i in range(len(data)): + for i in range(1,len(data)): data.append(data[i]) - window['-TABLE-'].update(values=data) + window['-TABLE-'].update(values=data[1:][:]) elif event == 'Change Colors': window['-TABLE-'].update(row_colors=((8, 'white', 'red'), (9, 'green')))