Skip to content

Commit

Permalink
Merge pull request #2505 from PySimpleGUI/Dev-latest
Browse files Browse the repository at this point in the history
All justification parameters can be shortned to 1 character, Fixed de…
  • Loading branch information
PySimpleGUI committed Jan 14, 2020
2 parents 09287af + 2d9c690 commit 75ec3f3
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions PySimpleGUI.py
@@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3


version = __version__ = "4.15.1.2 Unreleased - Fix for draw_pixel, fix Multline.update with no value specified" version = __version__ = "4.15.1.4 Unreleased - Fix for draw_pixel, fix Multline.update with no value specified, listbox update no longer selects a default, all justifications can be shortened to single letter, fix for debug window closed with Quit button"


port = 'PySimpleGUI' port = 'PySimpleGUI'


Expand Down Expand Up @@ -1352,7 +1352,7 @@ def Update(self, values=None, disabled=None, set_to_index=None, scroll_to_index=
self.TKListbox.delete(0, 'end') self.TKListbox.delete(0, 'end')
for item in values: for item in values:
self.TKListbox.insert(tk.END, item) self.TKListbox.insert(tk.END, item)
self.TKListbox.selection_set(0, 0) # self.TKListbox.selection_set(0, 0)
self.Values = values self.Values = values
if set_to_index is not None: if set_to_index is not None:
self.TKListbox.selection_clear(0, len(self.Values)) # clear all listbox selections self.TKListbox.selection_clear(0, len(self.Values)) # clear all listbox selections
Expand Down Expand Up @@ -2078,7 +2078,7 @@ def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], st
self.Count = None self.Count = None
self.PriorCount = 0 self.PriorCount = 0


if orientation[0].lower() == 'h': if orientation.lower().startswith('h'):
s = ttk.Style() s = ttk.Style()
s.theme_use(style) s.theme_use(style)
if BarColor != COLOR_SYSTEM_DEFAULT: if BarColor != COLOR_SYSTEM_DEFAULT:
Expand Down Expand Up @@ -8112,8 +8112,8 @@ def CharWidthInPixels():
justification = toplevel_form.TextJustification justification = toplevel_form.TextJustification
else: else:
justification = DEFAULT_TEXT_JUSTIFICATION justification = DEFAULT_TEXT_JUSTIFICATION
justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT justify = tk.LEFT if justification.startswith('l') else tk.CENTER if justification.startswith('c') else tk.RIGHT
anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE anchor = tk.NW if justification.startswith('l') else tk.N if justification.startswith('c') else tk.NE
tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width, tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width,
height=height, justify=justify, bd=bd, font=font) height=height, justify=justify, bd=bd, font=font)
# Set wrap-length for text (in PIXELS) == PAIN IN THE ASS # Set wrap-length for text (in PIXELS) == PAIN IN THE ASS
Expand Down Expand Up @@ -8418,7 +8418,7 @@ def CharWidthInPixels():
justification = element.Justification justification = element.Justification
else: else:
justification = DEFAULT_TEXT_JUSTIFICATION justification = DEFAULT_TEXT_JUSTIFICATION
justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT justify = tk.LEFT if justification.startswith('l') else tk.CENTER if justification.startswith('c') else tk.RIGHT
# anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE # anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE
element.TKEntry = element.Widget = tk.Entry(tk_row_frame, width=element_size[0], element.TKEntry = element.Widget = tk.Entry(tk_row_frame, width=element_size[0],
textvariable=element.TKStringVar, bd=bd, textvariable=element.TKStringVar, bd=bd,
Expand Down Expand Up @@ -9024,7 +9024,7 @@ def CharWidthInPixels():
slider_width = element_size[1] slider_width = element_size[1]
element.TKIntVar = tk.IntVar() element.TKIntVar = tk.IntVar()
element.TKIntVar.set(element.DefaultValue) element.TKIntVar.set(element.DefaultValue)
if element.Orientation[0] == 'v': if element.Orientation.startswith('v'):
range_from = element.Range[1] range_from = element.Range[1]
range_to = element.Range[0] range_to = element.Range[0]
slider_length += DEFAULT_MARGINS[1] * (element_size[0] * 2) # add in the padding slider_length += DEFAULT_MARGINS[1] * (element_size[0] * 2) # add in the padding
Expand Down Expand Up @@ -9071,9 +9071,9 @@ def CharWidthInPixels():
frame = tk.Frame(tk_row_frame) frame = tk.Frame(tk_row_frame)
element.table_frame = frame element.table_frame = frame
height = element.NumRows height = element.NumRows
if element.Justification == 'left': if element.Justification.startswith('l'):
anchor = tk.W anchor = tk.W
elif element.Justification == 'right': elif element.Justification.startswith('r'):
anchor = tk.E anchor = tk.E
else: else:
anchor = tk.CENTER anchor = tk.CENTER
Expand Down Expand Up @@ -9199,9 +9199,9 @@ def CharWidthInPixels():
frame = tk.Frame(tk_row_frame) frame = tk.Frame(tk_row_frame)


height = element.NumRows height = element.NumRows
if element.Justification == 'left': # justification if element.Justification.startswith('l'): # justification
anchor = tk.W anchor = tk.W
elif element.Justification == 'right': elif element.Justification.startswith('r'):
anchor = tk.E anchor = tk.E
else: else:
anchor = tk.CENTER anchor = tk.CENTER
Expand Down Expand Up @@ -9331,8 +9331,8 @@ def add_treeview_data(node):
justification = toplevel_form.TextJustification justification = toplevel_form.TextJustification
else: else:
justification = DEFAULT_TEXT_JUSTIFICATION justification = DEFAULT_TEXT_JUSTIFICATION
justify = tk.LEFT if justification == 'left' else tk.CENTER if justification == 'center' else tk.RIGHT justify = tk.LEFT if justification.startswith('l') else tk.CENTER if justification.startswith('c') else tk.RIGHT
anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE anchor = tk.NW if justification.startswith('l') else tk.N if justification.startswith('c') else tk.NE
# tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height, # tktext_label = tk.Label(tk_row_frame, textvariable=stringvar, width=width, height=height,
# justify=justify, bd=border_depth, font=font) # justify=justify, bd=border_depth, font=font)
tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width, tktext_label = element.Widget = tk.Label(tk_row_frame, textvariable=stringvar, width=width,
Expand Down Expand Up @@ -9827,14 +9827,12 @@ def __init__(self, size=(None, None), location=(None, None), font=None, no_title
if no_button: if no_button:
self.layout = [[self.output_element]] self.layout = [[self.output_element]]
else: else:
self.layout = [ self.layout = [ [self.output_element],
[self.output_element], [DummyButton('Quit'), Stretch()]]
[DummyButton('Quit'), Stretch()]
]


self.window = Window('Debug Window', self.layout, no_titlebar=no_titlebar, auto_size_text=True, location=location, self.window = Window('Debug Window', self.layout, no_titlebar=no_titlebar, auto_size_text=True, location=location,
font=font or ('Courier New', 10), grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, finalize=True) font=font or ('Courier New', 10), grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, finalize=False)

# self.window.NonBlocking = True # if finalizing this window, then need to uncommment this line
return return


def Print(self, *args, end=None, sep=None, text_color=None, background_color=None): def Print(self, *args, end=None, sep=None, text_color=None, background_color=None):
Expand All @@ -9858,6 +9856,8 @@ def Print(self, *args, end=None, sep=None, text_color=None, background_color=Non
self.__init__(size=self.size, location=self.location, font=self.font, no_titlebar=self.no_titlebar, self.__init__(size=self.size, location=self.location, font=self.font, no_titlebar=self.no_titlebar,
no_button=self.no_button, grab_anywhere=self.grab_anywhere, keep_on_top=self.keep_on_top, no_button=self.no_button, grab_anywhere=self.grab_anywhere, keep_on_top=self.keep_on_top,
do_not_reroute_stdout=self.do_not_reroute_stdout) do_not_reroute_stdout=self.do_not_reroute_stdout)
event, values = self.window.Read(timeout=0)
# print(f'Printing {ObjToStringSingleObj(self.output_element)}')
if self.do_not_reroute_stdout: if self.do_not_reroute_stdout:
outstring = '' outstring = ''
for arg in args: for arg in args:
Expand Down

0 comments on commit 75ec3f3

Please sign in to comment.