PySimpleGUI 6.0__py3-none-any.whl → 6.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@
37
37
  April 2026
38
38
 
39
39
  This release of PSG 6 contains most of the features that were in version 5. Some of the features
40
- that were removed include the maintance upgrades, online documenation, and other features that
40
+ that were removed include the maintenance upgrades, online documenation, and other features that
41
41
  relied on infrastructure that is no longer available. I'm planning on porting these back into
42
42
  version 6.
43
43
 
@@ -54,14 +54,14 @@
54
54
 
55
55
  """
56
56
 
57
- version = "6.0"
57
+ version = "6.2"
58
58
 
59
59
 
60
60
 
61
61
  """
62
62
  Changelog since last major release
63
63
 
64
- 6.0 5-Apr-2026 Initial release
64
+ 6.2 14-Jun-2026 released to GitHub
65
65
 
66
66
  """
67
67
 
@@ -702,6 +702,7 @@ ELEM_TYPE_BUTTONMENU = 'buttonmenu'
702
702
  ELEM_TYPE_TITLEBAR = 'titlebar'
703
703
  ELEM_TYPE_SIZEGRIP = 'sizegrip'
704
704
 
705
+
705
706
  # STRETCH == ERROR ELEMENT as a filler
706
707
 
707
708
  # ------------------------- Popup Buttons Types ------------------------- #
@@ -746,12 +747,12 @@ DEFAULT_TTK_PART_MAPPING_DICT = {TTK_SCROLLBAR_PART_TROUGH_COLOR: PSG_THEME_PART
746
747
  ttk_part_mapping_dict = copy.copy(DEFAULT_TTK_PART_MAPPING_DICT)
747
748
 
748
749
 
749
-
750
750
  # ------------------------- Web Destinations ------------------------- #
751
- URL_PRIVACY = r'http://privacy.PySimpleGUI.com'
752
- URL_TERMS = r'http://terms.PySimpleGUI.com'
753
751
  URL_HOME = r'http://home.PySimpleGUI.com'
754
752
  URL_DOCS = r'http://docs.PySimpleGUI.com'
753
+ URL_PSG_GITHUB_SOURCE = r'https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/refs/heads/master/PySimpleGUI/PySimpleGUI.py'
754
+ URL_PSG_GITHUB_SETUP_FILE = r'https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/refs/heads/master/setup.py'
755
+ URL_PSG_PIP_INSTALL_FROM_GITHUB = r'https://github.com/PySimpleGUI/PySimpleGUI/zipball/master'
755
756
 
756
757
 
757
758
  class TTKPartOverrides:
@@ -1229,7 +1230,7 @@ class Element:
1229
1230
  self.MenuItemChosen = item_chosen
1230
1231
  self.ParentForm.LastButtonClicked = self.MenuItemChosen
1231
1232
  self.ParentForm.FormRemainedOpen = True
1232
- _exit_mainloop(self.ParentForm)
1233
+ _exit_mainloop(self.ParentForm, self)
1233
1234
  # Window._window_that_exited = self.ParentForm
1234
1235
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
1235
1236
 
@@ -1323,7 +1324,7 @@ class Element:
1323
1324
  self.ParentForm.LastButtonClicked = alternative_to_key
1324
1325
  self.ParentForm.FormRemainedOpen = True
1325
1326
 
1326
- _exit_mainloop(self.ParentForm)
1327
+ _exit_mainloop(self.ParentForm, self)
1327
1328
  # if self.ParentForm.CurrentlyRunningMainloop:
1328
1329
  # Window._window_that_exited = self.ParentForm
1329
1330
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
@@ -3568,7 +3569,7 @@ class Spin(Element):
3568
3569
  else:
3569
3570
  self.ParentForm.LastButtonClicked = ''
3570
3571
  self.ParentForm.FormRemainedOpen = True
3571
- _exit_mainloop(self.ParentForm)
3572
+ _exit_mainloop(self.ParentForm, self)
3572
3573
  # if self.ParentForm.CurrentlyRunningMainloop:
3573
3574
  # Window._window_that_exited = self.ParentForm
3574
3575
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
@@ -3683,7 +3684,7 @@ class Multiline(Element):
3683
3684
  :type reroute_stderr: (bool)
3684
3685
  :param reroute_cprint: If True your cprint calls will output to this element. It's the same as you calling cprint_set_output_destination
3685
3686
  :type reroute_cprint: (bool)
3686
- :param echo_stdout_stderr: If True then output to stdout and stderr will be output to this element AND also to the normal console location
3687
+ :param echo_stdout_stderr: If True then output to stdout and stderr will be output to this element AND also to the normal sys.stdout location. Need to ALSO set reroute to True
3687
3688
  :type echo_stdout_stderr: (bool)
3688
3689
  :param focus: if True initial focus will go to this element
3689
3690
  :type focus: (bool)
@@ -3766,6 +3767,7 @@ class Multiline(Element):
3766
3767
  self.hscrollbar = None # The horizontal scrollbar
3767
3768
  self.auto_scroll_only_at_bottom = autoscroll_only_at_bottom
3768
3769
  sz = size if size != (None, None) else s
3770
+ self.images_for_print = [] # holds a reference for images so that tkinter will render them correctly
3769
3771
  if setting is not None:
3770
3772
  self.setting = str(setting)
3771
3773
  self.DefaultText = user_settings_get_entry(key, self.setting)
@@ -3776,7 +3778,7 @@ class Multiline(Element):
3776
3778
  return
3777
3779
 
3778
3780
  def update(self, value=None, disabled=None, append=False, font=None, text_color=None, background_color=None, text_color_for_value=None,
3779
- background_color_for_value=None, visible=None, autoscroll=None, justification=None, font_for_value=None):
3781
+ background_color_for_value=None, visible=None, autoscroll=None, justification=None, font_for_value=None, image=None, image_subsample=None):
3780
3782
  """
3781
3783
  Changes some of the settings for the Multiline Element. Must call `Window.read` or set finalize=True when creating window.
3782
3784
 
@@ -3810,6 +3812,10 @@ class Multiline(Element):
3810
3812
  :type justification: (str)
3811
3813
  :param font_for_value: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike for the value being updated
3812
3814
  :type font_for_value: str | (str, int)
3815
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
3816
+ :type image: (str | bytes)
3817
+ :param image_subsample: amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc
3818
+ :type image_subsample: (int)
3813
3819
  """
3814
3820
 
3815
3821
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
@@ -3835,6 +3841,7 @@ class Multiline(Element):
3835
3841
 
3836
3842
  starting_point = self.Widget.index(tk.INSERT)
3837
3843
  tag = None
3844
+ # First insert the text
3838
3845
  if value is not None:
3839
3846
  value = str(value)
3840
3847
  if background_color_for_value is not None or text_color_for_value is not None or font_for_value is not None:
@@ -3867,6 +3874,19 @@ class Multiline(Element):
3867
3874
  if self.Disabled:
3868
3875
  self.TKText.configure(state='disabled')
3869
3876
  self.DefaultText = value
3877
+ # Insert an image
3878
+ if image is not None:
3879
+ try:
3880
+ if isinstance(image, bytes):
3881
+ self.tkimage = tk.PhotoImage(data=image)
3882
+ elif isinstance(image, str):
3883
+ self.tkimage = tk.PhotoImage(file=image)
3884
+ if image_subsample is not None:
3885
+ self.tkimage = self.tkimage.subsample(image_subsample)
3886
+ self.images_for_print.append(self.tkimage)
3887
+ self.widget.image_create(tk.END, image=self.tkimage)
3888
+ except Exception as e:
3889
+ print("* Error updating multiline with an image *", e)
3870
3890
 
3871
3891
  # if self.Autoscroll:
3872
3892
  # self.TKText.see(tk.END)
@@ -3914,7 +3934,7 @@ class Multiline(Element):
3914
3934
  return value
3915
3935
 
3916
3936
  def print(self, *args, end=None, sep=None, text_color=None, background_color=None, justification=None, font=None, colors=None, t=None, b=None, c=None,
3917
- autoscroll=True):
3937
+ autoscroll=True, image=None, image_subsample=None):
3918
3938
  """
3919
3939
  Print like Python normally prints except route the output to a multiline element and also add colors if desired
3920
3940
 
@@ -3956,6 +3976,10 @@ class Multiline(Element):
3956
3976
  :type c: (str) or (str, str)
3957
3977
  :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
3958
3978
  :type autoscroll: (bool)
3979
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
3980
+ :type image: (str | bytes)
3981
+ :param image_subsample: amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc
3982
+ :type image_subsample: (int)
3959
3983
  """
3960
3984
 
3961
3985
  kw_text_color = text_color or t
@@ -3973,9 +3997,9 @@ class Multiline(Element):
3973
3997
  kw_text_color = dual_color
3974
3998
  except Exception as e:
3975
3999
  print('* multiline print warning * you messed up with color formatting', e)
3976
-
4000
+ # NOTE - this is NOT calling a method, it's calling a function outside of this object
3977
4001
  _print_to_element(self, *args, end=end, sep=sep, text_color=kw_text_color, background_color=kw_background_color, justification=justification,
3978
- autoscroll=autoscroll, font=font)
4002
+ autoscroll=autoscroll, font=font, image=image, image_subsample=image_subsample)
3979
4003
 
3980
4004
  def reroute_stdout_to_here(self):
3981
4005
  """
@@ -4015,16 +4039,13 @@ class Multiline(Element):
4015
4039
  :param txt: text of output
4016
4040
  :type txt: (str)
4017
4041
  """
4018
- try:
4019
- self.update(txt, append=True)
4020
- # if need to echo, then send the same text to the destinatoin that isn't thesame as this one
4021
- if self.echo_stdout_stderr:
4022
- if sys.stdout != self:
4023
- sys.stdout.write(txt)
4024
- elif sys.stderr != self:
4025
- sys.stderr.write(txt)
4026
- except:
4027
- pass
4042
+ self.update(txt, append=True)
4043
+ # if need to echo, then send the same text to the saved stdout and stderr
4044
+ if self.echo_stdout_stderr:
4045
+ if Window._original_stdout is not None:
4046
+ Window._original_stdout.write(txt)
4047
+ elif Window._original_stderr is not None:
4048
+ Window._original_stderr.write(txt)
4028
4049
 
4029
4050
  def flush(self):
4030
4051
  """
@@ -4406,6 +4427,8 @@ class Text(Element):
4406
4427
  :type c: (str) or (str, str)
4407
4428
  :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
4408
4429
  :type autoscroll: (bool)
4430
+ :param append: If True the contents of the element will automatically scroll as more data added to the end
4431
+ :type append: (bool)
4409
4432
  """
4410
4433
 
4411
4434
  kw_text_color = text_color or t
@@ -4963,7 +4986,7 @@ class Button(Element):
4963
4986
  # if self.ParentForm.CurrentlyRunningMainloop:
4964
4987
  # Window._window_that_exited = self.ParentForm
4965
4988
  # self.ParentForm.TKroot.quit() # kick out of loop if read was called
4966
- _exit_mainloop(self.ParentForm)
4989
+ _exit_mainloop(self.ParentForm, self)
4967
4990
 
4968
4991
  def _find_target(self):
4969
4992
  target = self.Target
@@ -5098,7 +5121,7 @@ class Button(Element):
5098
5121
  self.ParentForm.LastButtonClicked = self.ButtonText
5099
5122
  self.ParentForm.FormRemainedOpen = False
5100
5123
  self.ParentForm._Close()
5101
- _exit_mainloop(self.ParentForm)
5124
+ _exit_mainloop(self.ParentForm, self)
5102
5125
 
5103
5126
  if self.ParentForm.NonBlocking:
5104
5127
  self.ParentForm.TKroot.destroy()
@@ -5112,7 +5135,7 @@ class Button(Element):
5112
5135
  else:
5113
5136
  self.ParentForm.LastButtonClicked = self.ButtonText
5114
5137
  self.ParentForm.FormRemainedOpen = True
5115
- _exit_mainloop(self.ParentForm)
5138
+ _exit_mainloop(self.ParentForm, self)
5116
5139
  elif self.BType == BUTTON_TYPE_CLOSES_WIN_ONLY: # special kind of button that does not exit main loop
5117
5140
  self.ParentForm._Close(without_event=True)
5118
5141
  self.ParentForm.TKroot.destroy() # close the window with tkinter
@@ -5122,12 +5145,12 @@ class Button(Element):
5122
5145
  self.ParentForm.LastButtonClicked = self.Key # key should have been generated already if not set by user
5123
5146
  self.ParentForm.FormRemainedOpen = True
5124
5147
  should_submit_window = False
5125
- _exit_mainloop(self.ParentForm)
5148
+ _exit_mainloop(self.ParentForm, self)
5126
5149
 
5127
5150
  if should_submit_window:
5128
5151
  self.ParentForm.LastButtonClicked = target_element.Key
5129
5152
  self.ParentForm.FormRemainedOpen = True
5130
- _exit_mainloop(self.ParentForm)
5153
+ _exit_mainloop(self.ParentForm, self)
5131
5154
 
5132
5155
  return
5133
5156
 
@@ -5430,7 +5453,7 @@ class ButtonMenu(Element):
5430
5453
  self.ParentForm.FormRemainedOpen = True
5431
5454
  # if self.ParentForm.CurrentlyRunningMainloop:
5432
5455
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
5433
- _exit_mainloop(self.ParentForm)
5456
+ _exit_mainloop(self.ParentForm, self)
5434
5457
 
5435
5458
  def update(self, menu_definition=None, visible=None, image_source=None, image_size=(None, None), image_subsample=None, image_zoom=None, button_text=None, button_color=None):
5436
5459
  """
@@ -6773,7 +6796,7 @@ class Graph(Element):
6773
6796
  self.ParentForm.LastButtonClicked = self.Key
6774
6797
  else:
6775
6798
  self.ParentForm.LastButtonClicked = '__GRAPH__' # need to put something rather than None
6776
- _exit_mainloop(self.ParentForm)
6799
+ _exit_mainloop(self.ParentForm, self)
6777
6800
  if isinstance(self.ParentForm.LastButtonClicked, str):
6778
6801
  self.ParentForm.LastButtonClicked = self.ParentForm.LastButtonClicked + '+UP'
6779
6802
  else:
@@ -6797,7 +6820,7 @@ class Graph(Element):
6797
6820
  self.ParentForm.LastButtonClicked = '__GRAPH__' # need to put something rather than None
6798
6821
  # if self.ParentForm.CurrentlyRunningMainloop:
6799
6822
  # self.ParentForm.TKroot.quit() # kick out of loop if read was called
6800
- _exit_mainloop(self.ParentForm)
6823
+ _exit_mainloop(self.ParentForm, self)
6801
6824
  self.MouseButtonDown = True
6802
6825
 
6803
6826
  def _update_position_for_returned_values(self, event):
@@ -6844,7 +6867,7 @@ class Graph(Element):
6844
6867
  self.ParentForm.LastButtonClicked = self.ParentForm.LastButtonClicked + '+MOVE'
6845
6868
  else:
6846
6869
  self.ParentForm.LastButtonClicked = (self.ParentForm.LastButtonClicked, '+MOVE')
6847
- _exit_mainloop(self.ParentForm)
6870
+ _exit_mainloop(self.ParentForm, self)
6848
6871
 
6849
6872
  BringFigureToFront = bring_figure_to_front
6850
6873
  ButtonPressCallBack = button_press_call_back
@@ -6884,7 +6907,7 @@ class Frame(Element):
6884
6907
  """
6885
6908
 
6886
6909
  def __init__(self, title, layout, title_color=None, background_color=None, title_location=None,
6887
- relief=DEFAULT_FRAME_RELIEF, size=(None, None), s=(None, None), font=None, pad=None, p=None, border_width=None, key=None, k=None,
6910
+ relief=DEFAULT_FRAME_RELIEF, size=(None, None), s=(None, None), font=None, pad=None, p=None, border_width=None, border_width_no_relief=None, border_color=None, key=None, k=None,
6888
6911
  tooltip=None, right_click_menu=None, expand_x=False, expand_y=False, grab=None, visible=True, element_justification='left', vertical_alignment=None,
6889
6912
  metadata=None):
6890
6913
  """
@@ -6910,8 +6933,12 @@ class Frame(Element):
6910
6933
  :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
6911
6934
  :param p: Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used
6912
6935
  :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
6913
- :param border_width: width of border around element in pixels
6936
+ :param border_width: width of border around element in pixels (used with the frame's relief)
6914
6937
  :type border_width: (int)
6938
+ :param border_color: Custom color of the border around frame. Set by system if using a relief. Use border_width_no_relief with border_color to get a custom frame color. defaults to text elem color
6939
+ :type border_color: (str)
6940
+ :param border_width_no_relief: width of border around element in pixels. This is used without a relief. border_width should be 0 if this parm is non-zero
6941
+ :type border_width_no_relief: (int)
6915
6942
  :param key: Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
6916
6943
  :type key: str | int | tuple | object
6917
6944
  :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
@@ -6949,6 +6976,8 @@ class Frame(Element):
6949
6976
  self.Relief = relief
6950
6977
  self.TitleLocation = title_location
6951
6978
  self.BorderWidth = border_width
6979
+ self.BorderColor = border_color if border_color is not None else theme_text_color()
6980
+ self.BorderWidthNoRelief = border_width_no_relief
6952
6981
  self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
6953
6982
  self.RightClickMenu = right_click_menu
6954
6983
  self.ContainerElemementNumber = Window._GetAContainerNumber()
@@ -7967,7 +7996,7 @@ class Slider(Element):
7967
7996
  self.ParentForm.FormRemainedOpen = True
7968
7997
  # if self.ParentForm.CurrentlyRunningMainloop:
7969
7998
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
7970
- _exit_mainloop(self.ParentForm)
7999
+ _exit_mainloop(self.ParentForm, self)
7971
8000
 
7972
8001
  Update = update
7973
8002
 
@@ -8016,7 +8045,7 @@ class TkScrollableFrame(tk.Frame):
8016
8045
  A frame with one or two scrollbars. Used to make Columns with scrollbars
8017
8046
  """
8018
8047
 
8019
- def __init__(self, master, vertical_only, element, window, **kwargs):
8048
+ def __init__(self, master, vertical_only, horizontal_only, element, window, **kwargs):
8020
8049
  """
8021
8050
  :param master: The parent widget
8022
8051
  :type master: (tk.Widget)
@@ -8032,26 +8061,23 @@ class TkScrollableFrame(tk.Frame):
8032
8061
  element.Widget = self.canvas
8033
8062
  # Okay, we're gonna make a list. Containing the y-min, x-min, y-max, and x-max of the frame
8034
8063
  element.element_frame = self
8035
- _make_ttk_scrollbar(element, 'v', window)
8036
- # element.vsb = tk.Scrollbar(self, orient=tk.VERTICAL)
8037
- element.vsb.pack(side='right', fill="y", expand="false")
8064
+ if not horizontal_only:
8065
+ _make_ttk_scrollbar(element, 'v', window)
8066
+ element.vsb.pack(side='right', fill="y", expand="false")
8067
+ self.canvas.config(yscrollcommand=element.vsb.set)
8038
8068
 
8039
8069
  if not vertical_only:
8040
8070
  _make_ttk_scrollbar(element, 'h', window)
8041
- # self.hscrollbar = tk.Scrollbar(self, orient=tk.HORIZONTAL)
8042
8071
  element.hsb.pack(side='bottom', fill="x", expand="false")
8043
8072
  self.canvas.config(xscrollcommand=element.hsb.set)
8044
- # self.canvas = tk.Canvas(self, )
8045
- # else:
8046
- # self.canvas = tk.Canvas(self)
8047
8073
 
8048
- self.canvas.config(yscrollcommand=element.vsb.set)
8049
8074
  self.canvas.pack(side="left", fill="both", expand=True)
8050
- # element.vsb.config(command=self.canvas.yview)
8051
- element.vsb.config(command=self.yview_override)
8075
+
8052
8076
  if not vertical_only:
8053
- # element.hsb.config(command=self.canvas.xview)
8054
8077
  element.hsb.config(command=self.xview_override)
8078
+ if not horizontal_only:
8079
+ element.vsb.config(command=self.yview_override)
8080
+
8055
8081
 
8056
8082
  # reset the view
8057
8083
  self.canvas.xview_moveto(0)
@@ -8147,7 +8173,7 @@ class Column(Element):
8147
8173
  """
8148
8174
 
8149
8175
  def __init__(self, layout, background_color=None, size=(None, None), s=(None, None), size_subsample_width=1, size_subsample_height=2, pad=None, p=None, scrollable=False,
8150
- vertical_scroll_only=False, right_click_menu=None, key=None, k=None, visible=True, justification=None, element_justification=None,
8176
+ vertical_scroll_only=False, horizontal_scroll_only=False, right_click_menu=None, key=None, k=None, visible=True, justification=None, element_justification=None,
8151
8177
  vertical_alignment=None, grab=None, expand_x=None, expand_y=None, metadata=None,
8152
8178
  sbar_trough_color=None, sbar_background_color=None, sbar_arrow_color=None, sbar_width=None, sbar_arrow_width=None,
8153
8179
  sbar_frame_color=None, sbar_relief=None):
@@ -8172,6 +8198,8 @@ class Column(Element):
8172
8198
  :type scrollable: (bool)
8173
8199
  :param vertical_scroll_only: if True then no horizontal scrollbar will be shown if a scrollable column
8174
8200
  :type vertical_scroll_only: (bool)
8201
+ :param horizontal_scroll_only: if True then no verticale scrollbar will be shown if a scrollable column
8202
+ :type horizontal_scroll_only: (bool)
8175
8203
  :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
8176
8204
  :type right_click_menu: List[List[ List[str] | str ]]
8177
8205
  :param key: Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
@@ -8222,6 +8250,7 @@ class Column(Element):
8222
8250
  self.TKColFrame = None # type: tk.Frame
8223
8251
  self.Scrollable = scrollable
8224
8252
  self.VerticalScrollOnly = vertical_scroll_only
8253
+ self.HorizontalScrollOnly = horizontal_scroll_only
8225
8254
 
8226
8255
  self.RightClickMenu = right_click_menu
8227
8256
  bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
@@ -8587,7 +8616,7 @@ class Menu(Element):
8587
8616
  self.ParentForm.FormRemainedOpen = True
8588
8617
  # if self.ParentForm.CurrentlyRunningMainloop:
8589
8618
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
8590
- _exit_mainloop(self.ParentForm)
8619
+ _exit_mainloop(self.ParentForm, self)
8591
8620
 
8592
8621
  def update(self, menu_definition=None, visible=None):
8593
8622
  """
@@ -8975,7 +9004,7 @@ class Table(Element):
8975
9004
  self.ParentForm.FormRemainedOpen = True
8976
9005
  # if self.ParentForm.CurrentlyRunningMainloop:
8977
9006
  # self.ParentForm.TKroot.quit()
8978
- _exit_mainloop(self.ParentForm)
9007
+ _exit_mainloop(self.ParentForm, self)
8979
9008
 
8980
9009
  def _treeview_double_click(self, event):
8981
9010
  """
@@ -9005,7 +9034,7 @@ class Table(Element):
9005
9034
  else:
9006
9035
  self.ParentForm.LastButtonClicked = ''
9007
9036
  self.ParentForm.FormRemainedOpen = True
9008
- _exit_mainloop(self.ParentForm)
9037
+ _exit_mainloop(self.ParentForm, self)
9009
9038
 
9010
9039
  def on_escape(table, widget, event, item, column, value_type):
9011
9040
  if widget.entry:
@@ -9051,7 +9080,7 @@ class Table(Element):
9051
9080
  else:
9052
9081
  self.ParentForm.LastButtonClicked = ''
9053
9082
  self.ParentForm.FormRemainedOpen = True
9054
- _exit_mainloop(self.ParentForm)
9083
+ _exit_mainloop(self.ParentForm, self)
9055
9084
 
9056
9085
  def _table_clicked(self, event):
9057
9086
  """
@@ -9106,7 +9135,7 @@ class Table(Element):
9106
9135
  else:
9107
9136
  self.ParentForm.LastButtonClicked = ''
9108
9137
  self.ParentForm.FormRemainedOpen = True
9109
- _exit_mainloop(self.ParentForm)
9138
+ _exit_mainloop(self.ParentForm, self)
9110
9139
 
9111
9140
 
9112
9141
  def disable_edit_for_cells(self, list_of_cells_to_disable=None):
@@ -9352,7 +9381,7 @@ class Tree(Element):
9352
9381
  self.ParentForm.FormRemainedOpen = True
9353
9382
  # if self.ParentForm.CurrentlyRunningMainloop:
9354
9383
  # self.ParentForm.TKroot.quit()
9355
- _exit_mainloop(self.ParentForm)
9384
+ _exit_mainloop(self.ParentForm, self)
9356
9385
 
9357
9386
  def add_treeview_data(self, node):
9358
9387
  """
@@ -9389,7 +9418,7 @@ class Tree(Element):
9389
9418
  for node in node.children:
9390
9419
  self.add_treeview_data(node)
9391
9420
 
9392
- def update(self, values=None, key=None, value=None, text=None, icon=None, visible=None, expand_node=None):
9421
+ def update(self, values=None, key=None, value=None, text=None, icon=None, visible=None, expand_node=None, select_node_keys=None):
9393
9422
  """
9394
9423
  Changes some of the settings for the Tree Element. Must call `Window.Read` or `Window.Finalize` prior
9395
9424
 
@@ -9413,6 +9442,8 @@ class Tree(Element):
9413
9442
  :type visible: (bool)
9414
9443
  :param expand_node: if True the node specified by key parameter will be expanded
9415
9444
  :type expand_node: (bool)
9445
+ :param select_node_keys: List of nodes to select as if user selected. You'll want to use Extended mode + control key to navigate to retain selection
9446
+ :type select_node_keys: List[str | int | tuple | object]
9416
9447
  """
9417
9448
 
9418
9449
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
@@ -9459,6 +9490,20 @@ class Tree(Element):
9459
9490
  except:
9460
9491
  pass
9461
9492
  # item = self.TKTreeview.item(id)
9493
+ if select_node_keys is not None:
9494
+ select_node_ids = []
9495
+ try:
9496
+ for node_key in select_node_keys:
9497
+ node_id = self.KeyToID.get(node_key, None)
9498
+ if node_id is None:
9499
+ print(f'Node key {node_key} not found in Tree.update')
9500
+ else:
9501
+ select_node_ids.append(node_id)
9502
+ self.TKTreeview.selection_set(select_node_ids)
9503
+ except Exception as e:
9504
+ _error_popup_with_traceback('Error trying to select nodes in Tree.update', e)
9505
+
9506
+
9462
9507
  if visible is False:
9463
9508
  self._pack_forget_save_settings(self.element_frame)
9464
9509
  elif visible is True:
@@ -9666,7 +9711,7 @@ VP = VPush
9666
9711
  class _TimerPeriodic:
9667
9712
  id_counter = 1
9668
9713
  # Dictionary containing the active timers. Format is {id : _TimerPeriodic object}
9669
- active_timers = {} # type: dict[int:_TimerPeriodic]
9714
+ active_timers = {} # type: dict[int , _TimerPeriodic]
9670
9715
 
9671
9716
  def __init__(self, window, frequency_ms, key=EVENT_TIMER, repeating=True):
9672
9717
  """
@@ -9770,7 +9815,7 @@ class Window:
9770
9815
  _user_defined_icon = None
9771
9816
  hidden_master_root = None # type: tk.Tk
9772
9817
  _animated_popup_dict = {} # type: Dict
9773
- _active_windows = {} # type: Dict[Window, tk.Tk()]
9818
+ _active_windows = {} # type: Dict[Window, tk.Tk]
9774
9819
  _move_all_windows = False # if one window moved, they will move
9775
9820
  _window_that_exited = None # type: Window
9776
9821
  _root_running_mainloop = None # type: tk.Tk() # (may be the hidden root or a window's root)
@@ -9982,6 +10027,7 @@ class Window:
9982
10027
  self.DictionaryKeyCounter = 0
9983
10028
  self.LastButtonClicked = None
9984
10029
  self.LastButtonClickedWasRealtime = False
10030
+ self.element_that_generated_event = None # type:Element
9985
10031
  self.UseDictionary = False
9986
10032
  self.UseDefaultFocus = use_default_focus
9987
10033
  self.ReturnKeyboardEvents = return_keyboard_events
@@ -10544,7 +10590,7 @@ class Window:
10544
10590
  if no other GUI events happen first.
10545
10591
 
10546
10592
  :param timeout: Milliseconds to wait until the Read will return IF no other GUI events happen first
10547
- :type timeout: int|None
10593
+ :type timeout: int | None
10548
10594
  :param timeout_key: The value that will be returned from the call if the timer expired
10549
10595
  :type timeout_key: (Any)
10550
10596
  :param close: if True the window will be closed prior to returning
@@ -11095,12 +11141,17 @@ class Window:
11095
11141
  def settings_save(self, values):
11096
11142
  """
11097
11143
  Saves settings to settings file using the values dictionary that is passed in.
11098
-
11144
+ If all of the values in the dictionary are None, then it will not be saved
11099
11145
  :param values: Dictionary of values to potentially save
11100
11146
  :type values: (Dict)
11101
11147
  """
11102
11148
  if values is None: # sometimes users may accidently pass in None, so just ignore it
11103
11149
  return
11150
+ # if all values in the value dictionary are None, then assume the windows was closed
11151
+ # and no values should be saved
11152
+ if all(v is None for v in values.values()):
11153
+ return
11154
+
11104
11155
  for key, value in values.items():
11105
11156
  try:
11106
11157
  element = self.find_element(key)
@@ -11365,7 +11416,7 @@ class Window:
11365
11416
  self.LastButtonClicked = WINDOW_CONFIG_EVENT
11366
11417
  self.FormRemainedOpen = True
11367
11418
  self.user_bind_event = event
11368
- _exit_mainloop(self)
11419
+ _exit_mainloop(self, None)
11369
11420
 
11370
11421
  def _move_callback(self, event):
11371
11422
  """
@@ -11449,7 +11500,7 @@ class Window:
11449
11500
  self.LastKeyboardEvent = str(event.keysym) + ':' + str(event.keycode)
11450
11501
  # if not self.NonBlocking:
11451
11502
  # _BuildResults(self, False, self)
11452
- _exit_mainloop(self)
11503
+ _exit_mainloop(self, None)
11453
11504
 
11454
11505
  def _MouseWheelCallback(self, event):
11455
11506
  """
@@ -11464,7 +11515,7 @@ class Window:
11464
11515
  self.LastKeyboardEvent = 'MouseWheel:Down' if event.delta < 0 or event.num == 5 else 'MouseWheel:Up'
11465
11516
  # if not self.NonBlocking:
11466
11517
  # _BuildResults(self, False, self)
11467
- _exit_mainloop(self)
11518
+ _exit_mainloop(self, None)
11468
11519
 
11469
11520
  @property
11470
11521
  def right_click_menu_element(self):
@@ -11586,7 +11637,7 @@ class Window:
11586
11637
  return
11587
11638
  self._auto_save_location()
11588
11639
  if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!
11589
- _exit_mainloop(self)
11640
+ _exit_mainloop(self, None)
11590
11641
  if self.close_destroys_window:
11591
11642
  self.TKroot.destroy() # destroy this window
11592
11643
  self.TKrootDestroyed = True
@@ -11594,7 +11645,7 @@ class Window:
11594
11645
  else:
11595
11646
  self.LastButtonClicked = WINDOW_CLOSE_ATTEMPTED_EVENT
11596
11647
  elif Window._root_running_mainloop == Window.hidden_master_root:
11597
- _exit_mainloop(self)
11648
+ _exit_mainloop(self, None)
11598
11649
  else:
11599
11650
  if self.close_destroys_window:
11600
11651
  self.TKroot.destroy() # destroy this window
@@ -11778,7 +11829,7 @@ class Window:
11778
11829
  :param without_titlebar: If True, return location of top left of main window area without the titlebar (may be OS dependent?)
11779
11830
  :type without_titlebar: (bool)
11780
11831
  :return: The x and y location in tuple form (x,y)
11781
- :rtype: Tuple[(int | None), (int | None)]
11832
+ :rtype: Tuple[int, int] | Tuple[None, None]
11782
11833
  """
11783
11834
 
11784
11835
  if not self._is_window_created('tried Window.current_location'):
@@ -11969,7 +12020,7 @@ class Window:
11969
12020
  self.FormRemainedOpen = True
11970
12021
  # if self.CurrentlyRunningMainloop:
11971
12022
  # self.TKroot.quit()
11972
- _exit_mainloop(self)
12023
+ _exit_mainloop(self, None)
11973
12024
  return 'break' if propagate is not True else None
11974
12025
 
11975
12026
  def bind(self, bind_string, key, propagate=True):
@@ -12163,7 +12214,7 @@ class Window:
12163
12214
 
12164
12215
  if self._queued_thread_event_available():
12165
12216
  self.FormRemainedOpen = True
12166
- _exit_mainloop(self)
12217
+ _exit_mainloop(self, None)
12167
12218
 
12168
12219
  def _create_thread_queue(self):
12169
12220
  """
@@ -12446,22 +12497,49 @@ class Window:
12446
12497
  if not self.DisableClose:
12447
12498
  self._OnClosingCallback()
12448
12499
 
12500
+ def _parse_h_m_s(self, h_m_s):
12501
+ """
12502
+ Parses Hour:Minute:Seconds string into an int tuple (hour, min, sec)
12503
+
12504
+ :param h_m_s: If True then repeat timer events until timer is explicitly stopped
12505
+ :type h_m_s: str
12506
+ :return: Timer ID for the timer or None if error
12507
+ :rtype: Tuple(int, int, int) | Tuple(None, None, None)
12508
+ """
12509
+
12510
+ try:
12511
+ hours, minutes, seconds = map(int, h_m_s.split(":"))
12512
+ except:
12513
+ return None, None, None
12514
+ return hours, minutes, seconds
12515
+
12516
+
12449
12517
  def timer_start(self, frequency_ms, key=EVENT_TIMER, repeating=True):
12450
12518
  """
12451
- Starts a timer that gnerates Timer Events. The default is to repeat the timer events until timer is stopped.
12519
+ Starts a timer that gnerates Timer Events.
12520
+ Time can be specified as an integer number of milliseconds or a string format "H:M:S"
12521
+ The default is to repeat the timer events until timer is stopped.
12452
12522
  You can provide your own key or a default key will be used. The default key is defined
12453
12523
  with the constants EVENT_TIMER or TIMER_KEY. They both equal the same value.
12454
12524
  The values dictionary will contain the timer ID that is returned from this function.
12455
12525
 
12456
- :param frequency_ms: How often to generate timer events in milliseconds
12457
- :type frequency_ms: int
12526
+ :param frequency_ms: How often to generate timer events in milliseconds or a string "HH:MM:SS". HH, MM, SS each can be any length of chars
12527
+ :type frequency_ms: None | int | str
12458
12528
  :param key: Key to be returned as the timer event
12459
12529
  :type key: str | int | tuple | object
12460
12530
  :param repeating: If True then repeat timer events until timer is explicitly stopped
12461
12531
  :type repeating: bool
12462
- :return: Timer ID for the timer
12463
- :rtype: int
12532
+ :return: Timer ID for the timer or None if error
12533
+ :rtype: int | None
12464
12534
  """
12535
+ if isinstance(frequency_ms, str):
12536
+ try:
12537
+ hour, min, sec = self._parse_h_m_s(frequency_ms)
12538
+ frequency_ms = (hour * 3600 + min * 60 + sec) * 1000
12539
+ except Exception as e:
12540
+ popup_error_with_traceback('Error in H:M:S string', f'Error in H:M:S string = {frequency_ms}', e)
12541
+ return None
12542
+
12465
12543
  timer = _TimerPeriodic(self, frequency_ms=frequency_ms, key=key, repeating=repeating)
12466
12544
  return timer.id
12467
12545
 
@@ -12523,7 +12601,7 @@ class Window:
12523
12601
  :param key: The key to find
12524
12602
  :type key: str | int | tuple | object
12525
12603
  :return: The element found
12526
- :rtype: Element | Input | Combo | OptionMenu | Listbox | Radio | Checkbox | Spin | Multiline | Text | StatusBar | Output | Button | ButtonMenu | ProgressBar | Image | Canvas | Graph | Frame | VerticalSeparator | HorizontalSeparator | Tab | TabGroup | Slider | Column | Pane | Menu | Table | Tree | ErrorElement | None
12604
+ :rtype: Element
12527
12605
  """
12528
12606
 
12529
12607
  return self.find_element(key)
@@ -12606,6 +12684,7 @@ class Window:
12606
12684
  FlexForm = Window
12607
12685
 
12608
12686
 
12687
+
12609
12688
  def _long_func_thread(window, end_key, original_func):
12610
12689
  """
12611
12690
  Used to run long operations on the user's behalf. Called by the window object
@@ -12623,8 +12702,16 @@ def _long_func_thread(window, end_key, original_func):
12623
12702
  window.write_event_value(end_key, return_value)
12624
12703
 
12625
12704
 
12626
- def _exit_mainloop(exiting_window):
12705
+ def _exit_mainloop(exiting_window, element_causing_event):
12706
+ """
12707
+ Used to break out of the tkinter mainloop. Elements can call this to cause a Window.read function to return to use
12708
+ :param exiting_window: The window that wants to exit
12709
+ :type exiting_window: (Window)
12710
+ :param element_causing_event: Element that's causing the exit. Will be None if not an element that's causing it (could be the window itself)
12711
+ :type element_causing_event: (Element|None)
12712
+ """
12627
12713
  if exiting_window == Window._window_running_mainloop or Window._root_running_mainloop == Window.hidden_master_root:
12714
+ exiting_window.element_that_generated_event = element_causing_event
12628
12715
  Window._window_that_exited = exiting_window
12629
12716
  if Window._root_running_mainloop is not None:
12630
12717
  Window._root_running_mainloop.quit()
@@ -14897,7 +14984,8 @@ def _BuildResultsForSubform(form, initialize_only, top_level_form):
14897
14984
  except:
14898
14985
  value = ''
14899
14986
  if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents:
14900
- element.TKStringVar.set('')
14987
+ if top_level_form.element_that_generated_event is not None and top_level_form.element_that_generated_event.BType != BUTTON_TYPE_CALENDAR_CHOOSER:
14988
+ element.TKStringVar.set('')
14901
14989
  elif element.Type == ELEM_TYPE_INPUT_CHECKBOX:
14902
14990
  value = element.TKIntVar.get()
14903
14991
  value = (value != 0)
@@ -14959,7 +15047,8 @@ def _BuildResultsForSubform(form, initialize_only, top_level_form):
14959
15047
  if element.rstrip:
14960
15048
  value = value.rstrip()
14961
15049
  if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents:
14962
- element.TKText.delete('1.0', tk.END)
15050
+ if top_level_form.element_that_generated_event is not None and top_level_form.element_that_generated_event.BType != BUTTON_TYPE_CALENDAR_CHOOSER:
15051
+ element.TKText.delete('1.0', tk.END)
14963
15052
  except:
14964
15053
  value = None
14965
15054
  elif element.Type == ELEM_TYPE_TAB_GROUP:
@@ -14977,6 +15066,9 @@ def _BuildResultsForSubform(form, initialize_only, top_level_form):
14977
15066
  value = element.SelectedRows
14978
15067
  elif element.Type == ELEM_TYPE_GRAPH:
14979
15068
  value = element.ClickPosition
15069
+ if top_level_form.element_that_generated_event == element:
15070
+ top_level_form.LastButtonClickedWasRealtime = False
15071
+ top_level_form.element_that_generated_event = None
14980
15072
  elif element.Type == ELEM_TYPE_MENUBAR:
14981
15073
  if element.MenuItemChosen is not None:
14982
15074
  event = top_level_form.LastButtonClicked = element.MenuItemChosen
@@ -15722,12 +15814,17 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
15722
15814
  element = element # type: Column
15723
15815
  # ----------------------- SCROLLABLE Column ----------------------
15724
15816
  if element.Scrollable:
15725
- element.Widget = element.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly, element, toplevel_form) # do not use yet! not working
15817
+ element.Widget = element.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly, element.HorizontalScrollOnly, element, toplevel_form) # do not use yet! not working
15726
15818
  PackFormIntoFrame(element, element.TKColFrame.TKFrame, toplevel_form)
15727
15819
  element.TKColFrame.TKFrame.update()
15728
15820
  if element.Size == (None, None): # if no size specified, use column width x column height/2
15729
- element.TKColFrame.canvas.config(width=element.TKColFrame.TKFrame.winfo_reqwidth() // element.size_subsample_width,
15730
- height=element.TKColFrame.TKFrame.winfo_reqheight() // element.size_subsample_height)
15821
+ width = element.TKColFrame.TKFrame.winfo_reqwidth()
15822
+ if element.HorizontalScrollOnly:
15823
+ width = width // element.size_subsample_width
15824
+ height = element.TKColFrame.TKFrame.winfo_reqheight()
15825
+ if element.VerticalScrollOnly:
15826
+ height = height // element.size_subsample_height
15827
+ element.TKColFrame.canvas.config(width=width, height=height)
15731
15828
  else:
15732
15829
  element.TKColFrame.canvas.config(width=element.TKColFrame.TKFrame.winfo_reqwidth() // element.size_subsample_width,
15733
15830
  height=element.TKColFrame.TKFrame.winfo_reqheight() // element.size_subsample_height)
@@ -16985,17 +17082,21 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16985
17082
  element._pack_forget_save_settings()
16986
17083
  # labeled_frame.pack_forget()
16987
17084
  if element.BackgroundColor != COLOR_SYSTEM_DEFAULT and element.BackgroundColor is not None:
16988
- labeled_frame.configure(background=element.BackgroundColor,
16989
- highlightbackground=element.BackgroundColor,
16990
- highlightcolor=element.BackgroundColor)
17085
+ labeled_frame.configure(background=element.BackgroundColor)
17086
+ if element.BorderColor != COLOR_SYSTEM_DEFAULT and element.BorderColor is not None:
17087
+ labeled_frame.configure( highlightcolor=element.BorderColor, highlightbackground=element.BorderColor)
17088
+ if element.BorderWidthNoRelief is not None:
17089
+ labeled_frame.configure(highlightthickness=element.BorderWidthNoRelief)
16991
17090
  if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None:
16992
17091
  labeled_frame.configure(foreground=element.TextColor)
16993
17092
  if font is not None:
16994
17093
  labeled_frame.configure(font=font)
16995
17094
  if element.TitleLocation is not None:
16996
17095
  labeled_frame.configure(labelanchor=element.TitleLocation)
16997
- if element.BorderWidth is not None:
17096
+ if element.BorderWidth is not None and element.BorderWidthNoRelief is None:
16998
17097
  labeled_frame.configure(borderwidth=element.BorderWidth)
17098
+ if element.BorderWidthNoRelief: # if a non-zero no-relief border width, force borderwidth to zero
17099
+ labeled_frame.configure(borderwidth=0)
16999
17100
  if element.Tooltip is not None:
17000
17101
  element.TooltipObject = ToolTip(labeled_frame, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17001
17102
  _add_right_click_menu_and_grab(element)
@@ -18445,7 +18546,7 @@ def cprint_set_output_destination(window, multiline_key):
18445
18546
 
18446
18547
 
18447
18548
  def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, background_color=None, b=None, colors=None, c=None, window=None, key=None,
18448
- justification=None, autoscroll=True, erase_all=False):
18549
+ justification=None, autoscroll=True, image=None, image_subsample=None, erase_all=False):
18449
18550
  """
18450
18551
  Color print to a multiline element in a window of your choice.
18451
18552
  Must have EITHER called cprint_set_output_destination prior to making this call so that the
@@ -18502,6 +18603,10 @@ def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, backgro
18502
18603
  :type justification: (str)
18503
18604
  :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
18504
18605
  :type autoscroll: (bool)
18606
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
18607
+ :type image: (str | bytes)
18608
+ :param image_subsample: amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc
18609
+ :type image_subsample: (int)
18505
18610
  :param erase_all If True the contents of the element will be cleared before printing happens
18506
18611
  :type erase_all (bool)
18507
18612
  """
@@ -18539,11 +18644,11 @@ def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, backgro
18539
18644
  mline.update('')
18540
18645
  if end is None:
18541
18646
  mline.print(*args, text_color=kw_text_color, background_color=kw_background_color, end='', sep=sep, justification=justification, font=font,
18542
- autoscroll=autoscroll)
18647
+ autoscroll=autoscroll, image=image, image_subsample=image_subsample)
18543
18648
  mline.print('', justification=justification, autoscroll=autoscroll)
18544
18649
  else:
18545
18650
  mline.print(*args, text_color=kw_text_color, background_color=kw_background_color, end=end, sep=sep, justification=justification, font=font,
18546
- autoscroll=autoscroll)
18651
+ autoscroll=autoscroll, image=image, image_subsample=image_subsample)
18547
18652
  except Exception as e:
18548
18653
  print('** cprint error trying to print to the multiline. Printing to console instead **', e)
18549
18654
  print(*args, end=end, sep=sep)
@@ -18553,7 +18658,7 @@ def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, backgro
18553
18658
  # A print-like call that can be used to output to a multiline element as if it's an Output element #
18554
18659
  # ------------------------------------------------------------------------------------------------ #
18555
18660
 
18556
- def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=None, background_color=None, autoscroll=None, justification=None, font=None):
18661
+ def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=None, background_color=None, autoscroll=None, justification=None, font=None, image=None, image_subsample=None):
18557
18662
  """
18558
18663
  Print like Python normally prints except route the output to a multiline element and also add colors if desired
18559
18664
 
@@ -18573,6 +18678,10 @@ def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=N
18573
18678
  :type autoscroll: (bool)
18574
18679
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike for the value being updated
18575
18680
  :type font: str | (str, int)
18681
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
18682
+ :type image: (str | bytes)
18683
+ :param image_subsample: amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc
18684
+ :type image_subsample: (int)
18576
18685
  """
18577
18686
  end_str = str(end) if end is not None else '\n'
18578
18687
  sep_str = str(sep) if sep is not None else ' '
@@ -18586,7 +18695,7 @@ def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=N
18586
18695
  outstring += end_str
18587
18696
 
18588
18697
  multiline_element.update(outstring, append=True, text_color_for_value=text_color, background_color_for_value=background_color, autoscroll=autoscroll,
18589
- justification=justification, font_for_value=font)
18698
+ justification=justification, font_for_value=font, image=image, image_subsample=image_subsample)
18590
18699
 
18591
18700
  try: # if the element is set to autorefresh, then refresh the parent window
18592
18701
  if multiline_element.AutoRefresh:
@@ -24719,34 +24828,119 @@ def __show_package_version(package, print_function, interpreter):
24719
24828
 
24720
24829
 
24721
24830
  '''
24722
- MM'"""""`MM oo dP M""MMMMM""MM dP
24723
- M' .mmm. `M 88 M MMMMM MM 88
24724
- M MMMMMMMM dP d8888P M `M dP dP 88d888b.
24725
- M MMM `M 88 88 M MMMMM MM 88 88 88' `88
24726
- M. `MMM' .M 88 88 M MMMMM MM 88. .88 88. .88
24727
- MM. .MM dP dP M MMMMM MM `88888P' 88Y8888'
24728
- MMMMMMMMMMM MMMMMMMMMMMM
24729
-
24730
- M""MMMMM""M dP
24731
- M MMMMM M 88
24732
- M MMMMM M 88d888b. .d8888b. 88d888b. .d8888b. .d888b88 .d8888b.
24733
- M MMMMM M 88' `88 88' `88 88' `88 88' `88 88' `88 88ooood8
24734
- M `MMM' M 88. .88 88. .88 88 88. .88 88. .88 88. ...
24735
- Mb dM 88Y888P' `8888P88 dP `88888P8 `88888P8 `88888P'
24736
- MMMMMMMMMMM 88 .88
24737
- dP d8888P
24738
24831
 
24739
- M""""""""M dP dP
24740
- Mmmm mmmM 88 88
24741
- MMMM MMMM 88d888b. 88d888b. .d8888b. .d8888b. .d888b88
24742
- MMMM MMMM 88' `88 88' `88 88ooood8 88' `88 88' `88
24743
- MMMM MMMM 88 88 88 88. ... 88. .88 88. .88
24744
- MMMM MMMM dP dP dP `88888P' `88888P8 `88888P8
24745
- MMMMMMMMMM
24832
+ M""MMMMM""M dP MM'"""""`MM M""MMMMM""M M""M
24833
+ M MMMMM M 88 M' .mmm. `M M MMMMM M M M
24834
+ M MMMMM M 88d888b. .d8888b. 88d888b. .d8888b. .d888b88 .d8888b. M MMMMMMMM M MMMMM M M M
24835
+ M MMMMM M 88' `88 88' `88 88' `88 88' `88 88' `88 88ooood8 M MMM `M M MMMMM M M M
24836
+ M `MMM' M 88. .88 88. .88 88 88. .88 88. .88 88. ... M. `MMM' .M M `MMM' M M M
24837
+ Mb dM 88Y888P' `8888P88 dP `88888P8 `88888P8 `88888P' MM. .MM Mb dM M M
24838
+ MMMMMMMMMMM 88 .88 MMMMMMMMMMM MMMMMMMMMMM MMMM
24839
+ dP d8888P
24746
24840
  '''
24747
24841
 
24842
+ def upgrade_get_github_setuppy_version(silent_error=True):
24843
+ """
24844
+ Returns the version number found in the setup.py in the PySimpleGUI Github
24748
24845
 
24846
+ :param silent_error: If True then no error message displayed if error occurs
24847
+ :type silent_error: bool
24848
+ :returns: Version number as a string. Will be empty string if error
24849
+ :rtype: str
24850
+ """
24851
+ setup_py = net_download_file(URL_PSG_GITHUB_SETUP_FILE)
24852
+ if setup_py is None:
24853
+ if not silent_error:
24854
+ popup_error('Upgrade GUI - error downloading the setup.py file')
24855
+ return ''
24856
+
24857
+ lines = setup_py.splitlines()
24858
+ new_ver = None
24859
+ for line in lines:
24860
+ if 'version=' in line:
24861
+ running_ver = line.split('=')[1]
24862
+ start = running_ver.find('"')
24863
+ end = running_ver.find('"', start + 1)
24864
+ new_ver = running_ver[start + 1:end]
24865
+ break
24866
+ if not new_ver:
24867
+ if not silent_error:
24868
+ popup_error('Upgrade GUI - did not find version number is setup.py')
24869
+ return ''
24870
+ return new_ver
24749
24871
 
24872
+ def upgrade_PySimpleGUI_gui(no_gui=False):
24873
+ # print('Upgrading PySimpleGUI....')
24874
+ new_ver = upgrade_get_github_setuppy_version(silent_error=False)
24875
+ if not new_ver:
24876
+ return
24877
+ psg_source = net_download_file(URL_PSG_GITHUB_SOURCE)
24878
+ if psg_source is None:
24879
+ popup_error('Upgrade GUI - error downloading the PySimpleGUI.py file')
24880
+ return
24881
+ lines = psg_source.splitlines()
24882
+ start = end = None
24883
+ for i, line in enumerate(lines):
24884
+ if 'Changelog since' in line:
24885
+ start = i
24886
+ elif start:
24887
+ if '"""' in line:
24888
+ end = i
24889
+ break
24890
+ if not start or not end:
24891
+ popup_error('Upgrade GUI - error getting release notes')
24892
+ return
24893
+ else:
24894
+ release_notes = []
24895
+ for line in lines[start+1:end]:
24896
+ if line:
24897
+ release_notes.append(line)
24898
+ release_notes = '\n'.join(release_notes)
24899
+
24900
+ try:
24901
+ cur_ver = version[:version.index('\n')]
24902
+ except:
24903
+ cur_ver = version
24904
+
24905
+ pip_string= URL_PSG_PIP_INSTALL_FROM_GITHUB
24906
+ # if no_gui:
24907
+ # print(f'{cur_ver} is the version you are running now and will be overwritten')
24908
+ # print(f'{new_ver} is the version you are INSTALLING NOW....')
24909
+ # print(f'Wheel location = {pip_string}')
24910
+ # execute_pip_install_package(pip_string, force_reinstall=True, no_gui=True)
24911
+ # print('Install completed')
24912
+ # return
24913
+
24914
+ layout = [
24915
+ [Text('* WARNING *')],
24916
+ [Text('You are about to upgrade your PySimpleGUI package previously installed via pip')],
24917
+ [Text('to the latest Maintenance Release of PySimpleGUI.')],
24918
+ [Text(f'{cur_ver} is the version you are currently running',)],
24919
+ [Text(f'{new_ver} is the version you will install',)],
24920
+ [Text(f'{sys.executable } is location of python',)],
24921
+ [Text(f'Are you sure you want to overwrite your {cur_ver} release?')],
24922
+ [Push(), B('Yes', s=4), B('No', s=4), B('Show Release Notes', key='-REL NOTES-')],
24923
+ ]
24924
+
24925
+ window = Window('Upgrade To Maintenance Release', layout, keep_on_top=True)
24926
+
24927
+ while True:
24928
+ event, values = window.read()
24929
+ if event in ('No', WIN_CLOSED):
24930
+ popup_quick_message('Cancelled upgrade\nNothing overwritten', background_color='red', text_color='white', keep_on_top=True, non_blocking=False)
24931
+ break
24932
+ elif event == 'Yes':
24933
+ execute_pip_install_package(pip_string, force_reinstall=True)
24934
+ break
24935
+ elif event == '-REL NOTES-':
24936
+ if release_notes:
24937
+ # print(release_notes)
24938
+ notes_list = release_notes.split('\n')
24939
+ max_len = max(map(len, notes_list))
24940
+ # print(f'max_len = {max_len}, len = {len(notes_list)}')
24941
+ popup_scrolled(release_notes, title=f'Release Notes {new_ver}', keep_on_top=True, size=(max_len, len(notes_list)), font='Courier 10', button_justification='r')
24942
+
24943
+ window.close()
24750
24944
 
24751
24945
 
24752
24946
  def _upgrade_entry_point():
@@ -25275,7 +25469,7 @@ def _create_main_window():
25275
25469
  def VerLine(version, description, justification='r', size=(40, 1)):
25276
25470
  return [T(version, justification=justification, font='Any 10', text_color='yellow', size=size, pad=(0, 0)), T(description, font='Any 10', pad=(0, 0))]
25277
25471
 
25278
- security_emoji = EMOJI_BASE64_HAPPY_WINK
25472
+ security_emoji = _random_happy_emoji()
25279
25473
 
25280
25474
 
25281
25475
 
@@ -25291,16 +25485,19 @@ def _create_main_window():
25291
25485
  platform_name= 'Unknown platorm'
25292
25486
 
25293
25487
  platform_ver = platform.platform()
25294
-
25488
+ maint_release_version = upgrade_get_github_setuppy_version()
25295
25489
  versions_left_col_layout = [
25296
25490
  [Push(), Text('2026 LGPL Version of PySimpleGUI', p=0, text_color='yellow', font='_ 16'), Push()],
25297
25491
  VerLine(version, 'PySimpleGUI Version'),
25492
+ VerLine(upgrade_get_github_setuppy_version(), 'PySimpleGUI Maint Release'),
25493
+ [Text(s=40), B('Install Maint Release')] if maint_release_version != version and maint_release_version != '' else [],
25298
25494
  VerLine('{}.{}.{}'.format(sys.version_info.major, sys.version_info.minor, sys.version_info.micro,sys.version), 'Python Version', size=(40, 1)) + [Image(PYTHON_COLORED_HEARTS_BASE64, subsample=3, k='-PYTHON HEARTS-', enable_events=True, tooltip="Love Python? So do we!\nClick to be taken to the Python.org's download page.")],
25299
25495
  VerLine(tclversion_detailed, 'detailed tkinter version'),
25300
25496
  VerLine(os.path.dirname(os.path.abspath(__file__)), 'PySimpleGUI Location', size=(40, None)),
25301
25497
  VerLine(sys.executable, 'Python Executable'),
25302
25498
  VerLine(platform_name, 'Platform '),
25303
- VerLine(platform_ver, 'Platform Version')]
25499
+ VerLine(platform_ver, 'Platform Version'),
25500
+ ]
25304
25501
 
25305
25502
  # versions_tab_layout = [vtop([Column(versions_left_col_layout), Column(versions_right_col_layout)])]
25306
25503
  versions_tab_layout = versions_left_col_layout
@@ -25462,6 +25659,10 @@ def main():
25462
25659
  scripts_folder = os.path.join(os.path.dirname(sys.executable), 'Scripts')
25463
25660
  util_full_path = os.path.join(scripts_folder, util_to_run)
25464
25661
  execute_command_subprocess(util_full_path, cwd=scripts_folder, wait=False)
25662
+ elif event == 'Install Maint Release':
25663
+ upgrade_PySimpleGUI_gui()
25664
+
25665
+
25465
25666
 
25466
25667
  i += 1
25467
25668
  # _refresh_debugger()
@@ -25787,11 +25988,6 @@ Window._watermark_temp_forced = False
25787
25988
  Window._watermark_user_text = ''
25788
25989
 
25789
25990
 
25790
- # ------------------------- Web Destinations ------------------------- #
25791
- URL_HOME = r'http://home.PySimpleGUI.com'
25792
- URL_DOCS = r'http://docs.PySimpleGUI.com'
25793
-
25794
-
25795
25991
 
25796
25992
  def _convert_window_to_tk(window):
25797
25993
  # """
@@ -25937,10 +26133,11 @@ if _mac_should_set_alpha_to_99():
25937
26133
  def main_command_line():
25938
26134
  # To execute the upgrade from command line, type:
25939
26135
  # python -m PySimpleGUI upgrade
25940
- # print(f'In main with argv={sys.argv}')
25941
26136
  if len(sys.argv) > 1:
25942
26137
  if 'version' in sys.argv:
25943
26138
  print(get_versions())
26139
+ elif 'upgrade' in sys.argv:
26140
+ upgrade_PySimpleGUI_gui()
25944
26141
  elif 'help' in sys.argv:
25945
26142
  print('PySimpleGUI command line options\n')
25946
26143
  print('python -m PySmpleGUI upgrade', '\n Open GUI upgrade utility (same as psgupgrade)\n')