PySimpleGUI 6.0__py3-none-any.whl → 6.3__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,15 +54,14 @@
54
54
 
55
55
  """
56
56
 
57
- version = "6.0"
57
+ version = "6.3"
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
65
-
64
+ 6.3 2-Aug-2026 Released to GitHub
66
65
  """
67
66
 
68
67
 
@@ -80,7 +79,6 @@ port = 'PySimpleGUI'
80
79
  import os
81
80
  import sys
82
81
 
83
-
84
82
  # all of the tkinter involved imports
85
83
  import tkinter as tk
86
84
  from tkinter import filedialog
@@ -381,6 +379,7 @@ DEFAULT_SCALING = None
381
379
  DEFAULT_ALPHA_CHANNEL = 1.0
382
380
  DEFAULT_HIDE_WINDOW_WHEN_CREATING = True
383
381
  TOOLTIP_BACKGROUND_COLOR = "#ffffe0"
382
+ TOOLTIP_TEXT_COLOR = '#000000' # Black
384
383
  TOOLTIP_FONT = None
385
384
  DEFAULT_USE_BUTTON_SHORTCUTS = False
386
385
  DEFAULT_DICT_TO_STRING_WIDTH = 80
@@ -561,6 +560,14 @@ TITLEBAR_METADATA_MARKER = 'This window has a titlebar'
561
560
 
562
561
  CUSTOM_MENUBAR_METADATA_MARKER = 'This is a custom menubar'
563
562
 
563
+ # Position on a window to use as the anchor when creating / moving a window to a location
564
+ WIN_ANCHOR_UPPER_LEFT = 'UL'
565
+ WIN_ANCHOR_UPPER_RIGHT= 'UR'
566
+ WIN_ANCHOR_LOWER_LEFT = 'LL'
567
+ WIN_ANCHOR_LOWER_RIGHT = 'LR'
568
+ WIN_ANCHOR_CENTER = 'C'
569
+
570
+
564
571
  SUPPRESS_ERROR_POPUPS = False
565
572
  SUPPRESS_RAISE_KEY_ERRORS = True
566
573
  SUPPRESS_KEY_GUESSING = False
@@ -598,6 +605,9 @@ SYMBOL_RIGHT_ARROWHEAD = '⮞'
598
605
  SYMBOL_UP_ARROWHEAD = '⮝'
599
606
  SYMBOL_DOWN_ARROWHEAD = '⮟'
600
607
  SYMBOL_HOURGLASS = '⌛' if running_windows() or running_mac() else ''
608
+ SYMBOL_GEAR = '⛭'
609
+ SYMBOL_DEGREE = '°'
610
+ SYMBOL_REFRESH = '⟳'
601
611
 
602
612
  if sum([int(i) for i in tclversion_detailed.split('.')]) > 19:
603
613
  SYMBOL_TITLEBAR_MINIMIZE = '_'
@@ -702,6 +712,7 @@ ELEM_TYPE_BUTTONMENU = 'buttonmenu'
702
712
  ELEM_TYPE_TITLEBAR = 'titlebar'
703
713
  ELEM_TYPE_SIZEGRIP = 'sizegrip'
704
714
 
715
+
705
716
  # STRETCH == ERROR ELEMENT as a filler
706
717
 
707
718
  # ------------------------- Popup Buttons Types ------------------------- #
@@ -746,12 +757,12 @@ DEFAULT_TTK_PART_MAPPING_DICT = {TTK_SCROLLBAR_PART_TROUGH_COLOR: PSG_THEME_PART
746
757
  ttk_part_mapping_dict = copy.copy(DEFAULT_TTK_PART_MAPPING_DICT)
747
758
 
748
759
 
749
-
750
760
  # ------------------------- Web Destinations ------------------------- #
751
- URL_PRIVACY = r'http://privacy.PySimpleGUI.com'
752
- URL_TERMS = r'http://terms.PySimpleGUI.com'
753
761
  URL_HOME = r'http://home.PySimpleGUI.com'
754
762
  URL_DOCS = r'http://docs.PySimpleGUI.com'
763
+ URL_PSG_GITHUB_SOURCE = r'https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/refs/heads/master/PySimpleGUI/PySimpleGUI.py'
764
+ URL_PSG_GITHUB_SETUP_FILE = r'https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/refs/heads/master/setup.py'
765
+ URL_PSG_PIP_INSTALL_FROM_GITHUB = r'https://github.com/PySimpleGUI/PySimpleGUI/zipball/master'
755
766
 
756
767
 
757
768
  class TTKPartOverrides:
@@ -844,7 +855,27 @@ class ToolTip:
844
855
  This is an INTERNALLY USED only class. Users should not refer to this class at all.
845
856
  """
846
857
 
847
- def __init__(self, widget, text, timeout=DEFAULT_TOOLTIP_TIME):
858
+ def __init__(self, widget, text, timeout=DEFAULT_TOOLTIP_TIME, skip_bind=False, offset = DEFAULT_TOOLTIP_OFFSET, background_color=None, text_color=None, font=None):
859
+ """
860
+ :param widget: The tkinter widget
861
+ :type widget: widget type varies
862
+ :param text: text for the tooltip. It can inslude \n. If None tip won't be shown
863
+ :type text: str | None
864
+ :param timeout: Time in milliseconds that mouse must remain still before tip is shown
865
+ :type timeout: (int)
866
+ :param skip_bind: If True then the widget will not be bound with enter/leave events
867
+ :type skip_bind: (bool)
868
+ :param offset: Offset (x,y) from widget to show the tooltip.
869
+ :type offset: (int, int)
870
+ :param background_color: Background color
871
+ :type background_color: str
872
+ :param text_color: Text color
873
+ :type text_color: str
874
+ :param font: specifies the font family, size. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
875
+ :type font: (str or (str, int[, str]) or None)
876
+ """
877
+
878
+
848
879
  """
849
880
  :param widget: The tkinter widget
850
881
  :type widget: widget type varies
@@ -852,6 +883,8 @@ class ToolTip:
852
883
  :type text: str | None
853
884
  :param timeout: Time in milliseconds that mouse must remain still before tip is shown
854
885
  :type timeout: (int)
886
+ :param skip_bind: If True then the widget will not be bound with enter/leave events
887
+ :type skip_bind: (bool)
855
888
  """
856
889
  self.widget = widget
857
890
  self.text = text # Set to None and tooltip will be not shown
@@ -860,9 +893,15 @@ class ToolTip:
860
893
  self.tipwindow = None
861
894
  self.id = None
862
895
  self.x = self.y = 0
863
- self.widget.bind("<Enter>", self.enter)
864
- self.widget.bind("<Leave>", self.leave)
896
+ if not skip_bind:
897
+ # print(f'Binding tooltip enter/leave for widget {widget}')
898
+ self.widget.bind("<Enter>", self.enter)
899
+ self.widget.bind("<Leave>", self.leave)
865
900
  self.widget.bind("<ButtonPress>", self.leave)
901
+ self.text_color = text_color or TOOLTIP_TEXT_COLOR
902
+ self.background_color = background_color or TOOLTIP_BACKGROUND_COLOR
903
+ self.offset = offset
904
+ self.font = font
866
905
 
867
906
  def enter(self, event=None):
868
907
  """
@@ -908,8 +947,8 @@ class ToolTip:
908
947
  """
909
948
  if self.tipwindow:
910
949
  return
911
- x = self.widget.winfo_rootx() + self.x + DEFAULT_TOOLTIP_OFFSET[0]
912
- y = self.widget.winfo_rooty() + self.y + DEFAULT_TOOLTIP_OFFSET[1]
950
+ x = self.widget.winfo_rootx() + self.x + self.offset[0]
951
+ y = self.widget.winfo_rooty() + self.y + self.offset[1]
913
952
  self.tipwindow = tk.Toplevel(self.widget)
914
953
  # if not sys.platform.startswith('darwin'):
915
954
  try:
@@ -922,10 +961,9 @@ class ToolTip:
922
961
  self.tipwindow.wm_geometry("+%d+%d" % (x, y))
923
962
  self.tipwindow.wm_attributes("-topmost", 1)
924
963
 
925
- label = ttk.Label(self.tipwindow, text=self.text, justify=tk.LEFT,
926
- background=TOOLTIP_BACKGROUND_COLOR, relief=tk.SOLID, borderwidth=1)
927
- if TOOLTIP_FONT is not None:
928
- label.config(font=TOOLTIP_FONT)
964
+ label = ttk.Label(self.tipwindow, text=self.text, justify=tk.LEFT, background=self.background_color, foreground=self.text_color, relief=tk.SOLID, borderwidth=1)
965
+ if self.font is not None:
966
+ label.config(font=self.font)
929
967
  label.pack()
930
968
 
931
969
  def hidetip(self):
@@ -1178,7 +1216,6 @@ class Element:
1178
1216
  :type event:
1179
1217
 
1180
1218
  """
1181
-
1182
1219
  if self.Type == ELEM_TYPE_TAB_GROUP:
1183
1220
  try:
1184
1221
  index = self.Widget.index('@{},{}'.format(event.x, event.y))
@@ -1197,6 +1234,7 @@ class Element:
1197
1234
  if self.Type == ELEM_TYPE_GRAPH:
1198
1235
  self._update_position_for_returned_values(event)
1199
1236
  self.ParentForm._right_click_menu_element = self
1237
+ return 'break' # Tell tkinter no to call the window's right click menu
1200
1238
 
1201
1239
  def _tearoff_menu_callback(self, parent, menu):
1202
1240
  """
@@ -1229,7 +1267,7 @@ class Element:
1229
1267
  self.MenuItemChosen = item_chosen
1230
1268
  self.ParentForm.LastButtonClicked = self.MenuItemChosen
1231
1269
  self.ParentForm.FormRemainedOpen = True
1232
- _exit_mainloop(self.ParentForm)
1270
+ _exit_mainloop(self.ParentForm, self)
1233
1271
  # Window._window_that_exited = self.ParentForm
1234
1272
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
1235
1273
 
@@ -1323,7 +1361,7 @@ class Element:
1323
1361
  self.ParentForm.LastButtonClicked = alternative_to_key
1324
1362
  self.ParentForm.FormRemainedOpen = True
1325
1363
 
1326
- _exit_mainloop(self.ParentForm)
1364
+ _exit_mainloop(self.ParentForm, self)
1327
1365
  # if self.ParentForm.CurrentlyRunningMainloop:
1328
1366
  # Window._window_that_exited = self.ParentForm
1329
1367
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
@@ -1481,12 +1519,26 @@ class Element:
1481
1519
  self.Widget.unbind(bind_string)
1482
1520
  self.user_bind_dict.pop(bind_string, None)
1483
1521
 
1484
- def set_tooltip(self, tooltip_text):
1522
+
1523
+ def set_tooltip(self, tooltip_text=None, text_color=None, background_color=None, font=None, tooltip_time=DEFAULT_TOOLTIP_TIME, offset=DEFAULT_TOOLTIP_OFFSET, skip_bind=None):
1485
1524
  """
1486
- Called by application to change the tooltip text for an Element. Normally invoked using the Element Object such as: window.Element('key').SetToolTip('New tip').
1525
+ Called by application to change the tooltip text for an Element or customize the text/background colors, tooltip time, and tooltip offset.
1526
+ Normally invoked using the Element Object such as: window['key'].set_tooltip('New tip').
1487
1527
 
1488
- :param tooltip_text: the text to show in tooltip. If None then no tip will be shown
1489
- :type tooltip_text: str | None
1528
+ :param tooltip_text: Text to display in tooltip
1529
+ :type tooltip_text: str
1530
+ :param text_color: Text color as a string (tkinter format) to use as text color
1531
+ :type text_color: str
1532
+ :param background_color: Text color as a string (tkinter format) to use as text color
1533
+ :type background_color: str
1534
+ :param font: Font to use
1535
+ :type font: str
1536
+ :param tooltip_time: Milliseconds to show the tooltip
1537
+ :type tooltip_time: int
1538
+ :param offset: The x,y offset from the element's location (in pixels) marking where to show the tooltip
1539
+ :type offset: (int, int)
1540
+ :param skip_bind: If True tooltip will not register binding for enter/leave for the element
1541
+ :type skip_bind: bool
1490
1542
  """
1491
1543
 
1492
1544
  if self.TooltipObject:
@@ -1495,7 +1547,9 @@ class Element:
1495
1547
  except:
1496
1548
  pass
1497
1549
 
1498
- self.TooltipObject = ToolTip(self.Widget, text=tooltip_text, timeout=DEFAULT_TOOLTIP_TIME)
1550
+ tooltip_text = tooltip_text or self.TooltipObject.text
1551
+
1552
+ self.TooltipObject = ToolTip(self.Widget, text=tooltip_text, offset=offset, timeout=tooltip_time, text_color=text_color, background_color=background_color, font=font, skip_bind=skip_bind)
1499
1553
 
1500
1554
 
1501
1555
  def remove_tooltip(self):
@@ -1586,7 +1640,7 @@ class Element:
1586
1640
  It's possible to specify None for one of sizes so that only 1 of the element's dimensions are changed.
1587
1641
 
1588
1642
  :param size: The size in characters, rows typically. In some cases they are pixels
1589
- :type size: (int, int)
1643
+ :type size: (int, int) | (None, None)
1590
1644
  """
1591
1645
  try:
1592
1646
  if size[0] != None:
@@ -1795,12 +1849,14 @@ class Element:
1795
1849
  self.ParentForm._grab_anywhere_include_these_list.append(self.Widget)
1796
1850
 
1797
1851
 
1798
- def set_right_click_menu(self, menu=None):
1852
+ def set_right_click_menu(self, menu=None, propogate_to_window=False):
1799
1853
  """
1800
1854
  Sets a right click menu for an element.
1801
1855
  If a menu is already set for the element, it will call the tkinter destroy method to remove it
1802
1856
  :param menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
1803
1857
  :type menu: List[List[ List[str] | str ]]
1858
+ :param propogate_to_window If true, then the window's right click menu will also be modified
1859
+ :type propogate_to_window: bool
1804
1860
  """
1805
1861
  if menu == MENU_RIGHT_CLICK_DISABLED:
1806
1862
  return
@@ -1809,40 +1865,43 @@ class Element:
1809
1865
  if menu is None:
1810
1866
  return
1811
1867
  if menu:
1812
- # If previously had a menu destroy it
1813
- if self.TKRightClickMenu:
1814
- try:
1815
- self.TKRightClickMenu.destroy() # just in case there's a problem let's not crash
1816
- except:
1817
- pass
1818
- top_menu = tk.Menu(self.ParentForm.TKroot, tearoff=self.ParentForm.right_click_menu_tearoff, tearoffcommand=self._tearoff_menu_callback)
1819
-
1820
- if self.ParentForm.right_click_menu_background_color not in (COLOR_SYSTEM_DEFAULT, None):
1821
- top_menu.config(bg=self.ParentForm.right_click_menu_background_color)
1822
- if self.ParentForm.right_click_menu_text_color not in (COLOR_SYSTEM_DEFAULT, None):
1823
- top_menu.config(fg=self.ParentForm.right_click_menu_text_color)
1824
- if self.ParentForm.right_click_menu_disabled_text_color not in (COLOR_SYSTEM_DEFAULT, None):
1825
- top_menu.config(disabledforeground=self.ParentForm.right_click_menu_disabled_text_color)
1826
- if self.ParentForm.right_click_menu_font is not None:
1827
- top_menu.config(font=self.ParentForm.right_click_menu_font)
1828
-
1829
- if self.ParentForm.right_click_menu_selected_colors[0] not in (COLOR_SYSTEM_DEFAULT, None):
1830
- top_menu.config(activeforeground=self.ParentForm.right_click_menu_selected_colors[0])
1831
- if self.ParentForm.right_click_menu_selected_colors[1] not in (COLOR_SYSTEM_DEFAULT, None):
1832
- top_menu.config(activebackground=self.ParentForm.right_click_menu_selected_colors[1])
1833
- AddMenuItem(top_menu, menu[1], self, right_click_menu=True)
1834
- self.TKRightClickMenu = top_menu
1835
- if self.ParentForm.RightClickMenu: # if the top level has a right click menu, then setup a callback for the Window itself
1868
+ # If previously had a menu destroy it if no longer needed
1869
+ if self.TKRightClickMenu is not None:
1870
+ if (self.TKRightClickMenu != self.ParentForm.TKRightClickMenu) or propogate_to_window:
1871
+ # print(f'set menu - destroying {id(self.TKRightClickMenu)=}')
1872
+ try:
1873
+ self.TKRightClickMenu.destroy() # just in case there's a problem let's not crash
1874
+ except:
1875
+ pass
1876
+ top_menu = tk.Menu(self.ParentForm.TKroot, tearoff=self.ParentForm.right_click_menu_tearoff, tearoffcommand=self._tearoff_menu_callback)
1877
+ # Style the meny
1878
+ if self.ParentForm.right_click_menu_background_color not in (COLOR_SYSTEM_DEFAULT, None):
1879
+ top_menu.config(bg=self.ParentForm.right_click_menu_background_color)
1880
+ if self.ParentForm.right_click_menu_text_color not in (COLOR_SYSTEM_DEFAULT, None):
1881
+ top_menu.config(fg=self.ParentForm.right_click_menu_text_color)
1882
+ if self.ParentForm.right_click_menu_disabled_text_color not in (COLOR_SYSTEM_DEFAULT, None):
1883
+ top_menu.config(disabledforeground=self.ParentForm.right_click_menu_disabled_text_color)
1884
+ if self.ParentForm.right_click_menu_font is not None:
1885
+ top_menu.config(font=self.ParentForm.right_click_menu_font)
1886
+ if self.ParentForm.right_click_menu_selected_colors[0] not in (COLOR_SYSTEM_DEFAULT, None):
1887
+ top_menu.config(activeforeground=self.ParentForm.right_click_menu_selected_colors[0])
1888
+ if self.ParentForm.right_click_menu_selected_colors[1] not in (COLOR_SYSTEM_DEFAULT, None):
1889
+ top_menu.config(activebackground=self.ParentForm.right_click_menu_selected_colors[1])
1890
+ AddMenuItem(top_menu, menu[1], self, right_click_menu=True)
1891
+ self.TKRightClickMenu = top_menu
1892
+ if propogate_to_window:
1893
+ if self.ParentForm.RightClickMenu:
1894
+ self.ParentForm.TKRightClickMenu = top_menu
1895
+ self.ParentForm.RightClickMenu = menu
1836
1896
  if self.ParentForm.TKRightClickMenu is None:
1837
- self.ParentForm.TKRightClickMenu = top_menu
1838
- if (running_mac()):
1897
+ if running_mac():
1839
1898
  self.ParentForm.TKroot.bind('<ButtonRelease-2>', self.ParentForm._RightClickMenuCallback)
1840
1899
  else:
1841
1900
  self.ParentForm.TKroot.bind('<ButtonRelease-3>', self.ParentForm._RightClickMenuCallback)
1842
- if (running_mac()):
1843
- self.Widget.bind('<ButtonRelease-2>', self._RightClickMenuCallback)
1844
- else:
1845
- self.Widget.bind('<ButtonRelease-3>', self._RightClickMenuCallback)
1901
+ if running_mac():
1902
+ self.Widget.bind('<ButtonRelease-2>', self._RightClickMenuCallback)
1903
+ else:
1904
+ self.Widget.bind('<ButtonRelease-3>', self._RightClickMenuCallback)
1846
1905
 
1847
1906
 
1848
1907
  def save_element_screenshot_to_disk(self, filename=None):
@@ -1933,6 +1992,60 @@ class Element:
1933
1992
  if widget is not None:
1934
1993
  widget.pack(**self.pack_settings)
1935
1994
 
1995
+
1996
+ def _mouseover_enter(self, event=None):
1997
+ """
1998
+ Called by tkinter when mouse enters a Button. Used for mouseover images
1999
+ :param event: from tkinter. Has x,y coordinates of mouse
2000
+ :type event:
2001
+
2002
+ """
2003
+ # print('mouesover enter')
2004
+ if self.mouseover_image_source:
2005
+ self._apply_mouseover_image(image_filename=self.mouseover_image_filename, image_data=self.mouseover_image_data)
2006
+ if self.TooltipObject:
2007
+ self.TooltipObject.enter(event)
2008
+
2009
+
2010
+ def _mouseover_leave(self, event=None):
2011
+ """
2012
+ Called by tktiner when mouse exits Button. Used for mouseover images
2013
+ :param event: from tkinter. Event info that's not used by function.
2014
+ :type event:
2015
+
2016
+ """
2017
+ if self.ImageSource:
2018
+ self._apply_mouseover_image(image_filename=self.ImageFilename, image_data=self.ImageData)
2019
+ if self.TooltipObject:
2020
+ self.TooltipObject.leave(event)
2021
+
2022
+
2023
+ def mouseover_image_set(self, image_source=None):
2024
+ """
2025
+ Used to set or clear the mouseover image for an element
2026
+ TODO: need to check it's valid to set a mouseover image for this element and also need to protect against widget not set.
2027
+ Also need to unhook the tooltip binding so it won't get stolen by tooltip. Get for image already set too
2028
+ :param image_source: Image to show when the element is moused over. Element must already have an image set.
2029
+ :type image_source: (str | bytes)
2030
+
2031
+ """
2032
+ if image_source is not None:
2033
+ if self.ImageSource is not None:
2034
+ self.widget.bind('<Enter>', self._mouseover_enter)
2035
+ self.widget.bind('<Leave>', self._mouseover_leave)
2036
+ self.mouseover_image_source = image_source
2037
+ self.mouseover_image_data = self.mouseover_image_filename = None
2038
+ if isinstance(image_source, bytes):
2039
+ self.mouseover_image_data = image_source
2040
+ elif isinstance(image_source, str):
2041
+ self.mouseover_image_filename = image_source
2042
+ self.update(mouseover_image_source=image_source)
2043
+ else:
2044
+ self.mouseover_image_source = self.mouseover_image_data = self.mouseover_image_filename = None
2045
+ self.widget.unbind('<Enter>')
2046
+ self.widget.unbind('<Leave>')
2047
+
2048
+
1936
2049
  def update(self, *args, **kwargs):
1937
2050
  """
1938
2051
  A dummy update call. This will only be called if an element hasn't implemented an update method
@@ -1967,15 +2080,18 @@ class Input(Element):
1967
2080
  Display a single text input field. Based on the tkinter Widget `Entry`
1968
2081
  """
1969
2082
 
1970
- def __init__(self, default_text='', size=(None, None), s=(None, None), disabled=False, password_char='', setting=None,
1971
- justification=None, background_color=None, text_color=None, font=None, tooltip=None, border_width=None,
1972
- change_submits=False, enable_events=False, do_not_clear=True, key=None, k=None, focus=False, pad=None, p=None,
1973
- use_readonly_for_disable=True, readonly=False, disabled_readonly_background_color=None, disabled_readonly_text_color=None, selected_text_color=None,
1974
- selected_background_color=None, expand_x=False, expand_y=False,
1975
- right_click_menu=None, visible=True, metadata=None):
2083
+ def __init__(self, default_text='',placeholder=None, placeholder_text_color=None, placeholder_background_color=None, placeholder_justification=None, size=(None, None), s=(None, None), disabled=False, password_char='', setting=None, justification=None, background_color=None, text_color=None, font=None, tooltip=None, border_width=None, change_submits=False, enable_events=False, do_not_clear=True, key=None, k=None, focus=False, pad=None, p=None, use_readonly_for_disable=True, readonly=False, disabled_readonly_background_color=None, disabled_readonly_text_color=None, selected_text_color=None, selected_background_color=None, expand_x=False, expand_y=False, right_click_menu=None, visible=True, metadata=None):
1976
2084
  """
1977
2085
  :param default_text: Text initially shown in the input box as a default value(Default value = ''). Will automatically be converted to string
1978
2086
  :type default_text: (Any)
2087
+ :param placeholder: The placeholder text
2088
+ :type placeholder: str
2089
+ :param placeholder_justification: justification for placeholder. Valid choices - left, right, center ("l", "r", "c")
2090
+ :type placeholder_justification: (str)
2091
+ :param placeholder_text_color: Color of the placeholder text. Uses input element disabled text color of nothing set
2092
+ :type placeholder_text_color: str
2093
+ :param placeholder_background_color: Background color for placeholder text. Uses input element disabled background color of nothing set
2094
+ :type placeholder_background_color: str
1979
2095
  :param size: w=characters-wide, h=rows-high. If an int is supplied rather than a tuple, then a tuple is created width=int supplied and heigh=1
1980
2096
  :type size: (int, int) | (int, None) | int
1981
2097
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
@@ -2044,6 +2160,11 @@ class Input(Element):
2044
2160
  fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
2045
2161
  self.selected_text_color = selected_text_color
2046
2162
  self.selected_background_color = selected_background_color
2163
+ self.placeholder = placeholder
2164
+ self.placeholder_text_color = placeholder_text_color or disabled_readonly_text_color or fg
2165
+ self.placeholder_background_color = placeholder_background_color or disabled_readonly_background_color
2166
+ self.mouse_over = self.has_focus = False # flags used by placeholder code
2167
+ self.showing_placeholder = False # True when currently showing the placeholder value
2047
2168
  self.Focus = focus
2048
2169
  self.do_not_clear = do_not_clear
2049
2170
  self.Justification = justification
@@ -2056,6 +2177,8 @@ class Input(Element):
2056
2177
  self.ReadOnly = readonly
2057
2178
  self.BorderWidth = border_width if border_width is not None else DEFAULT_BORDER_WIDTH
2058
2179
  self.TKEntry = self.Widget = None # type: tk.Entry
2180
+ self.tk_justify = None if justification is None else tk.LEFT if justification.startswith('l') else tk.CENTER if justification.startswith('c') else tk.RIGHT
2181
+ self.tk_justify_placeholder = None if placeholder_justification is None else tk.LEFT if placeholder_justification.startswith('l') else tk.CENTER if placeholder_justification.startswith('c') else tk.RIGHT
2059
2182
  key = key if key is not None else k
2060
2183
  sz = size if size != (None, None) else s
2061
2184
  pad = pad if pad is not None else p
@@ -2068,8 +2191,7 @@ class Input(Element):
2068
2191
  super().__init__(ELEM_TYPE_INPUT_TEXT, size=sz, background_color=bg, text_color=fg, key=key, pad=pad,
2069
2192
  font=font, tooltip=tooltip, visible=visible, metadata=metadata)
2070
2193
 
2071
- def update(self, value=None, disabled=None, select=None, visible=None, text_color=None, background_color=None, font=None, move_cursor_to='end', password_char=None, paste=None,
2072
- readonly=None):
2194
+ def update(self, value=None, disabled=None, select=None, visible=None, text_color=None, background_color=None, font=None, move_cursor_to='end', password_char=None, paste=None, readonly=None):
2073
2195
  """
2074
2196
  Changes some of the settings for the Input Element. Must call `Window.Read` or `Window.Finalize` prior.
2075
2197
  Changes will not be visible in your window until you call window.read or window.refresh.
@@ -2136,9 +2258,6 @@ class Input(Element):
2136
2258
  elif readonly is False:
2137
2259
  self.TKEntry['state'] = 'normal'
2138
2260
 
2139
-
2140
-
2141
-
2142
2261
  if value is not None:
2143
2262
  if paste is not True:
2144
2263
  try:
@@ -2156,17 +2275,20 @@ class Input(Element):
2156
2275
  self.TKEntry.icursor(tk.END)
2157
2276
  elif move_cursor_to is not None:
2158
2277
  self.TKEntry.icursor(move_cursor_to)
2278
+ # since value changed, update the placeholder
2279
+ self.showing_placeholder = False # set to not showing so it'll get set up again if needed
2280
+ self.TKEntry.config(fg=self.TextColor)
2281
+ self.TKEntry.config(bg=self.BackgroundColor)
2282
+ self.TKEntry.config(justify=self.tk_justify)
2283
+ self.update_placeholder()
2159
2284
  if select is True:
2160
2285
  self.TKEntry.select_range(0, 'end')
2161
2286
  elif select is False:
2162
2287
  self.TKEntry.select_clear()
2163
2288
  if visible is False:
2164
2289
  self._pack_forget_save_settings()
2165
- # self.TKEntry.pack_forget()
2166
2290
  elif visible is True:
2167
2291
  self._pack_restore_settings()
2168
- # self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1])
2169
- # self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1], in_=self.ParentRowFrame)
2170
2292
  if visible is not None:
2171
2293
  self._visible = visible
2172
2294
  if password_char is not None:
@@ -2176,6 +2298,43 @@ class Input(Element):
2176
2298
  self.TKEntry.configure(font=font)
2177
2299
 
2178
2300
 
2301
+ def update_placeholder(self):
2302
+ if self.placeholder is None:
2303
+ return
2304
+ entry_widget = self.widget
2305
+ text = self.TKStringVar.get()
2306
+ if not self.mouse_over and not self.has_focus and text == '' and not self.showing_placeholder:
2307
+ self.TKStringVar.set(self.placeholder)
2308
+ entry_widget.config(fg=self.placeholder_text_color if self.placeholder_text_color != COLOR_SYSTEM_DEFAULT else None)
2309
+ entry_widget.config(bg=self.placeholder_background_color if self.placeholder_background_color != COLOR_SYSTEM_DEFAULT else None)
2310
+ entry_widget.config(justify=self.tk_justify_placeholder)
2311
+ self.showing_placeholder = True
2312
+ elif self.showing_placeholder and (self.mouse_over or self.has_focus):
2313
+ self.TKStringVar.set('')
2314
+ entry_widget.config(fg=self.TextColor if self.TextColor != COLOR_SYSTEM_DEFAULT else None)
2315
+ entry_widget.config(bg=self.BackgroundColor if self.TextColor != COLOR_SYSTEM_DEFAULT else None)
2316
+ entry_widget.config(justify=self.tk_justify)
2317
+ self.showing_placeholder = False
2318
+
2319
+
2320
+ def _on_mouse_or_focus(self, event):
2321
+ if event.type == tk.EventType.Enter: # Mouse enter
2322
+ self.mouse_over = True
2323
+ self.update_placeholder()
2324
+ if self.TooltipObject:
2325
+ self.TooltipObject.enter(event)
2326
+ elif event.type == tk.EventType.Leave: # Mouse leave
2327
+ self.mouse_over = False
2328
+ self.update_placeholder()
2329
+ if self.TooltipObject:
2330
+ self.TooltipObject.leave(event)
2331
+ elif event.type == tk.EventType.FocusIn: # Focus in
2332
+ self.has_focus = True
2333
+ self.update_placeholder()
2334
+ elif event.type == tk.EventType.FocusOut: # Focus out
2335
+ self.has_focus = False
2336
+ self.update_placeholder()
2337
+
2179
2338
 
2180
2339
  def set_ibeam_color(self, ibeam_color=None):
2181
2340
  """
@@ -2206,10 +2365,13 @@ class Input(Element):
2206
2365
  :return: current value of Input field or '' if error encountered
2207
2366
  :rtype: (str)
2208
2367
  """
2209
- try:
2210
- text = self.TKStringVar.get()
2211
- except:
2368
+ if self.showing_placeholder: # if showing a placeholder, then the actual value should be ''
2212
2369
  text = ''
2370
+ else:
2371
+ try:
2372
+ text = self.TKStringVar.get()
2373
+ except:
2374
+ text = ''
2213
2375
  return text
2214
2376
 
2215
2377
  Get = get
@@ -2350,7 +2512,7 @@ class Combo(Element):
2350
2512
  :param visible: control visibility of element
2351
2513
  :type visible: (bool)
2352
2514
  :param size: width, height. Width = characters-wide, height = NOTE it's the number of entries to show in the list
2353
- :type size: (int, int)
2515
+ :type size: (int, int) | (None, None)
2354
2516
  :param select: if True, then the text will be selected, if False then selection will be cleared
2355
2517
  :type select: (bool)
2356
2518
  :param background_color: color of background
@@ -2589,7 +2751,7 @@ class OptionMenu(Element):
2589
2751
  :param visible: control visibility of element
2590
2752
  :type visible: (bool)
2591
2753
  :param size: (width, height) size in characters (wide), height is ignored and present to be consistent with other elements
2592
- :type size: (int, int) (width, UNUSED)
2754
+ :type size: (int, int) | (width, None) | (None, None)
2593
2755
  """
2594
2756
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
2595
2757
  return
@@ -2903,6 +3065,14 @@ class Listbox(Element):
2903
3065
  return value
2904
3066
 
2905
3067
 
3068
+ def get_active_index(self):
3069
+ """
3070
+ Returns the index of the currently active item. Active means where the "cursor" is located when using arrow keys.
3071
+
3072
+ :return: The index of the currently active item
3073
+ :rtype: int
3074
+ """
3075
+ return self.TKListbox.index(tk.ACTIVE)
2906
3076
 
2907
3077
 
2908
3078
  def select_index(self, index, highlight_text_color=None, highlight_background_color=None):
@@ -3568,7 +3738,7 @@ class Spin(Element):
3568
3738
  else:
3569
3739
  self.ParentForm.LastButtonClicked = ''
3570
3740
  self.ParentForm.FormRemainedOpen = True
3571
- _exit_mainloop(self.ParentForm)
3741
+ _exit_mainloop(self.ParentForm, self)
3572
3742
  # if self.ParentForm.CurrentlyRunningMainloop:
3573
3743
  # Window._window_that_exited = self.ParentForm
3574
3744
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
@@ -3683,7 +3853,7 @@ class Multiline(Element):
3683
3853
  :type reroute_stderr: (bool)
3684
3854
  :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
3855
  :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
3856
+ :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
3857
  :type echo_stdout_stderr: (bool)
3688
3858
  :param focus: if True initial focus will go to this element
3689
3859
  :type focus: (bool)
@@ -3766,6 +3936,7 @@ class Multiline(Element):
3766
3936
  self.hscrollbar = None # The horizontal scrollbar
3767
3937
  self.auto_scroll_only_at_bottom = autoscroll_only_at_bottom
3768
3938
  sz = size if size != (None, None) else s
3939
+ self.images_for_print = [] # holds a reference for images so that tkinter will render them correctly
3769
3940
  if setting is not None:
3770
3941
  self.setting = str(setting)
3771
3942
  self.DefaultText = user_settings_get_entry(key, self.setting)
@@ -3776,7 +3947,7 @@ class Multiline(Element):
3776
3947
  return
3777
3948
 
3778
3949
  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):
3950
+ background_color_for_value=None, visible=None, autoscroll=None, justification=None, font_for_value=None, image=None, image_subsample=None):
3780
3951
  """
3781
3952
  Changes some of the settings for the Multiline Element. Must call `Window.read` or set finalize=True when creating window.
3782
3953
 
@@ -3810,6 +3981,10 @@ class Multiline(Element):
3810
3981
  :type justification: (str)
3811
3982
  :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
3983
  :type font_for_value: str | (str, int)
3984
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
3985
+ :type image: (str | bytes)
3986
+ :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
3987
+ :type image_subsample: (int)
3813
3988
  """
3814
3989
 
3815
3990
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
@@ -3835,6 +4010,7 @@ class Multiline(Element):
3835
4010
 
3836
4011
  starting_point = self.Widget.index(tk.INSERT)
3837
4012
  tag = None
4013
+ # First insert the text
3838
4014
  if value is not None:
3839
4015
  value = str(value)
3840
4016
  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 +4043,19 @@ class Multiline(Element):
3867
4043
  if self.Disabled:
3868
4044
  self.TKText.configure(state='disabled')
3869
4045
  self.DefaultText = value
4046
+ # Insert an image
4047
+ if image is not None:
4048
+ try:
4049
+ if isinstance(image, bytes):
4050
+ self.tkimage = tk.PhotoImage(data=image)
4051
+ elif isinstance(image, str):
4052
+ self.tkimage = tk.PhotoImage(file=image)
4053
+ if image_subsample is not None:
4054
+ self.tkimage = self.tkimage.subsample(image_subsample)
4055
+ self.images_for_print.append(self.tkimage)
4056
+ self.widget.image_create(tk.END, image=self.tkimage)
4057
+ except Exception as e:
4058
+ print("* Error updating multiline with an image *", e)
3870
4059
 
3871
4060
  # if self.Autoscroll:
3872
4061
  # self.TKText.see(tk.END)
@@ -3914,7 +4103,7 @@ class Multiline(Element):
3914
4103
  return value
3915
4104
 
3916
4105
  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):
4106
+ autoscroll=True, image=None, image_subsample=None):
3918
4107
  """
3919
4108
  Print like Python normally prints except route the output to a multiline element and also add colors if desired
3920
4109
 
@@ -3956,6 +4145,10 @@ class Multiline(Element):
3956
4145
  :type c: (str) or (str, str)
3957
4146
  :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
3958
4147
  :type autoscroll: (bool)
4148
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
4149
+ :type image: (str | bytes)
4150
+ :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
4151
+ :type image_subsample: (int)
3959
4152
  """
3960
4153
 
3961
4154
  kw_text_color = text_color or t
@@ -3973,9 +4166,9 @@ class Multiline(Element):
3973
4166
  kw_text_color = dual_color
3974
4167
  except Exception as e:
3975
4168
  print('* multiline print warning * you messed up with color formatting', e)
3976
-
4169
+ # NOTE - this is NOT calling a method, it's calling a function outside of this object
3977
4170
  _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)
4171
+ autoscroll=autoscroll, font=font, image=image, image_subsample=image_subsample)
3979
4172
 
3980
4173
  def reroute_stdout_to_here(self):
3981
4174
  """
@@ -4015,16 +4208,13 @@ class Multiline(Element):
4015
4208
  :param txt: text of output
4016
4209
  :type txt: (str)
4017
4210
  """
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
4211
+ self.update(txt, append=True)
4212
+ # if need to echo, then send the same text to the saved stdout and stderr
4213
+ if self.echo_stdout_stderr:
4214
+ if Window._original_stdout is not None:
4215
+ Window._original_stdout.write(txt)
4216
+ elif Window._original_stderr is not None:
4217
+ Window._original_stderr.write(txt)
4028
4218
 
4029
4219
  def flush(self):
4030
4220
  """
@@ -4406,6 +4596,8 @@ class Text(Element):
4406
4596
  :type c: (str) or (str, str)
4407
4597
  :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
4408
4598
  :type autoscroll: (bool)
4599
+ :param append: If True the contents of the element will automatically scroll as more data added to the end
4600
+ :type append: (bool)
4409
4601
  """
4410
4602
 
4411
4603
  kw_text_color = text_color or t
@@ -4757,7 +4949,7 @@ class Button(Element):
4757
4949
  def __init__(self, button_text='', button_type=BUTTON_TYPE_READ_FORM, target=(None, None), tooltip=None,
4758
4950
  file_types=FILE_TYPES_ALL_FILES, initial_folder=None, default_extension='', disabled=False, change_submits=False,
4759
4951
  enable_events=False, image_filename=None, image_data=None, image_size=(None, None),
4760
- image_subsample=None, image_zoom=None, image_source=None, border_width=None, size=(None, None), s=(None, None), auto_size_button=None, button_color=None,
4952
+ image_subsample=None, image_zoom=None, image_source=None, mouseover_image_source=None, border_width=None, size=(None, None), s=(None, None), auto_size_button=None, button_color=None,
4761
4953
  disabled_button_color=None,
4762
4954
  highlight_colors=None, mouseover_colors=(None, None), use_ttk_buttons=None, font=None, bind_return_key=False, focus=False, pad=None, p=None, key=None,
4763
4955
  k=None, right_click_menu=None, expand_x=False, expand_y=False, visible=True, metadata=None):
@@ -4767,7 +4959,7 @@ class Button(Element):
4767
4959
  :param button_type: You should NOT be setting this directly. ONLY the shortcut functions set this
4768
4960
  :type button_type: (int)
4769
4961
  :param target: key or (row,col) target for the button. Note that -1 for column means 1 element to the left of this one. The constant ThisRow is used to indicate the current row. The Button itself is a valid target for some types of button
4770
- :type target: str | (int, int)
4962
+ :type target: str | (int, int) | (None, None)
4771
4963
  :param tooltip: text, that will appear when mouse hovers over the element
4772
4964
  :type tooltip: (str)
4773
4965
  :param file_types: the filetypes that will be used to match files. To indicate all files: (("ALL Files", "*.* *"),).
@@ -4789,11 +4981,13 @@ class Button(Element):
4789
4981
  :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
4790
4982
  :type image_data: bytes | str
4791
4983
  :param image_size: Size of the image in pixels (width, height)
4792
- :type image_size: (int, int)
4984
+ :type image_size: (int, int) | (None, None)
4793
4985
  :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
4794
4986
  :type image_subsample: (int)
4795
4987
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
4796
4988
  :type image_zoom: (int)
4989
+ :param mouseover_image_source: Image to show when the button is moused over. Note - must have a button image set to use a mouseover button image
4990
+ :type mouseover_image_source: (str | bytes)
4797
4991
  :param border_width: width of border around button in pixels
4798
4992
  :type border_width: (int)
4799
4993
  :param size: (w, h) w=characters-wide, h=rows-high. If an int instead of a tuple is supplied, then height is auto-set to 1
@@ -4849,13 +5043,24 @@ class Button(Element):
4849
5043
  self.ButtonText = str(button_text)
4850
5044
  self.RightClickMenu = right_click_menu
4851
5045
  self.ButtonColor = button_color_to_tuple(button_color)
4852
-
4853
5046
  self.DisabledButtonColor = button_color_to_tuple(disabled_button_color) if disabled_button_color is not None else (None, None)
4854
5047
  if image_source is not None:
4855
5048
  if isinstance(image_source, bytes):
4856
5049
  image_data = image_source
4857
5050
  elif isinstance(image_source, str):
4858
5051
  image_filename = image_source
5052
+
5053
+ self.ImageSource = image_data or image_filename
5054
+
5055
+ self.mouseover_image_source = mouseover_image_source if self.ImageSource is not None else None
5056
+ self.mouseover_image_filename = self.mouseover_image_data = None
5057
+ if mouseover_image_source is not None and self.ImageSource is not None:
5058
+ if isinstance(mouseover_image_source, bytes):
5059
+ self.mouseover_image_data = mouseover_image_source
5060
+ elif isinstance(mouseover_image_source, str):
5061
+ self.mouseover_image_filename = mouseover_image_source
5062
+ if mouseover_image_source is not None and self.ImageSource is None:
5063
+ print('** Button Warning - cannot use a mouseover image unless an image is also specified **')
4859
5064
  self.ImageFilename = image_filename
4860
5065
  self.ImageData = image_data
4861
5066
  self.ImageSize = image_size
@@ -4963,7 +5168,7 @@ class Button(Element):
4963
5168
  # if self.ParentForm.CurrentlyRunningMainloop:
4964
5169
  # Window._window_that_exited = self.ParentForm
4965
5170
  # self.ParentForm.TKroot.quit() # kick out of loop if read was called
4966
- _exit_mainloop(self.ParentForm)
5171
+ _exit_mainloop(self.ParentForm, self)
4967
5172
 
4968
5173
  def _find_target(self):
4969
5174
  target = self.Target
@@ -5098,7 +5303,7 @@ class Button(Element):
5098
5303
  self.ParentForm.LastButtonClicked = self.ButtonText
5099
5304
  self.ParentForm.FormRemainedOpen = False
5100
5305
  self.ParentForm._Close()
5101
- _exit_mainloop(self.ParentForm)
5306
+ _exit_mainloop(self.ParentForm, self)
5102
5307
 
5103
5308
  if self.ParentForm.NonBlocking:
5104
5309
  self.ParentForm.TKroot.destroy()
@@ -5112,7 +5317,7 @@ class Button(Element):
5112
5317
  else:
5113
5318
  self.ParentForm.LastButtonClicked = self.ButtonText
5114
5319
  self.ParentForm.FormRemainedOpen = True
5115
- _exit_mainloop(self.ParentForm)
5320
+ _exit_mainloop(self.ParentForm, self)
5116
5321
  elif self.BType == BUTTON_TYPE_CLOSES_WIN_ONLY: # special kind of button that does not exit main loop
5117
5322
  self.ParentForm._Close(without_event=True)
5118
5323
  self.ParentForm.TKroot.destroy() # close the window with tkinter
@@ -5122,17 +5327,34 @@ class Button(Element):
5122
5327
  self.ParentForm.LastButtonClicked = self.Key # key should have been generated already if not set by user
5123
5328
  self.ParentForm.FormRemainedOpen = True
5124
5329
  should_submit_window = False
5125
- _exit_mainloop(self.ParentForm)
5330
+ _exit_mainloop(self.ParentForm, self)
5126
5331
 
5127
5332
  if should_submit_window:
5128
5333
  self.ParentForm.LastButtonClicked = target_element.Key
5129
5334
  self.ParentForm.FormRemainedOpen = True
5130
- _exit_mainloop(self.ParentForm)
5335
+ _exit_mainloop(self.ParentForm, self)
5131
5336
 
5132
5337
  return
5133
5338
 
5134
- def update(self, text=None, button_color=(None, None), disabled=None, image_source=None, image_data=None, image_filename=None,
5135
- visible=None, image_subsample=None, image_zoom=None, disabled_button_color=(None, None), image_size=None):
5339
+
5340
+ def _apply_mouseover_image(self, image_filename=None, image_data=None):
5341
+ """
5342
+ Changes the image on a Button due to mouseover. Called when mouse enters or leaves a Button (means there's a mouseover image to apply).
5343
+ :param image_filename: Filename of the image
5344
+ :type image_filename: (str)
5345
+ :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5346
+ :type image_data: bytes | str
5347
+ """
5348
+ if self.UseTtkButtons:
5349
+ style_name = self.ttk_style_name # created when made initial window (in the pack)
5350
+ button_style = ttk.Style()
5351
+ else:
5352
+ style_name = button_style = None
5353
+ self._apply_image_to_button(image_filename=image_filename, image_data=image_data, image_subsample=self.ImageSubsample, image_zoom=self.zoom, image_size=self.ImageSize, button_style=button_style, style_name=style_name)
5354
+
5355
+
5356
+
5357
+ def update(self, text=None, button_color=(None, None), disabled=None, image_source=None, image_data=None, image_filename=None, mouseover_image_source=None, visible=None, image_subsample=None, image_zoom=None, disabled_button_color=(None, None), image_size=None):
5136
5358
  """
5137
5359
  Changes some of the settings for the Button Element. Must call `Window.Read` or `Window.Finalize` prior
5138
5360
 
@@ -5154,6 +5376,8 @@ class Button(Element):
5154
5376
  :type image_data: bytes | str
5155
5377
  :param image_filename: image filename if there is a button image. GIFs and PNGs only.
5156
5378
  :type image_filename: (str)
5379
+ :param mouseover_image_source: Image to show when the button is moused over. Note - must have a button image set to use a mouseover button image
5380
+ :type mouseover_image_source: (str | bytes)
5157
5381
  :param disabled_button_color: colors to use when button is disabled (text, background). Use None for a color if don't want to change. Only ttk buttons support both text and background colors. tk buttons only support changing text color
5158
5382
  :type disabled_button_color: (str, str)
5159
5383
  :param visible: control visibility of element
@@ -5163,7 +5387,7 @@ class Button(Element):
5163
5387
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
5164
5388
  :type image_zoom: (int)
5165
5389
  :param image_size: Size of the image in pixels (width, height)
5166
- :type image_size: (int, int)
5390
+ :type image_size: (int, int) | (None, None)
5167
5391
  """
5168
5392
 
5169
5393
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
@@ -5178,11 +5402,29 @@ class Button(Element):
5178
5402
  image_data = image_source
5179
5403
  elif isinstance(image_source, str):
5180
5404
  image_filename = image_source
5181
-
5405
+ if mouseover_image_source is not None:
5406
+ # if haven't setup mouseover yet, then need to do the binds here
5407
+ if self.mouseover_image_source is None:
5408
+ self.TKButton.bind('<Enter>', self._mouseover_enter)
5409
+ self.TKButton.bind('<Leave>', self._mouseover_leave)
5410
+ self.mouseover_image_source = mouseover_image_source
5411
+ if mouseover_image_source is not None:
5412
+ if isinstance(mouseover_image_source, bytes):
5413
+ self.mouseover_image_data = mouseover_image_source
5414
+ elif isinstance(mouseover_image_source, str):
5415
+ self.mouseover_image_filename = mouseover_image_source
5416
+ if any((image_source, image_data, image_filename)):
5417
+ self.ImageSource = image_source or image_data or image_filename
5418
+ self.ImageFilename = image_filename
5419
+ self.ImageData = image_data
5420
+ self.ImageSubsample = image_subsample
5421
+ self.zoom = image_zoom
5422
+ self.ImageSize = image_size
5182
5423
  if self.UseTtkButtons:
5183
5424
  style_name = self.ttk_style_name # created when made initial window (in the pack)
5184
- # style_name = str(self.Key) + 'custombutton.TButton'
5185
5425
  button_style = ttk.Style()
5426
+ else:
5427
+ style_name = button_style = None
5186
5428
  if text is not None:
5187
5429
  btext = text
5188
5430
  if DEFAULT_USE_BUTTON_SHORTCUTS is True:
@@ -5199,11 +5441,6 @@ class Button(Element):
5199
5441
  self.ButtonText = text
5200
5442
  if button_color != (None, None) and button_color != COLOR_SYSTEM_DEFAULT:
5201
5443
  bc = button_color_to_tuple(button_color, self.ButtonColor)
5202
- # if isinstance(button_color, str):
5203
- # try:
5204
- # button_color = button_color.split(' on ')
5205
- # except Exception as e:
5206
- # print('** Error in formatting your button color **', button_color, e)
5207
5444
  if self.UseTtkButtons:
5208
5445
  if bc[0] not in (None, COLOR_SYSTEM_DEFAULT):
5209
5446
  button_style.configure(style_name, foreground=bc[0])
@@ -5223,36 +5460,8 @@ class Button(Element):
5223
5460
  self.TKButton['state'] = 'normal'
5224
5461
  self.Disabled = disabled if disabled is not None else self.Disabled
5225
5462
 
5226
- if image_data is not None:
5227
- image = tk.PhotoImage(data=image_data)
5228
- if image_subsample:
5229
- image = image.subsample(image_subsample)
5230
- if image_zoom is not None:
5231
- image = image.zoom(int(image_zoom))
5232
- if image_size is not None:
5233
- width, height = image_size
5234
- else:
5235
- width, height = image.width(), image.height()
5236
- if self.UseTtkButtons:
5237
- button_style.configure(style_name, image=image, width=width, height=height)
5238
- else:
5239
- self.TKButton.config(image=image, width=width, height=height)
5240
- self.TKButton.image = image
5241
- if image_filename is not None:
5242
- image = tk.PhotoImage(file=image_filename)
5243
- if image_subsample:
5244
- image = image.subsample(image_subsample)
5245
- if image_zoom is not None:
5246
- image = image.zoom(int(image_zoom))
5247
- if image_size is not None:
5248
- width, height = image_size
5249
- else:
5250
- width, height = image.width(), image.height()
5251
- if self.UseTtkButtons:
5252
- button_style.configure(style_name, image=image, width=width, height=height)
5253
- else:
5254
- self.TKButton.config(highlightthickness=0, image=image, width=width, height=height)
5255
- self.TKButton.image = image
5463
+ self._apply_image_to_button(image_filename=image_filename, image_data=image_data, image_subsample=self.ImageSubsample, image_zoom=self.zoom, image_size=self.ImageSize, button_style=button_style, style_name=style_name)
5464
+
5256
5465
  if visible is False:
5257
5466
  self._pack_forget_save_settings()
5258
5467
  elif visible is True:
@@ -5271,6 +5480,51 @@ class Button(Element):
5271
5480
  if visible is not None:
5272
5481
  self._visible = visible
5273
5482
 
5483
+
5484
+ def _apply_image_to_button(self, image_filename=None, image_data=None, image_subsample=None, image_zoom=None, image_size=None, button_style=None, style_name=None):
5485
+ """
5486
+ Changes the image on a Button. Called by update method and the mouseover methods.
5487
+ :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5488
+ :type image_data: bytes | str
5489
+ :param image_filename: image filename if there is a button image. GIFs and PNGs only.
5490
+ :type image_filename: (str)
5491
+ :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
5492
+ :type image_subsample: (int)
5493
+ :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
5494
+ :type image_zoom: (int)
5495
+ :param image_size: Size of the image in pixels (width, height)
5496
+ :type image_size: (int, int) | (None, None)
5497
+ :param button_style: The ttk style object used to configure the button
5498
+ :type button_style: ttk.Style
5499
+ :param style_name: Style name set when Button was created
5500
+ :type style_name: (str)
5501
+ """
5502
+ if image_data is not None:
5503
+ image = tk.PhotoImage(data=image_data)
5504
+ elif image_filename is not None:
5505
+ image = tk.PhotoImage(file=image_filename)
5506
+ else:
5507
+ return
5508
+ if image_subsample:
5509
+ image = image.subsample(image_subsample)
5510
+ if image_zoom is not None:
5511
+ image = image.zoom(int(image_zoom))
5512
+ if image_size is not None and image_size != (None, None):
5513
+ width, height = image_size
5514
+ else:
5515
+ width, height = image.width(), image.height()
5516
+
5517
+ if self.TKButton.image is not None:
5518
+ del self.TKButton.image
5519
+ if self.UseTtkButtons:
5520
+ button_style.configure(style_name, borderwidth=0, image='', width=width, height=height) # clear previous image
5521
+ button_style.configure(style_name, borderwidth=0, image=image, width=width, height=height)
5522
+ else:
5523
+ self.TKButton.configure(image='') # clear previous image
5524
+ self.TKButton.config(highlightthickness=0, image=image, width=width, height=height)
5525
+ self.TKButton.image = image # Save a reference to the image so tktiner shows it on the Button
5526
+
5527
+
5274
5528
  def get_text(self):
5275
5529
  """
5276
5530
  Returns the current text shown on a button
@@ -5329,7 +5583,7 @@ class ButtonMenu(Element):
5329
5583
  :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5330
5584
  :type image_data: bytes | str
5331
5585
  :param image_size: Size of the image in pixels (width, height)
5332
- :type image_size: (int, int)
5586
+ :type image_size: (int, int) | (None, None)
5333
5587
  :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
5334
5588
  :type image_subsample: (int)
5335
5589
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
@@ -5430,7 +5684,7 @@ class ButtonMenu(Element):
5430
5684
  self.ParentForm.FormRemainedOpen = True
5431
5685
  # if self.ParentForm.CurrentlyRunningMainloop:
5432
5686
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
5433
- _exit_mainloop(self.ParentForm)
5687
+ _exit_mainloop(self.ParentForm, self)
5434
5688
 
5435
5689
  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
5690
  """
@@ -5449,7 +5703,7 @@ class ButtonMenu(Element):
5449
5703
  :param image_source: new image if image is to be changed. Can be a filename or a base64 encoded byte-string
5450
5704
  :type image_source: (str | bytes)
5451
5705
  :param image_size: Size of the image in pixels (width, height)
5452
- :type image_size: (int, int)
5706
+ :type image_size: (int, int) | (None, None)
5453
5707
  :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
5454
5708
  :type image_subsample: (int)
5455
5709
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
@@ -5724,7 +5978,7 @@ class Image(Element):
5724
5978
  Image Element - show an image in the window. Should be a GIF or a PNG only
5725
5979
  """
5726
5980
 
5727
- def __init__(self, source=None, filename=None, data=None, background_color=None, size=(None, None), s=(None, None), pad=None, p=None, key=None, k=None, tooltip=None,
5981
+ def __init__(self, source=None, filename=None, data=None, mouseover_image_source=None, background_color=None, size=(None, None), s=(None, None), pad=None, p=None, key=None, k=None, tooltip=None,
5728
5982
  subsample=None, zoom=None, right_click_menu=None, expand_x=False, expand_y=False, visible=True, enable_events=False, metadata=None):
5729
5983
  """
5730
5984
  :param source: A filename or a base64 bytes. Will automatically detect the type and fill in filename or data for you.
@@ -5733,10 +5987,12 @@ class Image(Element):
5733
5987
  :type filename: str | None
5734
5988
  :param data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5735
5989
  :type data: bytes | str | None
5990
+ :param mouseover_image_source: Image to show when the button is moused over. Note - must have a button image set to use a mouseover button image
5991
+ :type mouseover_image_source: (str | bytes)
5736
5992
  :param background_color: color of background
5737
5993
  :type background_color:
5738
5994
  :param size: (width, height) size of image in pixels
5739
- :type size: (int, int)
5995
+ :type size: (int, int) | (None, None)
5740
5996
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
5741
5997
  :type s: (int, int) | (None, None) | int
5742
5998
  :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
@@ -5775,12 +6031,22 @@ class Image(Element):
5775
6031
  else:
5776
6032
  warnings.warn('Image element - source is not a valid type: {}'.format(type(source)), UserWarning)
5777
6033
 
5778
- self.Filename = filename
5779
- self.Data = data
6034
+ self.ImageFilename = filename
6035
+ self.ImageData = data
6036
+ self.ImageSource = source or data or filename
5780
6037
  self.Widget = self.tktext_label = None # type: tk.Label
5781
6038
  self.BackgroundColor = background_color
5782
6039
  if data is None and filename is None:
5783
- self.Filename = ''
6040
+ self.ImageFilename = ''
6041
+
6042
+ self.mouseover_image_source = mouseover_image_source
6043
+ self.mouseover_image_filename = self.mouseover_image_data = None
6044
+ if mouseover_image_source is not None:
6045
+ if isinstance(mouseover_image_source, bytes):
6046
+ self.mouseover_image_data = mouseover_image_source
6047
+ elif isinstance(mouseover_image_source, str):
6048
+ self.mouseover_image_filename = mouseover_image_source
6049
+
5784
6050
  self.EnableEvents = enable_events
5785
6051
  self.RightClickMenu = right_click_menu
5786
6052
  self.AnimatedFrames = None
@@ -5792,16 +6058,16 @@ class Image(Element):
5792
6058
  self.frame_num = 0
5793
6059
  self.Source = filename if filename is not None else data
5794
6060
  key = key if key is not None else k
5795
- sz = size if size != (None, None) else s
6061
+ self.ImageSize = size if size != (None, None) else s
5796
6062
  pad = pad if pad is not None else p
5797
6063
  self.expand_x = expand_x
5798
6064
  self.expand_y = expand_y
5799
6065
 
5800
- super().__init__(ELEM_TYPE_IMAGE, size=sz, background_color=background_color, pad=pad, key=key,
6066
+ super().__init__(ELEM_TYPE_IMAGE, size=self.ImageSize, background_color=background_color, pad=pad, key=key,
5801
6067
  tooltip=tooltip, visible=visible, metadata=metadata)
5802
6068
  return
5803
6069
 
5804
- def update(self, source=None, filename=None, data=None, size=(None, None), subsample=None, zoom=None, visible=None):
6070
+ def update(self, source=None, filename=None, data=None, mouseover_image_source=None, size=(None, None), subsample=None, zoom=None, visible=None):
5805
6071
  """
5806
6072
  Changes some of the settings for the Image Element. Must call `Window.Read` or `Window.Finalize` prior.
5807
6073
  To clear an image that's been displayed, call with NONE of the options set. A blank update call will
@@ -5819,6 +6085,8 @@ class Image(Element):
5819
6085
  :type filename: (str)
5820
6086
  :param data: Base64 encoded string OR a tk.PhotoImage object
5821
6087
  :type data: str | tkPhotoImage
6088
+ :param mouseover_image_source: Image to show when the button is moused over. Note - must have an image set to use a mouseover button image
6089
+ :type mouseover_image_source: (str | bytes)
5822
6090
  :param size: (width, height) size of image in pixels
5823
6091
  :type size: Tuple[int,int]
5824
6092
  :param 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
@@ -5836,57 +6104,45 @@ class Image(Element):
5836
6104
  _error_popup_with_traceback('Error in Image.update - The window was closed')
5837
6105
  return
5838
6106
 
5839
- if source is not None:
6107
+ if mouseover_image_source is not None:
6108
+ if self.mouseover_image_source is None: # if haven't setup mouseover yet, then need to do the binds here
6109
+ self.tktext_label.bind('<Enter>', self._mouseover_enter)
6110
+ self.tktext_label.bind('<Leave>', self._mouseover_leave)
6111
+ self.mouseover_image_source = mouseover_image_source
6112
+ if isinstance(mouseover_image_source, bytes):
6113
+ self.mouseover_image_data = mouseover_image_source
6114
+ elif isinstance(mouseover_image_source, str):
6115
+ self.mouseover_image_filename = mouseover_image_source
6116
+
6117
+ if any((source, data, filename)):
6118
+ source = source or data or filename
6119
+ self.ImageSource = source
6120
+ self.ImageFilename = self.ImageData =None
5840
6121
  if isinstance(source, bytes):
5841
- data = source
6122
+ self.ImageData = data = source
5842
6123
  elif isinstance(source, str):
5843
- filename = source
6124
+ self.ImageFilename = filename = source
5844
6125
  else:
5845
6126
  warnings.warn('Image element - source is not a valid type: {}'.format(type(source)), UserWarning)
5846
6127
 
5847
- image = None
5848
- if filename is not None:
5849
- try:
5850
- image = tk.PhotoImage(file=filename)
5851
- if subsample is not None:
5852
- image = image.subsample(subsample)
5853
- if zoom is not None:
5854
- image = image.zoom(int(zoom))
5855
- except Exception as e:
5856
- _error_popup_with_traceback('Exception updating Image element', e)
6128
+ if size is not None:
6129
+ self.ImageSize = size
6130
+ if zoom is not None:
6131
+ self.zoom = zoom
6132
+ if subsample is not None:
6133
+ self.ImageSubsample = subsample
5857
6134
 
5858
- elif data is not None:
5859
- # if type(data) is bytes:
5860
- try:
5861
- image = tk.PhotoImage(data=data)
5862
- if subsample is not None:
5863
- image = image.subsample(subsample)
5864
- if zoom is not None:
5865
- image = image.zoom(int(zoom))
5866
- except Exception as e:
5867
- image = data
5868
- # return # an error likely means the window has closed so exit
5869
6135
 
5870
- if image is not None:
5871
- self.tktext_label.configure(image='') # clear previous image
5872
- if self.tktext_label.image is not None:
5873
- del self.tktext_label.image
5874
- if type(image) is not bytes:
5875
- width, height = size[0] if size[0] is not None else image.width(), size[1] if size[1] is not None else image.height()
5876
- else:
5877
- width, height = size
5878
- try: # sometimes crashes if user closed with X
5879
- self.tktext_label.configure(image=image, width=width, height=height)
5880
- except Exception as e:
5881
- _error_popup_with_traceback('Exception updating Image element', e)
5882
- self.tktext_label.image = image
6136
+ if any((source, data, filename)):
6137
+ self._apply_image_to_image_elem(image_filename=self.ImageFilename, image_data=self.ImageData, image_subsample=self.ImageSubsample, image_zoom=self.zoom, image_size=self.ImageSize)
6138
+ # image = None
5883
6139
  if visible is False:
5884
6140
  self._pack_forget_save_settings()
5885
6141
  elif visible is True:
5886
6142
  self._pack_restore_settings()
5887
6143
 
5888
6144
  # if everything is set to None, then delete the image
5889
- if filename is None and image is None and visible is None and size == (None, None):
6145
+ if not any((source, filename, data, visible, mouseover_image_source)) and size==(None, None):
5890
6146
  # Using a try because the image may have been previously deleted and don't want an error if that's happened
5891
6147
  try:
5892
6148
  self.tktext_label.configure(image='', width=1, height=1, bd=0)
@@ -5897,6 +6153,63 @@ class Image(Element):
5897
6153
  if visible is not None:
5898
6154
  self._visible = visible
5899
6155
 
6156
+ def _apply_mouseover_image(self, image_filename=None, image_data=None):
6157
+ """
6158
+ Changes the image on an Image due to mouseover. Called when mouse enters or leaves a Button (means there's a mouseover image to apply).
6159
+ :param image_filename: Filename of the image
6160
+ :type image_filename: (str)
6161
+ :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
6162
+ :type image_data: bytes | str
6163
+ """
6164
+
6165
+ self._apply_image_to_image_elem(image_filename=image_filename, image_data=image_data, image_subsample=self.ImageSubsample, image_zoom=self.zoom, image_size=self.ImageSize)
6166
+
6167
+
6168
+
6169
+ def _apply_image_to_image_elem(self, image_filename=None, image_data=None, image_subsample=None, image_zoom=None, image_size=None):
6170
+ """
6171
+ Changes the image on a Button. Called by update method and the mouseover methods.
6172
+ :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
6173
+ :type image_data: bytes | str
6174
+ :param image_filename: image filename if there is a button image. GIFs and PNGs only.
6175
+ :type image_filename: (str)
6176
+ :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
6177
+ :type image_subsample: (int)
6178
+ :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
6179
+ :type image_zoom: (int)
6180
+ :param image_size: Size of the image in pixels (width, height)
6181
+ :type image_size: (int, int) | (None, None) | None
6182
+ :param button_style: The ttk style object used to configure the button
6183
+ :type button_style: ttk.Style
6184
+ :param style_name: Style name set when Button was created
6185
+ :type style_name: (str)
6186
+ """
6187
+ if image_data is not None:
6188
+ image = tk.PhotoImage(data=image_data)
6189
+ elif image_filename is not None:
6190
+ image = tk.PhotoImage(file=image_filename)
6191
+ else:
6192
+ return
6193
+ if image_subsample:
6194
+ image = image.subsample(image_subsample)
6195
+ if image_zoom is not None:
6196
+ image = image.zoom(int(image_zoom))
6197
+ if image_size is not None and image_size != (None, None):
6198
+ width, height = image_size
6199
+ else:
6200
+ width, height = image.width(), image.height()
6201
+
6202
+ self.tktext_label.configure(image='') # clear previous image
6203
+ if self.tktext_label.image is not None:
6204
+ del self.tktext_label.image
6205
+
6206
+ try: # sometimes crashes if user closed with X
6207
+ self.tktext_label.configure(image=image, width=width, height=height)
6208
+ except Exception as e:
6209
+ _error_popup_with_traceback('Exception updating Image element', e)
6210
+ self.tktext_label.image = image # save reference to image so tkinter will show it
6211
+
6212
+
5900
6213
  def update_animation(self, source, time_between_frames=0):
5901
6214
  """
5902
6215
  Show an Animated GIF. Call the function as often as you like. The function will determine when to show the next frame and will automatically advance to the next frame at the right time.
@@ -6132,11 +6445,11 @@ class Graph(Element):
6132
6445
  right_click_menu=None, expand_x=False, expand_y=False, visible=True, float_values=False, border_width=0, metadata=None):
6133
6446
  """
6134
6447
  :param canvas_size: size of the canvas area in pixels
6135
- :type canvas_size: (int, int)
6448
+ :type canvas_size: (int, int) | (None, None)
6136
6449
  :param graph_bottom_left: (x,y) The bottoms left corner of your coordinate system
6137
- :type graph_bottom_left: (int, int)
6450
+ :type graph_bottom_left: (int, int) | (None, None)
6138
6451
  :param graph_top_right: (x,y) The top right corner of your coordinate system
6139
- :type graph_top_right: (int, int)
6452
+ :type graph_top_right: (int, int) | (None, None)
6140
6453
  :param background_color: background color of the drawing area
6141
6454
  :type background_color: (str)
6142
6455
  :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
@@ -6241,23 +6554,25 @@ class Graph(Element):
6241
6554
  else:
6242
6555
  return floor(new_x), floor(new_y)
6243
6556
 
6244
- def draw_line(self, point_from, point_to, color='black', width=1, arrow=None, arrow_shape=None):
6557
+ def draw_line(self, point_from, point_to, color='black', width=1, arrow=None, arrow_shape=None, capstyle=None):
6245
6558
  """
6246
6559
  Draws a line from one point to another point using USER'S coordinates. Can set the color and width of line
6247
6560
  :param point_from: Starting point for line
6248
- :type point_from: (int, int) | Tuple[float, float]
6249
- :param point_to: Ending point for line
6250
- :type point_to: (int, int) | Tuple[float, float]
6251
- :param color: Color of the line
6252
- :type color: (str)
6253
- :param width: width of line in pixels
6254
- :type width: (int)
6255
- :param arrow: Determines if an arrowhead will be added to the line. Literal string "first", "last", "both"
6256
- :type arrow: (str)
6257
- :param arrow_shape: Defines the shape of the arrowhead using a tuple with (length, width, thickness)
6258
- :type arrow_shape: Tuple[float, float, float]
6259
- :return: id returned from tktiner or None if user closed the window. id is used when you
6260
- :rtype: int | None
6561
+ :type point_from: (int, int) | Tuple[float, float]
6562
+ :param point_to: Ending point for line
6563
+ :type point_to: (int, int) | Tuple[float, float]
6564
+ :param color: Color of the line
6565
+ :type color: (str)
6566
+ :param width: width of line in pixels
6567
+ :type width: (int)
6568
+ :param arrow: Arrow Style - Determines if an arrowhead will be added to the line. Literal string: first, last, both
6569
+ :type arrow: (str)
6570
+ :param arrow_shape: Defines the shape of the arrowhead using a tuple with (length, width, thickness)
6571
+ :type arrow_shape: Tuple[float, float, float]
6572
+ :param capstyle: Eetermines if an arrowhead will be added to the line. Literal string: butt, projecting, round
6573
+ :type capstyle: (str)
6574
+ :return: id returned from tktiner or None if user closed the window. id is used when you
6575
+ :rtype: int | None
6261
6576
  """
6262
6577
  if point_from == (None, None):
6263
6578
  return
@@ -6268,30 +6583,38 @@ class Graph(Element):
6268
6583
  print('Call Window.Finalize() prior to this operation')
6269
6584
  return None
6270
6585
  try: # in case window was closed with an X
6271
- id = self._TKCanvas2.create_line(converted_point_from, converted_point_to, width=width, fill=color, arrow=arrow, arrowshape=arrow_shape)
6586
+ id = self._TKCanvas2.create_line(converted_point_from, converted_point_to, width=width, fill=color, arrow=arrow, arrowshape=arrow_shape, capstyle=capstyle)
6272
6587
  except Exception as e:
6273
6588
  # print(e)
6274
6589
  id = None
6275
6590
  return id
6276
6591
 
6277
6592
 
6278
- def draw_lines(self, points, color='black', width=1):
6593
+ def draw_lines(self, points, color='black', width=1, arrow=None, arrow_shape=None, joinstyle=None, capstyle=None):
6279
6594
  """
6280
6595
  Draw a series of lines given list of points
6281
6596
 
6282
- :param points: list of points that define the polygon
6283
- :type points: List[(int, int) | Tuple[float, float]]
6284
- :param color: Color of the line
6285
- :type color: (str)
6286
- :param width: width of line in pixels
6287
- :type width: (int)
6288
- :return: id returned from tktiner or None if user closed the window. id is used when you
6289
- :rtype: int | None
6597
+ :param points: list of points that define the polygon
6598
+ :type points: List[(int, int) | Tuple[float, float]]
6599
+ :param color: Color of the line
6600
+ :type color: (str)
6601
+ :param width: width of line in pixels
6602
+ :type width: (int)
6603
+ :param arrow: Arrow Style - Determines if an arrowhead will be added to the line. Literal string: first, last, both
6604
+ :type arrow: (str)
6605
+ :param arrow_shape: Defines the shape of the arrowhead using a tuple with (length, width, thickness)
6606
+ :type arrow_shape: Tuple[float, float, float]
6607
+ :param joinstyle: Determines if an arrowhead will be added to the line. Literal string: bevel, miter, round
6608
+ :type joinstyle: (str)
6609
+ :param capstyle: Eetermines if an arrowhead will be added to the line. Literal string: butt, projecting, round
6610
+ :type capstyle: (str)
6611
+ :return: id returned from tktiner or None if user closed the window. id is used when you
6612
+ :rtype: int | None
6290
6613
  """
6291
6614
  converted_points = [self._convert_xy_to_canvas_xy(point[0], point[1]) for point in points]
6292
6615
 
6293
6616
  try: # in case window was closed with an X
6294
- id = self._TKCanvas2.create_line(*converted_points, width=width, fill=color)
6617
+ id = self._TKCanvas2.create_line(*converted_points, width=width, fill=color, arrow=arrow, arrowshape=arrow_shape, joinstyle=joinstyle, capstyle=capstyle)
6295
6618
  except:
6296
6619
  if self._TKCanvas2 is None:
6297
6620
  print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
@@ -6409,7 +6732,7 @@ class Graph(Element):
6409
6732
  :type extent: (float)
6410
6733
  :param start_angle: Angle to begin drawing. Used in conjunction with extent
6411
6734
  :type start_angle: (float)
6412
- :param style: Valid choices are One of these Style strings- 'pieslice', 'chord', 'arc', 'first', 'last', 'butt', 'projecting', 'round', 'bevel', 'miter'
6735
+ :param style: Valid choices are One of these Style strings- 'pieslice', 'chord', 'arc'
6413
6736
  :type style: (str)
6414
6737
  :param arc_color: color to draw arc with
6415
6738
  :type arc_color: (str)
@@ -6773,7 +7096,7 @@ class Graph(Element):
6773
7096
  self.ParentForm.LastButtonClicked = self.Key
6774
7097
  else:
6775
7098
  self.ParentForm.LastButtonClicked = '__GRAPH__' # need to put something rather than None
6776
- _exit_mainloop(self.ParentForm)
7099
+ _exit_mainloop(self.ParentForm, self)
6777
7100
  if isinstance(self.ParentForm.LastButtonClicked, str):
6778
7101
  self.ParentForm.LastButtonClicked = self.ParentForm.LastButtonClicked + '+UP'
6779
7102
  else:
@@ -6797,7 +7120,7 @@ class Graph(Element):
6797
7120
  self.ParentForm.LastButtonClicked = '__GRAPH__' # need to put something rather than None
6798
7121
  # if self.ParentForm.CurrentlyRunningMainloop:
6799
7122
  # self.ParentForm.TKroot.quit() # kick out of loop if read was called
6800
- _exit_mainloop(self.ParentForm)
7123
+ _exit_mainloop(self.ParentForm, self)
6801
7124
  self.MouseButtonDown = True
6802
7125
 
6803
7126
  def _update_position_for_returned_values(self, event):
@@ -6844,7 +7167,7 @@ class Graph(Element):
6844
7167
  self.ParentForm.LastButtonClicked = self.ParentForm.LastButtonClicked + '+MOVE'
6845
7168
  else:
6846
7169
  self.ParentForm.LastButtonClicked = (self.ParentForm.LastButtonClicked, '+MOVE')
6847
- _exit_mainloop(self.ParentForm)
7170
+ _exit_mainloop(self.ParentForm, self)
6848
7171
 
6849
7172
  BringFigureToFront = bring_figure_to_front
6850
7173
  ButtonPressCallBack = button_press_call_back
@@ -6884,8 +7207,8 @@ class Frame(Element):
6884
7207
  """
6885
7208
 
6886
7209
  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,
6888
- tooltip=None, right_click_menu=None, expand_x=False, expand_y=False, grab=None, visible=True, element_justification='left', vertical_alignment=None,
7210
+ 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,
7211
+ tooltip=None, right_click_menu=None, expand_x=False, expand_y=False, grab=None, visible=True, element_justification='left', vertical_alignment=None, enable_events=None,
6889
7212
  metadata=None):
6890
7213
  """
6891
7214
  :param title: text that is displayed as the Frame's "label" or title
@@ -6901,7 +7224,7 @@ class Frame(Element):
6901
7224
  :param relief: relief style. Values are same as other elements with reliefs. Choices include RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID
6902
7225
  :type relief: (str)
6903
7226
  :param size: (width, height) Sets an initial hard-coded size for the Frame. This used to be a problem, but was fixed in 4.53.0 and works better than Columns when using the size paramter
6904
- :type size: (int, int)
7227
+ :type size: (int, int) | (None, None)
6905
7228
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
6906
7229
  :type s: (int, int) | (None, None) | int
6907
7230
  :param font: specifies the font family, size, etc. for the TITLE. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
@@ -6910,8 +7233,12 @@ class Frame(Element):
6910
7233
  :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
6911
7234
  :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
7235
  :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
7236
+ :param border_width: width of border around element in pixels (used with the frame's relief)
6914
7237
  :type border_width: (int)
7238
+ :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
7239
+ :type border_color: (str)
7240
+ :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
7241
+ :type border_width_no_relief: (int)
6915
7242
  :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
7243
  :type key: str | int | tuple | object
6917
7244
  :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
@@ -6932,6 +7259,8 @@ class Frame(Element):
6932
7259
  :type element_justification: (str)
6933
7260
  :param vertical_alignment: Place the Frame at the 'top', 'center', 'bottom' of the row (can also use t,c,r). Defaults to no setting (tkinter decides)
6934
7261
  :type vertical_alignment: (str)
7262
+ :param enable_events: NOT YET IMPLEMENTED - If True then clicking anywhere in the Frame element will generate an event
7263
+ :type enable_events: (bool)
6935
7264
  :param metadata: User metadata that can be set to ANYTHING
6936
7265
  :type metadata: (Any)
6937
7266
  """
@@ -6949,6 +7278,8 @@ class Frame(Element):
6949
7278
  self.Relief = relief
6950
7279
  self.TitleLocation = title_location
6951
7280
  self.BorderWidth = border_width
7281
+ self.BorderColor = border_color if border_color is not None else theme_text_color()
7282
+ self.BorderWidthNoRelief = border_width_no_relief
6952
7283
  self.BackgroundColor = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
6953
7284
  self.RightClickMenu = right_click_menu
6954
7285
  self.ContainerElemementNumber = Window._GetAContainerNumber()
@@ -6956,6 +7287,7 @@ class Frame(Element):
6956
7287
  self.VerticalAlignment = vertical_alignment
6957
7288
  self.Widget = None # type: tk.LabelFrame
6958
7289
  self.Grab = grab
7290
+ self.enable_events = enable_events
6959
7291
  self.Layout(layout)
6960
7292
  key = key if key is not None else k
6961
7293
  sz = size if size != (None, None) else s
@@ -7063,7 +7395,7 @@ class Frame(Element):
7063
7395
  element = row[col_num]
7064
7396
  return element
7065
7397
 
7066
- def update(self, value=None, visible=None):
7398
+ def update(self, value=None, visible=None, border_color=None):
7067
7399
  """
7068
7400
  Changes some of the settings for the Frame Element. Must call `Window.Read` or `Window.Finalize` prior
7069
7401
 
@@ -7073,10 +7405,12 @@ class Frame(Element):
7073
7405
  function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
7074
7406
  when made visible.
7075
7407
 
7076
- :param value: New text value (Title) to show on frame
7077
- :type value: (Any)
7078
- :param visible: control visibility of element
7079
- :type visible: (bool)
7408
+ :param value: New text value (Title) to show on frame
7409
+ :type value: (Any)
7410
+ :param visible: control visibility of element
7411
+ :type visible: (bool)
7412
+ :param border_color: control visibility of element
7413
+ :type border_color: (bool)
7080
7414
  """
7081
7415
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
7082
7416
  return
@@ -7095,6 +7429,9 @@ class Frame(Element):
7095
7429
  self.TKFrame.config(text=str(value))
7096
7430
  if visible is not None:
7097
7431
  self._visible = visible
7432
+ if border_color is not None:
7433
+ self.Widget.configure(highlightcolor=border_color , highlightbackground=border_color)
7434
+ self.BorderColor = border_color
7098
7435
 
7099
7436
  AddRow = add_row
7100
7437
  Layout = layout
@@ -7113,18 +7450,20 @@ class VerticalSeparator(Element):
7113
7450
  Column Element if extra height is needed
7114
7451
  """
7115
7452
 
7116
- def __init__(self, color=None, pad=None, p=None, key=None, k=None):
7453
+ def __init__(self, color=None, thickness=None, pad=None, p=None, key=None, k=None):
7117
7454
  """
7118
- :param color: Color of the line. Defaults to theme's text color. Can be name or #RRGGBB format
7119
- :type color: (str)
7120
- :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
7121
- :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7122
- :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
7123
- :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7124
- :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
7125
- :type key: str | int | tuple | object
7126
- :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7127
- :type k: str | int | tuple | object
7455
+ :param color: Color of the line. Defaults to theme's text color. Can be name or #RRGGBB format
7456
+ :type color: (str)
7457
+ :param thickness: Line thickness in pixels
7458
+ :type thickness: int | None
7459
+ :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
7460
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7461
+ :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
7462
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7463
+ :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
7464
+ :type key: str | int | tuple | object
7465
+ :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7466
+ :type k: str | int | tuple | object
7128
7467
  """
7129
7468
  key = key if key is not None else k
7130
7469
  pad = pad if pad is not None else p
@@ -7132,6 +7471,7 @@ class VerticalSeparator(Element):
7132
7471
  self.expand_y = None
7133
7472
  self.Orientation = 'vertical' # for now only vertical works
7134
7473
  self.color = color if color is not None else theme_text_color()
7474
+ self.thickness = thickness
7135
7475
  super().__init__(ELEM_TYPE_SEPARATOR, pad=pad, key=key)
7136
7476
 
7137
7477
 
@@ -7150,22 +7490,25 @@ class HorizontalSeparator(Element):
7150
7490
  Horizontal Separator Element draws a Horizontal line at the given location.
7151
7491
  """
7152
7492
 
7153
- def __init__(self, color=None, pad=None, p=None, key=None, k=None):
7493
+ def __init__(self, color=None, thickness=None, pad=None, p=None, key=None, k=None):
7154
7494
  """
7155
7495
  :param color: Color of the line. Defaults to theme's text color. Can be name or #RRGGBB format
7156
- :type color: (str)
7157
- :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
7158
- :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7159
- :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
7160
- :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7161
- :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
7162
- :type key: str | int | tuple | object
7163
- :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7164
- :type k: str | int | tuple | object
7496
+ :type color: (str)
7497
+ :param thickness: Line thickness in pixels
7498
+ :type thickness: int | None
7499
+ :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
7500
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7501
+ :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
7502
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7503
+ :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
7504
+ :type key: str | int | tuple | object
7505
+ :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7506
+ :type k: str | int | tuple | object
7165
7507
  """
7166
7508
 
7167
7509
  self.Orientation = 'horizontal' # for now only vertical works
7168
7510
  self.color = color if color is not None else theme_text_color()
7511
+ self.thickness = thickness
7169
7512
  self.expand_x = True
7170
7513
  self.expand_y = None
7171
7514
  key = key if key is not None else k
@@ -7227,50 +7570,52 @@ class Tab(Element):
7227
7570
 
7228
7571
  def __init__(self, title, layout, title_color=None, background_color=None, font=None, pad=None, p=None, disabled=False,
7229
7572
  border_width=None, key=None, k=None, tooltip=None, right_click_menu=None, expand_x=False, expand_y=False, visible=True, element_justification='left',
7230
- image_source=None, image_subsample=None, image_zoom=None, metadata=None):
7231
- """
7232
- :param title: text to show on the tab
7233
- :type title: (str)
7234
- :param layout: The element layout that will be shown in the tab
7235
- :type layout: List[List[Element]]
7236
- :param title_color: color of the tab text (note not currently working on tkinter)
7237
- :type title_color: (str)
7238
- :param background_color: color of background of the entire layout
7239
- :type background_color: (str)
7240
- :param font: NOT USED in the tkinter port
7241
- :type font: (str or (str, int[, str]) or None)
7242
- :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
7243
- :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7244
- :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
7245
- :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7246
- :param disabled: If True button will be created disabled
7247
- :type disabled: (bool)
7248
- :param border_width: NOT USED in tkinter port
7249
- :type border_width: (int)
7250
- :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
7251
- :type key: str | int | tuple | object
7252
- :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7253
- :type k: str | int | tuple | object
7254
- :param tooltip: text, that will appear when mouse hovers over the element
7255
- :type tooltip: (str)
7256
- :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.
7257
- :type right_click_menu: List[List[ List[str] | str ]]
7258
- :param expand_x: If True the element will automatically expand in the X direction to fill available space
7259
- :type expand_x: (bool)
7260
- :param expand_y: If True the element will automatically expand in the Y direction to fill available space
7261
- :type expand_y: (bool)
7262
- :param visible: set visibility state of the element
7263
- :type visible: (bool)
7264
- :param element_justification: All elements inside the Tab will have this justification 'left', 'right', 'center' are valid values
7265
- :type element_justification: (str)
7266
- :param image_source: A filename or a base64 bytes of an image to place on the Tab
7267
- :type image_source: str | bytes | None
7268
- :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
7269
- :type image_subsample: (int)
7270
- :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
7271
- :type image_zoom: (int)
7272
- :param metadata: User metadata that can be set to ANYTHING
7273
- :type metadata: (Any)
7573
+ image_source=None, image_subsample=None, image_zoom=None, mouseover_image_source=None, metadata=None):
7574
+ """
7575
+ :param title: text to show on the tab
7576
+ :type title: (str)
7577
+ :param layout: The element layout that will be shown in the tab
7578
+ :type layout: List[List[Element]]
7579
+ :param title_color: color of the tab text (note not currently working on tkinter)
7580
+ :type title_color: (str)
7581
+ :param background_color: color of background of the entire layout
7582
+ :type background_color: (str)
7583
+ :param font: NOT USED in the tkinter port
7584
+ :type font: (str or (str, int[, str]) or None)
7585
+ :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
7586
+ :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7587
+ :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
7588
+ :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7589
+ :param disabled: If True button will be created disabled
7590
+ :type disabled: (bool)
7591
+ :param border_width: NOT USED in tkinter port
7592
+ :type border_width: (int)
7593
+ :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
7594
+ :type key: str | int | tuple | object
7595
+ :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7596
+ :type k: str | int | tuple | object
7597
+ :param tooltip: text, that will appear when mouse hovers over the element
7598
+ :type tooltip: (str)
7599
+ :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.
7600
+ :type right_click_menu: List[List[ List[str] | str ]]
7601
+ :param expand_x: If True the element will automatically expand in the X direction to fill available space
7602
+ :type expand_x: (bool)
7603
+ :param expand_y: If True the element will automatically expand in the Y direction to fill available space
7604
+ :type expand_y: (bool)
7605
+ :param visible: set visibility state of the element
7606
+ :type visible: (bool)
7607
+ :param element_justification: All elements inside the Tab will have this justification 'left', 'right', 'center' are valid values
7608
+ :type element_justification: (str)
7609
+ :param image_source: A filename or a base64 bytes of an image to place on the Tab
7610
+ :type image_source: str | bytes | None
7611
+ :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
7612
+ :type image_subsample: (int)
7613
+ :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
7614
+ :type image_zoom: (int)
7615
+ :param mouseover_image_source: NOT YET IMPLEMENTED - Image to show when the button is moused over. Note - must have a button image set to use a mouseover button image
7616
+ :type mouseover_image_source: (str | bytes)
7617
+ :param metadata: User metadata that can be set to ANYTHING
7618
+ :type metadata: (Any)
7274
7619
  """
7275
7620
 
7276
7621
  filename = data = None
@@ -7281,11 +7626,21 @@ class Tab(Element):
7281
7626
  filename = image_source
7282
7627
  else:
7283
7628
  warnings.warn('Image element - source is not a valid type: {}'.format(type(image_source)), UserWarning)
7284
-
7285
- self.Filename = filename
7286
- self.Data = data
7629
+ self.ImageSource = data or filename
7630
+ self.ImageFilename = filename
7631
+ self.ImageData = data
7287
7632
  self.ImageSubsample = image_subsample
7633
+ self.ImageSize = None # not a parm for this element
7288
7634
  self.zoom = int(image_zoom) if image_zoom is not None else None
7635
+
7636
+ self.mouseover_image_source = mouseover_image_source = mouseover_image_source if self.ImageSource else None
7637
+ self.mouseover_image_filename = self.mouseover_image_data = None
7638
+ if image_source is not None and mouseover_image_source is not None:
7639
+ if isinstance(mouseover_image_source, bytes):
7640
+ self.mouseover_image_data = mouseover_image_source
7641
+ elif isinstance(mouseover_image_source, str):
7642
+ self.mouseover_image_filename = mouseover_image_source
7643
+
7289
7644
  self.UseDictionary = False
7290
7645
  self.ReturnValues = None
7291
7646
  self.ReturnValuesList = []
@@ -7435,6 +7790,65 @@ class Tab(Element):
7435
7790
  # self.ParentNotebook.pack()
7436
7791
  return self
7437
7792
 
7793
+
7794
+
7795
+ def _apply_mouseover_image(self, image_filename=None, image_data=None):
7796
+ """
7797
+ Changes the image on an Image due to mouseover. Called when mouse enters or leaves a Button (means there's a mouseover image to apply).
7798
+ :param image_filename: Filename of the image
7799
+ :type image_filename: (str)
7800
+ :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
7801
+ :type image_data: bytes | str
7802
+ """
7803
+ self._apply_image_to_tab_elem(image_filename=image_filename, image_data=image_data, image_subsample=self.ImageSubsample, image_zoom=self.zoom, image_size=self.ImageSize)
7804
+
7805
+
7806
+
7807
+ def _apply_image_to_tab_elem(self, image_filename=None, image_data=None, image_subsample=None, image_zoom=None, image_size=None):
7808
+ """
7809
+ Changes the image on a Tab. Called by update method and the mouseover methods.
7810
+ :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
7811
+ :type image_data: bytes | str
7812
+ :param image_filename: image filename if there is a button image. GIFs and PNGs only.
7813
+ :type image_filename: (str)
7814
+ :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
7815
+ :type image_subsample: (int)
7816
+ :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
7817
+ :type image_zoom: (int)
7818
+ :param image_size: Size of the image in pixels (width, height)
7819
+ :type image_size: (int, int) | (None, None)
7820
+ :param button_style: The ttk style object used to configure the button
7821
+ :type button_style: ttk.Style
7822
+ :param style_name: Style name set when Button was created
7823
+ :type style_name: (str)
7824
+ """
7825
+ if image_data is not None:
7826
+ image = tk.PhotoImage(data=image_data)
7827
+ elif image_filename is not None:
7828
+ image = tk.PhotoImage(file=image_filename)
7829
+ else:
7830
+ return
7831
+ if image_subsample:
7832
+ image = image.subsample(image_subsample)
7833
+ if image_zoom is not None:
7834
+ image = image.zoom(int(image_zoom))
7835
+ if image_size is not None and image_size != (None, None):
7836
+ width, height = image_size
7837
+ else:
7838
+ width, height = image.width(), image.height()
7839
+
7840
+
7841
+ self.tktext_label.configure(image='') # clear previous image
7842
+ if self.tktext_label.image is not None:
7843
+ del self.tktext_label.image
7844
+
7845
+ try: # sometimes crashes if user closed with X
7846
+ self.tktext_label.configure(image=image, width=width, height=height)
7847
+ except Exception as e:
7848
+ _error_popup_with_traceback('Exception updating Image element', e)
7849
+ self.tktext_label.image = image # save reference to image so tkinter will show it
7850
+
7851
+
7438
7852
  def _GetElementAtLocation(self, location):
7439
7853
  """
7440
7854
  Not user callable. Used to find the Element at a row, col position within the layout
@@ -7731,10 +8145,10 @@ class TabGroup(Element):
7731
8145
  # If there's an image in the tab, then do the imagey-stuff
7732
8146
  # ------------------- start of imagey-stuff -------------------
7733
8147
  try:
7734
- if tab_element.Filename is not None:
7735
- photo = tk.PhotoImage(file=tab_element.Filename)
7736
- elif tab_element.Data is not None:
7737
- photo = tk.PhotoImage(data=tab_element.Data)
8148
+ if tab_element.ImageFilename is not None:
8149
+ photo = tk.PhotoImage(file=tab_element.ImageFilename)
8150
+ elif tab_element.ImageData is not None:
8151
+ photo = tk.PhotoImage(data=tab_element.ImageData)
7738
8152
  else:
7739
8153
  photo = None
7740
8154
 
@@ -7776,7 +8190,7 @@ class TabGroup(Element):
7776
8190
  if tab_element.BorderWidth is not None:
7777
8191
  tab_element.TKFrame.configure(borderwidth=tab_element.BorderWidth)
7778
8192
  if tab_element.Tooltip is not None:
7779
- tab_element.TooltipObject = ToolTip(tab_element.TKFrame, text=tab_element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
8193
+ tab_element.TooltipObject = ToolTip(tab_element.TKFrame, text=tab_element.Tooltip, timeout=self.ParentForm.tooltip_time, offset=self.ParentForm.tooltip_offset, background_color=self.ParentForm.tooltip_background_color, text_color=self.ParentForm.tooltip_text_color, font=self.ParentForm.tooltip_font)
7780
8194
  _add_right_click_menu(tab_element, form)
7781
8195
 
7782
8196
  def update(self, visible=None):
@@ -7845,7 +8259,7 @@ class Slider(Element):
7845
8259
  :param disabled: set disable state for element
7846
8260
  :type disabled: (bool)
7847
8261
  :param size: (l=length chars/rows, w=width pixels)
7848
- :type size: (int, int)
8262
+ :type size: (int, int) | (None, None)
7849
8263
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
7850
8264
  :type s: (int, int) | (None, None)
7851
8265
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
@@ -7917,7 +8331,7 @@ class Slider(Element):
7917
8331
  :param value: sets current slider value
7918
8332
  :type value: int | float
7919
8333
  :param range: Sets a new range for slider
7920
- :type range: (int, int) | Tuple[float, float
8334
+ :type range: (int, int) | (float, float) | (None, None)
7921
8335
  :param disabled: disable or enable state of the element
7922
8336
  :type disabled: (bool)
7923
8337
  :param visible: control visibility of element
@@ -7967,7 +8381,7 @@ class Slider(Element):
7967
8381
  self.ParentForm.FormRemainedOpen = True
7968
8382
  # if self.ParentForm.CurrentlyRunningMainloop:
7969
8383
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
7970
- _exit_mainloop(self.ParentForm)
8384
+ _exit_mainloop(self.ParentForm, self)
7971
8385
 
7972
8386
  Update = update
7973
8387
 
@@ -8016,7 +8430,7 @@ class TkScrollableFrame(tk.Frame):
8016
8430
  A frame with one or two scrollbars. Used to make Columns with scrollbars
8017
8431
  """
8018
8432
 
8019
- def __init__(self, master, vertical_only, element, window, **kwargs):
8433
+ def __init__(self, master, vertical_only, horizontal_only, element, window, **kwargs):
8020
8434
  """
8021
8435
  :param master: The parent widget
8022
8436
  :type master: (tk.Widget)
@@ -8032,26 +8446,23 @@ class TkScrollableFrame(tk.Frame):
8032
8446
  element.Widget = self.canvas
8033
8447
  # Okay, we're gonna make a list. Containing the y-min, x-min, y-max, and x-max of the frame
8034
8448
  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")
8449
+ if not horizontal_only:
8450
+ _make_ttk_scrollbar(element, 'v', window)
8451
+ element.vsb.pack(side='right', fill="y", expand="false")
8452
+ self.canvas.config(yscrollcommand=element.vsb.set)
8038
8453
 
8039
8454
  if not vertical_only:
8040
8455
  _make_ttk_scrollbar(element, 'h', window)
8041
- # self.hscrollbar = tk.Scrollbar(self, orient=tk.HORIZONTAL)
8042
8456
  element.hsb.pack(side='bottom', fill="x", expand="false")
8043
8457
  self.canvas.config(xscrollcommand=element.hsb.set)
8044
- # self.canvas = tk.Canvas(self, )
8045
- # else:
8046
- # self.canvas = tk.Canvas(self)
8047
8458
 
8048
- self.canvas.config(yscrollcommand=element.vsb.set)
8049
8459
  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)
8460
+
8052
8461
  if not vertical_only:
8053
- # element.hsb.config(command=self.canvas.xview)
8054
8462
  element.hsb.config(command=self.xview_override)
8463
+ if not horizontal_only:
8464
+ element.vsb.config(command=self.yview_override)
8465
+
8055
8466
 
8056
8467
  # reset the view
8057
8468
  self.canvas.xview_moveto(0)
@@ -8147,8 +8558,8 @@ class Column(Element):
8147
8558
  """
8148
8559
 
8149
8560
  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,
8151
- vertical_alignment=None, grab=None, expand_x=None, expand_y=None, metadata=None,
8561
+ vertical_scroll_only=False, horizontal_scroll_only=False, right_click_menu=None, key=None, k=None, visible=True, justification=None, element_justification=None,
8562
+ vertical_alignment=None, grab=None, expand_x=None, expand_y=None, metadata=None, enable_events=None,
8152
8563
  sbar_trough_color=None, sbar_background_color=None, sbar_arrow_color=None, sbar_width=None, sbar_arrow_width=None,
8153
8564
  sbar_frame_color=None, sbar_relief=None):
8154
8565
  """
@@ -8168,10 +8579,12 @@ class Column(Element):
8168
8579
  :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
8169
8580
  :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
8170
8581
  :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
8171
- :param scrollable: if True then scrollbars will be added to the column. If you update the contents of a scrollable column, be sure and call Column.contents_changed also
8582
+ :param scrollable: if True then scrollbars will be added to the column. If you update the contents of a scrollable column, be sure and call window.refresh and Column.contents_changed
8172
8583
  :type scrollable: (bool)
8173
8584
  :param vertical_scroll_only: if True then no horizontal scrollbar will be shown if a scrollable column
8174
8585
  :type vertical_scroll_only: (bool)
8586
+ :param horizontal_scroll_only: if True then no verticale scrollbar will be shown if a scrollable column
8587
+ :type horizontal_scroll_only: (bool)
8175
8588
  :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
8589
  :type right_click_menu: List[List[ List[str] | str ]]
8177
8590
  :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
@@ -8194,6 +8607,8 @@ class Column(Element):
8194
8607
  :type expand_y: (bool)
8195
8608
  :param metadata: User metadata that can be set to ANYTHING
8196
8609
  :type metadata: (Any)
8610
+ :param enable_events: NOT YET IMPLEMENTED - If True then clicking anywhere in the Column element will generate an event
8611
+ :type enable_events: (bool)
8197
8612
  :param sbar_trough_color: Scrollbar color of the trough
8198
8613
  :type sbar_trough_color: (str)
8199
8614
  :param sbar_background_color: Scrollbar color of the background of the arrow buttons at the ends AND the color of the "thumb" (the thing you grab and slide). Switches to arrow color when mouse is over
@@ -8222,6 +8637,7 @@ class Column(Element):
8222
8637
  self.TKColFrame = None # type: tk.Frame
8223
8638
  self.Scrollable = scrollable
8224
8639
  self.VerticalScrollOnly = vertical_scroll_only
8640
+ self.HorizontalScrollOnly = horizontal_scroll_only
8225
8641
 
8226
8642
  self.RightClickMenu = right_click_menu
8227
8643
  bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
@@ -8229,6 +8645,7 @@ class Column(Element):
8229
8645
  self.ElementJustification = element_justification
8230
8646
  self.Justification = justification
8231
8647
  self.VerticalAlignment = vertical_alignment
8648
+ self.enable_events = enable_events
8232
8649
  key = key if key is not None else k
8233
8650
  self.Grab = grab
8234
8651
  self.expand_x = expand_x
@@ -8383,6 +8800,8 @@ class Column(Element):
8383
8800
  When a scrollable column has part of its layout changed by making elements visible or invisible or the
8384
8801
  layout is extended for the Column, then this method needs to be called so that the new scroll area
8385
8802
  is computed to match the new contents.
8803
+ Call window.refresh before calling column.contents_changed so that the window is fully updated with
8804
+ visible changes. This ensures the Column will update the scrollbars to match
8386
8805
  """
8387
8806
  self.TKColFrame.canvas.config(scrollregion=self.TKColFrame.canvas.bbox('all'))
8388
8807
 
@@ -8410,7 +8829,7 @@ class Pane(Element):
8410
8829
  :param background_color: color of background
8411
8830
  :type background_color: (str)
8412
8831
  :param size: (width, height) w=characters-wide, h=rows-high How much room to reserve for the Pane
8413
- :type size: (int, int)
8832
+ :type size: (int, int) | (None, None)
8414
8833
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
8415
8834
  :type s: (int, int) | (None, None)
8416
8835
  :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
@@ -8534,7 +8953,7 @@ class Menu(Element):
8534
8953
  :param disabled_text_color: color to use for text when item in submenu, not the menubar itself, is disabled. Can be in #RRGGBB format or a color name "black"
8535
8954
  :type disabled_text_color: (str)
8536
8955
  :param size: Not used in the tkinter port
8537
- :type size: (int, int)
8956
+ :type size: (int, int) | (None, None)
8538
8957
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
8539
8958
  :type s: (int, int) | (None, None)
8540
8959
  :param tearoff: if True, then can tear the menu off from the window ans use as a floating window. Very cool effect
@@ -8587,7 +9006,7 @@ class Menu(Element):
8587
9006
  self.ParentForm.FormRemainedOpen = True
8588
9007
  # if self.ParentForm.CurrentlyRunningMainloop:
8589
9008
  # self.ParentForm.TKroot.quit() # kick the users out of the mainloop
8590
- _exit_mainloop(self.ParentForm)
9009
+ _exit_mainloop(self.ParentForm, self)
8591
9010
 
8592
9011
  def update(self, menu_definition=None, visible=None):
8593
9012
  """
@@ -8754,7 +9173,7 @@ class Table(Element):
8754
9173
  :param sbar_relief: Scrollbar relief that will be used for the "thumb" of the scrollbar (the thing you grab that slides). Should be a constant that is defined at starting with "RELIEF_" - RELIEF_RAISED, RELIEF_SUNKEN, RELIEF_FLAT, RELIEF_RIDGE, RELIEF_GROOVE, RELIEF_SOLID
8755
9174
  :type sbar_relief: (str)
8756
9175
  :param size: DO NOT USE! Use num_rows instead
8757
- :type size: (int, int)
9176
+ :type size: (int, int) | (None, None)
8758
9177
  :param change_submits: DO NOT USE. Only listed for backwards compat - Use enable_events instead
8759
9178
  :type change_submits: (bool)
8760
9179
  :param enable_events: Turns on the element specific events. Table events happen when row is clicked
@@ -8975,7 +9394,7 @@ class Table(Element):
8975
9394
  self.ParentForm.FormRemainedOpen = True
8976
9395
  # if self.ParentForm.CurrentlyRunningMainloop:
8977
9396
  # self.ParentForm.TKroot.quit()
8978
- _exit_mainloop(self.ParentForm)
9397
+ _exit_mainloop(self.ParentForm, self)
8979
9398
 
8980
9399
  def _treeview_double_click(self, event):
8981
9400
  """
@@ -9005,7 +9424,7 @@ class Table(Element):
9005
9424
  else:
9006
9425
  self.ParentForm.LastButtonClicked = ''
9007
9426
  self.ParentForm.FormRemainedOpen = True
9008
- _exit_mainloop(self.ParentForm)
9427
+ _exit_mainloop(self.ParentForm, self)
9009
9428
 
9010
9429
  def on_escape(table, widget, event, item, column, value_type):
9011
9430
  if widget.entry:
@@ -9051,7 +9470,7 @@ class Table(Element):
9051
9470
  else:
9052
9471
  self.ParentForm.LastButtonClicked = ''
9053
9472
  self.ParentForm.FormRemainedOpen = True
9054
- _exit_mainloop(self.ParentForm)
9473
+ _exit_mainloop(self.ParentForm, self)
9055
9474
 
9056
9475
  def _table_clicked(self, event):
9057
9476
  """
@@ -9106,7 +9525,7 @@ class Table(Element):
9106
9525
  else:
9107
9526
  self.ParentForm.LastButtonClicked = ''
9108
9527
  self.ParentForm.FormRemainedOpen = True
9109
- _exit_mainloop(self.ParentForm)
9528
+ _exit_mainloop(self.ParentForm, self)
9110
9529
 
9111
9530
 
9112
9531
  def disable_edit_for_cells(self, list_of_cells_to_disable=None):
@@ -9352,7 +9771,7 @@ class Tree(Element):
9352
9771
  self.ParentForm.FormRemainedOpen = True
9353
9772
  # if self.ParentForm.CurrentlyRunningMainloop:
9354
9773
  # self.ParentForm.TKroot.quit()
9355
- _exit_mainloop(self.ParentForm)
9774
+ _exit_mainloop(self.ParentForm, self)
9356
9775
 
9357
9776
  def add_treeview_data(self, node):
9358
9777
  """
@@ -9389,7 +9808,7 @@ class Tree(Element):
9389
9808
  for node in node.children:
9390
9809
  self.add_treeview_data(node)
9391
9810
 
9392
- def update(self, values=None, key=None, value=None, text=None, icon=None, visible=None, expand_node=None):
9811
+ def update(self, values=None, key=None, value=None, text=None, icon=None, visible=None, expand_node=None, select_node_keys=None):
9393
9812
  """
9394
9813
  Changes some of the settings for the Tree Element. Must call `Window.Read` or `Window.Finalize` prior
9395
9814
 
@@ -9413,6 +9832,8 @@ class Tree(Element):
9413
9832
  :type visible: (bool)
9414
9833
  :param expand_node: if True the node specified by key parameter will be expanded
9415
9834
  :type expand_node: (bool)
9835
+ :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
9836
+ :type select_node_keys: List[str | int | tuple | object]
9416
9837
  """
9417
9838
 
9418
9839
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
@@ -9459,6 +9880,20 @@ class Tree(Element):
9459
9880
  except:
9460
9881
  pass
9461
9882
  # item = self.TKTreeview.item(id)
9883
+ if select_node_keys is not None:
9884
+ select_node_ids = []
9885
+ try:
9886
+ for node_key in select_node_keys:
9887
+ node_id = self.KeyToID.get(node_key, None)
9888
+ if node_id is None:
9889
+ print(f'Node key {node_key} not found in Tree.update')
9890
+ else:
9891
+ select_node_ids.append(node_id)
9892
+ self.TKTreeview.selection_set(select_node_ids)
9893
+ except Exception as e:
9894
+ _error_popup_with_traceback('Error trying to select nodes in Tree.update', e)
9895
+
9896
+
9462
9897
  if visible is False:
9463
9898
  self._pack_forget_save_settings(self.element_frame)
9464
9899
  elif visible is True:
@@ -9666,7 +10101,7 @@ VP = VPush
9666
10101
  class _TimerPeriodic:
9667
10102
  id_counter = 1
9668
10103
  # Dictionary containing the active timers. Format is {id : _TimerPeriodic object}
9669
- active_timers = {} # type: dict[int:_TimerPeriodic]
10104
+ active_timers = {} # type: dict[int , _TimerPeriodic]
9670
10105
 
9671
10106
  def __init__(self, window, frequency_ms, key=EVENT_TIMER, repeating=True):
9672
10107
  """
@@ -9770,7 +10205,7 @@ class Window:
9770
10205
  _user_defined_icon = None
9771
10206
  hidden_master_root = None # type: tk.Tk
9772
10207
  _animated_popup_dict = {} # type: Dict
9773
- _active_windows = {} # type: Dict[Window, tk.Tk()]
10208
+ _active_windows = {} # type: Dict[Window, tk.Tk]
9774
10209
  _move_all_windows = False # if one window moved, they will move
9775
10210
  _window_that_exited = None # type: Window
9776
10211
  _root_running_mainloop = None # type: tk.Tk() # (may be the hidden root or a window's root)
@@ -9792,19 +10227,20 @@ class Window:
9792
10227
 
9793
10228
  def __init__(self, title, layout=None, default_element_size=None,
9794
10229
  default_button_element_size=(None, None),
9795
- auto_size_text=None, auto_size_buttons=None, location=(None, None), relative_location=(None, None), auto_save_location=False, size=(None, None),
10230
+ auto_size_text=None, auto_size_buttons=None, location=(None, None), location_anchor=None, relative_location=(None, None), auto_save_location=False, size=(None, None),
9796
10231
  element_padding=None, margins=(None, None), button_color=None, font=None,
9797
10232
  progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
9798
10233
  auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=None, force_toplevel=False,
9799
10234
  alpha_channel=None, return_keyboard_events=False, use_default_focus=True, text_justification=None,
9800
- no_titlebar=False, grab_anywhere=False, grab_anywhere_using_control=True, keep_on_top=None, resizable=False, disable_close=False,
10235
+ no_titlebar=False, grab_anywhere=False, grab_anywhere_using_control=True, keep_on_top=None, resizable=False, use_min_size=False, disable_close=False,
9801
10236
  disable_minimize=False, right_click_menu=None, transparent_color=None, debugger_enabled=False,
9802
10237
  right_click_menu_background_color=None, right_click_menu_text_color=None, right_click_menu_disabled_text_color=None, right_click_menu_selected_colors=(None, None),
9803
10238
  right_click_menu_font=None, right_click_menu_tearoff=False,
9804
10239
  finalize=False, element_justification='left', ttk_theme=None, use_ttk_buttons=None, modal=False, enable_close_attempted_event=False,
9805
10240
  enable_window_config_events=False, repeating_timer_ms=None,
9806
- titlebar_background_color=None, titlebar_text_color=None, titlebar_font=None, titlebar_icon=None,
9807
- use_custom_titlebar=None, scaling=None,
10241
+ titlebar_background_color=None, titlebar_text_color=None, titlebar_font=None, titlebar_icon=None, use_custom_titlebar=None,
10242
+ tooltip_text_color=None, tooltip_background_color=None, tooltip_font=None, tooltip_time=DEFAULT_TOOLTIP_TIME, tooltip_offset=DEFAULT_TOOLTIP_OFFSET,
10243
+ scaling=None,
9808
10244
  sbar_trough_color=None, sbar_background_color=None, sbar_arrow_color=None, sbar_width=None, sbar_arrow_width=None, sbar_frame_color=None, sbar_relief=None, watermark=None, print_event_values=None,
9809
10245
  metadata=None):
9810
10246
  """
@@ -9815,23 +10251,25 @@ class Window:
9815
10251
  :param default_element_size: size in characters (wide) and rows (high) for all elements in this window
9816
10252
  :type default_element_size: (int, int) - (width, height)
9817
10253
  :param default_button_element_size: (width, height) size in characters (wide) and rows (high) for all Button elements in this window
9818
- :type default_button_element_size: (int, int)
10254
+ :type default_button_element_size: (int, int) | (None, None)
9819
10255
  :param auto_size_text: True if Elements in Window should be sized to exactly fir the length of text
9820
10256
  :type auto_size_text: (bool)
9821
10257
  :param auto_size_buttons: True if Buttons in this Window should be sized to exactly fit the text on this.
9822
10258
  :type auto_size_buttons: (bool)
9823
10259
  :param location: (x,y) location, in pixels, to locate the upper left corner of the window on the screen. Default is to center on screen. None will not set any location meaning the OS will decide
9824
10260
  :type location: (int, int) or (None, None) or None
9825
- :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
9826
- :type relative_location: (int, int)
10261
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
10262
+ :type location_anchor: (str)
10263
+ :param relative_location: (x,y) location relative to the default location of the window, in pixels. This location is relative to the location the window would be created. Note they can be negative.
10264
+ :type relative_location: (int, int) | (None, None)
9827
10265
  :param auto_save_location: If True the windows location will be automatically saved to a settings file and will be reloaded next time the program is run. Save happens when window close is detected
9828
10266
  :type auto_save_location: (bool)
9829
10267
  :param size: (width, height) size in pixels for this window. Normally the window is autosized to fit contents, not set to an absolute size by the user. Try not to set this value. You risk, the contents being cut off, etc. Let the layout determine the window size instead
9830
- :type size: (int, int)
10268
+ :type size: (int, int) | (None, None)
9831
10269
  :param element_padding: Default amount of padding to put around elements in window (left/right, top/bottom) or ((left, right), (top, bottom)), or an int. If an int, then it's converted into a tuple (int, int)
9832
10270
  :type element_padding: (int, int) or ((int, int),(int,int)) or int
9833
10271
  :param margins: (left/right, top/bottom) Amount of pixels to leave inside the window's frame around the edges before your elements are shown.
9834
- :type margins: (int, int)
10272
+ :type margins: (int, int) | (None, None)
9835
10273
  :param button_color: Default button colors for all buttons in the window
9836
10274
  :type button_color: (str, str) | str
9837
10275
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
@@ -9868,6 +10306,8 @@ class Window:
9868
10306
  :type keep_on_top: (bool)
9869
10307
  :param resizable: If True, allows the user to resize the window. Note the not all Elements will change size or location when resizing.
9870
10308
  :type resizable: (bool)
10309
+ :param use_min_size: If True the window's minimum size will be set when the window is created
10310
+ :type use_min_size: (bool)
9871
10311
  :param disable_close: If True, the X button in the top right corner of the window will no work. Use with caution and always give a way out toyour users
9872
10312
  :type disable_close: (bool)
9873
10313
  :param disable_minimize: if True the user won't be able to minimize window. Good for taking over entire screen and staying that way.
@@ -9875,7 +10315,7 @@ class Window:
9875
10315
  :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.
9876
10316
  :type right_click_menu: List[List[ List[str] | str ]]
9877
10317
  :param transparent_color: Any portion of the window that has this color will be completely transparent. You can even click through these spots to the window under this window.
9878
- :type transparent_color: (str)
10318
+ :type transparent_color: str | None
9879
10319
  :param debugger_enabled: If True then the internal debugger will be enabled. Also controllable via the global settings. If global settings is true then will be enabled for all windows
9880
10320
  :type debugger_enabled: (bool)
9881
10321
  :param right_click_menu_background_color: Background color for right click menus
@@ -9914,6 +10354,16 @@ class Window:
9914
10354
  :type titlebar_font: (str or (str, int[, str]) or None)
9915
10355
  :param titlebar_icon: If custom titlebar indicated by use_custom_titlebar, then use this as the icon (file or base64 bytes)
9916
10356
  :type titlebar_icon: (bytes | str)
10357
+ :param tooltip_text_color: Text color to use for tooltips in this window
10358
+ :type tooltip_text_color: str
10359
+ :param tooltip_background_color: Text background color to use for tooltips in this window
10360
+ :type tooltip_background_color: str
10361
+ :param tooltip_font: Font to use for tooltips in this window
10362
+ :type tooltip_font: str or (str, int[, str]) or None)
10363
+ :param tooltip_time: Milliseconds to show the tooltip
10364
+ :type tooltip_time: int
10365
+ :param tooltip_offset: The x,y offset from the element's location (in pixels) marking where to show the tooltip
10366
+ :type tooltip_offset: (int, int)
9917
10367
  :param use_custom_titlebar: If True, then a custom titlebar will be used instead of the normal titlebar
9918
10368
  :type use_custom_titlebar: bool
9919
10369
  :param scaling: Apply scaling to the elements in the window. Can be set on a global basis using set_options
@@ -9952,6 +10402,7 @@ class Window:
9952
10402
  self.Location = DEFAULT_WINDOW_LOCATION
9953
10403
  else:
9954
10404
  self.Location = location
10405
+ self.location_anchor = location_anchor
9955
10406
  self.RelativeLoction = relative_location
9956
10407
  self.ButtonColor = button_color_to_tuple(button_color)
9957
10408
  self.BackgroundColor = background_color if background_color else DEFAULT_BACKGROUND_COLOR
@@ -9982,6 +10433,7 @@ class Window:
9982
10433
  self.DictionaryKeyCounter = 0
9983
10434
  self.LastButtonClicked = None
9984
10435
  self.LastButtonClickedWasRealtime = False
10436
+ self.element_that_generated_event = None # type:Element
9985
10437
  self.UseDictionary = False
9986
10438
  self.UseDefaultFocus = use_default_focus
9987
10439
  self.ReturnKeyboardEvents = return_keyboard_events
@@ -9998,6 +10450,7 @@ class Window:
9998
10450
  self.KeepOnTop = keep_on_top
9999
10451
  self.ForceTopLevel = force_toplevel
10000
10452
  self.Resizable = resizable
10453
+ self.use_min_size = use_min_size
10001
10454
  self._AlphaChannel = alpha_channel if alpha_channel is not None else DEFAULT_ALPHA_CHANNEL
10002
10455
  self.Timeout = None
10003
10456
  self.TimeoutKey = TIMEOUT_KEY
@@ -10084,7 +10537,11 @@ class Window:
10084
10537
  self._mouse_offset_x = self._mouse_offset_y = 0
10085
10538
  self.watermark = watermark
10086
10539
  self.repeating_timer_ms = repeating_timer_ms
10087
-
10540
+ self.tooltip_text_color = tooltip_text_color
10541
+ self.tooltip_background_color = tooltip_background_color
10542
+ self.tooltip_font = tooltip_font
10543
+ self.tooltip_time = tooltip_time
10544
+ self.tooltip_offset = tooltip_offset
10088
10545
  # use the print event values setting if explicitly turned on or disable if explicitly turned off in this window
10089
10546
  if print_event_values is True or (pysimplegui_user_settings.get('-print event values-', False) and print_event_values is not False):
10090
10547
  self.print_event_values = True
@@ -10193,18 +10650,9 @@ class Window:
10193
10650
  CurrentRow = [] # start with a blank row and build up
10194
10651
  # ------------------------- Add the elements to a row ------------------------- #
10195
10652
  for i, element in enumerate(args): # Loop through list of elements and add them to the row
10196
-
10197
10653
  if isinstance(element, tuple) or isinstance(element, list):
10198
10654
  self.add_row(*element)
10199
10655
  continue
10200
- _error_popup_with_traceback('Error creating Window layout',
10201
- 'Layout has a LIST instead of an ELEMENT',
10202
- 'This sometimes means you have a badly placed ]',
10203
- 'The offensive list is:',
10204
- element,
10205
- 'This list will be stripped from your layout'
10206
- )
10207
- continue
10208
10656
  elif callable(element) and not isinstance(element, Element):
10209
10657
  _error_popup_with_traceback('Error creating Window layout',
10210
10658
  'Layout has a FUNCTION instead of an ELEMENT',
@@ -10544,13 +10992,13 @@ class Window:
10544
10992
  if no other GUI events happen first.
10545
10993
 
10546
10994
  :param timeout: Milliseconds to wait until the Read will return IF no other GUI events happen first
10547
- :type timeout: int|None
10995
+ :type timeout: int | None
10548
10996
  :param timeout_key: The value that will be returned from the call if the timer expired
10549
10997
  :type timeout_key: (Any)
10550
10998
  :param close: if True the window will be closed prior to returning
10551
10999
  :type close: (bool)
10552
11000
  :return: (event, values)
10553
- :rtype: Tuple[(Any), Dict[Any, Any], List[Any], None]
11001
+ :rtype: Tuple[(Any), Dict[Any, Any] | List[Any] | None]
10554
11002
  """
10555
11003
 
10556
11004
  if Window._floating_debug_window_build_needed is True:
@@ -10933,7 +11381,7 @@ class Window:
10933
11381
  :param supress_raise: Override for the global setting that determines if a key error should raise an exception
10934
11382
  :type supress_raise: (bool | None)
10935
11383
  :return: Return value can be: the Element that matches the supplied key if found; an Error Element if silent_on_error is False; None if silent_on_error True
10936
- :rtype: Element | ErrorElement | None
11384
+ :rtype: Text | Input | Multiline | Output | Combo | OptionMenu | Checkbox | Radio | Spin | Button | ButtonMenu | Slider | Listbox | Image | Graph | Canvas | ProgressBar | Table | Tree | Frame | Column | Tab | TabGroup | Pane | Push | VPush | Sizer | StatusBar | HorizontalSeparator | VerticalSeparator | Sizegrip | Menu | MenuBar | Titlebar | ErrorElement | None
10937
11385
  """
10938
11386
 
10939
11387
  key_error = False
@@ -11037,6 +11485,9 @@ class Window:
11037
11485
  ELEM_TYPE_TAB_GROUP, ELEM_TYPE_SEPARATOR):
11038
11486
  element.Key = top_window.DictionaryKeyCounter
11039
11487
  top_window.DictionaryKeyCounter += 1
11488
+ else:
11489
+ # wasn't an input element (could be a Text elem for example) and doesn't have a key so make one using the id
11490
+ element.Key = f'KeyID {hex(id(element)).upper()[2:]}'
11040
11491
  if element.Key is not None:
11041
11492
  if element.Key in key_dict.keys():
11042
11493
  if element.Type == ELEM_TYPE_BUTTON and WARN_DUPLICATE_BUTTON_KEY_ERRORS: # for Buttons see if should complain
@@ -11095,12 +11546,17 @@ class Window:
11095
11546
  def settings_save(self, values):
11096
11547
  """
11097
11548
  Saves settings to settings file using the values dictionary that is passed in.
11098
-
11549
+ If all of the values in the dictionary are None, then it will not be saved
11099
11550
  :param values: Dictionary of values to potentially save
11100
11551
  :type values: (Dict)
11101
11552
  """
11102
11553
  if values is None: # sometimes users may accidently pass in None, so just ignore it
11103
11554
  return
11555
+ # if all values in the value dictionary are None, then assume the windows was closed
11556
+ # and no values should be saved
11557
+ if all(v is None for v in values.values()):
11558
+ return
11559
+
11104
11560
  for key, value in values.items():
11105
11561
  try:
11106
11562
  element = self.find_element(key)
@@ -11120,7 +11576,7 @@ class Window:
11120
11576
  try:
11121
11577
  element = self.find_element(key)
11122
11578
  if element.setting is not None:
11123
- value = user_settings_get_entry(key, '')
11579
+ value = user_settings_get_entry(key, element.setting)
11124
11580
  element.update(value)
11125
11581
  except Exception as e:
11126
11582
  _error_popup_with_traceback('Error restoring settings', e)
@@ -11174,14 +11630,40 @@ class Window:
11174
11630
  screen_height = self.TKroot.winfo_screenheight()
11175
11631
  return screen_width, screen_height
11176
11632
 
11177
- def move(self, x, y):
11633
+
11634
+ def move(self, x, y, anchor=None):
11178
11635
  """
11179
- Move the upper left corner of this window to the x,y coordinates provided
11180
- :param x: x coordinate in pixels
11181
- :type x: (int)
11182
- :param y: y coordinate in pixels
11183
- :type y: (int)
11636
+ Move the upper left corner of this window to the x,y coordinates provided.
11637
+ If a window has an anchor set, then use the anchor. Override the window's anchor
11638
+ using the optional anchor parameter
11639
+ :param x: x coordinate in pixels
11640
+ :type x: int
11641
+ :param y: y coordinate in pixels
11642
+ :type y: int
11643
+ :param anchor: Optional anchor override
11644
+ :type anchor: str | None
11184
11645
  """
11646
+
11647
+ anchor = anchor or self.location_anchor
11648
+ if anchor != WIN_ANCHOR_UPPER_LEFT:
11649
+ win_width, win_height = self.size
11650
+
11651
+ xoff = yoff = 0
11652
+ if anchor == WIN_ANCHOR_CENTER:
11653
+ xoff, yoff = win_width // 2, win_height // 2
11654
+ elif anchor == WIN_ANCHOR_UPPER_LEFT:
11655
+ xoff, yoff = 0, 0
11656
+ elif anchor == WIN_ANCHOR_UPPER_RIGHT:
11657
+ xoff, yoff = win_width, 0
11658
+ elif anchor == WIN_ANCHOR_LOWER_LEFT:
11659
+ xoff, yoff = 0, win_height
11660
+ elif anchor == WIN_ANCHOR_LOWER_RIGHT:
11661
+ xoff, yoff = win_width, win_height
11662
+
11663
+ # move the window to the correct anchor point
11664
+ x -= xoff
11665
+ y -= yoff
11666
+
11185
11667
  try:
11186
11668
  self.TKroot.geometry("+%s+%s" % (x, y))
11187
11669
  self.config_last_location = (int(x), (int(y)))
@@ -11365,7 +11847,7 @@ class Window:
11365
11847
  self.LastButtonClicked = WINDOW_CONFIG_EVENT
11366
11848
  self.FormRemainedOpen = True
11367
11849
  self.user_bind_event = event
11368
- _exit_mainloop(self)
11850
+ _exit_mainloop(self, None)
11369
11851
 
11370
11852
  def _move_callback(self, event):
11371
11853
  """
@@ -11449,7 +11931,7 @@ class Window:
11449
11931
  self.LastKeyboardEvent = str(event.keysym) + ':' + str(event.keycode)
11450
11932
  # if not self.NonBlocking:
11451
11933
  # _BuildResults(self, False, self)
11452
- _exit_mainloop(self)
11934
+ _exit_mainloop(self, None)
11453
11935
 
11454
11936
  def _MouseWheelCallback(self, event):
11455
11937
  """
@@ -11464,7 +11946,7 @@ class Window:
11464
11946
  self.LastKeyboardEvent = 'MouseWheel:Down' if event.delta < 0 or event.num == 5 else 'MouseWheel:Up'
11465
11947
  # if not self.NonBlocking:
11466
11948
  # _BuildResults(self, False, self)
11467
- _exit_mainloop(self)
11949
+ _exit_mainloop(self, None)
11468
11950
 
11469
11951
  @property
11470
11952
  def right_click_menu_element(self):
@@ -11586,7 +12068,7 @@ class Window:
11586
12068
  return
11587
12069
  self._auto_save_location()
11588
12070
  if self.CurrentlyRunningMainloop: # quit if this is the current mainloop, otherwise don't quit!
11589
- _exit_mainloop(self)
12071
+ _exit_mainloop(self, None)
11590
12072
  if self.close_destroys_window:
11591
12073
  self.TKroot.destroy() # destroy this window
11592
12074
  self.TKrootDestroyed = True
@@ -11594,7 +12076,7 @@ class Window:
11594
12076
  else:
11595
12077
  self.LastButtonClicked = WINDOW_CLOSE_ATTEMPTED_EVENT
11596
12078
  elif Window._root_running_mainloop == Window.hidden_master_root:
11597
- _exit_mainloop(self)
12079
+ _exit_mainloop(self, None)
11598
12080
  else:
11599
12081
  if self.close_destroys_window:
11600
12082
  self.TKroot.destroy() # destroy this window
@@ -11763,7 +12245,7 @@ class Window:
11763
12245
  except Exception as e:
11764
12246
  warnings.warn('Problem in Window.keep_on_top_clear trying to clear wm_attributes topmost' + str(e), UserWarning)
11765
12247
 
11766
- def current_location(self, more_accurate=False, without_titlebar=False):
12248
+ def current_location(self, more_accurate=False, without_titlebar=False, use_anchor=None):
11767
12249
  """
11768
12250
  Get the current location of the window's top left corner.
11769
12251
  Sometimes, depending on the environment, the value returned does not include the titlebar,etc
@@ -11777,8 +12259,10 @@ class Window:
11777
12259
  :type more_accurate: (bool)
11778
12260
  :param without_titlebar: If True, return location of top left of main window area without the titlebar (may be OS dependent?)
11779
12261
  :type without_titlebar: (bool)
12262
+ :param use_anchor: Return location of a specific anchor point on the window. WIN_ANCHOR_UPPER_LEFT is default
12263
+ :type use_anchor: (str)
11780
12264
  :return: The x and y location in tuple form (x,y)
11781
- :rtype: Tuple[(int | None), (int | None)]
12265
+ :rtype: Tuple[int, int] | Tuple[None, None]
11782
12266
  """
11783
12267
 
11784
12268
  if not self._is_window_created('tried Window.current_location'):
@@ -11792,6 +12276,17 @@ class Window:
11792
12276
  x, y = int(location[0]), int(location[1])
11793
12277
  else:
11794
12278
  x, y = int(self.TKroot.winfo_x()), int(self.TKroot.winfo_y())
12279
+ if use_anchor is not None:
12280
+ if use_anchor == WIN_ANCHOR_UPPER_RIGHT:
12281
+ x += self.size[0]
12282
+ elif use_anchor == WIN_ANCHOR_LOWER_LEFT:
12283
+ y += self.size[1]
12284
+ elif use_anchor == WIN_ANCHOR_LOWER_RIGHT:
12285
+ x += self.size[0]
12286
+ y += self.size[1]
12287
+ elif use_anchor == WIN_ANCHOR_CENTER:
12288
+ x += self.size[0]//2
12289
+ y += self.size[1]//2
11795
12290
  except Exception as e:
11796
12291
  warnings.warn('Error in Window.current_location. Trouble getting x,y location\n' + str(e), UserWarning)
11797
12292
  x, y = (None, None)
@@ -11969,7 +12464,7 @@ class Window:
11969
12464
  self.FormRemainedOpen = True
11970
12465
  # if self.CurrentlyRunningMainloop:
11971
12466
  # self.TKroot.quit()
11972
- _exit_mainloop(self)
12467
+ _exit_mainloop(self, None)
11973
12468
  return 'break' if propagate is not True else None
11974
12469
 
11975
12470
  def bind(self, bind_string, key, propagate=True):
@@ -12163,7 +12658,7 @@ class Window:
12163
12658
 
12164
12659
  if self._queued_thread_event_available():
12165
12660
  self.FormRemainedOpen = True
12166
- _exit_mainloop(self)
12661
+ _exit_mainloop(self, None)
12167
12662
 
12168
12663
  def _create_thread_queue(self):
12169
12664
  """
@@ -12431,7 +12926,6 @@ class Window:
12431
12926
  """
12432
12927
  One of the Custom Titlbar buttons was clicked
12433
12928
  :param key:
12434
- :return:
12435
12929
  """
12436
12930
  if key == TITLEBAR_MINIMIZE_KEY:
12437
12931
  if not self.DisableMinimize:
@@ -12446,22 +12940,49 @@ class Window:
12446
12940
  if not self.DisableClose:
12447
12941
  self._OnClosingCallback()
12448
12942
 
12943
+ def _parse_h_m_s(self, h_m_s):
12944
+ """
12945
+ Parses Hour:Minute:Seconds string into an int tuple (hour, min, sec)
12946
+
12947
+ :param h_m_s: If True then repeat timer events until timer is explicitly stopped
12948
+ :type h_m_s: str
12949
+ :return: Timer ID for the timer or None if error
12950
+ :rtype: Tuple(int, int, int) | Tuple(None, None, None)
12951
+ """
12952
+
12953
+ try:
12954
+ hours, minutes, seconds = map(int, h_m_s.split(":"))
12955
+ except:
12956
+ return None, None, None
12957
+ return hours, minutes, seconds
12958
+
12959
+
12449
12960
  def timer_start(self, frequency_ms, key=EVENT_TIMER, repeating=True):
12450
12961
  """
12451
- Starts a timer that gnerates Timer Events. The default is to repeat the timer events until timer is stopped.
12962
+ Starts a timer that gnerates Timer Events.
12963
+ Time can be specified as an integer number of milliseconds or a string format "H:M:S"
12964
+ The default is to repeat the timer events until timer is stopped.
12452
12965
  You can provide your own key or a default key will be used. The default key is defined
12453
12966
  with the constants EVENT_TIMER or TIMER_KEY. They both equal the same value.
12454
12967
  The values dictionary will contain the timer ID that is returned from this function.
12455
12968
 
12456
- :param frequency_ms: How often to generate timer events in milliseconds
12457
- :type frequency_ms: int
12969
+ :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
12970
+ :type frequency_ms: None | int | str
12458
12971
  :param key: Key to be returned as the timer event
12459
12972
  :type key: str | int | tuple | object
12460
12973
  :param repeating: If True then repeat timer events until timer is explicitly stopped
12461
12974
  :type repeating: bool
12462
- :return: Timer ID for the timer
12463
- :rtype: int
12975
+ :return: Timer ID for the timer or None if error
12976
+ :rtype: int | None
12464
12977
  """
12978
+ if isinstance(frequency_ms, str):
12979
+ try:
12980
+ hour, min, sec = self._parse_h_m_s(frequency_ms)
12981
+ frequency_ms = (hour * 3600 + min * 60 + sec) * 1000
12982
+ except Exception as e:
12983
+ popup_error_with_traceback('Error in H:M:S string', f'Error in H:M:S string = {frequency_ms}', e)
12984
+ return None
12985
+
12465
12986
  timer = _TimerPeriodic(self, frequency_ms=frequency_ms, key=key, repeating=repeating)
12466
12987
  return timer.id
12467
12988
 
@@ -12523,7 +13044,7 @@ class Window:
12523
13044
  :param key: The key to find
12524
13045
  :type key: str | int | tuple | object
12525
13046
  :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
13047
+ :rtype: Text | Input | Multiline | Output | Combo | OptionMenu | Checkbox | Radio | Spin | Button | ButtonMenu | Slider | Listbox | Image | Graph | Canvas | ProgressBar | Table | Tree | Frame | Column | Tab | TabGroup | Pane | Push | VPush | Sizer | StatusBar | HorizontalSeparator | VerticalSeparator | Sizegrip | Menu | MenuBar | Titlebar
12527
13048
  """
12528
13049
 
12529
13050
  return self.find_element(key)
@@ -12606,6 +13127,7 @@ class Window:
12606
13127
  FlexForm = Window
12607
13128
 
12608
13129
 
13130
+
12609
13131
  def _long_func_thread(window, end_key, original_func):
12610
13132
  """
12611
13133
  Used to run long operations on the user's behalf. Called by the window object
@@ -12623,8 +13145,16 @@ def _long_func_thread(window, end_key, original_func):
12623
13145
  window.write_event_value(end_key, return_value)
12624
13146
 
12625
13147
 
12626
- def _exit_mainloop(exiting_window):
13148
+ def _exit_mainloop(exiting_window, element_causing_event):
13149
+ """
13150
+ Used to break out of the tkinter mainloop. Elements can call this to cause a Window.read function to return to use
13151
+ :param exiting_window: The window that wants to exit
13152
+ :type exiting_window: (Window)
13153
+ :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)
13154
+ :type element_causing_event: (Element|None)
13155
+ """
12627
13156
  if exiting_window == Window._window_running_mainloop or Window._root_running_mainloop == Window.hidden_master_root:
13157
+ exiting_window.element_that_generated_event = element_causing_event
12628
13158
  Window._window_that_exited = exiting_window
12629
13159
  if Window._root_running_mainloop is not None:
12630
13160
  Window._root_running_mainloop.quit()
@@ -12977,7 +13507,7 @@ class SystemTray:
12977
13507
  :param alpha: Alpha channel. 0 - invisible 1 - fully visible
12978
13508
  :type alpha: (float)
12979
13509
  :param location: Location on the screen to display the window
12980
- :type location: (int, int)
13510
+ :type location: (int, int) | None
12981
13511
  :return: (int) reason for returning
12982
13512
  :rtype: (int)
12983
13513
  """
@@ -12999,7 +13529,7 @@ class SystemTray:
12999
13529
  layout = [[Graph(canvas_size=(win_width, win_height), graph_bottom_left=(0, win_height), graph_top_right=(win_width, 0), key="-GRAPH-",
13000
13530
  background_color=SYSTEM_TRAY_MESSAGE_WIN_COLOR, enable_events=True)]]
13001
13531
 
13002
- win_location = location if location is not None else (screen_res_x - win_width - win_margin[0], screen_res_y - win_height - win_margin[1])
13532
+ win_location = location if location not in (None, (None, None)) else (screen_res_x - win_width - win_margin[0], screen_res_y - win_height - win_margin[1])
13003
13533
  window = Window(title, layout, background_color=SYSTEM_TRAY_MESSAGE_WIN_COLOR, no_titlebar=True,
13004
13534
  location=win_location, keep_on_top=True, alpha_channel=0, margins=(0, 0), element_padding=(0, 0), grab_anywhere=True, finalize=True)
13005
13535
 
@@ -13311,7 +13841,7 @@ def FolderBrowse(button_text='Browse', target=(ThisRow, -1), initial_folder=None
13311
13841
  :param tooltip: text, that will appear when mouse hovers over the element
13312
13842
  :type tooltip: (str)
13313
13843
  :param size: (w,h) w=characters-wide, h=rows-high
13314
- :type size: (int, int)
13844
+ :type size: (int, int) | (None, None) | int
13315
13845
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13316
13846
  :type s: (int, int) | (None, None) | int
13317
13847
  :param auto_size_button: True if button size is determined by button text
@@ -13370,7 +13900,7 @@ def FileBrowse(button_text='Browse', target=(ThisRow, -1), file_types=FILE_TYPES
13370
13900
  :param tooltip: text, that will appear when mouse hovers over the element
13371
13901
  :type tooltip: (str)
13372
13902
  :param size: (w,h) w=characters-wide, h=rows-high
13373
- :type size: (int, int)
13903
+ :type size: (int, int) | (None, None) | int
13374
13904
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13375
13905
  :type s: (int, int) | (None, None) | int
13376
13906
  :param auto_size_button: True if button size is determined by button text
@@ -13431,7 +13961,7 @@ def FilesBrowse(button_text='Browse', target=(ThisRow, -1), file_types=FILE_TYPE
13431
13961
  :param tooltip: text, that will appear when mouse hovers over the element
13432
13962
  :type tooltip: (str)
13433
13963
  :param size: (w,h) w=characters-wide, h=rows-high
13434
- :type size: (int, int)
13964
+ :type size: (int, int) | (None, None) | int
13435
13965
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13436
13966
  :type s: (int, int) | (None, None) | int
13437
13967
  :param auto_size_button: True if button size is determined by button text
@@ -13495,7 +14025,7 @@ def FileSaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=FILE_T
13495
14025
  :param tooltip: text, that will appear when mouse hovers over the element
13496
14026
  :type tooltip: (str)
13497
14027
  :param size: (w,h) w=characters-wide, h=rows-high
13498
- :type size: (int, int)
14028
+ :type size: (int, int) | (None, None) | int
13499
14029
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13500
14030
  :type s: (int, int) | (None, None) | int
13501
14031
  :param auto_size_button: True if button size is determined by button text
@@ -13554,7 +14084,7 @@ def SaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=FILE_TYPES
13554
14084
  :param tooltip: text, that will appear when mouse hovers over the element
13555
14085
  :type tooltip: (str)
13556
14086
  :param size: (w,h) w=characters-wide, h=rows-high
13557
- :type size: (int, int)
14087
+ :type size: (int, int) | (None, None) | int
13558
14088
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13559
14089
  :type s: (int, int) | (None, None) | int
13560
14090
  :param auto_size_button: True if button size is determined by button text
@@ -13599,7 +14129,7 @@ def Save(button_text='Save', size=(None, None), s=(None, None), auto_size_button
13599
14129
  :param button_text: text in the button (Default value = 'Save')
13600
14130
  :type button_text: (str)
13601
14131
  :param size: (w,h) w=characters-wide, h=rows-high
13602
- :type size: (int, int)
14132
+ :type size: (int, int) | (None, None) | int
13603
14133
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13604
14134
  :type s: (int, int) | (None, None) | int
13605
14135
  :param auto_size_button: True if button size is determined by button text
@@ -13698,7 +14228,7 @@ def Open(button_text='Open', size=(None, None), s=(None, None), auto_size_button
13698
14228
  :param button_text: text in the button (Default value = 'Open')
13699
14229
  :type button_text: (str)
13700
14230
  :param size: (w,h) w=characters-wide, h=rows-high
13701
- :type size: (int, int)
14231
+ :type size: (int, int) | (None, None) | int
13702
14232
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13703
14233
  :type s: (int, int) | (None, None) | int
13704
14234
  :param auto_size_button: True if button size is determined by button text
@@ -13747,7 +14277,7 @@ def OK(button_text='OK', size=(None, None), s=(None, None), auto_size_button=Non
13747
14277
  :param button_text: text in the button (Default value = 'OK')
13748
14278
  :type button_text: (str)
13749
14279
  :param size: (w,h) w=characters-wide, h=rows-high
13750
- :type size: (int, int)
14280
+ :type size: (int, int) | (None, None) | int
13751
14281
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13752
14282
  :type s: (int, int) | (None, None) | int
13753
14283
  :param auto_size_button: True if button size is determined by button text
@@ -13796,7 +14326,7 @@ def Ok(button_text='Ok', size=(None, None), s=(None, None), auto_size_button=Non
13796
14326
  :param button_text: text in the button (Default value = 'Ok')
13797
14327
  :type button_text: (str)
13798
14328
  :param size: (w,h) w=characters-wide, h=rows-high
13799
- :type size: (int, int)
14329
+ :type size: (int, int) | (None, None) | int
13800
14330
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13801
14331
  :type s: (int, int) | (None, None) | int
13802
14332
  :param auto_size_button: True if button size is determined by button text
@@ -13845,7 +14375,7 @@ def Cancel(button_text='Cancel', size=(None, None), s=(None, None), auto_size_bu
13845
14375
  :param button_text: text in the button (Default value = 'Cancel')
13846
14376
  :type button_text: (str)
13847
14377
  :param size: (w,h) w=characters-wide, h=rows-high
13848
- :type size: (int, int)
14378
+ :type size: (int, int) | (None, None) | int
13849
14379
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13850
14380
  :type s: (int, int) | (None, None) | int
13851
14381
  :param auto_size_button: True if button size is determined by button text
@@ -13894,7 +14424,7 @@ def Quit(button_text='Quit', size=(None, None), s=(None, None), auto_size_button
13894
14424
  :param button_text: text in the button (Default value = 'Quit')
13895
14425
  :type button_text: (str)
13896
14426
  :param size: (w,h) w=characters-wide, h=rows-high
13897
- :type size: (int, int)
14427
+ :type size: (int, int) | (None, None) | int
13898
14428
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13899
14429
  :type s: (int, int) | (None, None) | int
13900
14430
  :param auto_size_button: True if button size is determined by button text
@@ -13943,7 +14473,7 @@ def Exit(button_text='Exit', size=(None, None), s=(None, None), auto_size_button
13943
14473
  :param button_text: text in the button (Default value = 'Exit')
13944
14474
  :type button_text: (str)
13945
14475
  :param size: (w,h) w=characters-wide, h=rows-high
13946
- :type size: (int, int)
14476
+ :type size: (int, int) | (None, None) | int
13947
14477
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13948
14478
  :type s: (int, int) | (None, None) | int
13949
14479
  :param auto_size_button: True if button size is determined by button text
@@ -13992,7 +14522,7 @@ def Yes(button_text='Yes', size=(None, None), s=(None, None), auto_size_button=N
13992
14522
  :param button_text: text in the button (Default value = 'Yes')
13993
14523
  :type button_text: (str)
13994
14524
  :param size: (w,h) w=characters-wide, h=rows-high
13995
- :type size: (int, int)
14525
+ :type size: (int, int) | (None, None) | int
13996
14526
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
13997
14527
  :type s: (int, int) | (None, None) | int
13998
14528
  :param auto_size_button: True if button size is determined by button text
@@ -14041,7 +14571,7 @@ def No(button_text='No', size=(None, None), s=(None, None), auto_size_button=Non
14041
14571
  :param button_text: text in the button (Default value = 'No')
14042
14572
  :type button_text: (str)
14043
14573
  :param size: (w,h) w=characters-wide, h=rows-high
14044
- :type size: (int, int)
14574
+ :type size: (int, int) | (None, None) | int
14045
14575
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14046
14576
  :type s: (int, int) | (None, None) | int
14047
14577
  :param auto_size_button: True if button size is determined by button text
@@ -14090,7 +14620,7 @@ def Help(button_text='Help', size=(None, None), s=(None, None), auto_size_button
14090
14620
  :param button_text: text in the button (Default value = 'Help')
14091
14621
  :type button_text: (str)
14092
14622
  :param size: (w,h) w=characters-wide, h=rows-high
14093
- :type size: (int, int)
14623
+ :type size: (int, int) | (None, None) | int
14094
14624
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14095
14625
  :type s: (int, int) | (None, None) | int
14096
14626
  :param auto_size_button: True if button size is determined by button text
@@ -14142,7 +14672,7 @@ def Debug(button_text='', size=(None, None), s=(None, None), auto_size_button=No
14142
14672
  :param button_text: text in the button (Default value = '')
14143
14673
  :type button_text: (str)
14144
14674
  :param size: (w,h) w=characters-wide, h=rows-high
14145
- :type size: (int, int)
14675
+ :type size: (int, int) | (None, None) | int
14146
14676
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14147
14677
  :type s: (int, int) | (None, None) | int
14148
14678
  :param auto_size_button: True if button size is determined by button text
@@ -14209,7 +14739,7 @@ def SimpleButton(button_text, image_filename=None, image_data=None, image_size=(
14209
14739
  :param tooltip: text, that will appear when mouse hovers over the element
14210
14740
  :type tooltip: (str)
14211
14741
  :param size: (w,h) w=characters-wide, h=rows-high
14212
- :type size: (int, int)
14742
+ :type size: (int, int) | (None, None) | int
14213
14743
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14214
14744
  :type s: (int, int) | (None, None) | int
14215
14745
  :param auto_size_button: True if button size is determined by button text
@@ -14271,7 +14801,7 @@ def CloseButton(button_text, image_filename=None, image_data=None, image_size=(N
14271
14801
  :param tooltip: text, that will appear when mouse hovers over the element
14272
14802
  :type tooltip: (str)
14273
14803
  :param size: (w,h) w=characters-wide, h=rows-high
14274
- :type size: (int, int)
14804
+ :type size: (int, int) | (None, None) | int
14275
14805
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14276
14806
  :type s: (int, int) | (None, None) | int
14277
14807
  :param auto_size_button: True if button size is determined by button text
@@ -14331,7 +14861,7 @@ def ReadButton(button_text, image_filename=None, image_data=None, image_size=(No
14331
14861
  :param tooltip: text, that will appear when mouse hovers over the element
14332
14862
  :type tooltip: (str)
14333
14863
  :param size: (w,h) w=characters-wide, h=rows-high
14334
- :type size: (int, int)
14864
+ :type size: (int, int) | (None, None) | int
14335
14865
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14336
14866
  :type s: (int, int) | (None, None) | int
14337
14867
  :param auto_size_button: True if button size is determined by button text
@@ -14398,7 +14928,7 @@ def RealtimeButton(button_text, image_filename=None, image_data=None, image_size
14398
14928
  :param tooltip: text, that will appear when mouse hovers over the element
14399
14929
  :type tooltip: (str)
14400
14930
  :param size: (w,h) w=characters-wide, h=rows-high
14401
- :type size: (int, int)
14931
+ :type size: (int, int) | (None, None) | int
14402
14932
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14403
14933
  :type s: (int, int) | (None, None) | int
14404
14934
  :param auto_size_button: True if button size is determined by button text
@@ -14539,7 +15069,7 @@ def CalendarButton(button_text, target=(ThisRow, -1), close_when_date_chosen=Tru
14539
15069
  :param border_width: width of border around element
14540
15070
  :type border_width: width of border around element
14541
15071
  :param size: (w,h) w=characters-wide, h=rows-high
14542
- :type size: (int, int)
15072
+ :type size: (int, int) | (None, None) | int
14543
15073
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14544
15074
  :type s: (int, int) | (None, None) | int
14545
15075
  :param auto_size_button: True if button size is determined by button text
@@ -14577,7 +15107,7 @@ def CalendarButton(button_text, target=(ThisRow, -1), close_when_date_chosen=Tru
14577
15107
  :param no_titlebar: if True no titlebar will be shown on the date chooser window
14578
15108
  :type no_titlebar: bool
14579
15109
  :param location: Location on the screen (x,y) to show the calendar popup window
14580
- :type location: (int, int)
15110
+ :type location: (int, int) | (None, None)
14581
15111
  :param visible: set initial visibility state of the Button
14582
15112
  :type visible: (bool)
14583
15113
  :param metadata: Anything you want to store along with this button
@@ -14625,7 +15155,7 @@ def ColorChooserButton(button_text, target=(ThisRow, -1), image_filename=None, i
14625
15155
  :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
14626
15156
  :type image_data: bytes | str
14627
15157
  :param image_size: Size of the image in pixels (width, height)
14628
- :type image_size: (int, int)
15158
+ :type image_size: (int, int) | (None, None)
14629
15159
  :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
14630
15160
  :type image_subsample: (int)
14631
15161
  :param tooltip: text, that will appear when mouse hovers over the element
@@ -14633,7 +15163,7 @@ def ColorChooserButton(button_text, target=(ThisRow, -1), image_filename=None, i
14633
15163
  :param border_width: width of border around element
14634
15164
  :type border_width: (int)
14635
15165
  :param size: (w,h) w=characters-wide, h=rows-high
14636
- :type size: (int, int)
15166
+ :type size: (int, int) | (None, None) | int
14637
15167
  :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
14638
15168
  :type s: (int, int) | (None, None) | int
14639
15169
  :param auto_size_button: True if button size is determined by button text
@@ -14896,8 +15426,11 @@ def _BuildResultsForSubform(form, initialize_only, top_level_form):
14896
15426
  value = element.TKStringVar.get()
14897
15427
  except:
14898
15428
  value = ''
15429
+ if element.showing_placeholder: # if showing the placeholder then set value returned to ''
15430
+ value = ''
14899
15431
  if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents:
14900
- element.TKStringVar.set('')
15432
+ if top_level_form.element_that_generated_event is not None and top_level_form.element_that_generated_event.Type == ELEM_TYPE_BUTTON and top_level_form.element_that_generated_event.BType != BUTTON_TYPE_CALENDAR_CHOOSER:
15433
+ element.TKStringVar.set('')
14901
15434
  elif element.Type == ELEM_TYPE_INPUT_CHECKBOX:
14902
15435
  value = element.TKIntVar.get()
14903
15436
  value = (value != 0)
@@ -14959,7 +15492,8 @@ def _BuildResultsForSubform(form, initialize_only, top_level_form):
14959
15492
  if element.rstrip:
14960
15493
  value = value.rstrip()
14961
15494
  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)
15495
+ if top_level_form.element_that_generated_event is not None and top_level_form.element_that_generated_event.BType != BUTTON_TYPE_CALENDAR_CHOOSER:
15496
+ element.TKText.delete('1.0', tk.END)
14963
15497
  except:
14964
15498
  value = None
14965
15499
  elif element.Type == ELEM_TYPE_TAB_GROUP:
@@ -14977,6 +15511,9 @@ def _BuildResultsForSubform(form, initialize_only, top_level_form):
14977
15511
  value = element.SelectedRows
14978
15512
  elif element.Type == ELEM_TYPE_GRAPH:
14979
15513
  value = element.ClickPosition
15514
+ if top_level_form.element_that_generated_event == element:
15515
+ top_level_form.LastButtonClickedWasRealtime = False
15516
+ top_level_form.element_that_generated_event = None
14980
15517
  elif element.Type == ELEM_TYPE_MENUBAR:
14981
15518
  if element.MenuItemChosen is not None:
14982
15519
  event = top_level_form.LastButtonClicked = element.MenuItemChosen
@@ -15346,6 +15883,7 @@ def _add_right_click_menu(element, toplevel_form):
15346
15883
  top_menu.config(activebackground=toplevel_form.right_click_menu_selected_colors[1])
15347
15884
  AddMenuItem(top_menu, menu[1], element, right_click_menu=True)
15348
15885
  element.TKRightClickMenu = top_menu
15886
+ element.RightClickMenu = menu # Store the menu in the element in case the window was the source
15349
15887
  if (running_mac()):
15350
15888
  element.Widget.bind('<ButtonRelease-2>', element._RightClickMenuCallback)
15351
15889
  else:
@@ -15620,6 +16158,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
15620
16158
  top_menu.config(activebackground=toplevel_form.right_click_menu_selected_colors[1])
15621
16159
  AddMenuItem(top_menu, menu[1], element, right_click_menu=True)
15622
16160
  element.TKRightClickMenu = top_menu
16161
+ element.RightClickMenu = menu # Store the menu in the element in case the window was the source
15623
16162
  if toplevel_form.RightClickMenu: # if the top level has a right click menu, then setup a callback for the Window itself
15624
16163
  if toplevel_form.TKRightClickMenu is None:
15625
16164
  toplevel_form.TKRightClickMenu = top_menu
@@ -15722,12 +16261,17 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
15722
16261
  element = element # type: Column
15723
16262
  # ----------------------- SCROLLABLE Column ----------------------
15724
16263
  if element.Scrollable:
15725
- element.Widget = element.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly, element, toplevel_form) # do not use yet! not working
16264
+ element.Widget = element.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly, element.HorizontalScrollOnly, element, toplevel_form) # do not use yet! not working
15726
16265
  PackFormIntoFrame(element, element.TKColFrame.TKFrame, toplevel_form)
15727
16266
  element.TKColFrame.TKFrame.update()
15728
16267
  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)
16268
+ width = element.TKColFrame.TKFrame.winfo_reqwidth()
16269
+ if element.HorizontalScrollOnly:
16270
+ width = width // element.size_subsample_width
16271
+ height = element.TKColFrame.TKFrame.winfo_reqheight()
16272
+ if element.VerticalScrollOnly:
16273
+ height = height // element.size_subsample_height
16274
+ element.TKColFrame.canvas.config(width=width, height=height)
15731
16275
  else:
15732
16276
  element.TKColFrame.canvas.config(width=element.TKColFrame.TKFrame.winfo_reqwidth() // element.size_subsample_width,
15733
16277
  height=element.TKColFrame.TKFrame.winfo_reqheight() // element.size_subsample_height)
@@ -15898,7 +16442,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
15898
16442
  if element.ClickSubmits:
15899
16443
  tktext_label.bind('<Button-1>', element._TextClickedHandler)
15900
16444
  if element.Tooltip is not None:
15901
- element.TooltipObject = ToolTip(element.TKText, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
16445
+ element.TooltipObject = ToolTip(element.TKText, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
15902
16446
  _add_right_click_menu_and_grab(element)
15903
16447
  if element.Grab:
15904
16448
  element._grab_anywhere_on()
@@ -15970,7 +16514,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
15970
16514
  element.TKButton = tkbutton # not used yet but save the TK button in case
15971
16515
  if elementpad[0] == 0 or elementpad[1] == 0:
15972
16516
  tkbutton.config(highlightthickness=0)
15973
-
15974
16517
  ## -------------- TK Button With Image -------------- ##
15975
16518
  if element.ImageFilename: # if button has an image on it
15976
16519
  tkbutton.config(highlightthickness=0)
@@ -16011,11 +16554,17 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16011
16554
  'Buton element key: {}'.format(element.Key),
16012
16555
  "Parent Window's Title: {}".format(toplevel_form.Title))
16013
16556
 
16557
+ # Setup bindings if there's a mouseover image
16558
+ if element.mouseover_image_source:
16559
+ tkbutton.bind('<Enter>', element._mouseover_enter)
16560
+ tkbutton.bind('<Leave>', element._mouseover_leave)
16561
+
16014
16562
  if width != 0:
16015
16563
  wraplen = width * _char_width_in_pixels(font)
16016
16564
  tkbutton.configure(wraplength=wraplen) # set wrap to width of widget
16017
16565
  expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
16018
16566
 
16567
+
16019
16568
  tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill)
16020
16569
  if element.visible is False:
16021
16570
  element._pack_forget_save_settings()
@@ -16038,8 +16587,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16038
16587
  tkbutton.config(activeforeground=element.MouseOverColors[0])
16039
16588
 
16040
16589
  if element.Tooltip is not None:
16041
- element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip,
16042
- timeout=DEFAULT_TOOLTIP_TIME)
16590
+ element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font, skip_bind=element.mouseover_image_source is not None)
16043
16591
  try:
16044
16592
  if element.HighlightColors[1] != COLOR_SYSTEM_DEFAULT:
16045
16593
  tkbutton.config(highlightbackground=element.HighlightColors[1])
@@ -16164,6 +16712,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16164
16712
  # tkbutton.configure(image=photo, compound=tk.CENTER, width=width, height=height)
16165
16713
  tkbutton.image = photo
16166
16714
 
16715
+ # Setup bindings if there's a mouseover image
16716
+ if element.mouseover_image_source:
16717
+ tkbutton.bind('<Enter>', element._mouseover_enter)
16718
+ tkbutton.bind('<Leave>', element._mouseover_leave)
16719
+
16167
16720
  element.TKButton = tkbutton # not used yet but save the TK button in case
16168
16721
  expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
16169
16722
  tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill)
@@ -16184,8 +16737,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16184
16737
  _add_right_click_menu_and_grab(element)
16185
16738
 
16186
16739
  if element.Tooltip is not None:
16187
- element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip,
16188
- timeout=DEFAULT_TOOLTIP_TIME)
16740
+ element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font, skip_bind=element.mouseover_image_source is not None)
16189
16741
  # ------------------------- BUTTONMENU placement element ------------------------- #
16190
16742
  elif element_type == ELEM_TYPE_BUTTONMENU:
16191
16743
  element = element # type: ButtonMenu
@@ -16280,7 +16832,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16280
16832
  if element.Disabled == True:
16281
16833
  element.TKButton['state'] = 'disabled'
16282
16834
  if element.Tooltip is not None:
16283
- element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
16835
+ element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16284
16836
 
16285
16837
  # ------------------------- INPUT placement element ------------------------- #
16286
16838
  elif element_type == ELEM_TYPE_INPUT_TEXT:
@@ -16296,9 +16848,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16296
16848
  justification = DEFAULT_TEXT_JUSTIFICATION
16297
16849
  justify = tk.LEFT if justification.startswith('l') else tk.CENTER if justification.startswith('c') else tk.RIGHT
16298
16850
  # anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE
16299
- element.TKEntry = element.Widget = tk.Entry(tk_row_frame, width=element_size[0],
16300
- textvariable=element.TKStringVar, bd=bd,
16301
- font=font, show=show, justify=justify)
16851
+ element.TKEntry = element.Widget = tk.Entry(tk_row_frame, width=element_size[0], textvariable=element.TKStringVar, bd=bd, font=font, show=show, justify=justify)
16302
16852
  if element.ChangeSubmits:
16303
16853
  element.TKEntry.bind('<Key>', element._KeyboardHandler)
16304
16854
  element.TKEntry.bind('<Return>', element._ReturnKeyHandler)
@@ -16336,9 +16886,16 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16336
16886
  element.TKEntry['state'] = 'readonly'
16337
16887
 
16338
16888
  if element.Tooltip is not None:
16339
- element.TooltipObject = ToolTip(element.TKEntry, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
16889
+ element.TooltipObject = ToolTip(element.TKEntry, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font, skip_bind=element.placeholder is not None)
16340
16890
  _add_right_click_menu_and_grab(element)
16341
16891
 
16892
+ if element.placeholder:
16893
+ element.TKEntry.bind('<Enter>', element._on_mouse_or_focus)
16894
+ element.TKEntry.bind('<Leave>', element._on_mouse_or_focus)
16895
+ element.TKEntry.bind('<FocusIn>', element._on_mouse_or_focus)
16896
+ element.TKEntry.bind('<FocusOut>', element._on_mouse_or_focus)
16897
+ element.update_placeholder()
16898
+
16342
16899
  # row_should_expand = True
16343
16900
 
16344
16901
  # ------------------------- COMBO placement element ------------------------- #
@@ -16437,7 +16994,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16437
16994
  if element.Disabled is True: # note overrides readonly if disabled
16438
16995
  element.TKCombo['state'] = 'disabled'
16439
16996
  if element.Tooltip is not None:
16440
- element.TooltipObject = ToolTip(element.TKCombo, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
16997
+ element.TooltipObject = ToolTip(element.TKCombo, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16441
16998
  _add_right_click_menu_and_grab(element)
16442
16999
 
16443
17000
  # ------------------------- OPTIONMENU placement Element (Like ComboBox but different) element ------------------------- #
@@ -16471,8 +17028,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16471
17028
  if element.Disabled == True:
16472
17029
  element.TKOptionMenu['state'] = 'disabled'
16473
17030
  if element.Tooltip is not None:
16474
- element.TooltipObject = ToolTip(element.TKOptionMenu, text=element.Tooltip,
16475
- timeout=DEFAULT_TOOLTIP_TIME)
17031
+ element.TooltipObject = ToolTip(element.TKOptionMenu, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16476
17032
  # ------------------------- LISTBOX placement element ------------------------- #
16477
17033
  elif element_type == ELEM_TYPE_INPUT_LISTBOX:
16478
17034
  element = element # type: Listbox
@@ -16547,8 +17103,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16547
17103
  if element.Disabled is True:
16548
17104
  element.TKListbox['state'] = 'disabled'
16549
17105
  if element.Tooltip is not None:
16550
- element.TooltipObject = ToolTip(element.TKListbox, text=element.Tooltip,
16551
- timeout=DEFAULT_TOOLTIP_TIME)
17106
+ element.TooltipObject = ToolTip(element.TKListbox, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16552
17107
  _add_right_click_menu_and_grab(element)
16553
17108
  # ------------------------- MULTILINE placement element ------------------------- #
16554
17109
  elif element_type == ELEM_TYPE_INPUT_MULTILINE:
@@ -16634,7 +17189,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16634
17189
  if element.Disabled is True:
16635
17190
  element.TKText['state'] = 'disabled'
16636
17191
  if element.Tooltip is not None:
16637
- element.TooltipObject = ToolTip(element.TKText, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17192
+ element.TooltipObject = ToolTip(element.TKText, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16638
17193
 
16639
17194
  if element.reroute_cprint:
16640
17195
  cprint_set_output_destination(toplevel_form, element.Key)
@@ -16682,8 +17237,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16682
17237
  element._pack_forget_save_settings()
16683
17238
  # element.TKCheckbutton.pack_forget()
16684
17239
  if element.Tooltip is not None:
16685
- element.TooltipObject = ToolTip(element.TKCheckbutton, text=element.Tooltip,
16686
- timeout=DEFAULT_TOOLTIP_TIME)
17240
+ element.TooltipObject = ToolTip(element.TKCheckbutton, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16687
17241
  _add_right_click_menu_and_grab(element)
16688
17242
 
16689
17243
  # ------------------------- PROGRESS placement element ------------------------- #
@@ -16764,7 +17318,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16764
17318
  element._pack_forget_save_settings()
16765
17319
  # element.TKRadio.pack_forget()
16766
17320
  if element.Tooltip is not None:
16767
- element.TooltipObject = ToolTip(element.TKRadio, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17321
+ element.TooltipObject = ToolTip(element.TKRadio, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16768
17322
  _add_right_click_menu_and_grab(element)
16769
17323
 
16770
17324
  # ------------------------- SPIN placement element ------------------------- #
@@ -16801,7 +17355,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16801
17355
  if element.Disabled is True: # note overrides readonly if disabled
16802
17356
  element.TKSpinBox['state'] = 'disabled'
16803
17357
  if element.Tooltip is not None:
16804
- element.TooltipObject = ToolTip(element.TKSpinBox, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17358
+ element.TooltipObject = ToolTip(element.TKSpinBox, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16805
17359
  if element.BindReturnKey:
16806
17360
  element.TKSpinBox.bind('<Return>', element._SpinboxSelectHandler)
16807
17361
  _add_right_click_menu_and_grab(element)
@@ -16809,10 +17363,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16809
17363
  elif element_type == ELEM_TYPE_IMAGE:
16810
17364
  element = element # type: Image
16811
17365
  try:
16812
- if element.Filename is not None:
16813
- photo = tk.PhotoImage(file=element.Filename)
16814
- elif element.Data is not None:
16815
- photo = tk.PhotoImage(data=element.Data)
17366
+ if element.ImageFilename is not None:
17367
+ photo = tk.PhotoImage(file=element.ImageFilename)
17368
+ elif element.ImageData is not None:
17369
+ photo = tk.PhotoImage(data=element.ImageData)
16816
17370
  else:
16817
17371
  photo = None
16818
17372
 
@@ -16846,12 +17400,18 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16846
17400
  expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
16847
17401
  element.tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill)
16848
17402
 
17403
+ # Setup bindings if there's a mouseover image
17404
+ if element.mouseover_image_source:
17405
+ element.tktext_label.bind('<Enter>', element._mouseover_enter)
17406
+ element.tktext_label.bind('<Leave>', element._mouseover_leave)
17407
+
17408
+ if element.Tooltip is not None:
17409
+ element.TooltipObject = ToolTip(element.tktext_label, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font, skip_bind=element.mouseover_image_source is not None)
17410
+
16849
17411
  if element.visible is False:
16850
17412
  element._pack_forget_save_settings()
16851
17413
  # element.tktext_label.pack_forget()
16852
- if element.Tooltip is not None:
16853
- element.TooltipObject = ToolTip(element.tktext_label, text=element.Tooltip,
16854
- timeout=DEFAULT_TOOLTIP_TIME)
17414
+
16855
17415
  if element.EnableEvents and element.tktext_label is not None:
16856
17416
  element.tktext_label.bind('<ButtonPress-1>', element._ClickHandler)
16857
17417
 
@@ -16875,8 +17435,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16875
17435
  element._pack_forget_save_settings()
16876
17436
  # element._TKCanvas.pack_forget()
16877
17437
  if element.Tooltip is not None:
16878
- element.TooltipObject = ToolTip(element._TKCanvas, text=element.Tooltip,
16879
- timeout=DEFAULT_TOOLTIP_TIME)
17438
+ element.TooltipObject = ToolTip(element._TKCanvas, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16880
17439
  _add_right_click_menu_and_grab(element)
16881
17440
 
16882
17441
  # ------------------------- Graph placement element ------------------------- #
@@ -16901,8 +17460,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16901
17460
  element._pack_forget_save_settings()
16902
17461
  # element._TKCanvas2.pack_forget()
16903
17462
  if element.Tooltip is not None:
16904
- element.TooltipObject = ToolTip(element._TKCanvas2, text=element.Tooltip,
16905
- timeout=DEFAULT_TOOLTIP_TIME)
17463
+ element.TooltipObject = ToolTip(element._TKCanvas2, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
16906
17464
  if element.ChangeSubmits:
16907
17465
  element._TKCanvas2.bind('<ButtonRelease-1>', element.ButtonReleaseCallBack)
16908
17466
  element._TKCanvas2.bind('<ButtonPress-1>', element.ButtonPressCallBack)
@@ -16985,19 +17543,23 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16985
17543
  element._pack_forget_save_settings()
16986
17544
  # labeled_frame.pack_forget()
16987
17545
  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)
17546
+ labeled_frame.configure(background=element.BackgroundColor)
17547
+ if element.BorderColor != COLOR_SYSTEM_DEFAULT and element.BorderColor is not None:
17548
+ labeled_frame.configure( highlightcolor=element.BorderColor, highlightbackground=element.BorderColor)
17549
+ if element.BorderWidthNoRelief is not None:
17550
+ labeled_frame.configure(highlightthickness=element.BorderWidthNoRelief)
16991
17551
  if element.TextColor != COLOR_SYSTEM_DEFAULT and element.TextColor is not None:
16992
17552
  labeled_frame.configure(foreground=element.TextColor)
16993
17553
  if font is not None:
16994
17554
  labeled_frame.configure(font=font)
16995
17555
  if element.TitleLocation is not None:
16996
17556
  labeled_frame.configure(labelanchor=element.TitleLocation)
16997
- if element.BorderWidth is not None:
17557
+ if element.BorderWidth is not None and element.BorderWidthNoRelief is None:
16998
17558
  labeled_frame.configure(borderwidth=element.BorderWidth)
17559
+ if element.BorderWidthNoRelief: # if a non-zero no-relief border width, force borderwidth to zero
17560
+ labeled_frame.configure(borderwidth=0)
16999
17561
  if element.Tooltip is not None:
17000
- element.TooltipObject = ToolTip(labeled_frame, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17562
+ element.TooltipObject = ToolTip(labeled_frame, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
17001
17563
  _add_right_click_menu_and_grab(element)
17002
17564
  # row_should_expand=True
17003
17565
  # ------------------------- Tab placement element ------------------------- #
@@ -17013,10 +17575,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17013
17575
  state = 'hidden'
17014
17576
  # this code will add an image to the tab. Use it when adding the image on a tab enhancement
17015
17577
  try:
17016
- if element.Filename is not None:
17017
- photo = tk.PhotoImage(file=element.Filename)
17018
- elif element.Data is not None:
17019
- photo = tk.PhotoImage(data=element.Data)
17578
+ if element.ImageFilename is not None:
17579
+ photo = tk.PhotoImage(file=element.ImageFilename)
17580
+ elif element.ImageData is not None:
17581
+ photo = tk.PhotoImage(data=element.ImageData)
17020
17582
  else:
17021
17583
  photo = None
17022
17584
 
@@ -17039,15 +17601,18 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17039
17601
  else:
17040
17602
  width, height = element_size
17041
17603
  element.tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=0)
17604
+ element.tktext_label.image = photo
17042
17605
  else:
17043
17606
  element.tktext_label = tk.Label(tk_row_frame, bd=0)
17044
17607
  if photo is not None:
17045
17608
  form.TKNotebook.add(element.TKFrame, text=element.Title, compound=tk.LEFT, state=state,image=photo)
17609
+ else:
17610
+ form.TKNotebook.add(element.TKFrame, text=element.Title, state=state)
17046
17611
 
17047
17612
  # element.photo_image = tk.PhotoImage(data=DEFAULT_BASE64_ICON)
17048
17613
  # form.TKNotebook.add(element.TKFrame, text=element.Title, compound=tk.LEFT, state=state,image = element.photo_image)
17049
17614
 
17050
- form.TKNotebook.add(element.TKFrame, text=element.Title, state=state)
17615
+ # form.TKNotebook.add(element.TKFrame, text=element.Title, state=state)
17051
17616
  # July 28 2022 removing the expansion and pack as a test
17052
17617
  # expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
17053
17618
  # form.TKNotebook.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=fill, expand=expand)
@@ -17061,8 +17626,19 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17061
17626
 
17062
17627
  # if element.BorderWidth is not None:
17063
17628
  # element.TKFrame.configure(borderwidth=element.BorderWidth)
17064
- if element.Tooltip is not None:
17065
- element.TooltipObject = ToolTip(element.TKFrame, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17629
+
17630
+ # Setup bindings if there's a mouseover image
17631
+ # Have to set it up for the entire notebook
17632
+ if element.mouseover_image_source:
17633
+ # print(f'Binding mouseover events to {element.ParentNotebook=}')
17634
+ element.ParentNotebook.bind('<Enter>', element._mouseover_enter)
17635
+ element.ParentNotebook.bind('<Leave>', element._mouseover_leave)
17636
+
17637
+ # if element.Tooltip is not None:
17638
+ # element.TooltipObject = ToolTip(element.TKFrame, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME, skip_bind=element.mouseover_image_source is not None)
17639
+ # Set tooltip for the layout part of the Tab (not the Tab label though)
17640
+ # element.TooltipObject = ToolTip(element.TKFrame, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME, skip_bind=False)
17641
+
17066
17642
  _add_right_click_menu_and_grab(element)
17067
17643
  # row_should_expand = True
17068
17644
  # ------------------------- TabGroup placement element ------------------------- #
@@ -17115,7 +17691,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17115
17691
  if element.ChangeSubmits:
17116
17692
  element.TKNotebook.bind('<<NotebookTabChanged>>', element._TabGroupSelectHandler)
17117
17693
  if element.Tooltip is not None:
17118
- element.TooltipObject = ToolTip(element.TKNotebook, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17694
+ element.TooltipObject = ToolTip(element.TKNotebook, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
17119
17695
  if element.Size != (None, None):
17120
17696
  element.TKNotebook.configure(width=element.Size[0], height=element.Size[1])
17121
17697
  _add_right_click_menu_and_grab(element)
@@ -17163,7 +17739,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17163
17739
  if element.Disabled == True:
17164
17740
  element.TKScale['state'] = 'disabled'
17165
17741
  if element.Tooltip is not None:
17166
- element.TooltipObject = ToolTip(element.TKScale, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
17742
+ element.TooltipObject = ToolTip(element.TKScale, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
17167
17743
  _add_right_click_menu_and_grab(element)
17168
17744
 
17169
17745
  # ------------------------- TABLE placement element ------------------------- #
@@ -17346,8 +17922,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17346
17922
  element._pack_forget_save_settings(alternate_widget=element.element_frame) # seems like it should be the frame if following other elements conventions
17347
17923
  # element.TKTreeview.pack_forget()
17348
17924
  if element.Tooltip is not None:
17349
- element.TooltipObject = ToolTip(element.TKTreeview, text=element.Tooltip,
17350
- timeout=DEFAULT_TOOLTIP_TIME)
17925
+ element.TooltipObject = ToolTip(element.TKTreeview, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
17351
17926
  _add_right_click_menu_and_grab(element)
17352
17927
 
17353
17928
  if tclversion_detailed == '8.6.9' and ENABLE_TREEVIEW_869_PATCH:
@@ -17504,8 +18079,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17504
18079
  # element.TKTreeview.pack_forget()
17505
18080
  treeview.bind("<<TreeviewSelect>>", element._treeview_selected)
17506
18081
  if element.Tooltip is not None: # tooltip
17507
- element.TooltipObject = ToolTip(element.TKTreeview, text=element.Tooltip,
17508
- timeout=DEFAULT_TOOLTIP_TIME)
18082
+ element.TooltipObject = Tooltip(element.TKTreeview, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
17509
18083
  _add_right_click_menu_and_grab(element)
17510
18084
 
17511
18085
  if tclversion_detailed == '8.6.9' and ENABLE_TREEVIEW_869_PATCH:
@@ -17517,23 +18091,42 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17517
18091
  # ------------------------- Separator placement element ------------------------- #
17518
18092
  elif element_type == ELEM_TYPE_SEPARATOR:
17519
18093
  element = element # type: VerticalSeparator
17520
- # style_name = str(element.Key) + "Line.TSeparator"
17521
- style_name = _make_ttk_style_name(".Line.TSeparator", element, primary_style=True)
17522
- style = ttk.Style()
18094
+ if element.thickness is not None:
18095
+ separator = element.Widget = tk.Frame(tk_row_frame)
18096
+ if element.Orientation.lower() in ('h', 'horizontal'):
18097
+ separator.configure(height=element.thickness or 1)
18098
+ else:
18099
+ separator.configure(width=element.thickness or 1)
18100
+ if element.color not in (None, COLOR_SYSTEM_DEFAULT):
18101
+ separator.configure(bg=element.color)
18102
+ separator.configure(highlightthickness=0, bd=0, relief='flat')
17523
18103
 
17524
- _change_ttk_theme(style, toplevel_form.TtkTheme)
18104
+ expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
17525
18105
 
17526
- if element.color not in (None, COLOR_SYSTEM_DEFAULT):
17527
- style.configure(style_name, background=element.color)
17528
- separator = element.Widget = ttk.Separator(tk_row_frame, orient=element.Orientation, )
18106
+ if element.Orientation.startswith('h'):
18107
+ separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.X, expand=True)
18108
+ else:
18109
+ separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.Y, expand=False)
18110
+ else:
18111
+ style_name = _make_ttk_style_name(".Line.TSeparator", element, primary_style=True)
18112
+ style = ttk.Style()
17529
18113
 
17530
- expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
18114
+ _change_ttk_theme(style, toplevel_form.TtkTheme)
17531
18115
 
17532
- if element.Orientation.startswith('h'):
17533
- separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.X, expand=True)
17534
- else:
17535
- separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.Y, expand=False)
17536
- element.Widget.configure(style=style_name) # IMPORTANT! Apply the style
18116
+ if element.color not in (None, COLOR_SYSTEM_DEFAULT):
18117
+ style.configure(style_name, background=element.color)
18118
+ if element.thickness is not None:
18119
+ style.configure(style_name, thickness=element.thickness)
18120
+
18121
+ separator = element.Widget = ttk.Separator(tk_row_frame, orient=element.Orientation, )
18122
+
18123
+ expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
18124
+
18125
+ if element.Orientation.startswith('h'):
18126
+ separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.X, expand=True)
18127
+ else:
18128
+ separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.Y, expand=False)
18129
+ element.Widget.configure(style=style_name) # IMPORTANT! Apply the style
17537
18130
  # ------------------------- SizeGrip placement element ------------------------- #
17538
18131
  elif element_type == ELEM_TYPE_SIZEGRIP:
17539
18132
  element = element # type: Sizegrip
@@ -17611,7 +18204,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17611
18204
  if element.ClickSubmits:
17612
18205
  tktext_label.bind('<Button-1>', element._TextClickedHandler)
17613
18206
  if element.Tooltip is not None:
17614
- element.TooltipObject = ToolTip(element.TKText, text=element.Tooltip, timeout=DEFAULT_TOOLTIP_TIME)
18207
+ element.TooltipObject = ToolTip(element.TKText, text=element.Tooltip, timeout=toplevel_form.tooltip_time, offset=toplevel_form.tooltip_offset, background_color=toplevel_form.tooltip_background_color, text_color=toplevel_form.tooltip_text_color, font=toplevel_form.tooltip_font)
17615
18208
  _add_right_click_menu_and_grab(element)
17616
18209
 
17617
18210
  # ............................DONE WITH ROW pack the row of widgets ..........................#
@@ -17973,7 +18566,7 @@ class _QuickMeter(object):
17973
18566
  :param button_color: button color (foreground, background)
17974
18567
  :type button_color: (str, str) | str
17975
18568
  :param size: (w,h) w=characters-wide, h=rows-high (Default value = DEFAULT_PROGRESS_BAR_SIZE)
17976
- :type size: (int, int)
18569
+ :type size: (int, int) | (None, None)
17977
18570
  :param border_width: width of border around element
17978
18571
  :type border_width: (int)
17979
18572
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
@@ -18097,7 +18690,7 @@ def one_line_progress_meter(title, current_value, max_value, *args, key='OK for
18097
18690
  :param button_color: button color (foreground, background)
18098
18691
  :type button_color: (str, str) | str
18099
18692
  :param size: (w,h) w=characters-wide, h=rows-high (Default value = DEFAULT_PROGRESS_BAR_SIZE)
18100
- :type size: (int, int)
18693
+ :type size: (int, int) | (None, None)
18101
18694
  :param border_width: width of border around element
18102
18695
  :type border_width: (int)
18103
18696
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
@@ -18169,16 +18762,17 @@ def get_complimentary_hex(color):
18169
18762
  class _DebugWin():
18170
18763
  debug_window = None
18171
18764
 
18172
- def __init__(self, size=(None, None), location=(None, None), relative_location=(None, None), font=None, no_titlebar=False, no_button=False,
18173
- grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, resizable=True, blocking=False):
18765
+ def __init__(self, size=(None, None), location=(None, None), relative_location=(None, None), location_anchor=None, font=None, no_titlebar=False, no_button=False, grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, resizable=True, blocking=False):
18174
18766
  """
18175
18767
 
18176
18768
  :param size: (w,h) w=characters-wide, h=rows-high
18177
- :type size: (int, int)
18769
+ :type size: (int, int) | (None, None)
18178
18770
  :param location: Location of upper left corner of the window
18179
- :type location: (int, int)
18771
+ :type location: (int, int) | (None, None)
18180
18772
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
18181
- :type relative_location: (int, int)
18773
+ :type relative_location: (int, int) | (None, None)
18774
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
18775
+ :type location_anchor: (str)
18182
18776
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
18183
18777
  :type font: (str or (str, int[, str]) or None)
18184
18778
  :param no_titlebar: If True no titlebar will be shown
@@ -18187,8 +18781,6 @@ class _DebugWin():
18187
18781
  :type no_button: (bool)
18188
18782
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
18189
18783
  :type grab_anywhere: (bool)
18190
- :param location: Location of upper left corner of the window
18191
- :type location: (int, int)
18192
18784
  :param do_not_reroute_stdout: bool value
18193
18785
  :type do_not_reroute_stdout: (bool)
18194
18786
  :param echo_stdout: If True stdout is sent to both the console and the debug window
@@ -18196,13 +18788,14 @@ class _DebugWin():
18196
18788
  :param resizable: if True, makes the window resizble
18197
18789
  :type resizable: (bool)
18198
18790
  :param blocking: if True, makes the window block instead of returning immediately
18199
- :type blocking: (bool)
18791
+ :type blocking: bool | None
18200
18792
  """
18201
18793
 
18202
18794
  # Show a form that's a running counter
18203
18795
  self.size = size
18204
18796
  self.location = location
18205
18797
  self.relative_location = relative_location
18798
+ self.location_anchor = location_anchor
18206
18799
  self.font = font
18207
18800
  self.no_titlebar = no_titlebar
18208
18801
  self.no_button = no_button
@@ -18230,14 +18823,12 @@ class _DebugWin():
18230
18823
  self.layout[-1] += [Sizegrip()]
18231
18824
 
18232
18825
  self.window = Window('Debug Window', self.layout, no_titlebar=no_titlebar, auto_size_text=True, location=location, relative_location=relative_location,
18233
- font=font or ('Courier New', 10), grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, finalize=True, resizable=resizable)
18826
+ font=font or ('Courier New', 10), grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, finalize=True, resizable=resizable, location_anchor=location_anchor)
18234
18827
  return
18235
18828
 
18236
18829
  def reopen_window(self):
18237
18830
  if self.window is None or (self.window is not None and self.window.is_closed()):
18238
- self.__init__(size=self.size, location=self.location, relative_location=self.relative_location, font=self.font, no_titlebar=self.no_titlebar,
18239
- no_button=self.no_button, grab_anywhere=self.grab_anywhere, keep_on_top=self.keep_on_top,
18240
- do_not_reroute_stdout=self.do_not_reroute_stdout, resizable=self.resizable, echo_stdout=self.echo_stdout)
18831
+ self.__init__(size=self.size, location=self.location, relative_location=self.relative_location, location_anchor=self.location_anchor, 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, do_not_reroute_stdout=self.do_not_reroute_stdout, resizable=self.resizable, echo_stdout=self.echo_stdout)
18241
18832
 
18242
18833
  def Print(self, *args, end=None, sep=None, text_color=None, background_color=None, erase_all=False, font=None, blocking=None):
18243
18834
  global SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
@@ -18327,7 +18918,7 @@ class _DebugWin():
18327
18918
  self.window = None
18328
18919
 
18329
18920
 
18330
- def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, None), relative_location=(None, None), font=None, no_titlebar=False,
18921
+ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, None), relative_location=(None, None), location_anchor=None, font=None, no_titlebar=False,
18331
18922
  no_button=False, grab_anywhere=False, keep_on_top=None, do_not_reroute_stdout=True, echo_stdout=False, text_color=None, background_color=None, colors=None, c=None,
18332
18923
  erase_all=False, resizable=True, blocking=None, wait=None):
18333
18924
  """
@@ -18343,15 +18934,17 @@ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, Non
18343
18934
  :param *args: stuff to output
18344
18935
  :type *args: (Any)
18345
18936
  :param size: (w,h) w=characters-wide, h=rows-high
18346
- :type size: (int, int)
18937
+ :type size: (int, int) | (None, None)
18347
18938
  :param end: end character
18348
18939
  :type end: (str)
18349
18940
  :param sep: separator character
18350
18941
  :type sep: (str)
18351
18942
  :param location: Location of upper left corner of the window
18352
- :type location: (int, int)
18943
+ :type location: (int, int) | (None, None)
18353
18944
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
18354
- :type relative_location: (int, int)
18945
+ :type relative_location: (int, int) | (None, None)
18946
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
18947
+ :type location_anchor: (str)
18355
18948
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
18356
18949
  :type font: (str or (str, int[, str]) or None)
18357
18950
  :param no_titlebar: If True no titlebar will be shown
@@ -18366,8 +18959,6 @@ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, Non
18366
18959
  :type text_color: (str)
18367
18960
  :param keep_on_top: If True the window will remain above all current windows
18368
18961
  :type keep_on_top: (bool)
18369
- :param location: Location of upper left corner of the window
18370
- :type location: (int, int)
18371
18962
  :param do_not_reroute_stdout: do not reroute stdout and stderr. If False, both stdout and stderr will reroute to here
18372
18963
  :type do_not_reroute_stdout: (bool)
18373
18964
  :param echo_stdout: If True stdout is sent to both the console and the debug window
@@ -18388,14 +18979,10 @@ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, Non
18388
18979
  :rtype:
18389
18980
  """
18390
18981
 
18391
- blocking = blocking or wait
18392
18982
  if _DebugWin.debug_window is None:
18393
- _DebugWin.debug_window = _DebugWin(size=size, location=location, relative_location=relative_location, font=font, no_titlebar=no_titlebar,
18394
- no_button=no_button, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
18395
- do_not_reroute_stdout=do_not_reroute_stdout, echo_stdout=echo_stdout, resizable=resizable, blocking=blocking)
18983
+ _DebugWin.debug_window = _DebugWin(size=size, location=location, relative_location=relative_location, font=font, no_titlebar=no_titlebar, no_button=no_button, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, do_not_reroute_stdout=do_not_reroute_stdout, echo_stdout=echo_stdout, resizable=resizable, blocking=blocking or wait, location_anchor=location_anchor)
18396
18984
  txt_color, bg_color = _parse_colors_parm(c or colors)
18397
- _DebugWin.debug_window.Print(*args, end=end, sep=sep, text_color=text_color or txt_color, background_color=background_color or bg_color,
18398
- erase_all=erase_all, font=font, blocking=blocking)
18985
+ _DebugWin.debug_window.Print(*args, end=end, sep=sep, text_color=text_color or txt_color, background_color=background_color or bg_color, erase_all=erase_all, font=font, blocking=blocking)
18399
18986
 
18400
18987
 
18401
18988
  def easy_print_close():
@@ -18445,7 +19032,7 @@ def cprint_set_output_destination(window, multiline_key):
18445
19032
 
18446
19033
 
18447
19034
  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):
19035
+ justification=None, autoscroll=True, image=None, image_subsample=None, erase_all=False):
18449
19036
  """
18450
19037
  Color print to a multiline element in a window of your choice.
18451
19038
  Must have EITHER called cprint_set_output_destination prior to making this call so that the
@@ -18502,6 +19089,10 @@ def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, backgro
18502
19089
  :type justification: (str)
18503
19090
  :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
18504
19091
  :type autoscroll: (bool)
19092
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
19093
+ :type image: (str | bytes)
19094
+ :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
19095
+ :type image_subsample: (int)
18505
19096
  :param erase_all If True the contents of the element will be cleared before printing happens
18506
19097
  :type erase_all (bool)
18507
19098
  """
@@ -18539,11 +19130,11 @@ def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, backgro
18539
19130
  mline.update('')
18540
19131
  if end is None:
18541
19132
  mline.print(*args, text_color=kw_text_color, background_color=kw_background_color, end='', sep=sep, justification=justification, font=font,
18542
- autoscroll=autoscroll)
19133
+ autoscroll=autoscroll, image=image, image_subsample=image_subsample)
18543
19134
  mline.print('', justification=justification, autoscroll=autoscroll)
18544
19135
  else:
18545
19136
  mline.print(*args, text_color=kw_text_color, background_color=kw_background_color, end=end, sep=sep, justification=justification, font=font,
18546
- autoscroll=autoscroll)
19137
+ autoscroll=autoscroll, image=image, image_subsample=image_subsample)
18547
19138
  except Exception as e:
18548
19139
  print('** cprint error trying to print to the multiline. Printing to console instead **', e)
18549
19140
  print(*args, end=end, sep=sep)
@@ -18553,7 +19144,7 @@ def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, backgro
18553
19144
  # A print-like call that can be used to output to a multiline element as if it's an Output element #
18554
19145
  # ------------------------------------------------------------------------------------------------ #
18555
19146
 
18556
- def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=None, background_color=None, autoscroll=None, justification=None, font=None):
19147
+ 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
19148
  """
18558
19149
  Print like Python normally prints except route the output to a multiline element and also add colors if desired
18559
19150
 
@@ -18573,6 +19164,10 @@ def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=N
18573
19164
  :type autoscroll: (bool)
18574
19165
  :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
19166
  :type font: str | (str, int)
19167
+ :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image
19168
+ :type image: (str | bytes)
19169
+ :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
19170
+ :type image_subsample: (int)
18576
19171
  """
18577
19172
  end_str = str(end) if end is not None else '\n'
18578
19173
  sep_str = str(sep) if sep is not None else ' '
@@ -18586,7 +19181,7 @@ def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=N
18586
19181
  outstring += end_str
18587
19182
 
18588
19183
  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)
19184
+ justification=justification, font_for_value=font, image=image, image_subsample=image_subsample)
18590
19185
 
18591
19186
  try: # if the element is set to autorefresh, then refresh the parent window
18592
19187
  if multiline_element.AutoRefresh:
@@ -19831,11 +20426,11 @@ def theme_previewer(columns=12, scrollable=False, scroll_area_size=(None, None),
19831
20426
  :param scrollable: If True then scrollbars will be added
19832
20427
  :type scrollable: bool
19833
20428
  :param scroll_area_size: Size of the scrollable area (The Column Element used to make scrollable)
19834
- :type scroll_area_size: (int, int)
20429
+ :type scroll_area_size: (int, int) | (None, None)
19835
20430
  :param search_string: If specified then only themes containing this string will be shown
19836
20431
  :type search_string: str
19837
20432
  :param location: Location on the screen to place the window. Defaults to the center like all windows
19838
- :type location: (int, int)
20433
+ :type location: (int, int) | (None, None)
19839
20434
  """
19840
20435
 
19841
20436
  current_theme = theme()
@@ -20155,7 +20750,7 @@ def dict_to_string(dict_var, sort_keys=True, compact=False, indent=10, width=Non
20155
20750
  :param indent: Number of spaces to indent (passed to pprint directly)
20156
20751
  :type indent: (int)
20157
20752
  :param width: specifies the desired maximum number of characters per line in the output. Defaults to 1 (sounds weird but it works best). Settablein PySimpleGUI Settings window
20158
- :type width: (int)
20753
+ :type width: int | None
20159
20754
  :return: Formatted output of the dictionary's values
20160
20755
  :rtype: (str)
20161
20756
  """
@@ -20227,7 +20822,7 @@ def clipboard_get():
20227
20822
 
20228
20823
  def popup(*args, title=None, button_color=None, background_color=None, text_color=None, button_type=POPUP_BUTTONS_OK, auto_close=False,
20229
20824
  auto_close_duration=None, custom_text=(None, None), non_blocking=False, icon=None, line_width=None, font=None, no_titlebar=False, grab_anywhere=False,
20230
- keep_on_top=None, location=(None, None), relative_location=(None, None), any_key_closes=False, image=None, modal=True, button_justification=None, drop_whitespace=True):
20825
+ keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, any_key_closes=False, image=None, modal=True, button_justification=None, drop_whitespace=True):
20231
20826
  """
20232
20827
  Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
20233
20828
  "print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
@@ -20267,9 +20862,11 @@ def popup(*args, title=None, button_color=None, background_color=None, text_colo
20267
20862
  :param grab_anywhere: If True can grab anywhere to move the window. If no_titlebar is True, grab_anywhere should likely be enabled too
20268
20863
  :type grab_anywhere: (bool)
20269
20864
  :param location: Location on screen to display the top left corner of window. Defaults to window centered on screen
20270
- :type location: (int, int)
20865
+ :type location: (int, int) | (None, None)
20271
20866
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20272
- :type relative_location: (int, int)
20867
+ :type relative_location: (int, int) | (None, None)
20868
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
20869
+ :type location_anchor: (str)
20273
20870
  :param keep_on_top: If True the window will remain above all current windows
20274
20871
  :type keep_on_top: (bool)
20275
20872
  :param any_key_closes: If True then will turn on return_keyboard_events for the window which will cause window to close as soon as any key is pressed. Normally the return key only will close the window. Default is false.
@@ -20368,7 +20965,7 @@ def popup(*args, title=None, button_color=None, background_color=None, text_colo
20368
20965
 
20369
20966
  window = Window(_title, layout, auto_size_text=True, background_color=background_color, button_color=button_color,
20370
20967
  auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font,
20371
- no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location,
20968
+ no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor,
20372
20969
  return_keyboard_events=any_key_closes,
20373
20970
  modal=modal)
20374
20971
 
@@ -20400,7 +20997,7 @@ def MsgBox(*args):
20400
20997
  # ======================== Scrolled Text Box =====#
20401
20998
  # ===================================================#
20402
20999
  def popup_scrolled(*args, title=None, button_color=None, background_color=None, text_color=None, yes_no=False, no_buttons=False, button_justification='l', auto_close=False,
20403
- auto_close_duration=None, size=(None, None), location=(None, None), relative_location=(None, None), non_blocking=False, no_titlebar=False, grab_anywhere=False,
21000
+ auto_close_duration=None, size=(None, None), location=(None, None), relative_location=(None, None), location_anchor=None, non_blocking=False, no_titlebar=False, grab_anywhere=False,
20404
21001
  keep_on_top=None, font=None, image=None, icon=None, modal=True, no_sizegrip=False):
20405
21002
  """
20406
21003
  Show a scrolled Popup window containing the user's text that was supplied. Use with as many items to print as you
@@ -20423,11 +21020,13 @@ def popup_scrolled(*args, title=None, button_color=None, background_color=None,
20423
21020
  :param auto_close_duration: Older versions only accept int. Time in seconds until window will close
20424
21021
  :type auto_close_duration: int | float
20425
21022
  :param size: (w,h) w=characters-wide, h=rows-high
20426
- :type size: (int, int)
21023
+ :type size: (int, int) | (None, None)
20427
21024
  :param location: Location on the screen to place the upper left corner of the window
20428
- :type location: (int, int)
21025
+ :type location: (int, int) | (None, None)
20429
21026
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20430
- :type relative_location: (int, int)
21027
+ :type relative_location: (int, int) | (None, None)
21028
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21029
+ :type location_anchor: (str)
20431
21030
  :param non_blocking: if True the call will immediately return rather than waiting on user input
20432
21031
  :type non_blocking: (bool)
20433
21032
  :param background_color: color of background
@@ -20507,7 +21106,7 @@ def popup_scrolled(*args, title=None, button_color=None, background_color=None,
20507
21106
  layout[-1] += [Sizegrip()]
20508
21107
 
20509
21108
  window = Window(title or args[0], layout, auto_size_text=True, button_color=button_color, auto_close=auto_close,
20510
- auto_close_duration=auto_close_duration, location=location, relative_location=relative_location, resizable=True, font=font, background_color=background_color,
21109
+ auto_close_duration=auto_close_duration, location=location, relative_location=relative_location, location_anchor=location_anchor, resizable=True, font=font, background_color=background_color,
20511
21110
  no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, modal=modal, icon=icon)
20512
21111
  if non_blocking:
20513
21112
  button, values = window.read(timeout=0)
@@ -20530,7 +21129,7 @@ def popup_scrolled(*args, title=None, button_color=None, background_color=None,
20530
21129
  # --------------------------- popup_no_buttons ---------------------------
20531
21130
  def popup_no_buttons(*args, title=None, background_color=None, text_color=None, auto_close=False,
20532
21131
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
20533
- no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=True):
21132
+ no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), location_anchor=None, relative_location=(None, None), image=None, modal=True):
20534
21133
  """Show a Popup but without any buttons
20535
21134
 
20536
21135
  :param *args: Variable number of items to display
@@ -20558,9 +21157,11 @@ def popup_no_buttons(*args, title=None, background_color=None, text_color=None,
20558
21157
  :param grab_anywhere: If True, than can grab anywhere to move the window (Default = False)
20559
21158
  :type grab_anywhere: (bool)
20560
21159
  :param location: Location of upper left corner of the window
20561
- :type location: (int, int)
21160
+ :type location: (int, int) | (None, None)
20562
21161
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20563
- :type relative_location: (int, int)
21162
+ :type relative_location: (int, int) | (None, None)
21163
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21164
+ :type location_anchor: (str)
20564
21165
  :param image: Image to include at the top of the popup window
20565
21166
  :type image: (str) or (bytes)
20566
21167
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -20571,14 +21172,14 @@ def popup_no_buttons(*args, title=None, background_color=None, text_color=None,
20571
21172
  button_type=POPUP_BUTTONS_NO_BUTTONS,
20572
21173
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20573
21174
  line_width=line_width,
20574
- font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21175
+ font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20575
21176
 
20576
21177
 
20577
21178
  # --------------------------- popup_non_blocking ---------------------------
20578
21179
  def popup_non_blocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None,
20579
21180
  text_color=None, auto_close=False, auto_close_duration=None, non_blocking=True, icon=None,
20580
21181
  line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None,
20581
- location=(None, None), relative_location=(None, None), image=None, modal=False):
21182
+ location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=False):
20582
21183
  """
20583
21184
  Show Popup window and immediately return (does not block)
20584
21185
 
@@ -20611,9 +21212,11 @@ def popup_non_blocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_c
20611
21212
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
20612
21213
  :type grab_anywhere: (bool)
20613
21214
  :param location: Location of upper left corner of the window
20614
- :type location: (int, int)
21215
+ :type location: (int, int) | (None, None)
20615
21216
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20616
- :type relative_location: (int, int)
21217
+ :type relative_location: (int, int) | (None, None)
21218
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21219
+ :type location_anchor: (str)
20617
21220
  :param image: Image to include at the top of the popup window
20618
21221
  :type image: (str) or (bytes)
20619
21222
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = False
@@ -20626,13 +21229,13 @@ def popup_non_blocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_c
20626
21229
  button_type=button_type,
20627
21230
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20628
21231
  line_width=line_width,
20629
- font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21232
+ font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20630
21233
 
20631
21234
 
20632
21235
  # --------------------------- popup_quick - a NonBlocking, Self-closing Popup ---------------------------
20633
21236
  def popup_quick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None,
20634
21237
  text_color=None, auto_close=True, auto_close_duration=2, non_blocking=True, icon=None, line_width=None,
20635
- font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=False):
21238
+ font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=False):
20636
21239
  """
20637
21240
  Show Popup box that doesn't block and closes itself
20638
21241
 
@@ -20667,9 +21270,11 @@ def popup_quick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=No
20667
21270
  :param keep_on_top: If True the window will remain above all current windows
20668
21271
  :type keep_on_top: (bool)
20669
21272
  :param location: Location of upper left corner of the window
20670
- :type location: (int, int)
21273
+ :type location: (int, int) | (None, None)
20671
21274
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20672
- :type relative_location: (int, int)
21275
+ :type relative_location: (int, int) | (None, None)
21276
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21277
+ :type location_anchor: (str)
20673
21278
  :param image: Image to include at the top of the popup window
20674
21279
  :type image: (str) or (bytes)
20675
21280
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = False
@@ -20682,13 +21287,13 @@ def popup_quick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=No
20682
21287
  button_type=button_type,
20683
21288
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20684
21289
  line_width=line_width,
20685
- font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21290
+ font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20686
21291
 
20687
21292
 
20688
21293
  # --------------------------- popup_quick_message - a NonBlocking, Self-closing Popup with no titlebar and no buttons ---------------------------
20689
21294
  def popup_quick_message(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS, button_color=None, background_color=None,
20690
21295
  text_color=None, auto_close=True, auto_close_duration=2, non_blocking=True, icon=None, line_width=None,
20691
- font=None, no_titlebar=True, grab_anywhere=False, keep_on_top=True, location=(None, None), relative_location=(None, None), image=None, modal=False):
21296
+ font=None, no_titlebar=True, grab_anywhere=False, keep_on_top=True, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=False):
20692
21297
  """
20693
21298
  Show Popup window with no titlebar, doesn't block, and auto closes itself.
20694
21299
 
@@ -20723,9 +21328,11 @@ def popup_quick_message(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS,
20723
21328
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
20724
21329
  :type grab_anywhere: (bool)
20725
21330
  :param location: Location of upper left corner of the window
20726
- :type location: (int, int)
21331
+ :type location: (int, int) | (None, None)
20727
21332
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20728
- :type relative_location: (int, int)
21333
+ :type relative_location: (int, int) | (None, None)
21334
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21335
+ :type location_anchor: (str)
20729
21336
  :param image: Image to include at the top of the popup window
20730
21337
  :type image: (str) or (bytes)
20731
21338
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = False
@@ -20737,13 +21344,13 @@ def popup_quick_message(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS,
20737
21344
  button_type=button_type,
20738
21345
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20739
21346
  line_width=line_width,
20740
- font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21347
+ font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20741
21348
 
20742
21349
 
20743
21350
  # --------------------------- PopupNoTitlebar ---------------------------
20744
21351
  def popup_no_titlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None,
20745
21352
  text_color=None, auto_close=False, auto_close_duration=None, non_blocking=False, icon=None,
20746
- line_width=None, font=None, grab_anywhere=True, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=True):
21353
+ line_width=None, font=None, grab_anywhere=True, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=True):
20747
21354
  """
20748
21355
  Display a Popup without a titlebar. Enables grab anywhere so you can move it
20749
21356
 
@@ -20776,9 +21383,11 @@ def popup_no_titlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_co
20776
21383
  :param keep_on_top: If True the window will remain above all current windows
20777
21384
  :type keep_on_top: (bool)
20778
21385
  :param location: Location of upper left corner of the window
20779
- :type location: (int, int)
21386
+ :type location: (int, int) | (None, None)
20780
21387
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20781
- :type relative_location: (int, int)
21388
+ :type relative_location: (int, int) | (None, None)
21389
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21390
+ :type location_anchor: (str)
20782
21391
  :param image: Image to include at the top of the popup window
20783
21392
  :type image: (str) or (bytes)
20784
21393
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -20790,14 +21399,14 @@ def popup_no_titlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_co
20790
21399
  button_type=button_type,
20791
21400
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20792
21401
  line_width=line_width,
20793
- font=font, no_titlebar=True, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21402
+ font=font, no_titlebar=True, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20794
21403
 
20795
21404
 
20796
21405
  # --------------------------- PopupAutoClose ---------------------------
20797
21406
  def popup_auto_close(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
20798
21407
  auto_close=True, auto_close_duration=None, non_blocking=False, icon=None,
20799
21408
  line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None,
20800
- location=(None, None), relative_location=(None, None), image=None, modal=True):
21409
+ location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=True):
20801
21410
  """Popup that closes itself after some time period
20802
21411
 
20803
21412
  :param *args: Variable number of items to display
@@ -20831,9 +21440,11 @@ def popup_auto_close(*args, title=None, button_type=POPUP_BUTTONS_OK, button_col
20831
21440
  :param keep_on_top: If True the window will remain above all current windows
20832
21441
  :type keep_on_top: (bool)
20833
21442
  :param location: Location of upper left corner of the window
20834
- :type location: (int, int)
21443
+ :type location: (int, int) | (None, None)
20835
21444
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20836
- :type relative_location: (int, int)
21445
+ :type relative_location: (int, int) | (None, None)
21446
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21447
+ :type location_anchor: (str)
20837
21448
  :param image: Image to include at the top of the popup window
20838
21449
  :type image: (str) or (bytes)
20839
21450
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -20846,13 +21457,13 @@ def popup_auto_close(*args, title=None, button_type=POPUP_BUTTONS_OK, button_col
20846
21457
  button_type=button_type,
20847
21458
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20848
21459
  line_width=line_width,
20849
- font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21460
+ font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20850
21461
 
20851
21462
 
20852
21463
  # --------------------------- popup_error ---------------------------
20853
21464
  def popup_error(*args, title=None, button_color=(None, None), background_color=None, text_color=None, auto_close=False,
20854
21465
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
20855
- no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=True):
21466
+ no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=True):
20856
21467
  """
20857
21468
  Popup with colored button and 'Error' as button text
20858
21469
 
@@ -20885,9 +21496,11 @@ def popup_error(*args, title=None, button_color=(None, None), background_color=N
20885
21496
  :param keep_on_top: If True the window will remain above all current windows
20886
21497
  :type keep_on_top: (bool)
20887
21498
  :param location: Location of upper left corner of the window
20888
- :type location: (int, int)
21499
+ :type location: (int, int) | (None, None)
20889
21500
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20890
- :type relative_location: (int, int)
21501
+ :type relative_location: (int, int) | (None, None)
21502
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21503
+ :type location_anchor: (str)
20891
21504
  :param image: Image to include at the top of the popup window
20892
21505
  :type image: (str) or (bytes)
20893
21506
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -20900,13 +21513,13 @@ def popup_error(*args, title=None, button_color=(None, None), background_color=N
20900
21513
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=tbutton_color,
20901
21514
  auto_close=auto_close,
20902
21515
  auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
20903
- keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21516
+ keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20904
21517
 
20905
21518
 
20906
21519
  # --------------------------- popup_cancel ---------------------------
20907
21520
  def popup_cancel(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
20908
21521
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
20909
- no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=True):
21522
+ no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=True):
20910
21523
  """
20911
21524
  Display Popup with "cancelled" button text
20912
21525
 
@@ -20939,9 +21552,11 @@ def popup_cancel(*args, title=None, button_color=None, background_color=None, te
20939
21552
  :param keep_on_top: If True the window will remain above all current windows
20940
21553
  :type keep_on_top: (bool)
20941
21554
  :param location: Location of upper left corner of the window
20942
- :type location: (int, int)
21555
+ :type location: (int, int) | (None, None)
20943
21556
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20944
- :type relative_location: (int, int)
21557
+ :type relative_location: (int, int) | (None, None)
21558
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21559
+ :type location_anchor: (str)
20945
21560
  :param image: Image to include at the top of the popup window
20946
21561
  :type image: (str) or (bytes)
20947
21562
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -20953,13 +21568,13 @@ def popup_cancel(*args, title=None, button_color=None, background_color=None, te
20953
21568
  text_color=text_color,
20954
21569
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color, auto_close=auto_close,
20955
21570
  auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
20956
- keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21571
+ keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
20957
21572
 
20958
21573
 
20959
21574
  # --------------------------- popup_ok ---------------------------
20960
21575
  def popup_ok(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
20961
21576
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
20962
- no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=True):
21577
+ no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=True):
20963
21578
  """
20964
21579
  Display Popup with OK button only
20965
21580
 
@@ -20992,9 +21607,11 @@ def popup_ok(*args, title=None, button_color=None, background_color=None, text_c
20992
21607
  :param keep_on_top: If True the window will remain above all current windows
20993
21608
  :type keep_on_top: (bool)
20994
21609
  :param location: Location of upper left corner of the window
20995
- :type location: (int, int)
21610
+ :type location: (int, int) | (None, None)
20996
21611
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
20997
- :type relative_location: (int, int)
21612
+ :type relative_location: (int, int) | (None, None)
21613
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21614
+ :type location_anchor: (str)
20998
21615
  :param image: Image to include at the top of the popup window
20999
21616
  :type image: (str) or (bytes)
21000
21617
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -21005,13 +21622,13 @@ def popup_ok(*args, title=None, button_color=None, background_color=None, text_c
21005
21622
  return popup(*args, title=title, button_type=POPUP_BUTTONS_OK, background_color=background_color, text_color=text_color,
21006
21623
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color, auto_close=auto_close,
21007
21624
  auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
21008
- keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21625
+ keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
21009
21626
 
21010
21627
 
21011
21628
  # --------------------------- popup_ok_cancel ---------------------------
21012
21629
  def popup_ok_cancel(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
21013
21630
  auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
21014
- no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=True):
21631
+ no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=True):
21015
21632
  """
21016
21633
  Display popup with OK and Cancel buttons
21017
21634
 
@@ -21044,9 +21661,11 @@ def popup_ok_cancel(*args, title=None, button_color=None, background_color=None,
21044
21661
  :param keep_on_top: If True the window will remain above all current windows
21045
21662
  :type keep_on_top: (bool)
21046
21663
  :param location: Location of upper left corner of the window
21047
- :type location: (int, int)
21664
+ :type location: (int, int) | (None, None)
21048
21665
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21049
- :type relative_location: (int, int)
21666
+ :type relative_location: (int, int) | (None, None)
21667
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21668
+ :type location_anchor: (str)
21050
21669
  :param image: Image to include at the top of the popup window
21051
21670
  :type image: (str) or (bytes)
21052
21671
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -21058,13 +21677,13 @@ def popup_ok_cancel(*args, title=None, button_color=None, background_color=None,
21058
21677
  text_color=text_color,
21059
21678
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color,
21060
21679
  auto_close=auto_close, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar,
21061
- grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21680
+ grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
21062
21681
 
21063
21682
 
21064
21683
  # --------------------------- popup_yes_no ---------------------------
21065
21684
  def popup_yes_no(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
21066
21685
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
21067
- no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, modal=True):
21686
+ no_titlebar=False, grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, modal=True):
21068
21687
  """
21069
21688
  Display Popup with Yes and No buttons
21070
21689
 
@@ -21097,9 +21716,11 @@ def popup_yes_no(*args, title=None, button_color=None, background_color=None, te
21097
21716
  :param keep_on_top: If True the window will remain above all current windows
21098
21717
  :type keep_on_top: (bool)
21099
21718
  :param location: Location of upper left corner of the window
21100
- :type location: (int, int)
21719
+ :type location: (int, int) | (None, None)
21101
21720
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21102
- :type relative_location: (int, int)
21721
+ :type relative_location: (int, int) | (None, None)
21722
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21723
+ :type location_anchor: (str)
21103
21724
  :param image: Image to include at the top of the popup window
21104
21725
  :type image: (str) or (bytes)
21105
21726
  :param modal: If True then makes the popup will behave like a Modal window... all other windows are non-operational until this one is closed. Default = True
@@ -21111,7 +21732,7 @@ def popup_yes_no(*args, title=None, button_color=None, background_color=None, te
21111
21732
  text_color=text_color,
21112
21733
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color,
21113
21734
  auto_close=auto_close, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar,
21114
- grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, image=image, modal=modal)
21735
+ grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, image=image, modal=modal)
21115
21736
 
21116
21737
 
21117
21738
  ##############################################################################
@@ -21123,7 +21744,7 @@ def popup_yes_no(*args, title=None, button_color=None, background_color=None, te
21123
21744
 
21124
21745
  def popup_get_folder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
21125
21746
  background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
21126
- grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), initial_folder=None, image=None, modal=True, history=False,
21747
+ grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, initial_folder=None, image=None, modal=True, history=False,
21127
21748
  history_setting_filename=None):
21128
21749
  """
21129
21750
  Display popup with text entry field and browse button so that a folder can be chosen.
@@ -21137,7 +21758,7 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
21137
21758
  :param no_window: if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown
21138
21759
  :type no_window: (bool)
21139
21760
  :param size: (width, height) of the InputText Element
21140
- :type size: (int, int)
21761
+ :type size: (int, int) | (None, None)
21141
21762
  :param button_color: button color (foreground, background)
21142
21763
  :type button_color: (str, str) | str
21143
21764
  :param background_color: color of background
@@ -21155,9 +21776,11 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
21155
21776
  :param keep_on_top: If True the window will remain above all current windows
21156
21777
  :type keep_on_top: (bool)
21157
21778
  :param location: Location of upper left corner of the window
21158
- :type location: (int, int)
21779
+ :type location: (int, int) | (None, None)
21159
21780
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21160
- :type relative_location: (int, int)
21781
+ :type relative_location: (int, int) | (None, None)
21782
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21783
+ :type location_anchor: (str)
21161
21784
  :param initial_folder: location in filesystem to begin browsing
21162
21785
  :type initial_folder: (str)
21163
21786
  :param image: Image to include at the top of the popup window
@@ -21232,7 +21855,7 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
21232
21855
 
21233
21856
  window = Window(title=title or message, layout=layout, icon=icon, auto_size_text=True, button_color=button_color,
21234
21857
  font=font, background_color=background_color, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
21235
- location=location, relative_location=relative_location, modal=modal)
21858
+ location=location, relative_location=relative_location, location_anchor=location_anchor, modal=modal)
21236
21859
 
21237
21860
  while True:
21238
21861
  event, values = window.read()
@@ -21266,7 +21889,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21266
21889
  file_types=FILE_TYPES_ALL_FILES,
21267
21890
  no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
21268
21891
  icon=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None,
21269
- location=(None, None), relative_location=(None, None), initial_folder=None, image=None, files_delimiter=BROWSE_FILES_DELIMITER, modal=True, history=False, show_hidden=True,
21892
+ location=(None, None), relative_location=(None, None), location_anchor=None, initial_folder=None, image=None, files_delimiter=BROWSE_FILES_DELIMITER, modal=True, history=False, show_hidden=True,
21270
21893
  history_setting_filename=None):
21271
21894
  """
21272
21895
  Display popup window with text entry field and browse button so that a file can be chosen by user.
@@ -21288,7 +21911,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21288
21911
  :param no_window: if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown
21289
21912
  :type no_window: (bool)
21290
21913
  :param size: (width, height) of the InputText Element or Combo element if using history feature
21291
- :type size: (int, int)
21914
+ :type size: (int, int) | (None, None)
21292
21915
  :param button_color: Color of the button (text, background)
21293
21916
  :type button_color: (str, str) | str
21294
21917
  :param background_color: background color of the entire window
@@ -21306,9 +21929,11 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21306
21929
  :param keep_on_top: If True the window will remain above all current windows
21307
21930
  :type keep_on_top: (bool)
21308
21931
  :param location: Location of upper left corner of the window
21309
- :type location: (int, int)
21932
+ :type location: (int, int) | (None, None)
21310
21933
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21311
- :type relative_location: (int, int)
21934
+ :type relative_location: (int, int) | (None, None)
21935
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
21936
+ :type location_anchor: (str)
21312
21937
  :param initial_folder: location in filesystem to begin browsing
21313
21938
  :type initial_folder: (str)
21314
21939
  :param image: Image to include at the top of the popup window
@@ -21468,7 +22093,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21468
22093
  layout += [[Button('Ok', size=(6, 1), bind_return_key=True), Button('Cancel', size=(6, 1))]]
21469
22094
 
21470
22095
  window = Window(title=title or message, layout=layout, icon=icon, auto_size_text=True, button_color=button_color,
21471
- font=font, background_color=background_color, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, modal=modal, finalize=True)
22096
+ font=font, background_color=background_color, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, modal=modal, finalize=True)
21472
22097
 
21473
22098
  if running_linux() and show_hidden is True:
21474
22099
  window.TKroot.tk.eval('catch {tk_getOpenFile -badoption}') # dirty hack to force autoloading of Tk's file dialog code
@@ -21505,7 +22130,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21505
22130
 
21506
22131
  def popup_get_text(message, title=None, default_text='', password_char='', size=(None, None), button_color=None,
21507
22132
  background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
21508
- grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), image=None, history=False, history_setting_filename=None, modal=True):
22133
+ grab_anywhere=False, keep_on_top=None, location=(None, None), relative_location=(None, None), location_anchor=None, image=None, history=False, history_setting_filename=None, modal=True):
21509
22134
  """
21510
22135
  Display Popup with text entry field. Returns the text entered or None if closed / cancelled
21511
22136
 
@@ -21518,7 +22143,7 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21518
22143
  :param password_char: character to be shown instead of actually typed characters. WARNING - if history=True then can't hide passwords
21519
22144
  :type password_char: (str)
21520
22145
  :param size: (width, height) of the input. If not specied a single line Input element used. If height >1 a Mulitline is shown
21521
- :type size: (int, int)
22146
+ :type size: (int, int) | (None, None)
21522
22147
  :param button_color: Color of the button (text, background)
21523
22148
  :type button_color: (str, str) | str
21524
22149
  :param background_color: background color of the entire window
@@ -21536,9 +22161,11 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21536
22161
  :param keep_on_top: If True the window will remain above all current windows
21537
22162
  :type keep_on_top: (bool)
21538
22163
  :param location: (x,y) Location on screen to display the upper left corner of window
21539
- :type location: (int, int)
22164
+ :type location: (int, int) | (None, None)
21540
22165
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21541
- :type relative_location: (int, int)
22166
+ :type relative_location: (int, int) | (None, None)
22167
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
22168
+ :type location_anchor: (str)
21542
22169
  :param image: Image to include at the top of the popup window
21543
22170
  :type image: (str) or (bytes)
21544
22171
  :param history: If True then enable a "history" feature that will display previous entries used. Uses settings filename provided or default if none provided
@@ -21588,7 +22215,7 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21588
22215
  layout += [[Button('Ok', size=(6, 1), bind_return_key=True), Button('Cancel', size=(6, 1))]]
21589
22216
 
21590
22217
  window = Window(title=title or message, layout=layout, icon=icon, auto_size_text=True, button_color=button_color, no_titlebar=no_titlebar,
21591
- background_color=background_color, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, finalize=True, modal=modal, font=font)
22218
+ background_color=background_color, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, location=location, relative_location=relative_location, location_anchor=location_anchor, finalize=True, modal=modal, font=font)
21592
22219
  window.force_focus()
21593
22220
  window['-INPUT-'].set_focus()
21594
22221
 
@@ -21620,7 +22247,7 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21620
22247
 
21621
22248
 
21622
22249
  def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sunday_plus=0, no_titlebar=True, title='Choose Date', keep_on_top=True,
21623
- location=(None, None), relative_location=(None, None), close_when_chosen=False, icon=None, locale=None, month_names=None, day_abbreviations=None, day_font = 'TkFixedFont 9', mon_year_font = 'TkFixedFont 10', arrow_font = 'TkFixedFont 7', modal=True):
22250
+ location=(None, None), relative_location=(None, None), location_anchor=None, close_when_chosen=False, icon=None, locale=None, month_names=None, day_abbreviations=None, day_font = 'TkFixedFont 9', mon_year_font = 'TkFixedFont 10', arrow_font = 'TkFixedFont 7', modal=True):
21624
22251
  """
21625
22252
  Display a calendar window, get the user's choice, return as a tuple (mon, day, year)
21626
22253
 
@@ -21635,9 +22262,11 @@ def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sun
21635
22262
  :param icon: Same as Window icon parameter. Can be either a filename or Base64 value. For Windows if filename, it MUST be ICO format. For Linux, must NOT be ICO
21636
22263
  :type icon: (str | bytes)
21637
22264
  :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
21638
- :type location: (int, int)
22265
+ :type location: (int, int) | (None, None)
21639
22266
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21640
- :type relative_location: (int, int)
22267
+ :type relative_location: (int, int) | (None, None)
22268
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
22269
+ :type location_anchor: (str)
21641
22270
  :param title: Title that will be shown on the window
21642
22271
  :type title: (str)
21643
22272
  :param close_when_chosen: If True, the window will close and function return when a day is clicked
@@ -21735,7 +22364,7 @@ def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sun
21735
22364
  layout += [[Button('Ok', border_width=0, font='TkFixedFont 8'), Button('Cancel', border_width=0, font='TkFixedFont 8')]]
21736
22365
 
21737
22366
  window = Window(title, layout, no_titlebar=no_titlebar, grab_anywhere=True, keep_on_top=keep_on_top, font='TkFixedFont 12', use_default_focus=False,
21738
- location=location, relative_location=relative_location, finalize=True, icon=icon)
22367
+ location=location, relative_location=relative_location, location_anchor=location_anchor, finalize=True, icon=icon)
21739
22368
 
21740
22369
  update_days(window, cur_month, cur_year, begin_at_sunday_plus)
21741
22370
 
@@ -21791,7 +22420,7 @@ def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sun
21791
22420
  # --------------------------- PopupAnimated ---------------------------
21792
22421
 
21793
22422
  def popup_animated(image_source, message=None, background_color=None, text_color=None, font=None, no_titlebar=True, grab_anywhere=True, keep_on_top=True,
21794
- location=(None, None), relative_location=(None, None), alpha_channel=None, time_between_frames=0, transparent_color=None, title='', icon=None, no_buffering=False):
22423
+ location=(None, None), relative_location=(None, None), location_anchor=None, alpha_channel=None, time_between_frames=0, transparent_color=None, title='', icon=None, no_buffering=False):
21795
22424
  """
21796
22425
  Show animation one frame at a time. This function has its own internal clocking meaning you can call it at any frequency
21797
22426
  and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
@@ -21815,9 +22444,11 @@ def popup_animated(image_source, message=None, background_color=None, text_color
21815
22444
  :param keep_on_top: If True then Window will remain on top of all other windows currently shownn
21816
22445
  :type keep_on_top: (bool)
21817
22446
  :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
21818
- :type location: (int, int)
22447
+ :type location: (int, int) | (None, None)
21819
22448
  :param relative_location: (x,y) location relative to the default location of the window, in pixels. Normally the window centers. This location is relative to the location the window would be created. Note they can be negative.
21820
- :type relative_location: (int, int)
22449
+ :type relative_location: (int, int) | (None, None)
22450
+ :param location_anchor: Position on a window that is used to achnor the widow to a location. Default = WIN_ANCHOR_UPPER_LEFT if location is specified
22451
+ :type location_anchor: (str)
21821
22452
  :param alpha_channel: Window transparency 0 = invisible 1 = completely visible. Values between are see through
21822
22453
  :type alpha_channel: (float)
21823
22454
  :param time_between_frames: Amount of time in milliseconds between each frame
@@ -21851,7 +22482,7 @@ def popup_animated(image_source, message=None, background_color=None, text_color
21851
22482
  window = Window(title, layout, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
21852
22483
  keep_on_top=keep_on_top, background_color=background_color, location=location,
21853
22484
  alpha_channel=alpha_channel, element_padding=(0, 0), margins=(0, 0),
21854
- transparent_color=transparent_color, finalize=True, element_justification='c', icon=icon, relative_location=relative_location)
22485
+ transparent_color=transparent_color, finalize=True, element_justification='c', icon=icon, relative_location=relative_location, location_anchor=location_anchor)
21855
22486
  Window._animated_popup_dict[image_source] = window
21856
22487
  else:
21857
22488
  window = Window._animated_popup_dict[image_source]
@@ -21889,7 +22520,7 @@ def popup_notify(*args, title='', icon=SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, dis
21889
22520
  :param alpha: Alpha channel. 0 - invisible 1 - fully visible
21890
22521
  :type alpha: (float)
21891
22522
  :param location: Location on the screen to display the window
21892
- :type location: (int, int)
22523
+ :type location: (int, int) | (None, None)
21893
22524
  :return: reason for returning
21894
22525
  :rtype: (int)
21895
22526
  """
@@ -22122,7 +22753,7 @@ def shell_with_animation(command, args=None, image_source=DEFAULT_BASE64_LOADING
22122
22753
  :param keep_on_top: If True then Window will remain on top of all other windows currently shownn
22123
22754
  :type keep_on_top: (bool)
22124
22755
  :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
22125
- :type location: (int, int)
22756
+ :type location: (int, int) | (None, None)
22126
22757
  :param alpha_channel: Window transparency 0 = invisible 1 = completely visible. Values between are see through
22127
22758
  :type alpha_channel: (float)
22128
22759
  :param time_between_frames: Amount of time in milliseconds between each frame
@@ -22542,7 +23173,9 @@ class UserSettings:
22542
23173
  os.makedirs(self.path)
22543
23174
  with open(self.full_filename, 'w') as f:
22544
23175
  if not self.use_config_file:
22545
- json.dump(self.dict, f)
23176
+ # json.dump(self.dict, f) # Previously, the dictionary was simply saved
23177
+ serializable = {json.dumps(k) if isinstance(k, tuple) else k: v for k, v in self.dict.items()} # But now, tuples are being serialized first
23178
+ json.dump(serializable, f)
22546
23179
  else:
22547
23180
  self.config.write(f)
22548
23181
  except Exception as e:
@@ -22619,7 +23252,16 @@ class UserSettings:
22619
23252
  if os.path.exists(self.full_filename):
22620
23253
  with open(self.full_filename, 'r') as f:
22621
23254
  if not self.use_config_file: # if using json
22622
- self.dict = json.load(f)
23255
+ # self.dict = json.load(f) # Used to be able to simple read the json
23256
+ loaded = json.load(f)
23257
+ self.dict = {}
23258
+ for k, v in loaded.items(): # But more complex now since tuples are being converted to
23259
+ try:
23260
+ parsed = json.loads(k) # Deserialize the key and try to convert to a tuple
23261
+ key = tuple(parsed) if isinstance(parsed, list) else k
23262
+ except (json.JSONDecodeError, TypeError): # If error, then not a tuple
23263
+ key = k
23264
+ self.dict[key] = v
22623
23265
  else: # if using a config file
22624
23266
  self.config.read_file(f)
22625
23267
  # Make a dictionary of SectionDict classses. Keys are the config.sections().
@@ -23185,7 +23827,7 @@ def execute_editor(file_to_edit, line_number=None):
23185
23827
  sp = execute_command_subprocess(editor_program, file_to_edit)
23186
23828
  else:
23187
23829
  command = _create_full_editor_command(file_to_edit, line_number, format_string)
23188
- # print('final command line = ', command)
23830
+ # print(f'final command line = {editor_program} {command}')
23189
23831
  sp = execute_command_subprocess(editor_program, command)
23190
23832
  else:
23191
23833
  print('No editor has been configured in the global settings')
@@ -23334,18 +23976,17 @@ def execute_restart(your_filename, parms=''):
23334
23976
  Restarts your program. The currently running process is exited and a new one is started.
23335
23977
  NOTE - this function calls exit and thus will not return
23336
23978
 
23337
- :param your_filename: Set this parm to __file__
23979
+ :param your_filename: Normally set this parm to sys.argv[0]
23338
23980
  :type your_filename: str
23339
23981
  :param parms: Parameters to pass to your program when it's restarted
23340
23982
  :type parms: str
23341
23983
 
23342
23984
  """
23343
-
23344
23985
  try:
23345
23986
  execute_py_file(your_filename, parms, pipe_output=False, wait=False) # restart this program
23346
23987
  exit() # Exit instead of returning
23347
23988
  except Exception as e:
23348
- print(f'ERROR restarting your program: {your_filename}')
23989
+ print(f'ERROR restarting your program: {your_filename}', e)
23349
23990
  exit()
23350
23991
 
23351
23992
 
@@ -24067,7 +24708,7 @@ def show_debugger_window(location=(None, None), *args):
24067
24708
  """
24068
24709
  Shows the large main debugger window
24069
24710
  :param location: Locations (x,y) on the screen to place upper left corner of the window
24070
- :type location: (int, int)
24711
+ :type location: (int, int) | (None, None)
24071
24712
  :return: None
24072
24713
  :rtype: None
24073
24714
  """
@@ -24093,7 +24734,7 @@ def show_debugger_popout_window(location=(None, None), *args):
24093
24734
  Shows the smaller "popout" window. Default location is the upper right corner of your screen
24094
24735
 
24095
24736
  :param location: Locations (x,y) on the screen to place upper left corner of the window
24096
- :type location: (int, int)
24737
+ :type location: (int, int) | (None, None)
24097
24738
  :return: None
24098
24739
  :rtype: None
24099
24740
  """
@@ -24719,34 +25360,122 @@ def __show_package_version(package, print_function, interpreter):
24719
25360
 
24720
25361
 
24721
25362
  '''
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
25363
 
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
25364
+ M""MMMMM""M dP MM'"""""`MM M""MMMMM""M M""M
25365
+ M MMMMM M 88 M' .mmm. `M M MMMMM M M M
25366
+ M MMMMM M 88d888b. .d8888b. 88d888b. .d8888b. .d888b88 .d8888b. M MMMMMMMM M MMMMM M M M
25367
+ M MMMMM M 88' `88 88' `88 88' `88 88' `88 88' `88 88ooood8 M MMM `M M MMMMM M M M
25368
+ M `MMM' M 88. .88 88. .88 88 88. .88 88. .88 88. ... M. `MMM' .M M `MMM' M M M
25369
+ Mb dM 88Y888P' `8888P88 dP `88888P8 `88888P8 `88888P' MM. .MM Mb dM M M
25370
+ MMMMMMMMMMM 88 .88 MMMMMMMMMMM MMMMMMMMMMM MMMM
25371
+ dP d8888P
24746
25372
  '''
24747
25373
 
25374
+ def upgrade_get_github_setuppy_version(silent_error=True):
25375
+ """
25376
+ Returns the version number found in the setup.py in the PySimpleGUI Github
25377
+
25378
+ :param silent_error: If True then no error message displayed if error occurs
25379
+ :type silent_error: bool
25380
+ :returns: Version number as a string. Will be empty string if error
25381
+ :rtype: str
25382
+ """
25383
+ setup_py = net_download_file(URL_PSG_GITHUB_SETUP_FILE)
25384
+ if setup_py is None:
25385
+ if not silent_error:
25386
+ popup_error('Upgrade GUI - error downloading the setup.py file')
25387
+ return ''
25388
+
25389
+ lines = setup_py.splitlines()
25390
+ new_ver = None
25391
+ for line in lines:
25392
+ if 'version=' in line:
25393
+ running_ver = line.split('=')[1]
25394
+ start = running_ver.find('"')
25395
+ end = running_ver.find('"', start + 1)
25396
+ new_ver = running_ver[start + 1:end]
25397
+ break
25398
+ if not new_ver:
25399
+ if not silent_error:
25400
+ popup_error('Upgrade GUI - did not find version number is setup.py')
25401
+ return ''
25402
+ return new_ver
25403
+
25404
+ def upgrade_PySimpleGUI_gui(no_gui=False):
25405
+ # print('Upgrading PySimpleGUI....')
25406
+ new_ver = upgrade_get_github_setuppy_version(silent_error=False)
25407
+ if not new_ver:
25408
+ return
25409
+ psg_source = net_download_file(URL_PSG_GITHUB_SOURCE)
25410
+ if psg_source is None:
25411
+ popup_error('Upgrade GUI - error downloading the PySimpleGUI.py file')
25412
+ return
25413
+ lines = psg_source.splitlines()
25414
+ start = end = None
25415
+ for i, line in enumerate(lines):
25416
+ if 'Changelog since' in line:
25417
+ start = i
25418
+ elif start:
25419
+ if '"""' in line:
25420
+ end = i
25421
+ break
25422
+ if not start or not end:
25423
+ popup_error('Upgrade GUI - error getting release notes')
25424
+ return
25425
+ else:
25426
+ release_notes = []
25427
+ for line in lines[start+1:end]:
25428
+ if line:
25429
+ release_notes.append(line)
25430
+ release_notes = '\n'.join(release_notes)
25431
+
25432
+ try:
25433
+ cur_ver = version[:version.index('\n')]
25434
+ except:
25435
+ cur_ver = version
25436
+
25437
+ pip_string= URL_PSG_PIP_INSTALL_FROM_GITHUB
25438
+ # if no_gui:
25439
+ # print(f'{cur_ver} is the version you are running now and will be overwritten')
25440
+ # print(f'{new_ver} is the version you are INSTALLING NOW....')
25441
+ # print(f'Wheel location = {pip_string}')
25442
+ # execute_pip_install_package(pip_string, force_reinstall=True, no_gui=True)
25443
+ # print('Install completed')
25444
+ # return
25445
+
25446
+ layout = [
25447
+ [Text('* WARNING *')],
25448
+ [Text('You are about to upgrade your PySimpleGUI package previously installed via pip')],
25449
+ [Text('to the latest Maintenance Release of PySimpleGUI.')],
25450
+ [Text(f'{cur_ver} is the version you are currently running',)],
25451
+ [Text(f'{new_ver} is the version you will install',)],
25452
+ [Text(f'{sys.executable } is location of python',)],
25453
+ [Text(f'Are you sure you want to overwrite your {cur_ver} release?')],
25454
+ [Push(), B('Yes', s=4), B('No', s=4), B('Show Release Notes', key='-REL NOTES-')],
25455
+ ]
25456
+
25457
+ window = Window('Upgrade To Maintenance Release', layout, keep_on_top=True)
24748
25458
 
25459
+ while True:
25460
+ event, values = window.read()
25461
+ if event in ('No', WIN_CLOSED):
25462
+ popup_quick_message('Cancelled upgrade\nNothing overwritten', background_color='red', text_color='white', keep_on_top=True, non_blocking=False)
25463
+ break
25464
+ elif event == 'Yes':
25465
+ execute_pip_install_package(pip_string, force_reinstall=True)
25466
+ # Restart the user's program after pip install completes
25467
+ popup_auto_close('Restarting your application following the pip install...\nThis window closes in 3 seconds', auto_close_duration=3)
25468
+ execute_restart(sys.argv[0])
25469
+ break
25470
+ elif event == '-REL NOTES-':
25471
+ if release_notes:
25472
+ # print(release_notes)
25473
+ notes_list = release_notes.split('\n')
25474
+ max_len = max(map(len, notes_list))
25475
+ # print(f'max_len = {max_len}, len = {len(notes_list)}')
25476
+ 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')
24749
25477
 
25478
+ window.close()
24750
25479
 
24751
25480
 
24752
25481
  def _upgrade_entry_point():
@@ -24847,7 +25576,7 @@ def _global_settings_get_ttk_scrollbar_info():
24847
25576
  """
24848
25577
  global ttk_part_mapping_dict, DEFAULT_TTK_THEME
24849
25578
  for ttk_part in TTK_SCROLLBAR_PART_LIST:
24850
- value = pysimplegui_user_settings.get(json.dumps(('-ttk scroll-', ttk_part)), ttk_part_mapping_dict[ttk_part])
25579
+ value = pysimplegui_user_settings.get(('-ttk scroll-', ttk_part), ttk_part_mapping_dict[ttk_part])
24851
25580
  ttk_part_mapping_dict[ttk_part] = value
24852
25581
 
24853
25582
  DEFAULT_TTK_THEME = pysimplegui_user_settings.get('-ttk theme-', DEFAULT_TTK_THEME)
@@ -24864,7 +25593,7 @@ def main_global_get_screen_snapshot_symcode():
24864
25593
 
24865
25594
  screenshot_keysym = ''
24866
25595
  for i in range(4):
24867
- keysym = settings.get(json.dumps(('-snapshot keysym-', i)), '')
25596
+ keysym = settings.get(('-snapshot keysym-', i), '')
24868
25597
  if keysym:
24869
25598
  screenshot_keysym += "<{}>".format(keysym)
24870
25599
 
@@ -25275,7 +26004,7 @@ def _create_main_window():
25275
26004
  def VerLine(version, description, justification='r', size=(40, 1)):
25276
26005
  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
26006
 
25278
- security_emoji = EMOJI_BASE64_HAPPY_WINK
26007
+ security_emoji = _random_happy_emoji()
25279
26008
 
25280
26009
 
25281
26010
 
@@ -25291,16 +26020,19 @@ def _create_main_window():
25291
26020
  platform_name= 'Unknown platorm'
25292
26021
 
25293
26022
  platform_ver = platform.platform()
25294
-
26023
+ maint_release_version = upgrade_get_github_setuppy_version()
25295
26024
  versions_left_col_layout = [
25296
26025
  [Push(), Text('2026 LGPL Version of PySimpleGUI', p=0, text_color='yellow', font='_ 16'), Push()],
25297
26026
  VerLine(version, 'PySimpleGUI Version'),
26027
+ VerLine(upgrade_get_github_setuppy_version(), 'PySimpleGUI Maint Release'),
26028
+ [Text(s=40), B('Install Maint Release')] if maint_release_version != version and maint_release_version != '' else [],
25298
26029
  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
26030
  VerLine(tclversion_detailed, 'detailed tkinter version'),
25300
26031
  VerLine(os.path.dirname(os.path.abspath(__file__)), 'PySimpleGUI Location', size=(40, None)),
25301
26032
  VerLine(sys.executable, 'Python Executable'),
25302
26033
  VerLine(platform_name, 'Platform '),
25303
- VerLine(platform_ver, 'Platform Version')]
26034
+ VerLine(platform_ver, 'Platform Version'),
26035
+ ]
25304
26036
 
25305
26037
  # versions_tab_layout = [vtop([Column(versions_left_col_layout), Column(versions_right_col_layout)])]
25306
26038
  versions_tab_layout = versions_left_col_layout
@@ -25462,6 +26194,9 @@ def main():
25462
26194
  scripts_folder = os.path.join(os.path.dirname(sys.executable), 'Scripts')
25463
26195
  util_full_path = os.path.join(scripts_folder, util_to_run)
25464
26196
  execute_command_subprocess(util_full_path, cwd=scripts_folder, wait=False)
26197
+ elif event == 'Install Maint Release':
26198
+ upgrade_PySimpleGUI_gui()
26199
+
25465
26200
 
25466
26201
  i += 1
25467
26202
  # _refresh_debugger()
@@ -25647,7 +26382,7 @@ def main_global_pysimplegui_settings():
25647
26382
  # ------------------------- Snapshots Tab -------------------------
25648
26383
 
25649
26384
  snapshots_tab = Tab('Window Snapshots',
25650
- [[Combo(('',)+key_choices, default_value=settings.get(json.dumps(('-snapshot keysym-', i)), ''), readonly=True, k=('-SNAPSHOT KEYSYM-', i), s=(None, 30)) for i in range(4)],
26385
+ [[Combo(('',)+key_choices, default_value=settings.get(('-snapshot keysym-', i), ''), readonly=True, k=('-SNAPSHOT KEYSYM-', i), s=(None, 30)) for i in range(4)],
25651
26386
  [T('Manually Entered Bind String:'), Input(settings.get('-snapshot keysym manual-', ''),k='-SNAPSHOT KEYSYM MANUAL-')],
25652
26387
  [T('Folder to store screenshots:'), Push(), In(settings.get('-screenshots folder-', ''), k='-SCREENSHOTS FOLDER-'), FolderBrowse()],
25653
26388
  [T('Screenshots Filename or Prefix:'), Push(), In(settings.get('-screenshots filename-', ''), k='-SCREENSHOTS FILENAME-'), FileBrowse()],
@@ -25728,7 +26463,7 @@ def main_global_pysimplegui_settings():
25728
26463
  pysimplegui_user_settings.set('-snapshot keysym manual-', values['-SNAPSHOT KEYSYM MANUAL-'])
25729
26464
  screenshot_keysym = ''
25730
26465
  for i in range(4):
25731
- pysimplegui_user_settings.set(json.dumps(('-snapshot keysym-',i)), values[('-SNAPSHOT KEYSYM-', i)])
26466
+ pysimplegui_user_settings.set(('-snapshot keysym-',i), values[('-SNAPSHOT KEYSYM-', i)])
25732
26467
  if values[('-SNAPSHOT KEYSYM-', i)]:
25733
26468
  screenshot_keysym += "<{}>".format(values[('-SNAPSHOT KEYSYM-', i)])
25734
26469
  if screenshot_keysym_manual:
@@ -25743,7 +26478,7 @@ def main_global_pysimplegui_settings():
25743
26478
  for key, value in values.items():
25744
26479
  if isinstance(key, tuple):
25745
26480
  if key[0] == '-TTK SCROLL-':
25746
- pysimplegui_user_settings.set(json.dumps(('-ttk scroll-', key[1])), value)
26481
+ pysimplegui_user_settings.set(('-ttk scroll-', key[1]), value)
25747
26482
 
25748
26483
  theme(new_theme)
25749
26484
 
@@ -25787,11 +26522,6 @@ Window._watermark_temp_forced = False
25787
26522
  Window._watermark_user_text = ''
25788
26523
 
25789
26524
 
25790
- # ------------------------- Web Destinations ------------------------- #
25791
- URL_HOME = r'http://home.PySimpleGUI.com'
25792
- URL_DOCS = r'http://docs.PySimpleGUI.com'
25793
-
25794
-
25795
26525
 
25796
26526
  def _convert_window_to_tk(window):
25797
26527
  # """
@@ -25824,21 +26554,47 @@ def _convert_window_to_tk(window):
25824
26554
  master.geometry("%sx%s" % (window._Size[0], window._Size[1]))
25825
26555
  screen_width = master.winfo_screenwidth() # get window info to move to middle of screen
25826
26556
  screen_height = master.winfo_screenheight()
26557
+
26558
+ location_anchor = window.location_anchor
25827
26559
  if window.Location is not None:
25828
26560
  if window.Location != (None, None):
25829
26561
  x, y = window.Location
25830
26562
  elif DEFAULT_WINDOW_LOCATION != (None, None):
25831
26563
  x, y = DEFAULT_WINDOW_LOCATION
25832
- else:
25833
- master.update_idletasks() # don't forget to do updates or values are bad
25834
- win_width = master.winfo_width()
25835
- win_height = master.winfo_height()
25836
- x = screen_width / 2 - win_width / 2
25837
- y = screen_height / 2 - win_height / 2
25838
- if y + win_height > screen_height:
25839
- y = screen_height - win_height
26564
+ else: # put center of window in center of screen
26565
+ # x,y = center of screen - 1/2 window size
26566
+ x, y = screen_width//2, screen_height//2
26567
+ if location_anchor is None:
26568
+ location_anchor = WIN_ANCHOR_CENTER
26569
+
26570
+ master.update_idletasks() # don't forget to do updates or values are bad
26571
+ win_width = master.winfo_width()
26572
+ win_height = master.winfo_height()
26573
+
26574
+ xoff = yoff = 0
26575
+ if location_anchor == WIN_ANCHOR_CENTER:
26576
+ xoff, yoff = win_width//2, win_height//2
26577
+ elif location_anchor == WIN_ANCHOR_UPPER_LEFT:
26578
+ xoff, yoff = 0, 0
26579
+ elif location_anchor == WIN_ANCHOR_UPPER_RIGHT:
26580
+ xoff, yoff = win_width, 0
26581
+ elif location_anchor== WIN_ANCHOR_LOWER_LEFT:
26582
+ xoff, yoff = 0, win_height
26583
+ elif location_anchor == WIN_ANCHOR_LOWER_RIGHT:
26584
+ xoff, yoff = win_width, win_height
26585
+
26586
+ # move the window to the correct anchor point
26587
+ x -= xoff
26588
+ y -= yoff
26589
+
26590
+ # keep the window from going off the screen if creating at the default location
26591
+ if window.Location == (None, None) and DEFAULT_WINDOW_LOCATION == (None, None):
25840
26592
  if x + win_width > screen_width:
25841
26593
  x = screen_width - win_width
26594
+ if y + win_height > screen_height:
26595
+ y = screen_height - win_height
26596
+
26597
+
25842
26598
 
25843
26599
  if window.RelativeLoction != (None, None):
25844
26600
  x += window.RelativeLoction[0]
@@ -25861,6 +26617,9 @@ def _convert_window_to_tk(window):
25861
26617
  window.TKroot.x = x
25862
26618
  window.TKroot.y = y
25863
26619
  window.starting_window_position = x,y
26620
+ if window.use_min_size:
26621
+ window.TKroot.minsize(master.winfo_width(), master.winfo_height())
26622
+ window.TKroot.update_idletasks()
25864
26623
  _no_titlebar_setup(window)
25865
26624
 
25866
26625
  return
@@ -25937,10 +26696,12 @@ if _mac_should_set_alpha_to_99():
25937
26696
  def main_command_line():
25938
26697
  # To execute the upgrade from command line, type:
25939
26698
  # python -m PySimpleGUI upgrade
25940
- # print(f'In main with argv={sys.argv}')
25941
26699
  if len(sys.argv) > 1:
25942
26700
  if 'version' in sys.argv:
25943
26701
  print(get_versions())
26702
+ elif 'upgrade' in sys.argv:
26703
+ upgrade_PySimpleGUI_gui()
26704
+ execute_restart(sys.argv[1:])
25944
26705
  elif 'help' in sys.argv:
25945
26706
  print('PySimpleGUI command line options\n')
25946
26707
  print('python -m PySmpleGUI upgrade', '\n Open GUI upgrade utility (same as psgupgrade)\n')