PySimpleGUI 6.2__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.
@@ -54,15 +54,14 @@
54
54
 
55
55
  """
56
56
 
57
- version = "6.2"
57
+ version = "6.3"
58
58
 
59
59
 
60
60
 
61
61
  """
62
62
  Changelog since last major release
63
63
 
64
- 6.2 14-Jun-2026 released to GitHub
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 = '_'
@@ -845,7 +855,27 @@ class ToolTip:
845
855
  This is an INTERNALLY USED only class. Users should not refer to this class at all.
846
856
  """
847
857
 
848
- 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
+
849
879
  """
850
880
  :param widget: The tkinter widget
851
881
  :type widget: widget type varies
@@ -853,6 +883,8 @@ class ToolTip:
853
883
  :type text: str | None
854
884
  :param timeout: Time in milliseconds that mouse must remain still before tip is shown
855
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)
856
888
  """
857
889
  self.widget = widget
858
890
  self.text = text # Set to None and tooltip will be not shown
@@ -861,9 +893,15 @@ class ToolTip:
861
893
  self.tipwindow = None
862
894
  self.id = None
863
895
  self.x = self.y = 0
864
- self.widget.bind("<Enter>", self.enter)
865
- 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)
866
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
867
905
 
868
906
  def enter(self, event=None):
869
907
  """
@@ -909,8 +947,8 @@ class ToolTip:
909
947
  """
910
948
  if self.tipwindow:
911
949
  return
912
- x = self.widget.winfo_rootx() + self.x + DEFAULT_TOOLTIP_OFFSET[0]
913
- 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]
914
952
  self.tipwindow = tk.Toplevel(self.widget)
915
953
  # if not sys.platform.startswith('darwin'):
916
954
  try:
@@ -923,10 +961,9 @@ class ToolTip:
923
961
  self.tipwindow.wm_geometry("+%d+%d" % (x, y))
924
962
  self.tipwindow.wm_attributes("-topmost", 1)
925
963
 
926
- label = ttk.Label(self.tipwindow, text=self.text, justify=tk.LEFT,
927
- background=TOOLTIP_BACKGROUND_COLOR, relief=tk.SOLID, borderwidth=1)
928
- if TOOLTIP_FONT is not None:
929
- 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)
930
967
  label.pack()
931
968
 
932
969
  def hidetip(self):
@@ -1179,7 +1216,6 @@ class Element:
1179
1216
  :type event:
1180
1217
 
1181
1218
  """
1182
-
1183
1219
  if self.Type == ELEM_TYPE_TAB_GROUP:
1184
1220
  try:
1185
1221
  index = self.Widget.index('@{},{}'.format(event.x, event.y))
@@ -1198,6 +1234,7 @@ class Element:
1198
1234
  if self.Type == ELEM_TYPE_GRAPH:
1199
1235
  self._update_position_for_returned_values(event)
1200
1236
  self.ParentForm._right_click_menu_element = self
1237
+ return 'break' # Tell tkinter no to call the window's right click menu
1201
1238
 
1202
1239
  def _tearoff_menu_callback(self, parent, menu):
1203
1240
  """
@@ -1482,12 +1519,26 @@ class Element:
1482
1519
  self.Widget.unbind(bind_string)
1483
1520
  self.user_bind_dict.pop(bind_string, None)
1484
1521
 
1485
- 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):
1486
1524
  """
1487
- 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').
1488
1527
 
1489
- :param tooltip_text: the text to show in tooltip. If None then no tip will be shown
1490
- :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
1491
1542
  """
1492
1543
 
1493
1544
  if self.TooltipObject:
@@ -1496,7 +1547,9 @@ class Element:
1496
1547
  except:
1497
1548
  pass
1498
1549
 
1499
- 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)
1500
1553
 
1501
1554
 
1502
1555
  def remove_tooltip(self):
@@ -1587,7 +1640,7 @@ class Element:
1587
1640
  It's possible to specify None for one of sizes so that only 1 of the element's dimensions are changed.
1588
1641
 
1589
1642
  :param size: The size in characters, rows typically. In some cases they are pixels
1590
- :type size: (int, int)
1643
+ :type size: (int, int) | (None, None)
1591
1644
  """
1592
1645
  try:
1593
1646
  if size[0] != None:
@@ -1796,12 +1849,14 @@ class Element:
1796
1849
  self.ParentForm._grab_anywhere_include_these_list.append(self.Widget)
1797
1850
 
1798
1851
 
1799
- def set_right_click_menu(self, menu=None):
1852
+ def set_right_click_menu(self, menu=None, propogate_to_window=False):
1800
1853
  """
1801
1854
  Sets a right click menu for an element.
1802
1855
  If a menu is already set for the element, it will call the tkinter destroy method to remove it
1803
1856
  :param menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
1804
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
1805
1860
  """
1806
1861
  if menu == MENU_RIGHT_CLICK_DISABLED:
1807
1862
  return
@@ -1810,40 +1865,43 @@ class Element:
1810
1865
  if menu is None:
1811
1866
  return
1812
1867
  if menu:
1813
- # If previously had a menu destroy it
1814
- if self.TKRightClickMenu:
1815
- try:
1816
- self.TKRightClickMenu.destroy() # just in case there's a problem let's not crash
1817
- except:
1818
- pass
1819
- top_menu = tk.Menu(self.ParentForm.TKroot, tearoff=self.ParentForm.right_click_menu_tearoff, tearoffcommand=self._tearoff_menu_callback)
1820
-
1821
- if self.ParentForm.right_click_menu_background_color not in (COLOR_SYSTEM_DEFAULT, None):
1822
- top_menu.config(bg=self.ParentForm.right_click_menu_background_color)
1823
- if self.ParentForm.right_click_menu_text_color not in (COLOR_SYSTEM_DEFAULT, None):
1824
- top_menu.config(fg=self.ParentForm.right_click_menu_text_color)
1825
- if self.ParentForm.right_click_menu_disabled_text_color not in (COLOR_SYSTEM_DEFAULT, None):
1826
- top_menu.config(disabledforeground=self.ParentForm.right_click_menu_disabled_text_color)
1827
- if self.ParentForm.right_click_menu_font is not None:
1828
- top_menu.config(font=self.ParentForm.right_click_menu_font)
1829
-
1830
- if self.ParentForm.right_click_menu_selected_colors[0] not in (COLOR_SYSTEM_DEFAULT, None):
1831
- top_menu.config(activeforeground=self.ParentForm.right_click_menu_selected_colors[0])
1832
- if self.ParentForm.right_click_menu_selected_colors[1] not in (COLOR_SYSTEM_DEFAULT, None):
1833
- top_menu.config(activebackground=self.ParentForm.right_click_menu_selected_colors[1])
1834
- AddMenuItem(top_menu, menu[1], self, right_click_menu=True)
1835
- self.TKRightClickMenu = top_menu
1836
- 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
1837
1896
  if self.ParentForm.TKRightClickMenu is None:
1838
- self.ParentForm.TKRightClickMenu = top_menu
1839
- if (running_mac()):
1897
+ if running_mac():
1840
1898
  self.ParentForm.TKroot.bind('<ButtonRelease-2>', self.ParentForm._RightClickMenuCallback)
1841
1899
  else:
1842
1900
  self.ParentForm.TKroot.bind('<ButtonRelease-3>', self.ParentForm._RightClickMenuCallback)
1843
- if (running_mac()):
1844
- self.Widget.bind('<ButtonRelease-2>', self._RightClickMenuCallback)
1845
- else:
1846
- 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)
1847
1905
 
1848
1906
 
1849
1907
  def save_element_screenshot_to_disk(self, filename=None):
@@ -1934,6 +1992,60 @@ class Element:
1934
1992
  if widget is not None:
1935
1993
  widget.pack(**self.pack_settings)
1936
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
+
1937
2049
  def update(self, *args, **kwargs):
1938
2050
  """
1939
2051
  A dummy update call. This will only be called if an element hasn't implemented an update method
@@ -1968,15 +2080,18 @@ class Input(Element):
1968
2080
  Display a single text input field. Based on the tkinter Widget `Entry`
1969
2081
  """
1970
2082
 
1971
- def __init__(self, default_text='', size=(None, None), s=(None, None), disabled=False, password_char='', setting=None,
1972
- justification=None, background_color=None, text_color=None, font=None, tooltip=None, border_width=None,
1973
- change_submits=False, enable_events=False, do_not_clear=True, key=None, k=None, focus=False, pad=None, p=None,
1974
- use_readonly_for_disable=True, readonly=False, disabled_readonly_background_color=None, disabled_readonly_text_color=None, selected_text_color=None,
1975
- selected_background_color=None, expand_x=False, expand_y=False,
1976
- 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):
1977
2084
  """
1978
2085
  :param default_text: Text initially shown in the input box as a default value(Default value = ''). Will automatically be converted to string
1979
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
1980
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
1981
2096
  :type size: (int, int) | (int, None) | int
1982
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
@@ -2045,6 +2160,11 @@ class Input(Element):
2045
2160
  fg = text_color if text_color is not None else DEFAULT_INPUT_TEXT_COLOR
2046
2161
  self.selected_text_color = selected_text_color
2047
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
2048
2168
  self.Focus = focus
2049
2169
  self.do_not_clear = do_not_clear
2050
2170
  self.Justification = justification
@@ -2057,6 +2177,8 @@ class Input(Element):
2057
2177
  self.ReadOnly = readonly
2058
2178
  self.BorderWidth = border_width if border_width is not None else DEFAULT_BORDER_WIDTH
2059
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
2060
2182
  key = key if key is not None else k
2061
2183
  sz = size if size != (None, None) else s
2062
2184
  pad = pad if pad is not None else p
@@ -2069,8 +2191,7 @@ class Input(Element):
2069
2191
  super().__init__(ELEM_TYPE_INPUT_TEXT, size=sz, background_color=bg, text_color=fg, key=key, pad=pad,
2070
2192
  font=font, tooltip=tooltip, visible=visible, metadata=metadata)
2071
2193
 
2072
- 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,
2073
- 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):
2074
2195
  """
2075
2196
  Changes some of the settings for the Input Element. Must call `Window.Read` or `Window.Finalize` prior.
2076
2197
  Changes will not be visible in your window until you call window.read or window.refresh.
@@ -2137,9 +2258,6 @@ class Input(Element):
2137
2258
  elif readonly is False:
2138
2259
  self.TKEntry['state'] = 'normal'
2139
2260
 
2140
-
2141
-
2142
-
2143
2261
  if value is not None:
2144
2262
  if paste is not True:
2145
2263
  try:
@@ -2157,17 +2275,20 @@ class Input(Element):
2157
2275
  self.TKEntry.icursor(tk.END)
2158
2276
  elif move_cursor_to is not None:
2159
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()
2160
2284
  if select is True:
2161
2285
  self.TKEntry.select_range(0, 'end')
2162
2286
  elif select is False:
2163
2287
  self.TKEntry.select_clear()
2164
2288
  if visible is False:
2165
2289
  self._pack_forget_save_settings()
2166
- # self.TKEntry.pack_forget()
2167
2290
  elif visible is True:
2168
2291
  self._pack_restore_settings()
2169
- # self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1])
2170
- # self.TKEntry.pack(padx=self.pad_used[0], pady=self.pad_used[1], in_=self.ParentRowFrame)
2171
2292
  if visible is not None:
2172
2293
  self._visible = visible
2173
2294
  if password_char is not None:
@@ -2177,6 +2298,43 @@ class Input(Element):
2177
2298
  self.TKEntry.configure(font=font)
2178
2299
 
2179
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
+
2180
2338
 
2181
2339
  def set_ibeam_color(self, ibeam_color=None):
2182
2340
  """
@@ -2207,10 +2365,13 @@ class Input(Element):
2207
2365
  :return: current value of Input field or '' if error encountered
2208
2366
  :rtype: (str)
2209
2367
  """
2210
- try:
2211
- text = self.TKStringVar.get()
2212
- except:
2368
+ if self.showing_placeholder: # if showing a placeholder, then the actual value should be ''
2213
2369
  text = ''
2370
+ else:
2371
+ try:
2372
+ text = self.TKStringVar.get()
2373
+ except:
2374
+ text = ''
2214
2375
  return text
2215
2376
 
2216
2377
  Get = get
@@ -2351,7 +2512,7 @@ class Combo(Element):
2351
2512
  :param visible: control visibility of element
2352
2513
  :type visible: (bool)
2353
2514
  :param size: width, height. Width = characters-wide, height = NOTE it's the number of entries to show in the list
2354
- :type size: (int, int)
2515
+ :type size: (int, int) | (None, None)
2355
2516
  :param select: if True, then the text will be selected, if False then selection will be cleared
2356
2517
  :type select: (bool)
2357
2518
  :param background_color: color of background
@@ -2590,7 +2751,7 @@ class OptionMenu(Element):
2590
2751
  :param visible: control visibility of element
2591
2752
  :type visible: (bool)
2592
2753
  :param size: (width, height) size in characters (wide), height is ignored and present to be consistent with other elements
2593
- :type size: (int, int) (width, UNUSED)
2754
+ :type size: (int, int) | (width, None) | (None, None)
2594
2755
  """
2595
2756
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
2596
2757
  return
@@ -2904,6 +3065,14 @@ class Listbox(Element):
2904
3065
  return value
2905
3066
 
2906
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)
2907
3076
 
2908
3077
 
2909
3078
  def select_index(self, index, highlight_text_color=None, highlight_background_color=None):
@@ -4780,7 +4949,7 @@ class Button(Element):
4780
4949
  def __init__(self, button_text='', button_type=BUTTON_TYPE_READ_FORM, target=(None, None), tooltip=None,
4781
4950
  file_types=FILE_TYPES_ALL_FILES, initial_folder=None, default_extension='', disabled=False, change_submits=False,
4782
4951
  enable_events=False, image_filename=None, image_data=None, image_size=(None, None),
4783
- 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,
4784
4953
  disabled_button_color=None,
4785
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,
4786
4955
  k=None, right_click_menu=None, expand_x=False, expand_y=False, visible=True, metadata=None):
@@ -4790,7 +4959,7 @@ class Button(Element):
4790
4959
  :param button_type: You should NOT be setting this directly. ONLY the shortcut functions set this
4791
4960
  :type button_type: (int)
4792
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
4793
- :type target: str | (int, int)
4962
+ :type target: str | (int, int) | (None, None)
4794
4963
  :param tooltip: text, that will appear when mouse hovers over the element
4795
4964
  :type tooltip: (str)
4796
4965
  :param file_types: the filetypes that will be used to match files. To indicate all files: (("ALL Files", "*.* *"),).
@@ -4812,11 +4981,13 @@ class Button(Element):
4812
4981
  :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
4813
4982
  :type image_data: bytes | str
4814
4983
  :param image_size: Size of the image in pixels (width, height)
4815
- :type image_size: (int, int)
4984
+ :type image_size: (int, int) | (None, None)
4816
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
4817
4986
  :type image_subsample: (int)
4818
4987
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
4819
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)
4820
4991
  :param border_width: width of border around button in pixels
4821
4992
  :type border_width: (int)
4822
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
@@ -4872,13 +5043,24 @@ class Button(Element):
4872
5043
  self.ButtonText = str(button_text)
4873
5044
  self.RightClickMenu = right_click_menu
4874
5045
  self.ButtonColor = button_color_to_tuple(button_color)
4875
-
4876
5046
  self.DisabledButtonColor = button_color_to_tuple(disabled_button_color) if disabled_button_color is not None else (None, None)
4877
5047
  if image_source is not None:
4878
5048
  if isinstance(image_source, bytes):
4879
5049
  image_data = image_source
4880
5050
  elif isinstance(image_source, str):
4881
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 **')
4882
5064
  self.ImageFilename = image_filename
4883
5065
  self.ImageData = image_data
4884
5066
  self.ImageSize = image_size
@@ -5154,8 +5336,25 @@ class Button(Element):
5154
5336
 
5155
5337
  return
5156
5338
 
5157
- def update(self, text=None, button_color=(None, None), disabled=None, image_source=None, image_data=None, image_filename=None,
5158
- 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):
5159
5358
  """
5160
5359
  Changes some of the settings for the Button Element. Must call `Window.Read` or `Window.Finalize` prior
5161
5360
 
@@ -5177,6 +5376,8 @@ class Button(Element):
5177
5376
  :type image_data: bytes | str
5178
5377
  :param image_filename: image filename if there is a button image. GIFs and PNGs only.
5179
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)
5180
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
5181
5382
  :type disabled_button_color: (str, str)
5182
5383
  :param visible: control visibility of element
@@ -5186,7 +5387,7 @@ class Button(Element):
5186
5387
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
5187
5388
  :type image_zoom: (int)
5188
5389
  :param image_size: Size of the image in pixels (width, height)
5189
- :type image_size: (int, int)
5390
+ :type image_size: (int, int) | (None, None)
5190
5391
  """
5191
5392
 
5192
5393
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
@@ -5201,11 +5402,29 @@ class Button(Element):
5201
5402
  image_data = image_source
5202
5403
  elif isinstance(image_source, str):
5203
5404
  image_filename = image_source
5204
-
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
5205
5423
  if self.UseTtkButtons:
5206
5424
  style_name = self.ttk_style_name # created when made initial window (in the pack)
5207
- # style_name = str(self.Key) + 'custombutton.TButton'
5208
5425
  button_style = ttk.Style()
5426
+ else:
5427
+ style_name = button_style = None
5209
5428
  if text is not None:
5210
5429
  btext = text
5211
5430
  if DEFAULT_USE_BUTTON_SHORTCUTS is True:
@@ -5222,11 +5441,6 @@ class Button(Element):
5222
5441
  self.ButtonText = text
5223
5442
  if button_color != (None, None) and button_color != COLOR_SYSTEM_DEFAULT:
5224
5443
  bc = button_color_to_tuple(button_color, self.ButtonColor)
5225
- # if isinstance(button_color, str):
5226
- # try:
5227
- # button_color = button_color.split(' on ')
5228
- # except Exception as e:
5229
- # print('** Error in formatting your button color **', button_color, e)
5230
5444
  if self.UseTtkButtons:
5231
5445
  if bc[0] not in (None, COLOR_SYSTEM_DEFAULT):
5232
5446
  button_style.configure(style_name, foreground=bc[0])
@@ -5246,36 +5460,8 @@ class Button(Element):
5246
5460
  self.TKButton['state'] = 'normal'
5247
5461
  self.Disabled = disabled if disabled is not None else self.Disabled
5248
5462
 
5249
- if image_data is not None:
5250
- image = tk.PhotoImage(data=image_data)
5251
- if image_subsample:
5252
- image = image.subsample(image_subsample)
5253
- if image_zoom is not None:
5254
- image = image.zoom(int(image_zoom))
5255
- if image_size is not None:
5256
- width, height = image_size
5257
- else:
5258
- width, height = image.width(), image.height()
5259
- if self.UseTtkButtons:
5260
- button_style.configure(style_name, image=image, width=width, height=height)
5261
- else:
5262
- self.TKButton.config(image=image, width=width, height=height)
5263
- self.TKButton.image = image
5264
- if image_filename is not None:
5265
- image = tk.PhotoImage(file=image_filename)
5266
- if image_subsample:
5267
- image = image.subsample(image_subsample)
5268
- if image_zoom is not None:
5269
- image = image.zoom(int(image_zoom))
5270
- if image_size is not None:
5271
- width, height = image_size
5272
- else:
5273
- width, height = image.width(), image.height()
5274
- if self.UseTtkButtons:
5275
- button_style.configure(style_name, image=image, width=width, height=height)
5276
- else:
5277
- self.TKButton.config(highlightthickness=0, image=image, width=width, height=height)
5278
- 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
+
5279
5465
  if visible is False:
5280
5466
  self._pack_forget_save_settings()
5281
5467
  elif visible is True:
@@ -5294,6 +5480,51 @@ class Button(Element):
5294
5480
  if visible is not None:
5295
5481
  self._visible = visible
5296
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
+
5297
5528
  def get_text(self):
5298
5529
  """
5299
5530
  Returns the current text shown on a button
@@ -5352,7 +5583,7 @@ class ButtonMenu(Element):
5352
5583
  :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5353
5584
  :type image_data: bytes | str
5354
5585
  :param image_size: Size of the image in pixels (width, height)
5355
- :type image_size: (int, int)
5586
+ :type image_size: (int, int) | (None, None)
5356
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
5357
5588
  :type image_subsample: (int)
5358
5589
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
@@ -5472,7 +5703,7 @@ class ButtonMenu(Element):
5472
5703
  :param image_source: new image if image is to be changed. Can be a filename or a base64 encoded byte-string
5473
5704
  :type image_source: (str | bytes)
5474
5705
  :param image_size: Size of the image in pixels (width, height)
5475
- :type image_size: (int, int)
5706
+ :type image_size: (int, int) | (None, None)
5476
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
5477
5708
  :type image_subsample: (int)
5478
5709
  :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
@@ -5747,7 +5978,7 @@ class Image(Element):
5747
5978
  Image Element - show an image in the window. Should be a GIF or a PNG only
5748
5979
  """
5749
5980
 
5750
- 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,
5751
5982
  subsample=None, zoom=None, right_click_menu=None, expand_x=False, expand_y=False, visible=True, enable_events=False, metadata=None):
5752
5983
  """
5753
5984
  :param source: A filename or a base64 bytes. Will automatically detect the type and fill in filename or data for you.
@@ -5756,10 +5987,12 @@ class Image(Element):
5756
5987
  :type filename: str | None
5757
5988
  :param data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5758
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)
5759
5992
  :param background_color: color of background
5760
5993
  :type background_color:
5761
5994
  :param size: (width, height) size of image in pixels
5762
- :type size: (int, int)
5995
+ :type size: (int, int) | (None, None)
5763
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
5764
5997
  :type s: (int, int) | (None, None) | int
5765
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)
@@ -5798,12 +6031,22 @@ class Image(Element):
5798
6031
  else:
5799
6032
  warnings.warn('Image element - source is not a valid type: {}'.format(type(source)), UserWarning)
5800
6033
 
5801
- self.Filename = filename
5802
- self.Data = data
6034
+ self.ImageFilename = filename
6035
+ self.ImageData = data
6036
+ self.ImageSource = source or data or filename
5803
6037
  self.Widget = self.tktext_label = None # type: tk.Label
5804
6038
  self.BackgroundColor = background_color
5805
6039
  if data is None and filename is None:
5806
- 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
+
5807
6050
  self.EnableEvents = enable_events
5808
6051
  self.RightClickMenu = right_click_menu
5809
6052
  self.AnimatedFrames = None
@@ -5815,16 +6058,16 @@ class Image(Element):
5815
6058
  self.frame_num = 0
5816
6059
  self.Source = filename if filename is not None else data
5817
6060
  key = key if key is not None else k
5818
- sz = size if size != (None, None) else s
6061
+ self.ImageSize = size if size != (None, None) else s
5819
6062
  pad = pad if pad is not None else p
5820
6063
  self.expand_x = expand_x
5821
6064
  self.expand_y = expand_y
5822
6065
 
5823
- 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,
5824
6067
  tooltip=tooltip, visible=visible, metadata=metadata)
5825
6068
  return
5826
6069
 
5827
- 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):
5828
6071
  """
5829
6072
  Changes some of the settings for the Image Element. Must call `Window.Read` or `Window.Finalize` prior.
5830
6073
  To clear an image that's been displayed, call with NONE of the options set. A blank update call will
@@ -5842,6 +6085,8 @@ class Image(Element):
5842
6085
  :type filename: (str)
5843
6086
  :param data: Base64 encoded string OR a tk.PhotoImage object
5844
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)
5845
6090
  :param size: (width, height) size of image in pixels
5846
6091
  :type size: Tuple[int,int]
5847
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
@@ -5859,57 +6104,45 @@ class Image(Element):
5859
6104
  _error_popup_with_traceback('Error in Image.update - The window was closed')
5860
6105
  return
5861
6106
 
5862
- 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
5863
6121
  if isinstance(source, bytes):
5864
- data = source
6122
+ self.ImageData = data = source
5865
6123
  elif isinstance(source, str):
5866
- filename = source
6124
+ self.ImageFilename = filename = source
5867
6125
  else:
5868
6126
  warnings.warn('Image element - source is not a valid type: {}'.format(type(source)), UserWarning)
5869
6127
 
5870
- image = None
5871
- if filename is not None:
5872
- try:
5873
- image = tk.PhotoImage(file=filename)
5874
- if subsample is not None:
5875
- image = image.subsample(subsample)
5876
- if zoom is not None:
5877
- image = image.zoom(int(zoom))
5878
- except Exception as e:
5879
- _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
5880
6134
 
5881
- elif data is not None:
5882
- # if type(data) is bytes:
5883
- try:
5884
- image = tk.PhotoImage(data=data)
5885
- if subsample is not None:
5886
- image = image.subsample(subsample)
5887
- if zoom is not None:
5888
- image = image.zoom(int(zoom))
5889
- except Exception as e:
5890
- image = data
5891
- # return # an error likely means the window has closed so exit
5892
6135
 
5893
- if image is not None:
5894
- self.tktext_label.configure(image='') # clear previous image
5895
- if self.tktext_label.image is not None:
5896
- del self.tktext_label.image
5897
- if type(image) is not bytes:
5898
- width, height = size[0] if size[0] is not None else image.width(), size[1] if size[1] is not None else image.height()
5899
- else:
5900
- width, height = size
5901
- try: # sometimes crashes if user closed with X
5902
- self.tktext_label.configure(image=image, width=width, height=height)
5903
- except Exception as e:
5904
- _error_popup_with_traceback('Exception updating Image element', e)
5905
- 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
5906
6139
  if visible is False:
5907
6140
  self._pack_forget_save_settings()
5908
6141
  elif visible is True:
5909
6142
  self._pack_restore_settings()
5910
6143
 
5911
6144
  # if everything is set to None, then delete the image
5912
- 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):
5913
6146
  # Using a try because the image may have been previously deleted and don't want an error if that's happened
5914
6147
  try:
5915
6148
  self.tktext_label.configure(image='', width=1, height=1, bd=0)
@@ -5920,6 +6153,63 @@ class Image(Element):
5920
6153
  if visible is not None:
5921
6154
  self._visible = visible
5922
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
+
5923
6213
  def update_animation(self, source, time_between_frames=0):
5924
6214
  """
5925
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.
@@ -6155,11 +6445,11 @@ class Graph(Element):
6155
6445
  right_click_menu=None, expand_x=False, expand_y=False, visible=True, float_values=False, border_width=0, metadata=None):
6156
6446
  """
6157
6447
  :param canvas_size: size of the canvas area in pixels
6158
- :type canvas_size: (int, int)
6448
+ :type canvas_size: (int, int) | (None, None)
6159
6449
  :param graph_bottom_left: (x,y) The bottoms left corner of your coordinate system
6160
- :type graph_bottom_left: (int, int)
6450
+ :type graph_bottom_left: (int, int) | (None, None)
6161
6451
  :param graph_top_right: (x,y) The top right corner of your coordinate system
6162
- :type graph_top_right: (int, int)
6452
+ :type graph_top_right: (int, int) | (None, None)
6163
6453
  :param background_color: background color of the drawing area
6164
6454
  :type background_color: (str)
6165
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)
@@ -6264,23 +6554,25 @@ class Graph(Element):
6264
6554
  else:
6265
6555
  return floor(new_x), floor(new_y)
6266
6556
 
6267
- 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):
6268
6558
  """
6269
6559
  Draws a line from one point to another point using USER'S coordinates. Can set the color and width of line
6270
6560
  :param point_from: Starting point for line
6271
- :type point_from: (int, int) | Tuple[float, float]
6272
- :param point_to: Ending point for line
6273
- :type point_to: (int, int) | Tuple[float, float]
6274
- :param color: Color of the line
6275
- :type color: (str)
6276
- :param width: width of line in pixels
6277
- :type width: (int)
6278
- :param arrow: Determines if an arrowhead will be added to the line. Literal string "first", "last", "both"
6279
- :type arrow: (str)
6280
- :param arrow_shape: Defines the shape of the arrowhead using a tuple with (length, width, thickness)
6281
- :type arrow_shape: Tuple[float, float, float]
6282
- :return: id returned from tktiner or None if user closed the window. id is used when you
6283
- :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
6284
6576
  """
6285
6577
  if point_from == (None, None):
6286
6578
  return
@@ -6291,30 +6583,38 @@ class Graph(Element):
6291
6583
  print('Call Window.Finalize() prior to this operation')
6292
6584
  return None
6293
6585
  try: # in case window was closed with an X
6294
- 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)
6295
6587
  except Exception as e:
6296
6588
  # print(e)
6297
6589
  id = None
6298
6590
  return id
6299
6591
 
6300
6592
 
6301
- 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):
6302
6594
  """
6303
6595
  Draw a series of lines given list of points
6304
6596
 
6305
- :param points: list of points that define the polygon
6306
- :type points: List[(int, int) | Tuple[float, float]]
6307
- :param color: Color of the line
6308
- :type color: (str)
6309
- :param width: width of line in pixels
6310
- :type width: (int)
6311
- :return: id returned from tktiner or None if user closed the window. id is used when you
6312
- :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
6313
6613
  """
6314
6614
  converted_points = [self._convert_xy_to_canvas_xy(point[0], point[1]) for point in points]
6315
6615
 
6316
6616
  try: # in case window was closed with an X
6317
- 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)
6318
6618
  except:
6319
6619
  if self._TKCanvas2 is None:
6320
6620
  print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
@@ -6432,7 +6732,7 @@ class Graph(Element):
6432
6732
  :type extent: (float)
6433
6733
  :param start_angle: Angle to begin drawing. Used in conjunction with extent
6434
6734
  :type start_angle: (float)
6435
- :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'
6436
6736
  :type style: (str)
6437
6737
  :param arc_color: color to draw arc with
6438
6738
  :type arc_color: (str)
@@ -6908,7 +7208,7 @@ class Frame(Element):
6908
7208
 
6909
7209
  def __init__(self, title, layout, title_color=None, background_color=None, title_location=None,
6910
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,
6911
- tooltip=None, right_click_menu=None, expand_x=False, expand_y=False, grab=None, visible=True, element_justification='left', vertical_alignment=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,
6912
7212
  metadata=None):
6913
7213
  """
6914
7214
  :param title: text that is displayed as the Frame's "label" or title
@@ -6924,7 +7224,7 @@ class Frame(Element):
6924
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
6925
7225
  :type relief: (str)
6926
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
6927
- :type size: (int, int)
7227
+ :type size: (int, int) | (None, None)
6928
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
6929
7229
  :type s: (int, int) | (None, None) | int
6930
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
@@ -6959,6 +7259,8 @@ class Frame(Element):
6959
7259
  :type element_justification: (str)
6960
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)
6961
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)
6962
7264
  :param metadata: User metadata that can be set to ANYTHING
6963
7265
  :type metadata: (Any)
6964
7266
  """
@@ -6985,6 +7287,7 @@ class Frame(Element):
6985
7287
  self.VerticalAlignment = vertical_alignment
6986
7288
  self.Widget = None # type: tk.LabelFrame
6987
7289
  self.Grab = grab
7290
+ self.enable_events = enable_events
6988
7291
  self.Layout(layout)
6989
7292
  key = key if key is not None else k
6990
7293
  sz = size if size != (None, None) else s
@@ -7092,7 +7395,7 @@ class Frame(Element):
7092
7395
  element = row[col_num]
7093
7396
  return element
7094
7397
 
7095
- def update(self, value=None, visible=None):
7398
+ def update(self, value=None, visible=None, border_color=None):
7096
7399
  """
7097
7400
  Changes some of the settings for the Frame Element. Must call `Window.Read` or `Window.Finalize` prior
7098
7401
 
@@ -7102,10 +7405,12 @@ class Frame(Element):
7102
7405
  function "pin" to ensure your element is "pinned" to that location in your layout so that it returns there
7103
7406
  when made visible.
7104
7407
 
7105
- :param value: New text value (Title) to show on frame
7106
- :type value: (Any)
7107
- :param visible: control visibility of element
7108
- :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)
7109
7414
  """
7110
7415
  if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
7111
7416
  return
@@ -7124,6 +7429,9 @@ class Frame(Element):
7124
7429
  self.TKFrame.config(text=str(value))
7125
7430
  if visible is not None:
7126
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
7127
7435
 
7128
7436
  AddRow = add_row
7129
7437
  Layout = layout
@@ -7142,18 +7450,20 @@ class VerticalSeparator(Element):
7142
7450
  Column Element if extra height is needed
7143
7451
  """
7144
7452
 
7145
- 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):
7146
7454
  """
7147
- :param color: Color of the line. Defaults to theme's text color. Can be name or #RRGGBB format
7148
- :type color: (str)
7149
- :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)
7150
- :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7151
- :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
7152
- :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7153
- :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
7154
- :type key: str | int | tuple | object
7155
- :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7156
- :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
7157
7467
  """
7158
7468
  key = key if key is not None else k
7159
7469
  pad = pad if pad is not None else p
@@ -7161,6 +7471,7 @@ class VerticalSeparator(Element):
7161
7471
  self.expand_y = None
7162
7472
  self.Orientation = 'vertical' # for now only vertical works
7163
7473
  self.color = color if color is not None else theme_text_color()
7474
+ self.thickness = thickness
7164
7475
  super().__init__(ELEM_TYPE_SEPARATOR, pad=pad, key=key)
7165
7476
 
7166
7477
 
@@ -7179,22 +7490,25 @@ class HorizontalSeparator(Element):
7179
7490
  Horizontal Separator Element draws a Horizontal line at the given location.
7180
7491
  """
7181
7492
 
7182
- 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):
7183
7494
  """
7184
7495
  :param color: Color of the line. Defaults to theme's text color. Can be name or #RRGGBB format
7185
- :type color: (str)
7186
- :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)
7187
- :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7188
- :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
7189
- :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7190
- :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
7191
- :type key: str | int | tuple | object
7192
- :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7193
- :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
7194
7507
  """
7195
7508
 
7196
7509
  self.Orientation = 'horizontal' # for now only vertical works
7197
7510
  self.color = color if color is not None else theme_text_color()
7511
+ self.thickness = thickness
7198
7512
  self.expand_x = True
7199
7513
  self.expand_y = None
7200
7514
  key = key if key is not None else k
@@ -7256,50 +7570,52 @@ class Tab(Element):
7256
7570
 
7257
7571
  def __init__(self, title, layout, title_color=None, background_color=None, font=None, pad=None, p=None, disabled=False,
7258
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',
7259
- image_source=None, image_subsample=None, image_zoom=None, metadata=None):
7260
- """
7261
- :param title: text to show on the tab
7262
- :type title: (str)
7263
- :param layout: The element layout that will be shown in the tab
7264
- :type layout: List[List[Element]]
7265
- :param title_color: color of the tab text (note not currently working on tkinter)
7266
- :type title_color: (str)
7267
- :param background_color: color of background of the entire layout
7268
- :type background_color: (str)
7269
- :param font: NOT USED in the tkinter port
7270
- :type font: (str or (str, int[, str]) or None)
7271
- :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)
7272
- :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7273
- :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
7274
- :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
7275
- :param disabled: If True button will be created disabled
7276
- :type disabled: (bool)
7277
- :param border_width: NOT USED in tkinter port
7278
- :type border_width: (int)
7279
- :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
7280
- :type key: str | int | tuple | object
7281
- :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
7282
- :type k: str | int | tuple | object
7283
- :param tooltip: text, that will appear when mouse hovers over the element
7284
- :type tooltip: (str)
7285
- :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.
7286
- :type right_click_menu: List[List[ List[str] | str ]]
7287
- :param expand_x: If True the element will automatically expand in the X direction to fill available space
7288
- :type expand_x: (bool)
7289
- :param expand_y: If True the element will automatically expand in the Y direction to fill available space
7290
- :type expand_y: (bool)
7291
- :param visible: set visibility state of the element
7292
- :type visible: (bool)
7293
- :param element_justification: All elements inside the Tab will have this justification 'left', 'right', 'center' are valid values
7294
- :type element_justification: (str)
7295
- :param image_source: A filename or a base64 bytes of an image to place on the Tab
7296
- :type image_source: str | bytes | None
7297
- :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
7298
- :type image_subsample: (int)
7299
- :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
7300
- :type image_zoom: (int)
7301
- :param metadata: User metadata that can be set to ANYTHING
7302
- :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)
7303
7619
  """
7304
7620
 
7305
7621
  filename = data = None
@@ -7310,11 +7626,21 @@ class Tab(Element):
7310
7626
  filename = image_source
7311
7627
  else:
7312
7628
  warnings.warn('Image element - source is not a valid type: {}'.format(type(image_source)), UserWarning)
7313
-
7314
- self.Filename = filename
7315
- self.Data = data
7629
+ self.ImageSource = data or filename
7630
+ self.ImageFilename = filename
7631
+ self.ImageData = data
7316
7632
  self.ImageSubsample = image_subsample
7633
+ self.ImageSize = None # not a parm for this element
7317
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
+
7318
7644
  self.UseDictionary = False
7319
7645
  self.ReturnValues = None
7320
7646
  self.ReturnValuesList = []
@@ -7464,6 +7790,65 @@ class Tab(Element):
7464
7790
  # self.ParentNotebook.pack()
7465
7791
  return self
7466
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
+
7467
7852
  def _GetElementAtLocation(self, location):
7468
7853
  """
7469
7854
  Not user callable. Used to find the Element at a row, col position within the layout
@@ -7760,10 +8145,10 @@ class TabGroup(Element):
7760
8145
  # If there's an image in the tab, then do the imagey-stuff
7761
8146
  # ------------------- start of imagey-stuff -------------------
7762
8147
  try:
7763
- if tab_element.Filename is not None:
7764
- photo = tk.PhotoImage(file=tab_element.Filename)
7765
- elif tab_element.Data is not None:
7766
- 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)
7767
8152
  else:
7768
8153
  photo = None
7769
8154
 
@@ -7805,7 +8190,7 @@ class TabGroup(Element):
7805
8190
  if tab_element.BorderWidth is not None:
7806
8191
  tab_element.TKFrame.configure(borderwidth=tab_element.BorderWidth)
7807
8192
  if tab_element.Tooltip is not None:
7808
- 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)
7809
8194
  _add_right_click_menu(tab_element, form)
7810
8195
 
7811
8196
  def update(self, visible=None):
@@ -7874,7 +8259,7 @@ class Slider(Element):
7874
8259
  :param disabled: set disable state for element
7875
8260
  :type disabled: (bool)
7876
8261
  :param size: (l=length chars/rows, w=width pixels)
7877
- :type size: (int, int)
8262
+ :type size: (int, int) | (None, None)
7878
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
7879
8264
  :type s: (int, int) | (None, None)
7880
8265
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
@@ -7946,7 +8331,7 @@ class Slider(Element):
7946
8331
  :param value: sets current slider value
7947
8332
  :type value: int | float
7948
8333
  :param range: Sets a new range for slider
7949
- :type range: (int, int) | Tuple[float, float
8334
+ :type range: (int, int) | (float, float) | (None, None)
7950
8335
  :param disabled: disable or enable state of the element
7951
8336
  :type disabled: (bool)
7952
8337
  :param visible: control visibility of element
@@ -8174,7 +8559,7 @@ class Column(Element):
8174
8559
 
8175
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,
8176
8561
  vertical_scroll_only=False, horizontal_scroll_only=False, right_click_menu=None, key=None, k=None, visible=True, justification=None, element_justification=None,
8177
- vertical_alignment=None, grab=None, expand_x=None, expand_y=None, metadata=None,
8562
+ vertical_alignment=None, grab=None, expand_x=None, expand_y=None, metadata=None, enable_events=None,
8178
8563
  sbar_trough_color=None, sbar_background_color=None, sbar_arrow_color=None, sbar_width=None, sbar_arrow_width=None,
8179
8564
  sbar_frame_color=None, sbar_relief=None):
8180
8565
  """
@@ -8194,7 +8579,7 @@ class Column(Element):
8194
8579
  :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
8195
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
8196
8581
  :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
8197
- :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
8198
8583
  :type scrollable: (bool)
8199
8584
  :param vertical_scroll_only: if True then no horizontal scrollbar will be shown if a scrollable column
8200
8585
  :type vertical_scroll_only: (bool)
@@ -8222,6 +8607,8 @@ class Column(Element):
8222
8607
  :type expand_y: (bool)
8223
8608
  :param metadata: User metadata that can be set to ANYTHING
8224
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)
8225
8612
  :param sbar_trough_color: Scrollbar color of the trough
8226
8613
  :type sbar_trough_color: (str)
8227
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
@@ -8258,6 +8645,7 @@ class Column(Element):
8258
8645
  self.ElementJustification = element_justification
8259
8646
  self.Justification = justification
8260
8647
  self.VerticalAlignment = vertical_alignment
8648
+ self.enable_events = enable_events
8261
8649
  key = key if key is not None else k
8262
8650
  self.Grab = grab
8263
8651
  self.expand_x = expand_x
@@ -8412,6 +8800,8 @@ class Column(Element):
8412
8800
  When a scrollable column has part of its layout changed by making elements visible or invisible or the
8413
8801
  layout is extended for the Column, then this method needs to be called so that the new scroll area
8414
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
8415
8805
  """
8416
8806
  self.TKColFrame.canvas.config(scrollregion=self.TKColFrame.canvas.bbox('all'))
8417
8807
 
@@ -8439,7 +8829,7 @@ class Pane(Element):
8439
8829
  :param background_color: color of background
8440
8830
  :type background_color: (str)
8441
8831
  :param size: (width, height) w=characters-wide, h=rows-high How much room to reserve for the Pane
8442
- :type size: (int, int)
8832
+ :type size: (int, int) | (None, None)
8443
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
8444
8834
  :type s: (int, int) | (None, None)
8445
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)
@@ -8563,7 +8953,7 @@ class Menu(Element):
8563
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"
8564
8954
  :type disabled_text_color: (str)
8565
8955
  :param size: Not used in the tkinter port
8566
- :type size: (int, int)
8956
+ :type size: (int, int) | (None, None)
8567
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
8568
8958
  :type s: (int, int) | (None, None)
8569
8959
  :param tearoff: if True, then can tear the menu off from the window ans use as a floating window. Very cool effect
@@ -8783,7 +9173,7 @@ class Table(Element):
8783
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
8784
9174
  :type sbar_relief: (str)
8785
9175
  :param size: DO NOT USE! Use num_rows instead
8786
- :type size: (int, int)
9176
+ :type size: (int, int) | (None, None)
8787
9177
  :param change_submits: DO NOT USE. Only listed for backwards compat - Use enable_events instead
8788
9178
  :type change_submits: (bool)
8789
9179
  :param enable_events: Turns on the element specific events. Table events happen when row is clicked
@@ -9837,19 +10227,20 @@ class Window:
9837
10227
 
9838
10228
  def __init__(self, title, layout=None, default_element_size=None,
9839
10229
  default_button_element_size=(None, None),
9840
- 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),
9841
10231
  element_padding=None, margins=(None, None), button_color=None, font=None,
9842
10232
  progress_bar_color=(None, None), background_color=None, border_depth=None, auto_close=False,
9843
10233
  auto_close_duration=DEFAULT_AUTOCLOSE_TIME, icon=None, force_toplevel=False,
9844
10234
  alpha_channel=None, return_keyboard_events=False, use_default_focus=True, text_justification=None,
9845
- 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,
9846
10236
  disable_minimize=False, right_click_menu=None, transparent_color=None, debugger_enabled=False,
9847
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),
9848
10238
  right_click_menu_font=None, right_click_menu_tearoff=False,
9849
10239
  finalize=False, element_justification='left', ttk_theme=None, use_ttk_buttons=None, modal=False, enable_close_attempted_event=False,
9850
10240
  enable_window_config_events=False, repeating_timer_ms=None,
9851
- titlebar_background_color=None, titlebar_text_color=None, titlebar_font=None, titlebar_icon=None,
9852
- 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,
9853
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,
9854
10245
  metadata=None):
9855
10246
  """
@@ -9860,23 +10251,25 @@ class Window:
9860
10251
  :param default_element_size: size in characters (wide) and rows (high) for all elements in this window
9861
10252
  :type default_element_size: (int, int) - (width, height)
9862
10253
  :param default_button_element_size: (width, height) size in characters (wide) and rows (high) for all Button elements in this window
9863
- :type default_button_element_size: (int, int)
10254
+ :type default_button_element_size: (int, int) | (None, None)
9864
10255
  :param auto_size_text: True if Elements in Window should be sized to exactly fir the length of text
9865
10256
  :type auto_size_text: (bool)
9866
10257
  :param auto_size_buttons: True if Buttons in this Window should be sized to exactly fit the text on this.
9867
10258
  :type auto_size_buttons: (bool)
9868
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
9869
10260
  :type location: (int, int) or (None, None) or None
9870
- :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.
9871
- :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)
9872
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
9873
10266
  :type auto_save_location: (bool)
9874
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
9875
- :type size: (int, int)
10268
+ :type size: (int, int) | (None, None)
9876
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)
9877
10270
  :type element_padding: (int, int) or ((int, int),(int,int)) or int
9878
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.
9879
- :type margins: (int, int)
10272
+ :type margins: (int, int) | (None, None)
9880
10273
  :param button_color: Default button colors for all buttons in the window
9881
10274
  :type button_color: (str, str) | str
9882
10275
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
@@ -9913,6 +10306,8 @@ class Window:
9913
10306
  :type keep_on_top: (bool)
9914
10307
  :param resizable: If True, allows the user to resize the window. Note the not all Elements will change size or location when resizing.
9915
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)
9916
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
9917
10312
  :type disable_close: (bool)
9918
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.
@@ -9920,7 +10315,7 @@ class Window:
9920
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.
9921
10316
  :type right_click_menu: List[List[ List[str] | str ]]
9922
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.
9923
- :type transparent_color: (str)
10318
+ :type transparent_color: str | None
9924
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
9925
10320
  :type debugger_enabled: (bool)
9926
10321
  :param right_click_menu_background_color: Background color for right click menus
@@ -9959,6 +10354,16 @@ class Window:
9959
10354
  :type titlebar_font: (str or (str, int[, str]) or None)
9960
10355
  :param titlebar_icon: If custom titlebar indicated by use_custom_titlebar, then use this as the icon (file or base64 bytes)
9961
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)
9962
10367
  :param use_custom_titlebar: If True, then a custom titlebar will be used instead of the normal titlebar
9963
10368
  :type use_custom_titlebar: bool
9964
10369
  :param scaling: Apply scaling to the elements in the window. Can be set on a global basis using set_options
@@ -9997,6 +10402,7 @@ class Window:
9997
10402
  self.Location = DEFAULT_WINDOW_LOCATION
9998
10403
  else:
9999
10404
  self.Location = location
10405
+ self.location_anchor = location_anchor
10000
10406
  self.RelativeLoction = relative_location
10001
10407
  self.ButtonColor = button_color_to_tuple(button_color)
10002
10408
  self.BackgroundColor = background_color if background_color else DEFAULT_BACKGROUND_COLOR
@@ -10044,6 +10450,7 @@ class Window:
10044
10450
  self.KeepOnTop = keep_on_top
10045
10451
  self.ForceTopLevel = force_toplevel
10046
10452
  self.Resizable = resizable
10453
+ self.use_min_size = use_min_size
10047
10454
  self._AlphaChannel = alpha_channel if alpha_channel is not None else DEFAULT_ALPHA_CHANNEL
10048
10455
  self.Timeout = None
10049
10456
  self.TimeoutKey = TIMEOUT_KEY
@@ -10130,7 +10537,11 @@ class Window:
10130
10537
  self._mouse_offset_x = self._mouse_offset_y = 0
10131
10538
  self.watermark = watermark
10132
10539
  self.repeating_timer_ms = repeating_timer_ms
10133
-
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
10134
10545
  # use the print event values setting if explicitly turned on or disable if explicitly turned off in this window
10135
10546
  if print_event_values is True or (pysimplegui_user_settings.get('-print event values-', False) and print_event_values is not False):
10136
10547
  self.print_event_values = True
@@ -10239,18 +10650,9 @@ class Window:
10239
10650
  CurrentRow = [] # start with a blank row and build up
10240
10651
  # ------------------------- Add the elements to a row ------------------------- #
10241
10652
  for i, element in enumerate(args): # Loop through list of elements and add them to the row
10242
-
10243
10653
  if isinstance(element, tuple) or isinstance(element, list):
10244
10654
  self.add_row(*element)
10245
10655
  continue
10246
- _error_popup_with_traceback('Error creating Window layout',
10247
- 'Layout has a LIST instead of an ELEMENT',
10248
- 'This sometimes means you have a badly placed ]',
10249
- 'The offensive list is:',
10250
- element,
10251
- 'This list will be stripped from your layout'
10252
- )
10253
- continue
10254
10656
  elif callable(element) and not isinstance(element, Element):
10255
10657
  _error_popup_with_traceback('Error creating Window layout',
10256
10658
  'Layout has a FUNCTION instead of an ELEMENT',
@@ -10596,7 +10998,7 @@ class Window:
10596
10998
  :param close: if True the window will be closed prior to returning
10597
10999
  :type close: (bool)
10598
11000
  :return: (event, values)
10599
- :rtype: Tuple[(Any), Dict[Any, Any], List[Any], None]
11001
+ :rtype: Tuple[(Any), Dict[Any, Any] | List[Any] | None]
10600
11002
  """
10601
11003
 
10602
11004
  if Window._floating_debug_window_build_needed is True:
@@ -10979,7 +11381,7 @@ class Window:
10979
11381
  :param supress_raise: Override for the global setting that determines if a key error should raise an exception
10980
11382
  :type supress_raise: (bool | None)
10981
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
10982
- :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
10983
11385
  """
10984
11386
 
10985
11387
  key_error = False
@@ -11083,6 +11485,9 @@ class Window:
11083
11485
  ELEM_TYPE_TAB_GROUP, ELEM_TYPE_SEPARATOR):
11084
11486
  element.Key = top_window.DictionaryKeyCounter
11085
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:]}'
11086
11491
  if element.Key is not None:
11087
11492
  if element.Key in key_dict.keys():
11088
11493
  if element.Type == ELEM_TYPE_BUTTON and WARN_DUPLICATE_BUTTON_KEY_ERRORS: # for Buttons see if should complain
@@ -11171,7 +11576,7 @@ class Window:
11171
11576
  try:
11172
11577
  element = self.find_element(key)
11173
11578
  if element.setting is not None:
11174
- value = user_settings_get_entry(key, '')
11579
+ value = user_settings_get_entry(key, element.setting)
11175
11580
  element.update(value)
11176
11581
  except Exception as e:
11177
11582
  _error_popup_with_traceback('Error restoring settings', e)
@@ -11225,14 +11630,40 @@ class Window:
11225
11630
  screen_height = self.TKroot.winfo_screenheight()
11226
11631
  return screen_width, screen_height
11227
11632
 
11228
- def move(self, x, y):
11633
+
11634
+ def move(self, x, y, anchor=None):
11229
11635
  """
11230
- Move the upper left corner of this window to the x,y coordinates provided
11231
- :param x: x coordinate in pixels
11232
- :type x: (int)
11233
- :param y: y coordinate in pixels
11234
- :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
11235
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
+
11236
11667
  try:
11237
11668
  self.TKroot.geometry("+%s+%s" % (x, y))
11238
11669
  self.config_last_location = (int(x), (int(y)))
@@ -11814,7 +12245,7 @@ class Window:
11814
12245
  except Exception as e:
11815
12246
  warnings.warn('Problem in Window.keep_on_top_clear trying to clear wm_attributes topmost' + str(e), UserWarning)
11816
12247
 
11817
- def current_location(self, more_accurate=False, without_titlebar=False):
12248
+ def current_location(self, more_accurate=False, without_titlebar=False, use_anchor=None):
11818
12249
  """
11819
12250
  Get the current location of the window's top left corner.
11820
12251
  Sometimes, depending on the environment, the value returned does not include the titlebar,etc
@@ -11828,6 +12259,8 @@ class Window:
11828
12259
  :type more_accurate: (bool)
11829
12260
  :param without_titlebar: If True, return location of top left of main window area without the titlebar (may be OS dependent?)
11830
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)
11831
12264
  :return: The x and y location in tuple form (x,y)
11832
12265
  :rtype: Tuple[int, int] | Tuple[None, None]
11833
12266
  """
@@ -11843,6 +12276,17 @@ class Window:
11843
12276
  x, y = int(location[0]), int(location[1])
11844
12277
  else:
11845
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
11846
12290
  except Exception as e:
11847
12291
  warnings.warn('Error in Window.current_location. Trouble getting x,y location\n' + str(e), UserWarning)
11848
12292
  x, y = (None, None)
@@ -12482,7 +12926,6 @@ class Window:
12482
12926
  """
12483
12927
  One of the Custom Titlbar buttons was clicked
12484
12928
  :param key:
12485
- :return:
12486
12929
  """
12487
12930
  if key == TITLEBAR_MINIMIZE_KEY:
12488
12931
  if not self.DisableMinimize:
@@ -12601,7 +13044,7 @@ class Window:
12601
13044
  :param key: The key to find
12602
13045
  :type key: str | int | tuple | object
12603
13046
  :return: The element found
12604
- :rtype: Element
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
12605
13048
  """
12606
13049
 
12607
13050
  return self.find_element(key)
@@ -13064,7 +13507,7 @@ class SystemTray:
13064
13507
  :param alpha: Alpha channel. 0 - invisible 1 - fully visible
13065
13508
  :type alpha: (float)
13066
13509
  :param location: Location on the screen to display the window
13067
- :type location: (int, int)
13510
+ :type location: (int, int) | None
13068
13511
  :return: (int) reason for returning
13069
13512
  :rtype: (int)
13070
13513
  """
@@ -13086,7 +13529,7 @@ class SystemTray:
13086
13529
  layout = [[Graph(canvas_size=(win_width, win_height), graph_bottom_left=(0, win_height), graph_top_right=(win_width, 0), key="-GRAPH-",
13087
13530
  background_color=SYSTEM_TRAY_MESSAGE_WIN_COLOR, enable_events=True)]]
13088
13531
 
13089
- 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])
13090
13533
  window = Window(title, layout, background_color=SYSTEM_TRAY_MESSAGE_WIN_COLOR, no_titlebar=True,
13091
13534
  location=win_location, keep_on_top=True, alpha_channel=0, margins=(0, 0), element_padding=(0, 0), grab_anywhere=True, finalize=True)
13092
13535
 
@@ -13398,7 +13841,7 @@ def FolderBrowse(button_text='Browse', target=(ThisRow, -1), initial_folder=None
13398
13841
  :param tooltip: text, that will appear when mouse hovers over the element
13399
13842
  :type tooltip: (str)
13400
13843
  :param size: (w,h) w=characters-wide, h=rows-high
13401
- :type size: (int, int)
13844
+ :type size: (int, int) | (None, None) | int
13402
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
13403
13846
  :type s: (int, int) | (None, None) | int
13404
13847
  :param auto_size_button: True if button size is determined by button text
@@ -13457,7 +13900,7 @@ def FileBrowse(button_text='Browse', target=(ThisRow, -1), file_types=FILE_TYPES
13457
13900
  :param tooltip: text, that will appear when mouse hovers over the element
13458
13901
  :type tooltip: (str)
13459
13902
  :param size: (w,h) w=characters-wide, h=rows-high
13460
- :type size: (int, int)
13903
+ :type size: (int, int) | (None, None) | int
13461
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
13462
13905
  :type s: (int, int) | (None, None) | int
13463
13906
  :param auto_size_button: True if button size is determined by button text
@@ -13518,7 +13961,7 @@ def FilesBrowse(button_text='Browse', target=(ThisRow, -1), file_types=FILE_TYPE
13518
13961
  :param tooltip: text, that will appear when mouse hovers over the element
13519
13962
  :type tooltip: (str)
13520
13963
  :param size: (w,h) w=characters-wide, h=rows-high
13521
- :type size: (int, int)
13964
+ :type size: (int, int) | (None, None) | int
13522
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
13523
13966
  :type s: (int, int) | (None, None) | int
13524
13967
  :param auto_size_button: True if button size is determined by button text
@@ -13582,7 +14025,7 @@ def FileSaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=FILE_T
13582
14025
  :param tooltip: text, that will appear when mouse hovers over the element
13583
14026
  :type tooltip: (str)
13584
14027
  :param size: (w,h) w=characters-wide, h=rows-high
13585
- :type size: (int, int)
14028
+ :type size: (int, int) | (None, None) | int
13586
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
13587
14030
  :type s: (int, int) | (None, None) | int
13588
14031
  :param auto_size_button: True if button size is determined by button text
@@ -13641,7 +14084,7 @@ def SaveAs(button_text='Save As...', target=(ThisRow, -1), file_types=FILE_TYPES
13641
14084
  :param tooltip: text, that will appear when mouse hovers over the element
13642
14085
  :type tooltip: (str)
13643
14086
  :param size: (w,h) w=characters-wide, h=rows-high
13644
- :type size: (int, int)
14087
+ :type size: (int, int) | (None, None) | int
13645
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
13646
14089
  :type s: (int, int) | (None, None) | int
13647
14090
  :param auto_size_button: True if button size is determined by button text
@@ -13686,7 +14129,7 @@ def Save(button_text='Save', size=(None, None), s=(None, None), auto_size_button
13686
14129
  :param button_text: text in the button (Default value = 'Save')
13687
14130
  :type button_text: (str)
13688
14131
  :param size: (w,h) w=characters-wide, h=rows-high
13689
- :type size: (int, int)
14132
+ :type size: (int, int) | (None, None) | int
13690
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
13691
14134
  :type s: (int, int) | (None, None) | int
13692
14135
  :param auto_size_button: True if button size is determined by button text
@@ -13785,7 +14228,7 @@ def Open(button_text='Open', size=(None, None), s=(None, None), auto_size_button
13785
14228
  :param button_text: text in the button (Default value = 'Open')
13786
14229
  :type button_text: (str)
13787
14230
  :param size: (w,h) w=characters-wide, h=rows-high
13788
- :type size: (int, int)
14231
+ :type size: (int, int) | (None, None) | int
13789
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
13790
14233
  :type s: (int, int) | (None, None) | int
13791
14234
  :param auto_size_button: True if button size is determined by button text
@@ -13834,7 +14277,7 @@ def OK(button_text='OK', size=(None, None), s=(None, None), auto_size_button=Non
13834
14277
  :param button_text: text in the button (Default value = 'OK')
13835
14278
  :type button_text: (str)
13836
14279
  :param size: (w,h) w=characters-wide, h=rows-high
13837
- :type size: (int, int)
14280
+ :type size: (int, int) | (None, None) | int
13838
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
13839
14282
  :type s: (int, int) | (None, None) | int
13840
14283
  :param auto_size_button: True if button size is determined by button text
@@ -13883,7 +14326,7 @@ def Ok(button_text='Ok', size=(None, None), s=(None, None), auto_size_button=Non
13883
14326
  :param button_text: text in the button (Default value = 'Ok')
13884
14327
  :type button_text: (str)
13885
14328
  :param size: (w,h) w=characters-wide, h=rows-high
13886
- :type size: (int, int)
14329
+ :type size: (int, int) | (None, None) | int
13887
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
13888
14331
  :type s: (int, int) | (None, None) | int
13889
14332
  :param auto_size_button: True if button size is determined by button text
@@ -13932,7 +14375,7 @@ def Cancel(button_text='Cancel', size=(None, None), s=(None, None), auto_size_bu
13932
14375
  :param button_text: text in the button (Default value = 'Cancel')
13933
14376
  :type button_text: (str)
13934
14377
  :param size: (w,h) w=characters-wide, h=rows-high
13935
- :type size: (int, int)
14378
+ :type size: (int, int) | (None, None) | int
13936
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
13937
14380
  :type s: (int, int) | (None, None) | int
13938
14381
  :param auto_size_button: True if button size is determined by button text
@@ -13981,7 +14424,7 @@ def Quit(button_text='Quit', size=(None, None), s=(None, None), auto_size_button
13981
14424
  :param button_text: text in the button (Default value = 'Quit')
13982
14425
  :type button_text: (str)
13983
14426
  :param size: (w,h) w=characters-wide, h=rows-high
13984
- :type size: (int, int)
14427
+ :type size: (int, int) | (None, None) | int
13985
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
13986
14429
  :type s: (int, int) | (None, None) | int
13987
14430
  :param auto_size_button: True if button size is determined by button text
@@ -14030,7 +14473,7 @@ def Exit(button_text='Exit', size=(None, None), s=(None, None), auto_size_button
14030
14473
  :param button_text: text in the button (Default value = 'Exit')
14031
14474
  :type button_text: (str)
14032
14475
  :param size: (w,h) w=characters-wide, h=rows-high
14033
- :type size: (int, int)
14476
+ :type size: (int, int) | (None, None) | int
14034
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
14035
14478
  :type s: (int, int) | (None, None) | int
14036
14479
  :param auto_size_button: True if button size is determined by button text
@@ -14079,7 +14522,7 @@ def Yes(button_text='Yes', size=(None, None), s=(None, None), auto_size_button=N
14079
14522
  :param button_text: text in the button (Default value = 'Yes')
14080
14523
  :type button_text: (str)
14081
14524
  :param size: (w,h) w=characters-wide, h=rows-high
14082
- :type size: (int, int)
14525
+ :type size: (int, int) | (None, None) | int
14083
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
14084
14527
  :type s: (int, int) | (None, None) | int
14085
14528
  :param auto_size_button: True if button size is determined by button text
@@ -14128,7 +14571,7 @@ def No(button_text='No', size=(None, None), s=(None, None), auto_size_button=Non
14128
14571
  :param button_text: text in the button (Default value = 'No')
14129
14572
  :type button_text: (str)
14130
14573
  :param size: (w,h) w=characters-wide, h=rows-high
14131
- :type size: (int, int)
14574
+ :type size: (int, int) | (None, None) | int
14132
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
14133
14576
  :type s: (int, int) | (None, None) | int
14134
14577
  :param auto_size_button: True if button size is determined by button text
@@ -14177,7 +14620,7 @@ def Help(button_text='Help', size=(None, None), s=(None, None), auto_size_button
14177
14620
  :param button_text: text in the button (Default value = 'Help')
14178
14621
  :type button_text: (str)
14179
14622
  :param size: (w,h) w=characters-wide, h=rows-high
14180
- :type size: (int, int)
14623
+ :type size: (int, int) | (None, None) | int
14181
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
14182
14625
  :type s: (int, int) | (None, None) | int
14183
14626
  :param auto_size_button: True if button size is determined by button text
@@ -14229,7 +14672,7 @@ def Debug(button_text='', size=(None, None), s=(None, None), auto_size_button=No
14229
14672
  :param button_text: text in the button (Default value = '')
14230
14673
  :type button_text: (str)
14231
14674
  :param size: (w,h) w=characters-wide, h=rows-high
14232
- :type size: (int, int)
14675
+ :type size: (int, int) | (None, None) | int
14233
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
14234
14677
  :type s: (int, int) | (None, None) | int
14235
14678
  :param auto_size_button: True if button size is determined by button text
@@ -14296,7 +14739,7 @@ def SimpleButton(button_text, image_filename=None, image_data=None, image_size=(
14296
14739
  :param tooltip: text, that will appear when mouse hovers over the element
14297
14740
  :type tooltip: (str)
14298
14741
  :param size: (w,h) w=characters-wide, h=rows-high
14299
- :type size: (int, int)
14742
+ :type size: (int, int) | (None, None) | int
14300
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
14301
14744
  :type s: (int, int) | (None, None) | int
14302
14745
  :param auto_size_button: True if button size is determined by button text
@@ -14358,7 +14801,7 @@ def CloseButton(button_text, image_filename=None, image_data=None, image_size=(N
14358
14801
  :param tooltip: text, that will appear when mouse hovers over the element
14359
14802
  :type tooltip: (str)
14360
14803
  :param size: (w,h) w=characters-wide, h=rows-high
14361
- :type size: (int, int)
14804
+ :type size: (int, int) | (None, None) | int
14362
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
14363
14806
  :type s: (int, int) | (None, None) | int
14364
14807
  :param auto_size_button: True if button size is determined by button text
@@ -14418,7 +14861,7 @@ def ReadButton(button_text, image_filename=None, image_data=None, image_size=(No
14418
14861
  :param tooltip: text, that will appear when mouse hovers over the element
14419
14862
  :type tooltip: (str)
14420
14863
  :param size: (w,h) w=characters-wide, h=rows-high
14421
- :type size: (int, int)
14864
+ :type size: (int, int) | (None, None) | int
14422
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
14423
14866
  :type s: (int, int) | (None, None) | int
14424
14867
  :param auto_size_button: True if button size is determined by button text
@@ -14485,7 +14928,7 @@ def RealtimeButton(button_text, image_filename=None, image_data=None, image_size
14485
14928
  :param tooltip: text, that will appear when mouse hovers over the element
14486
14929
  :type tooltip: (str)
14487
14930
  :param size: (w,h) w=characters-wide, h=rows-high
14488
- :type size: (int, int)
14931
+ :type size: (int, int) | (None, None) | int
14489
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
14490
14933
  :type s: (int, int) | (None, None) | int
14491
14934
  :param auto_size_button: True if button size is determined by button text
@@ -14626,7 +15069,7 @@ def CalendarButton(button_text, target=(ThisRow, -1), close_when_date_chosen=Tru
14626
15069
  :param border_width: width of border around element
14627
15070
  :type border_width: width of border around element
14628
15071
  :param size: (w,h) w=characters-wide, h=rows-high
14629
- :type size: (int, int)
15072
+ :type size: (int, int) | (None, None) | int
14630
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
14631
15074
  :type s: (int, int) | (None, None) | int
14632
15075
  :param auto_size_button: True if button size is determined by button text
@@ -14664,7 +15107,7 @@ def CalendarButton(button_text, target=(ThisRow, -1), close_when_date_chosen=Tru
14664
15107
  :param no_titlebar: if True no titlebar will be shown on the date chooser window
14665
15108
  :type no_titlebar: bool
14666
15109
  :param location: Location on the screen (x,y) to show the calendar popup window
14667
- :type location: (int, int)
15110
+ :type location: (int, int) | (None, None)
14668
15111
  :param visible: set initial visibility state of the Button
14669
15112
  :type visible: (bool)
14670
15113
  :param metadata: Anything you want to store along with this button
@@ -14712,7 +15155,7 @@ def ColorChooserButton(button_text, target=(ThisRow, -1), image_filename=None, i
14712
15155
  :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
14713
15156
  :type image_data: bytes | str
14714
15157
  :param image_size: Size of the image in pixels (width, height)
14715
- :type image_size: (int, int)
15158
+ :type image_size: (int, int) | (None, None)
14716
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
14717
15160
  :type image_subsample: (int)
14718
15161
  :param tooltip: text, that will appear when mouse hovers over the element
@@ -14720,7 +15163,7 @@ def ColorChooserButton(button_text, target=(ThisRow, -1), image_filename=None, i
14720
15163
  :param border_width: width of border around element
14721
15164
  :type border_width: (int)
14722
15165
  :param size: (w,h) w=characters-wide, h=rows-high
14723
- :type size: (int, int)
15166
+ :type size: (int, int) | (None, None) | int
14724
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
14725
15168
  :type s: (int, int) | (None, None) | int
14726
15169
  :param auto_size_button: True if button size is determined by button text
@@ -14983,8 +15426,10 @@ def _BuildResultsForSubform(form, initialize_only, top_level_form):
14983
15426
  value = element.TKStringVar.get()
14984
15427
  except:
14985
15428
  value = ''
15429
+ if element.showing_placeholder: # if showing the placeholder then set value returned to ''
15430
+ value = ''
14986
15431
  if not top_level_form.NonBlocking and not element.do_not_clear and not top_level_form.ReturnKeyboardEvents:
14987
- if top_level_form.element_that_generated_event is not None and top_level_form.element_that_generated_event.BType != BUTTON_TYPE_CALENDAR_CHOOSER:
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:
14988
15433
  element.TKStringVar.set('')
14989
15434
  elif element.Type == ELEM_TYPE_INPUT_CHECKBOX:
14990
15435
  value = element.TKIntVar.get()
@@ -15438,6 +15883,7 @@ def _add_right_click_menu(element, toplevel_form):
15438
15883
  top_menu.config(activebackground=toplevel_form.right_click_menu_selected_colors[1])
15439
15884
  AddMenuItem(top_menu, menu[1], element, right_click_menu=True)
15440
15885
  element.TKRightClickMenu = top_menu
15886
+ element.RightClickMenu = menu # Store the menu in the element in case the window was the source
15441
15887
  if (running_mac()):
15442
15888
  element.Widget.bind('<ButtonRelease-2>', element._RightClickMenuCallback)
15443
15889
  else:
@@ -15712,6 +16158,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
15712
16158
  top_menu.config(activebackground=toplevel_form.right_click_menu_selected_colors[1])
15713
16159
  AddMenuItem(top_menu, menu[1], element, right_click_menu=True)
15714
16160
  element.TKRightClickMenu = top_menu
16161
+ element.RightClickMenu = menu # Store the menu in the element in case the window was the source
15715
16162
  if toplevel_form.RightClickMenu: # if the top level has a right click menu, then setup a callback for the Window itself
15716
16163
  if toplevel_form.TKRightClickMenu is None:
15717
16164
  toplevel_form.TKRightClickMenu = top_menu
@@ -15995,7 +16442,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
15995
16442
  if element.ClickSubmits:
15996
16443
  tktext_label.bind('<Button-1>', element._TextClickedHandler)
15997
16444
  if element.Tooltip is not None:
15998
- 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)
15999
16446
  _add_right_click_menu_and_grab(element)
16000
16447
  if element.Grab:
16001
16448
  element._grab_anywhere_on()
@@ -16067,7 +16514,6 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16067
16514
  element.TKButton = tkbutton # not used yet but save the TK button in case
16068
16515
  if elementpad[0] == 0 or elementpad[1] == 0:
16069
16516
  tkbutton.config(highlightthickness=0)
16070
-
16071
16517
  ## -------------- TK Button With Image -------------- ##
16072
16518
  if element.ImageFilename: # if button has an image on it
16073
16519
  tkbutton.config(highlightthickness=0)
@@ -16108,11 +16554,17 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16108
16554
  'Buton element key: {}'.format(element.Key),
16109
16555
  "Parent Window's Title: {}".format(toplevel_form.Title))
16110
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
+
16111
16562
  if width != 0:
16112
16563
  wraplen = width * _char_width_in_pixels(font)
16113
16564
  tkbutton.configure(wraplength=wraplen) # set wrap to width of widget
16114
16565
  expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
16115
16566
 
16567
+
16116
16568
  tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill)
16117
16569
  if element.visible is False:
16118
16570
  element._pack_forget_save_settings()
@@ -16135,8 +16587,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16135
16587
  tkbutton.config(activeforeground=element.MouseOverColors[0])
16136
16588
 
16137
16589
  if element.Tooltip is not None:
16138
- element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip,
16139
- 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)
16140
16591
  try:
16141
16592
  if element.HighlightColors[1] != COLOR_SYSTEM_DEFAULT:
16142
16593
  tkbutton.config(highlightbackground=element.HighlightColors[1])
@@ -16261,6 +16712,11 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16261
16712
  # tkbutton.configure(image=photo, compound=tk.CENTER, width=width, height=height)
16262
16713
  tkbutton.image = photo
16263
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
+
16264
16720
  element.TKButton = tkbutton # not used yet but save the TK button in case
16265
16721
  expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
16266
16722
  tkbutton.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill)
@@ -16281,8 +16737,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16281
16737
  _add_right_click_menu_and_grab(element)
16282
16738
 
16283
16739
  if element.Tooltip is not None:
16284
- element.TooltipObject = ToolTip(element.TKButton, text=element.Tooltip,
16285
- 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)
16286
16741
  # ------------------------- BUTTONMENU placement element ------------------------- #
16287
16742
  elif element_type == ELEM_TYPE_BUTTONMENU:
16288
16743
  element = element # type: ButtonMenu
@@ -16377,7 +16832,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16377
16832
  if element.Disabled == True:
16378
16833
  element.TKButton['state'] = 'disabled'
16379
16834
  if element.Tooltip is not None:
16380
- 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)
16381
16836
 
16382
16837
  # ------------------------- INPUT placement element ------------------------- #
16383
16838
  elif element_type == ELEM_TYPE_INPUT_TEXT:
@@ -16393,9 +16848,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16393
16848
  justification = DEFAULT_TEXT_JUSTIFICATION
16394
16849
  justify = tk.LEFT if justification.startswith('l') else tk.CENTER if justification.startswith('c') else tk.RIGHT
16395
16850
  # anchor = tk.NW if justification == 'left' else tk.N if justification == 'center' else tk.NE
16396
- element.TKEntry = element.Widget = tk.Entry(tk_row_frame, width=element_size[0],
16397
- textvariable=element.TKStringVar, bd=bd,
16398
- 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)
16399
16852
  if element.ChangeSubmits:
16400
16853
  element.TKEntry.bind('<Key>', element._KeyboardHandler)
16401
16854
  element.TKEntry.bind('<Return>', element._ReturnKeyHandler)
@@ -16433,9 +16886,16 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16433
16886
  element.TKEntry['state'] = 'readonly'
16434
16887
 
16435
16888
  if element.Tooltip is not None:
16436
- 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)
16437
16890
  _add_right_click_menu_and_grab(element)
16438
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
+
16439
16899
  # row_should_expand = True
16440
16900
 
16441
16901
  # ------------------------- COMBO placement element ------------------------- #
@@ -16534,7 +16994,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16534
16994
  if element.Disabled is True: # note overrides readonly if disabled
16535
16995
  element.TKCombo['state'] = 'disabled'
16536
16996
  if element.Tooltip is not None:
16537
- 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)
16538
16998
  _add_right_click_menu_and_grab(element)
16539
16999
 
16540
17000
  # ------------------------- OPTIONMENU placement Element (Like ComboBox but different) element ------------------------- #
@@ -16568,8 +17028,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16568
17028
  if element.Disabled == True:
16569
17029
  element.TKOptionMenu['state'] = 'disabled'
16570
17030
  if element.Tooltip is not None:
16571
- element.TooltipObject = ToolTip(element.TKOptionMenu, text=element.Tooltip,
16572
- 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)
16573
17032
  # ------------------------- LISTBOX placement element ------------------------- #
16574
17033
  elif element_type == ELEM_TYPE_INPUT_LISTBOX:
16575
17034
  element = element # type: Listbox
@@ -16644,8 +17103,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16644
17103
  if element.Disabled is True:
16645
17104
  element.TKListbox['state'] = 'disabled'
16646
17105
  if element.Tooltip is not None:
16647
- element.TooltipObject = ToolTip(element.TKListbox, text=element.Tooltip,
16648
- 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)
16649
17107
  _add_right_click_menu_and_grab(element)
16650
17108
  # ------------------------- MULTILINE placement element ------------------------- #
16651
17109
  elif element_type == ELEM_TYPE_INPUT_MULTILINE:
@@ -16731,7 +17189,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16731
17189
  if element.Disabled is True:
16732
17190
  element.TKText['state'] = 'disabled'
16733
17191
  if element.Tooltip is not None:
16734
- 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)
16735
17193
 
16736
17194
  if element.reroute_cprint:
16737
17195
  cprint_set_output_destination(toplevel_form, element.Key)
@@ -16779,8 +17237,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16779
17237
  element._pack_forget_save_settings()
16780
17238
  # element.TKCheckbutton.pack_forget()
16781
17239
  if element.Tooltip is not None:
16782
- element.TooltipObject = ToolTip(element.TKCheckbutton, text=element.Tooltip,
16783
- 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)
16784
17241
  _add_right_click_menu_and_grab(element)
16785
17242
 
16786
17243
  # ------------------------- PROGRESS placement element ------------------------- #
@@ -16861,7 +17318,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16861
17318
  element._pack_forget_save_settings()
16862
17319
  # element.TKRadio.pack_forget()
16863
17320
  if element.Tooltip is not None:
16864
- 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)
16865
17322
  _add_right_click_menu_and_grab(element)
16866
17323
 
16867
17324
  # ------------------------- SPIN placement element ------------------------- #
@@ -16898,7 +17355,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16898
17355
  if element.Disabled is True: # note overrides readonly if disabled
16899
17356
  element.TKSpinBox['state'] = 'disabled'
16900
17357
  if element.Tooltip is not None:
16901
- 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)
16902
17359
  if element.BindReturnKey:
16903
17360
  element.TKSpinBox.bind('<Return>', element._SpinboxSelectHandler)
16904
17361
  _add_right_click_menu_and_grab(element)
@@ -16906,10 +17363,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16906
17363
  elif element_type == ELEM_TYPE_IMAGE:
16907
17364
  element = element # type: Image
16908
17365
  try:
16909
- if element.Filename is not None:
16910
- photo = tk.PhotoImage(file=element.Filename)
16911
- elif element.Data is not None:
16912
- 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)
16913
17370
  else:
16914
17371
  photo = None
16915
17372
 
@@ -16943,12 +17400,18 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16943
17400
  expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
16944
17401
  element.tktext_label.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], expand=expand, fill=fill)
16945
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
+
16946
17411
  if element.visible is False:
16947
17412
  element._pack_forget_save_settings()
16948
17413
  # element.tktext_label.pack_forget()
16949
- if element.Tooltip is not None:
16950
- element.TooltipObject = ToolTip(element.tktext_label, text=element.Tooltip,
16951
- timeout=DEFAULT_TOOLTIP_TIME)
17414
+
16952
17415
  if element.EnableEvents and element.tktext_label is not None:
16953
17416
  element.tktext_label.bind('<ButtonPress-1>', element._ClickHandler)
16954
17417
 
@@ -16972,8 +17435,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16972
17435
  element._pack_forget_save_settings()
16973
17436
  # element._TKCanvas.pack_forget()
16974
17437
  if element.Tooltip is not None:
16975
- element.TooltipObject = ToolTip(element._TKCanvas, text=element.Tooltip,
16976
- 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)
16977
17439
  _add_right_click_menu_and_grab(element)
16978
17440
 
16979
17441
  # ------------------------- Graph placement element ------------------------- #
@@ -16998,8 +17460,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
16998
17460
  element._pack_forget_save_settings()
16999
17461
  # element._TKCanvas2.pack_forget()
17000
17462
  if element.Tooltip is not None:
17001
- element.TooltipObject = ToolTip(element._TKCanvas2, text=element.Tooltip,
17002
- 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)
17003
17464
  if element.ChangeSubmits:
17004
17465
  element._TKCanvas2.bind('<ButtonRelease-1>', element.ButtonReleaseCallBack)
17005
17466
  element._TKCanvas2.bind('<ButtonPress-1>', element.ButtonPressCallBack)
@@ -17098,7 +17559,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17098
17559
  if element.BorderWidthNoRelief: # if a non-zero no-relief border width, force borderwidth to zero
17099
17560
  labeled_frame.configure(borderwidth=0)
17100
17561
  if element.Tooltip is not None:
17101
- 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)
17102
17563
  _add_right_click_menu_and_grab(element)
17103
17564
  # row_should_expand=True
17104
17565
  # ------------------------- Tab placement element ------------------------- #
@@ -17114,10 +17575,10 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17114
17575
  state = 'hidden'
17115
17576
  # this code will add an image to the tab. Use it when adding the image on a tab enhancement
17116
17577
  try:
17117
- if element.Filename is not None:
17118
- photo = tk.PhotoImage(file=element.Filename)
17119
- elif element.Data is not None:
17120
- 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)
17121
17582
  else:
17122
17583
  photo = None
17123
17584
 
@@ -17140,15 +17601,18 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17140
17601
  else:
17141
17602
  width, height = element_size
17142
17603
  element.tktext_label = tk.Label(tk_row_frame, image=photo, width=width, height=height, bd=0)
17604
+ element.tktext_label.image = photo
17143
17605
  else:
17144
17606
  element.tktext_label = tk.Label(tk_row_frame, bd=0)
17145
17607
  if photo is not None:
17146
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)
17147
17611
 
17148
17612
  # element.photo_image = tk.PhotoImage(data=DEFAULT_BASE64_ICON)
17149
17613
  # form.TKNotebook.add(element.TKFrame, text=element.Title, compound=tk.LEFT, state=state,image = element.photo_image)
17150
17614
 
17151
- form.TKNotebook.add(element.TKFrame, text=element.Title, state=state)
17615
+ # form.TKNotebook.add(element.TKFrame, text=element.Title, state=state)
17152
17616
  # July 28 2022 removing the expansion and pack as a test
17153
17617
  # expand, fill, row_should_expand, row_fill_direction = _add_expansion(element, row_should_expand, row_fill_direction)
17154
17618
  # form.TKNotebook.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=fill, expand=expand)
@@ -17162,8 +17626,19 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17162
17626
 
17163
17627
  # if element.BorderWidth is not None:
17164
17628
  # element.TKFrame.configure(borderwidth=element.BorderWidth)
17165
- if element.Tooltip is not None:
17166
- 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
+
17167
17642
  _add_right_click_menu_and_grab(element)
17168
17643
  # row_should_expand = True
17169
17644
  # ------------------------- TabGroup placement element ------------------------- #
@@ -17216,7 +17691,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17216
17691
  if element.ChangeSubmits:
17217
17692
  element.TKNotebook.bind('<<NotebookTabChanged>>', element._TabGroupSelectHandler)
17218
17693
  if element.Tooltip is not None:
17219
- 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)
17220
17695
  if element.Size != (None, None):
17221
17696
  element.TKNotebook.configure(width=element.Size[0], height=element.Size[1])
17222
17697
  _add_right_click_menu_and_grab(element)
@@ -17264,7 +17739,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17264
17739
  if element.Disabled == True:
17265
17740
  element.TKScale['state'] = 'disabled'
17266
17741
  if element.Tooltip is not None:
17267
- 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)
17268
17743
  _add_right_click_menu_and_grab(element)
17269
17744
 
17270
17745
  # ------------------------- TABLE placement element ------------------------- #
@@ -17447,8 +17922,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17447
17922
  element._pack_forget_save_settings(alternate_widget=element.element_frame) # seems like it should be the frame if following other elements conventions
17448
17923
  # element.TKTreeview.pack_forget()
17449
17924
  if element.Tooltip is not None:
17450
- element.TooltipObject = ToolTip(element.TKTreeview, text=element.Tooltip,
17451
- 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)
17452
17926
  _add_right_click_menu_and_grab(element)
17453
17927
 
17454
17928
  if tclversion_detailed == '8.6.9' and ENABLE_TREEVIEW_869_PATCH:
@@ -17605,8 +18079,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17605
18079
  # element.TKTreeview.pack_forget()
17606
18080
  treeview.bind("<<TreeviewSelect>>", element._treeview_selected)
17607
18081
  if element.Tooltip is not None: # tooltip
17608
- element.TooltipObject = ToolTip(element.TKTreeview, text=element.Tooltip,
17609
- 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)
17610
18083
  _add_right_click_menu_and_grab(element)
17611
18084
 
17612
18085
  if tclversion_detailed == '8.6.9' and ENABLE_TREEVIEW_869_PATCH:
@@ -17618,23 +18091,42 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17618
18091
  # ------------------------- Separator placement element ------------------------- #
17619
18092
  elif element_type == ELEM_TYPE_SEPARATOR:
17620
18093
  element = element # type: VerticalSeparator
17621
- # style_name = str(element.Key) + "Line.TSeparator"
17622
- style_name = _make_ttk_style_name(".Line.TSeparator", element, primary_style=True)
17623
- 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')
17624
18103
 
17625
- _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)
17626
18105
 
17627
- if element.color not in (None, COLOR_SYSTEM_DEFAULT):
17628
- style.configure(style_name, background=element.color)
17629
- 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()
17630
18113
 
17631
- 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)
17632
18115
 
17633
- if element.Orientation.startswith('h'):
17634
- separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.X, expand=True)
17635
- else:
17636
- separator.pack(side=tk.LEFT, padx=elementpad[0], pady=elementpad[1], fill=tk.Y, expand=False)
17637
- 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
17638
18130
  # ------------------------- SizeGrip placement element ------------------------- #
17639
18131
  elif element_type == ELEM_TYPE_SIZEGRIP:
17640
18132
  element = element # type: Sizegrip
@@ -17712,7 +18204,7 @@ def PackFormIntoFrame(form, containing_frame, toplevel_form):
17712
18204
  if element.ClickSubmits:
17713
18205
  tktext_label.bind('<Button-1>', element._TextClickedHandler)
17714
18206
  if element.Tooltip is not None:
17715
- 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)
17716
18208
  _add_right_click_menu_and_grab(element)
17717
18209
 
17718
18210
  # ............................DONE WITH ROW pack the row of widgets ..........................#
@@ -18074,7 +18566,7 @@ class _QuickMeter(object):
18074
18566
  :param button_color: button color (foreground, background)
18075
18567
  :type button_color: (str, str) | str
18076
18568
  :param size: (w,h) w=characters-wide, h=rows-high (Default value = DEFAULT_PROGRESS_BAR_SIZE)
18077
- :type size: (int, int)
18569
+ :type size: (int, int) | (None, None)
18078
18570
  :param border_width: width of border around element
18079
18571
  :type border_width: (int)
18080
18572
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
@@ -18198,7 +18690,7 @@ def one_line_progress_meter(title, current_value, max_value, *args, key='OK for
18198
18690
  :param button_color: button color (foreground, background)
18199
18691
  :type button_color: (str, str) | str
18200
18692
  :param size: (w,h) w=characters-wide, h=rows-high (Default value = DEFAULT_PROGRESS_BAR_SIZE)
18201
- :type size: (int, int)
18693
+ :type size: (int, int) | (None, None)
18202
18694
  :param border_width: width of border around element
18203
18695
  :type border_width: (int)
18204
18696
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
@@ -18270,16 +18762,17 @@ def get_complimentary_hex(color):
18270
18762
  class _DebugWin():
18271
18763
  debug_window = None
18272
18764
 
18273
- def __init__(self, size=(None, None), location=(None, None), relative_location=(None, None), font=None, no_titlebar=False, no_button=False,
18274
- 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):
18275
18766
  """
18276
18767
 
18277
18768
  :param size: (w,h) w=characters-wide, h=rows-high
18278
- :type size: (int, int)
18769
+ :type size: (int, int) | (None, None)
18279
18770
  :param location: Location of upper left corner of the window
18280
- :type location: (int, int)
18771
+ :type location: (int, int) | (None, None)
18281
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.
18282
- :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)
18283
18776
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
18284
18777
  :type font: (str or (str, int[, str]) or None)
18285
18778
  :param no_titlebar: If True no titlebar will be shown
@@ -18288,8 +18781,6 @@ class _DebugWin():
18288
18781
  :type no_button: (bool)
18289
18782
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
18290
18783
  :type grab_anywhere: (bool)
18291
- :param location: Location of upper left corner of the window
18292
- :type location: (int, int)
18293
18784
  :param do_not_reroute_stdout: bool value
18294
18785
  :type do_not_reroute_stdout: (bool)
18295
18786
  :param echo_stdout: If True stdout is sent to both the console and the debug window
@@ -18297,13 +18788,14 @@ class _DebugWin():
18297
18788
  :param resizable: if True, makes the window resizble
18298
18789
  :type resizable: (bool)
18299
18790
  :param blocking: if True, makes the window block instead of returning immediately
18300
- :type blocking: (bool)
18791
+ :type blocking: bool | None
18301
18792
  """
18302
18793
 
18303
18794
  # Show a form that's a running counter
18304
18795
  self.size = size
18305
18796
  self.location = location
18306
18797
  self.relative_location = relative_location
18798
+ self.location_anchor = location_anchor
18307
18799
  self.font = font
18308
18800
  self.no_titlebar = no_titlebar
18309
18801
  self.no_button = no_button
@@ -18331,14 +18823,12 @@ class _DebugWin():
18331
18823
  self.layout[-1] += [Sizegrip()]
18332
18824
 
18333
18825
  self.window = Window('Debug Window', self.layout, no_titlebar=no_titlebar, auto_size_text=True, location=location, relative_location=relative_location,
18334
- 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)
18335
18827
  return
18336
18828
 
18337
18829
  def reopen_window(self):
18338
18830
  if self.window is None or (self.window is not None and self.window.is_closed()):
18339
- self.__init__(size=self.size, location=self.location, relative_location=self.relative_location, font=self.font, no_titlebar=self.no_titlebar,
18340
- no_button=self.no_button, grab_anywhere=self.grab_anywhere, keep_on_top=self.keep_on_top,
18341
- 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)
18342
18832
 
18343
18833
  def Print(self, *args, end=None, sep=None, text_color=None, background_color=None, erase_all=False, font=None, blocking=None):
18344
18834
  global SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
@@ -18428,7 +18918,7 @@ class _DebugWin():
18428
18918
  self.window = None
18429
18919
 
18430
18920
 
18431
- 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,
18432
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,
18433
18923
  erase_all=False, resizable=True, blocking=None, wait=None):
18434
18924
  """
@@ -18444,15 +18934,17 @@ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, Non
18444
18934
  :param *args: stuff to output
18445
18935
  :type *args: (Any)
18446
18936
  :param size: (w,h) w=characters-wide, h=rows-high
18447
- :type size: (int, int)
18937
+ :type size: (int, int) | (None, None)
18448
18938
  :param end: end character
18449
18939
  :type end: (str)
18450
18940
  :param sep: separator character
18451
18941
  :type sep: (str)
18452
18942
  :param location: Location of upper left corner of the window
18453
- :type location: (int, int)
18943
+ :type location: (int, int) | (None, None)
18454
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.
18455
- :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)
18456
18948
  :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
18457
18949
  :type font: (str or (str, int[, str]) or None)
18458
18950
  :param no_titlebar: If True no titlebar will be shown
@@ -18467,8 +18959,6 @@ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, Non
18467
18959
  :type text_color: (str)
18468
18960
  :param keep_on_top: If True the window will remain above all current windows
18469
18961
  :type keep_on_top: (bool)
18470
- :param location: Location of upper left corner of the window
18471
- :type location: (int, int)
18472
18962
  :param do_not_reroute_stdout: do not reroute stdout and stderr. If False, both stdout and stderr will reroute to here
18473
18963
  :type do_not_reroute_stdout: (bool)
18474
18964
  :param echo_stdout: If True stdout is sent to both the console and the debug window
@@ -18489,14 +18979,10 @@ def easy_print(*args, size=(None, None), end=None, sep=None, location=(None, Non
18489
18979
  :rtype:
18490
18980
  """
18491
18981
 
18492
- blocking = blocking or wait
18493
18982
  if _DebugWin.debug_window is None:
18494
- _DebugWin.debug_window = _DebugWin(size=size, location=location, relative_location=relative_location, font=font, no_titlebar=no_titlebar,
18495
- no_button=no_button, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
18496
- 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)
18497
18984
  txt_color, bg_color = _parse_colors_parm(c or colors)
18498
- _DebugWin.debug_window.Print(*args, end=end, sep=sep, text_color=text_color or txt_color, background_color=background_color or bg_color,
18499
- 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)
18500
18986
 
18501
18987
 
18502
18988
  def easy_print_close():
@@ -19940,11 +20426,11 @@ def theme_previewer(columns=12, scrollable=False, scroll_area_size=(None, None),
19940
20426
  :param scrollable: If True then scrollbars will be added
19941
20427
  :type scrollable: bool
19942
20428
  :param scroll_area_size: Size of the scrollable area (The Column Element used to make scrollable)
19943
- :type scroll_area_size: (int, int)
20429
+ :type scroll_area_size: (int, int) | (None, None)
19944
20430
  :param search_string: If specified then only themes containing this string will be shown
19945
20431
  :type search_string: str
19946
20432
  :param location: Location on the screen to place the window. Defaults to the center like all windows
19947
- :type location: (int, int)
20433
+ :type location: (int, int) | (None, None)
19948
20434
  """
19949
20435
 
19950
20436
  current_theme = theme()
@@ -20264,7 +20750,7 @@ def dict_to_string(dict_var, sort_keys=True, compact=False, indent=10, width=Non
20264
20750
  :param indent: Number of spaces to indent (passed to pprint directly)
20265
20751
  :type indent: (int)
20266
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
20267
- :type width: (int)
20753
+ :type width: int | None
20268
20754
  :return: Formatted output of the dictionary's values
20269
20755
  :rtype: (str)
20270
20756
  """
@@ -20336,7 +20822,7 @@ def clipboard_get():
20336
20822
 
20337
20823
  def popup(*args, title=None, button_color=None, background_color=None, text_color=None, button_type=POPUP_BUTTONS_OK, auto_close=False,
20338
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,
20339
- 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):
20340
20826
  """
20341
20827
  Popup - Display a popup Window with as many parms as you wish to include. This is the GUI equivalent of the
20342
20828
  "print" statement. It's also great for "pausing" your program's flow until the user can read some error messages.
@@ -20376,9 +20862,11 @@ def popup(*args, title=None, button_color=None, background_color=None, text_colo
20376
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
20377
20863
  :type grab_anywhere: (bool)
20378
20864
  :param location: Location on screen to display the top left corner of window. Defaults to window centered on screen
20379
- :type location: (int, int)
20865
+ :type location: (int, int) | (None, None)
20380
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.
20381
- :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)
20382
20870
  :param keep_on_top: If True the window will remain above all current windows
20383
20871
  :type keep_on_top: (bool)
20384
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.
@@ -20477,7 +20965,7 @@ def popup(*args, title=None, button_color=None, background_color=None, text_colo
20477
20965
 
20478
20966
  window = Window(_title, layout, auto_size_text=True, background_color=background_color, button_color=button_color,
20479
20967
  auto_close=auto_close, auto_close_duration=auto_close_duration, icon=icon, font=font,
20480
- 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,
20481
20969
  return_keyboard_events=any_key_closes,
20482
20970
  modal=modal)
20483
20971
 
@@ -20509,7 +20997,7 @@ def MsgBox(*args):
20509
20997
  # ======================== Scrolled Text Box =====#
20510
20998
  # ===================================================#
20511
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,
20512
- 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,
20513
21001
  keep_on_top=None, font=None, image=None, icon=None, modal=True, no_sizegrip=False):
20514
21002
  """
20515
21003
  Show a scrolled Popup window containing the user's text that was supplied. Use with as many items to print as you
@@ -20532,11 +21020,13 @@ def popup_scrolled(*args, title=None, button_color=None, background_color=None,
20532
21020
  :param auto_close_duration: Older versions only accept int. Time in seconds until window will close
20533
21021
  :type auto_close_duration: int | float
20534
21022
  :param size: (w,h) w=characters-wide, h=rows-high
20535
- :type size: (int, int)
21023
+ :type size: (int, int) | (None, None)
20536
21024
  :param location: Location on the screen to place the upper left corner of the window
20537
- :type location: (int, int)
21025
+ :type location: (int, int) | (None, None)
20538
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.
20539
- :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)
20540
21030
  :param non_blocking: if True the call will immediately return rather than waiting on user input
20541
21031
  :type non_blocking: (bool)
20542
21032
  :param background_color: color of background
@@ -20616,7 +21106,7 @@ def popup_scrolled(*args, title=None, button_color=None, background_color=None,
20616
21106
  layout[-1] += [Sizegrip()]
20617
21107
 
20618
21108
  window = Window(title or args[0], layout, auto_size_text=True, button_color=button_color, auto_close=auto_close,
20619
- 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,
20620
21110
  no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top, modal=modal, icon=icon)
20621
21111
  if non_blocking:
20622
21112
  button, values = window.read(timeout=0)
@@ -20639,7 +21129,7 @@ def popup_scrolled(*args, title=None, button_color=None, background_color=None,
20639
21129
  # --------------------------- popup_no_buttons ---------------------------
20640
21130
  def popup_no_buttons(*args, title=None, background_color=None, text_color=None, auto_close=False,
20641
21131
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
20642
- 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):
20643
21133
  """Show a Popup but without any buttons
20644
21134
 
20645
21135
  :param *args: Variable number of items to display
@@ -20667,9 +21157,11 @@ def popup_no_buttons(*args, title=None, background_color=None, text_color=None,
20667
21157
  :param grab_anywhere: If True, than can grab anywhere to move the window (Default = False)
20668
21158
  :type grab_anywhere: (bool)
20669
21159
  :param location: Location of upper left corner of the window
20670
- :type location: (int, int)
21160
+ :type location: (int, int) | (None, None)
20671
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.
20672
- :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)
20673
21165
  :param image: Image to include at the top of the popup window
20674
21166
  :type image: (str) or (bytes)
20675
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
@@ -20680,14 +21172,14 @@ def popup_no_buttons(*args, title=None, background_color=None, text_color=None,
20680
21172
  button_type=POPUP_BUTTONS_NO_BUTTONS,
20681
21173
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20682
21174
  line_width=line_width,
20683
- 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)
20684
21176
 
20685
21177
 
20686
21178
  # --------------------------- popup_non_blocking ---------------------------
20687
21179
  def popup_non_blocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None,
20688
21180
  text_color=None, auto_close=False, auto_close_duration=None, non_blocking=True, icon=None,
20689
21181
  line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None,
20690
- 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):
20691
21183
  """
20692
21184
  Show Popup window and immediately return (does not block)
20693
21185
 
@@ -20720,9 +21212,11 @@ def popup_non_blocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_c
20720
21212
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
20721
21213
  :type grab_anywhere: (bool)
20722
21214
  :param location: Location of upper left corner of the window
20723
- :type location: (int, int)
21215
+ :type location: (int, int) | (None, None)
20724
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.
20725
- :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)
20726
21220
  :param image: Image to include at the top of the popup window
20727
21221
  :type image: (str) or (bytes)
20728
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
@@ -20735,13 +21229,13 @@ def popup_non_blocking(*args, title=None, button_type=POPUP_BUTTONS_OK, button_c
20735
21229
  button_type=button_type,
20736
21230
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20737
21231
  line_width=line_width,
20738
- 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)
20739
21233
 
20740
21234
 
20741
21235
  # --------------------------- popup_quick - a NonBlocking, Self-closing Popup ---------------------------
20742
21236
  def popup_quick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None,
20743
21237
  text_color=None, auto_close=True, auto_close_duration=2, non_blocking=True, icon=None, line_width=None,
20744
- 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):
20745
21239
  """
20746
21240
  Show Popup box that doesn't block and closes itself
20747
21241
 
@@ -20776,9 +21270,11 @@ def popup_quick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=No
20776
21270
  :param keep_on_top: If True the window will remain above all current windows
20777
21271
  :type keep_on_top: (bool)
20778
21272
  :param location: Location of upper left corner of the window
20779
- :type location: (int, int)
21273
+ :type location: (int, int) | (None, None)
20780
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.
20781
- :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)
20782
21278
  :param image: Image to include at the top of the popup window
20783
21279
  :type image: (str) or (bytes)
20784
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
@@ -20791,13 +21287,13 @@ def popup_quick(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=No
20791
21287
  button_type=button_type,
20792
21288
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20793
21289
  line_width=line_width,
20794
- 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)
20795
21291
 
20796
21292
 
20797
21293
  # --------------------------- popup_quick_message - a NonBlocking, Self-closing Popup with no titlebar and no buttons ---------------------------
20798
21294
  def popup_quick_message(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS, button_color=None, background_color=None,
20799
21295
  text_color=None, auto_close=True, auto_close_duration=2, non_blocking=True, icon=None, line_width=None,
20800
- 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):
20801
21297
  """
20802
21298
  Show Popup window with no titlebar, doesn't block, and auto closes itself.
20803
21299
 
@@ -20832,9 +21328,11 @@ def popup_quick_message(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS,
20832
21328
  :param grab_anywhere: If True: can grab anywhere to move the window (Default = False)
20833
21329
  :type grab_anywhere: (bool)
20834
21330
  :param location: Location of upper left corner of the window
20835
- :type location: (int, int)
21331
+ :type location: (int, int) | (None, None)
20836
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.
20837
- :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)
20838
21336
  :param image: Image to include at the top of the popup window
20839
21337
  :type image: (str) or (bytes)
20840
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
@@ -20846,13 +21344,13 @@ def popup_quick_message(*args, title=None, button_type=POPUP_BUTTONS_NO_BUTTONS,
20846
21344
  button_type=button_type,
20847
21345
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20848
21346
  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)
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)
20850
21348
 
20851
21349
 
20852
21350
  # --------------------------- PopupNoTitlebar ---------------------------
20853
21351
  def popup_no_titlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None,
20854
21352
  text_color=None, auto_close=False, auto_close_duration=None, non_blocking=False, icon=None,
20855
- 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):
20856
21354
  """
20857
21355
  Display a Popup without a titlebar. Enables grab anywhere so you can move it
20858
21356
 
@@ -20885,9 +21383,11 @@ def popup_no_titlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_co
20885
21383
  :param keep_on_top: If True the window will remain above all current windows
20886
21384
  :type keep_on_top: (bool)
20887
21385
  :param location: Location of upper left corner of the window
20888
- :type location: (int, int)
21386
+ :type location: (int, int) | (None, None)
20889
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.
20890
- :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)
20891
21391
  :param image: Image to include at the top of the popup window
20892
21392
  :type image: (str) or (bytes)
20893
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
@@ -20899,14 +21399,14 @@ def popup_no_titlebar(*args, title=None, button_type=POPUP_BUTTONS_OK, button_co
20899
21399
  button_type=button_type,
20900
21400
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20901
21401
  line_width=line_width,
20902
- 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)
20903
21403
 
20904
21404
 
20905
21405
  # --------------------------- PopupAutoClose ---------------------------
20906
21406
  def popup_auto_close(*args, title=None, button_type=POPUP_BUTTONS_OK, button_color=None, background_color=None, text_color=None,
20907
21407
  auto_close=True, auto_close_duration=None, non_blocking=False, icon=None,
20908
21408
  line_width=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None,
20909
- 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):
20910
21410
  """Popup that closes itself after some time period
20911
21411
 
20912
21412
  :param *args: Variable number of items to display
@@ -20940,9 +21440,11 @@ def popup_auto_close(*args, title=None, button_type=POPUP_BUTTONS_OK, button_col
20940
21440
  :param keep_on_top: If True the window will remain above all current windows
20941
21441
  :type keep_on_top: (bool)
20942
21442
  :param location: Location of upper left corner of the window
20943
- :type location: (int, int)
21443
+ :type location: (int, int) | (None, None)
20944
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.
20945
- :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)
20946
21448
  :param image: Image to include at the top of the popup window
20947
21449
  :type image: (str) or (bytes)
20948
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
@@ -20955,13 +21457,13 @@ def popup_auto_close(*args, title=None, button_type=POPUP_BUTTONS_OK, button_col
20955
21457
  button_type=button_type,
20956
21458
  auto_close=auto_close, auto_close_duration=auto_close_duration, non_blocking=non_blocking, icon=icon,
20957
21459
  line_width=line_width,
20958
- 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)
20959
21461
 
20960
21462
 
20961
21463
  # --------------------------- popup_error ---------------------------
20962
21464
  def popup_error(*args, title=None, button_color=(None, None), background_color=None, text_color=None, auto_close=False,
20963
21465
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
20964
- 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):
20965
21467
  """
20966
21468
  Popup with colored button and 'Error' as button text
20967
21469
 
@@ -20994,9 +21496,11 @@ def popup_error(*args, title=None, button_color=(None, None), background_color=N
20994
21496
  :param keep_on_top: If True the window will remain above all current windows
20995
21497
  :type keep_on_top: (bool)
20996
21498
  :param location: Location of upper left corner of the window
20997
- :type location: (int, int)
21499
+ :type location: (int, int) | (None, None)
20998
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.
20999
- :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)
21000
21504
  :param image: Image to include at the top of the popup window
21001
21505
  :type image: (str) or (bytes)
21002
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
@@ -21009,13 +21513,13 @@ def popup_error(*args, title=None, button_color=(None, None), background_color=N
21009
21513
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=tbutton_color,
21010
21514
  auto_close=auto_close,
21011
21515
  auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
21012
- 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)
21013
21517
 
21014
21518
 
21015
21519
  # --------------------------- popup_cancel ---------------------------
21016
21520
  def popup_cancel(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
21017
21521
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
21018
- 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):
21019
21523
  """
21020
21524
  Display Popup with "cancelled" button text
21021
21525
 
@@ -21048,9 +21552,11 @@ def popup_cancel(*args, title=None, button_color=None, background_color=None, te
21048
21552
  :param keep_on_top: If True the window will remain above all current windows
21049
21553
  :type keep_on_top: (bool)
21050
21554
  :param location: Location of upper left corner of the window
21051
- :type location: (int, int)
21555
+ :type location: (int, int) | (None, None)
21052
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.
21053
- :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)
21054
21560
  :param image: Image to include at the top of the popup window
21055
21561
  :type image: (str) or (bytes)
21056
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
@@ -21062,13 +21568,13 @@ def popup_cancel(*args, title=None, button_color=None, background_color=None, te
21062
21568
  text_color=text_color,
21063
21569
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color, auto_close=auto_close,
21064
21570
  auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
21065
- 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)
21066
21572
 
21067
21573
 
21068
21574
  # --------------------------- popup_ok ---------------------------
21069
21575
  def popup_ok(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
21070
21576
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
21071
- 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):
21072
21578
  """
21073
21579
  Display Popup with OK button only
21074
21580
 
@@ -21101,9 +21607,11 @@ def popup_ok(*args, title=None, button_color=None, background_color=None, text_c
21101
21607
  :param keep_on_top: If True the window will remain above all current windows
21102
21608
  :type keep_on_top: (bool)
21103
21609
  :param location: Location of upper left corner of the window
21104
- :type location: (int, int)
21610
+ :type location: (int, int) | (None, None)
21105
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.
21106
- :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)
21107
21615
  :param image: Image to include at the top of the popup window
21108
21616
  :type image: (str) or (bytes)
21109
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
@@ -21114,13 +21622,13 @@ def popup_ok(*args, title=None, button_color=None, background_color=None, text_c
21114
21622
  return popup(*args, title=title, button_type=POPUP_BUTTONS_OK, background_color=background_color, text_color=text_color,
21115
21623
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color, auto_close=auto_close,
21116
21624
  auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
21117
- 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)
21118
21626
 
21119
21627
 
21120
21628
  # --------------------------- popup_ok_cancel ---------------------------
21121
21629
  def popup_ok_cancel(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
21122
21630
  auto_close_duration=None, non_blocking=False, icon=DEFAULT_WINDOW_ICON, line_width=None, font=None,
21123
- 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):
21124
21632
  """
21125
21633
  Display popup with OK and Cancel buttons
21126
21634
 
@@ -21153,9 +21661,11 @@ def popup_ok_cancel(*args, title=None, button_color=None, background_color=None,
21153
21661
  :param keep_on_top: If True the window will remain above all current windows
21154
21662
  :type keep_on_top: (bool)
21155
21663
  :param location: Location of upper left corner of the window
21156
- :type location: (int, int)
21664
+ :type location: (int, int) | (None, None)
21157
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.
21158
- :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)
21159
21669
  :param image: Image to include at the top of the popup window
21160
21670
  :type image: (str) or (bytes)
21161
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
@@ -21167,13 +21677,13 @@ def popup_ok_cancel(*args, title=None, button_color=None, background_color=None,
21167
21677
  text_color=text_color,
21168
21678
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color,
21169
21679
  auto_close=auto_close, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar,
21170
- 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)
21171
21681
 
21172
21682
 
21173
21683
  # --------------------------- popup_yes_no ---------------------------
21174
21684
  def popup_yes_no(*args, title=None, button_color=None, background_color=None, text_color=None, auto_close=False,
21175
21685
  auto_close_duration=None, non_blocking=False, icon=None, line_width=None, font=None,
21176
- 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):
21177
21687
  """
21178
21688
  Display Popup with Yes and No buttons
21179
21689
 
@@ -21206,9 +21716,11 @@ def popup_yes_no(*args, title=None, button_color=None, background_color=None, te
21206
21716
  :param keep_on_top: If True the window will remain above all current windows
21207
21717
  :type keep_on_top: (bool)
21208
21718
  :param location: Location of upper left corner of the window
21209
- :type location: (int, int)
21719
+ :type location: (int, int) | (None, None)
21210
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.
21211
- :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)
21212
21724
  :param image: Image to include at the top of the popup window
21213
21725
  :type image: (str) or (bytes)
21214
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
@@ -21220,7 +21732,7 @@ def popup_yes_no(*args, title=None, button_color=None, background_color=None, te
21220
21732
  text_color=text_color,
21221
21733
  non_blocking=non_blocking, icon=icon, line_width=line_width, button_color=button_color,
21222
21734
  auto_close=auto_close, auto_close_duration=auto_close_duration, font=font, no_titlebar=no_titlebar,
21223
- 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)
21224
21736
 
21225
21737
 
21226
21738
  ##############################################################################
@@ -21232,7 +21744,7 @@ def popup_yes_no(*args, title=None, button_color=None, background_color=None, te
21232
21744
 
21233
21745
  def popup_get_folder(message, title=None, default_path='', no_window=False, size=(None, None), button_color=None,
21234
21746
  background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
21235
- 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,
21236
21748
  history_setting_filename=None):
21237
21749
  """
21238
21750
  Display popup with text entry field and browse button so that a folder can be chosen.
@@ -21246,7 +21758,7 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
21246
21758
  :param no_window: if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown
21247
21759
  :type no_window: (bool)
21248
21760
  :param size: (width, height) of the InputText Element
21249
- :type size: (int, int)
21761
+ :type size: (int, int) | (None, None)
21250
21762
  :param button_color: button color (foreground, background)
21251
21763
  :type button_color: (str, str) | str
21252
21764
  :param background_color: color of background
@@ -21264,9 +21776,11 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
21264
21776
  :param keep_on_top: If True the window will remain above all current windows
21265
21777
  :type keep_on_top: (bool)
21266
21778
  :param location: Location of upper left corner of the window
21267
- :type location: (int, int)
21779
+ :type location: (int, int) | (None, None)
21268
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.
21269
- :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)
21270
21784
  :param initial_folder: location in filesystem to begin browsing
21271
21785
  :type initial_folder: (str)
21272
21786
  :param image: Image to include at the top of the popup window
@@ -21341,7 +21855,7 @@ def popup_get_folder(message, title=None, default_path='', no_window=False, size
21341
21855
 
21342
21856
  window = Window(title=title or message, layout=layout, icon=icon, auto_size_text=True, button_color=button_color,
21343
21857
  font=font, background_color=background_color, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere, keep_on_top=keep_on_top,
21344
- location=location, relative_location=relative_location, modal=modal)
21858
+ location=location, relative_location=relative_location, location_anchor=location_anchor, modal=modal)
21345
21859
 
21346
21860
  while True:
21347
21861
  event, values = window.read()
@@ -21375,7 +21889,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21375
21889
  file_types=FILE_TYPES_ALL_FILES,
21376
21890
  no_window=False, size=(None, None), button_color=None, background_color=None, text_color=None,
21377
21891
  icon=None, font=None, no_titlebar=False, grab_anywhere=False, keep_on_top=None,
21378
- 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,
21379
21893
  history_setting_filename=None):
21380
21894
  """
21381
21895
  Display popup window with text entry field and browse button so that a file can be chosen by user.
@@ -21397,7 +21911,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21397
21911
  :param no_window: if True, no PySimpleGUI window will be shown. Instead just the tkinter dialog is shown
21398
21912
  :type no_window: (bool)
21399
21913
  :param size: (width, height) of the InputText Element or Combo element if using history feature
21400
- :type size: (int, int)
21914
+ :type size: (int, int) | (None, None)
21401
21915
  :param button_color: Color of the button (text, background)
21402
21916
  :type button_color: (str, str) | str
21403
21917
  :param background_color: background color of the entire window
@@ -21415,9 +21929,11 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21415
21929
  :param keep_on_top: If True the window will remain above all current windows
21416
21930
  :type keep_on_top: (bool)
21417
21931
  :param location: Location of upper left corner of the window
21418
- :type location: (int, int)
21932
+ :type location: (int, int) | (None, None)
21419
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.
21420
- :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)
21421
21937
  :param initial_folder: location in filesystem to begin browsing
21422
21938
  :type initial_folder: (str)
21423
21939
  :param image: Image to include at the top of the popup window
@@ -21577,7 +22093,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21577
22093
  layout += [[Button('Ok', size=(6, 1), bind_return_key=True), Button('Cancel', size=(6, 1))]]
21578
22094
 
21579
22095
  window = Window(title=title or message, layout=layout, icon=icon, auto_size_text=True, button_color=button_color,
21580
- 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)
21581
22097
 
21582
22098
  if running_linux() and show_hidden is True:
21583
22099
  window.TKroot.tk.eval('catch {tk_getOpenFile -badoption}') # dirty hack to force autoloading of Tk's file dialog code
@@ -21614,7 +22130,7 @@ def popup_get_file(message, title=None, default_path='', default_extension='', s
21614
22130
 
21615
22131
  def popup_get_text(message, title=None, default_text='', password_char='', size=(None, None), button_color=None,
21616
22132
  background_color=None, text_color=None, icon=None, font=None, no_titlebar=False,
21617
- 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):
21618
22134
  """
21619
22135
  Display Popup with text entry field. Returns the text entered or None if closed / cancelled
21620
22136
 
@@ -21627,7 +22143,7 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21627
22143
  :param password_char: character to be shown instead of actually typed characters. WARNING - if history=True then can't hide passwords
21628
22144
  :type password_char: (str)
21629
22145
  :param size: (width, height) of the input. If not specied a single line Input element used. If height >1 a Mulitline is shown
21630
- :type size: (int, int)
22146
+ :type size: (int, int) | (None, None)
21631
22147
  :param button_color: Color of the button (text, background)
21632
22148
  :type button_color: (str, str) | str
21633
22149
  :param background_color: background color of the entire window
@@ -21645,9 +22161,11 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21645
22161
  :param keep_on_top: If True the window will remain above all current windows
21646
22162
  :type keep_on_top: (bool)
21647
22163
  :param location: (x,y) Location on screen to display the upper left corner of window
21648
- :type location: (int, int)
22164
+ :type location: (int, int) | (None, None)
21649
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.
21650
- :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)
21651
22169
  :param image: Image to include at the top of the popup window
21652
22170
  :type image: (str) or (bytes)
21653
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
@@ -21697,7 +22215,7 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21697
22215
  layout += [[Button('Ok', size=(6, 1), bind_return_key=True), Button('Cancel', size=(6, 1))]]
21698
22216
 
21699
22217
  window = Window(title=title or message, layout=layout, icon=icon, auto_size_text=True, button_color=button_color, no_titlebar=no_titlebar,
21700
- 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)
21701
22219
  window.force_focus()
21702
22220
  window['-INPUT-'].set_focus()
21703
22221
 
@@ -21729,7 +22247,7 @@ def popup_get_text(message, title=None, default_text='', password_char='', size=
21729
22247
 
21730
22248
 
21731
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,
21732
- 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):
21733
22251
  """
21734
22252
  Display a calendar window, get the user's choice, return as a tuple (mon, day, year)
21735
22253
 
@@ -21744,9 +22262,11 @@ def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sun
21744
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
21745
22263
  :type icon: (str | bytes)
21746
22264
  :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
21747
- :type location: (int, int)
22265
+ :type location: (int, int) | (None, None)
21748
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.
21749
- :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)
21750
22270
  :param title: Title that will be shown on the window
21751
22271
  :type title: (str)
21752
22272
  :param close_when_chosen: If True, the window will close and function return when a day is clicked
@@ -21844,7 +22364,7 @@ def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sun
21844
22364
  layout += [[Button('Ok', border_width=0, font='TkFixedFont 8'), Button('Cancel', border_width=0, font='TkFixedFont 8')]]
21845
22365
 
21846
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,
21847
- 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)
21848
22368
 
21849
22369
  update_days(window, cur_month, cur_year, begin_at_sunday_plus)
21850
22370
 
@@ -21900,7 +22420,7 @@ def popup_get_date(start_mon=None, start_day=None, start_year=None, begin_at_sun
21900
22420
  # --------------------------- PopupAnimated ---------------------------
21901
22421
 
21902
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,
21903
- 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):
21904
22424
  """
21905
22425
  Show animation one frame at a time. This function has its own internal clocking meaning you can call it at any frequency
21906
22426
  and the rate the frames of video is shown remains constant. Maybe your frames update every 30 ms but your
@@ -21924,9 +22444,11 @@ def popup_animated(image_source, message=None, background_color=None, text_color
21924
22444
  :param keep_on_top: If True then Window will remain on top of all other windows currently shownn
21925
22445
  :type keep_on_top: (bool)
21926
22446
  :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
21927
- :type location: (int, int)
22447
+ :type location: (int, int) | (None, None)
21928
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.
21929
- :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)
21930
22452
  :param alpha_channel: Window transparency 0 = invisible 1 = completely visible. Values between are see through
21931
22453
  :type alpha_channel: (float)
21932
22454
  :param time_between_frames: Amount of time in milliseconds between each frame
@@ -21960,7 +22482,7 @@ def popup_animated(image_source, message=None, background_color=None, text_color
21960
22482
  window = Window(title, layout, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
21961
22483
  keep_on_top=keep_on_top, background_color=background_color, location=location,
21962
22484
  alpha_channel=alpha_channel, element_padding=(0, 0), margins=(0, 0),
21963
- 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)
21964
22486
  Window._animated_popup_dict[image_source] = window
21965
22487
  else:
21966
22488
  window = Window._animated_popup_dict[image_source]
@@ -21998,7 +22520,7 @@ def popup_notify(*args, title='', icon=SYSTEM_TRAY_MESSAGE_ICON_INFORMATION, dis
21998
22520
  :param alpha: Alpha channel. 0 - invisible 1 - fully visible
21999
22521
  :type alpha: (float)
22000
22522
  :param location: Location on the screen to display the window
22001
- :type location: (int, int)
22523
+ :type location: (int, int) | (None, None)
22002
22524
  :return: reason for returning
22003
22525
  :rtype: (int)
22004
22526
  """
@@ -22231,7 +22753,7 @@ def shell_with_animation(command, args=None, image_source=DEFAULT_BASE64_LOADING
22231
22753
  :param keep_on_top: If True then Window will remain on top of all other windows currently shownn
22232
22754
  :type keep_on_top: (bool)
22233
22755
  :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
22234
- :type location: (int, int)
22756
+ :type location: (int, int) | (None, None)
22235
22757
  :param alpha_channel: Window transparency 0 = invisible 1 = completely visible. Values between are see through
22236
22758
  :type alpha_channel: (float)
22237
22759
  :param time_between_frames: Amount of time in milliseconds between each frame
@@ -22651,7 +23173,9 @@ class UserSettings:
22651
23173
  os.makedirs(self.path)
22652
23174
  with open(self.full_filename, 'w') as f:
22653
23175
  if not self.use_config_file:
22654
- 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)
22655
23179
  else:
22656
23180
  self.config.write(f)
22657
23181
  except Exception as e:
@@ -22728,7 +23252,16 @@ class UserSettings:
22728
23252
  if os.path.exists(self.full_filename):
22729
23253
  with open(self.full_filename, 'r') as f:
22730
23254
  if not self.use_config_file: # if using json
22731
- 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
22732
23265
  else: # if using a config file
22733
23266
  self.config.read_file(f)
22734
23267
  # Make a dictionary of SectionDict classses. Keys are the config.sections().
@@ -23294,7 +23827,7 @@ def execute_editor(file_to_edit, line_number=None):
23294
23827
  sp = execute_command_subprocess(editor_program, file_to_edit)
23295
23828
  else:
23296
23829
  command = _create_full_editor_command(file_to_edit, line_number, format_string)
23297
- # print('final command line = ', command)
23830
+ # print(f'final command line = {editor_program} {command}')
23298
23831
  sp = execute_command_subprocess(editor_program, command)
23299
23832
  else:
23300
23833
  print('No editor has been configured in the global settings')
@@ -23443,18 +23976,17 @@ def execute_restart(your_filename, parms=''):
23443
23976
  Restarts your program. The currently running process is exited and a new one is started.
23444
23977
  NOTE - this function calls exit and thus will not return
23445
23978
 
23446
- :param your_filename: Set this parm to __file__
23979
+ :param your_filename: Normally set this parm to sys.argv[0]
23447
23980
  :type your_filename: str
23448
23981
  :param parms: Parameters to pass to your program when it's restarted
23449
23982
  :type parms: str
23450
23983
 
23451
23984
  """
23452
-
23453
23985
  try:
23454
23986
  execute_py_file(your_filename, parms, pipe_output=False, wait=False) # restart this program
23455
23987
  exit() # Exit instead of returning
23456
23988
  except Exception as e:
23457
- print(f'ERROR restarting your program: {your_filename}')
23989
+ print(f'ERROR restarting your program: {your_filename}', e)
23458
23990
  exit()
23459
23991
 
23460
23992
 
@@ -24176,7 +24708,7 @@ def show_debugger_window(location=(None, None), *args):
24176
24708
  """
24177
24709
  Shows the large main debugger window
24178
24710
  :param location: Locations (x,y) on the screen to place upper left corner of the window
24179
- :type location: (int, int)
24711
+ :type location: (int, int) | (None, None)
24180
24712
  :return: None
24181
24713
  :rtype: None
24182
24714
  """
@@ -24202,7 +24734,7 @@ def show_debugger_popout_window(location=(None, None), *args):
24202
24734
  Shows the smaller "popout" window. Default location is the upper right corner of your screen
24203
24735
 
24204
24736
  :param location: Locations (x,y) on the screen to place upper left corner of the window
24205
- :type location: (int, int)
24737
+ :type location: (int, int) | (None, None)
24206
24738
  :return: None
24207
24739
  :rtype: None
24208
24740
  """
@@ -24931,6 +25463,9 @@ def upgrade_PySimpleGUI_gui(no_gui=False):
24931
25463
  break
24932
25464
  elif event == 'Yes':
24933
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])
24934
25469
  break
24935
25470
  elif event == '-REL NOTES-':
24936
25471
  if release_notes:
@@ -25041,7 +25576,7 @@ def _global_settings_get_ttk_scrollbar_info():
25041
25576
  """
25042
25577
  global ttk_part_mapping_dict, DEFAULT_TTK_THEME
25043
25578
  for ttk_part in TTK_SCROLLBAR_PART_LIST:
25044
- 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])
25045
25580
  ttk_part_mapping_dict[ttk_part] = value
25046
25581
 
25047
25582
  DEFAULT_TTK_THEME = pysimplegui_user_settings.get('-ttk theme-', DEFAULT_TTK_THEME)
@@ -25058,7 +25593,7 @@ def main_global_get_screen_snapshot_symcode():
25058
25593
 
25059
25594
  screenshot_keysym = ''
25060
25595
  for i in range(4):
25061
- keysym = settings.get(json.dumps(('-snapshot keysym-', i)), '')
25596
+ keysym = settings.get(('-snapshot keysym-', i), '')
25062
25597
  if keysym:
25063
25598
  screenshot_keysym += "<{}>".format(keysym)
25064
25599
 
@@ -25663,7 +26198,6 @@ def main():
25663
26198
  upgrade_PySimpleGUI_gui()
25664
26199
 
25665
26200
 
25666
-
25667
26201
  i += 1
25668
26202
  # _refresh_debugger()
25669
26203
  print('event = ', event)
@@ -25848,7 +26382,7 @@ def main_global_pysimplegui_settings():
25848
26382
  # ------------------------- Snapshots Tab -------------------------
25849
26383
 
25850
26384
  snapshots_tab = Tab('Window Snapshots',
25851
- [[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)],
25852
26386
  [T('Manually Entered Bind String:'), Input(settings.get('-snapshot keysym manual-', ''),k='-SNAPSHOT KEYSYM MANUAL-')],
25853
26387
  [T('Folder to store screenshots:'), Push(), In(settings.get('-screenshots folder-', ''), k='-SCREENSHOTS FOLDER-'), FolderBrowse()],
25854
26388
  [T('Screenshots Filename or Prefix:'), Push(), In(settings.get('-screenshots filename-', ''), k='-SCREENSHOTS FILENAME-'), FileBrowse()],
@@ -25929,7 +26463,7 @@ def main_global_pysimplegui_settings():
25929
26463
  pysimplegui_user_settings.set('-snapshot keysym manual-', values['-SNAPSHOT KEYSYM MANUAL-'])
25930
26464
  screenshot_keysym = ''
25931
26465
  for i in range(4):
25932
- 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)])
25933
26467
  if values[('-SNAPSHOT KEYSYM-', i)]:
25934
26468
  screenshot_keysym += "<{}>".format(values[('-SNAPSHOT KEYSYM-', i)])
25935
26469
  if screenshot_keysym_manual:
@@ -25944,7 +26478,7 @@ def main_global_pysimplegui_settings():
25944
26478
  for key, value in values.items():
25945
26479
  if isinstance(key, tuple):
25946
26480
  if key[0] == '-TTK SCROLL-':
25947
- pysimplegui_user_settings.set(json.dumps(('-ttk scroll-', key[1])), value)
26481
+ pysimplegui_user_settings.set(('-ttk scroll-', key[1]), value)
25948
26482
 
25949
26483
  theme(new_theme)
25950
26484
 
@@ -26020,21 +26554,47 @@ def _convert_window_to_tk(window):
26020
26554
  master.geometry("%sx%s" % (window._Size[0], window._Size[1]))
26021
26555
  screen_width = master.winfo_screenwidth() # get window info to move to middle of screen
26022
26556
  screen_height = master.winfo_screenheight()
26557
+
26558
+ location_anchor = window.location_anchor
26023
26559
  if window.Location is not None:
26024
26560
  if window.Location != (None, None):
26025
26561
  x, y = window.Location
26026
26562
  elif DEFAULT_WINDOW_LOCATION != (None, None):
26027
26563
  x, y = DEFAULT_WINDOW_LOCATION
26028
- else:
26029
- master.update_idletasks() # don't forget to do updates or values are bad
26030
- win_width = master.winfo_width()
26031
- win_height = master.winfo_height()
26032
- x = screen_width / 2 - win_width / 2
26033
- y = screen_height / 2 - win_height / 2
26034
- if y + win_height > screen_height:
26035
- 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):
26036
26592
  if x + win_width > screen_width:
26037
26593
  x = screen_width - win_width
26594
+ if y + win_height > screen_height:
26595
+ y = screen_height - win_height
26596
+
26597
+
26038
26598
 
26039
26599
  if window.RelativeLoction != (None, None):
26040
26600
  x += window.RelativeLoction[0]
@@ -26057,6 +26617,9 @@ def _convert_window_to_tk(window):
26057
26617
  window.TKroot.x = x
26058
26618
  window.TKroot.y = y
26059
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()
26060
26623
  _no_titlebar_setup(window)
26061
26624
 
26062
26625
  return
@@ -26138,6 +26701,7 @@ def main_command_line():
26138
26701
  print(get_versions())
26139
26702
  elif 'upgrade' in sys.argv:
26140
26703
  upgrade_PySimpleGUI_gui()
26704
+ execute_restart(sys.argv[1:])
26141
26705
  elif 'help' in sys.argv:
26142
26706
  print('PySimpleGUI command line options\n')
26143
26707
  print('python -m PySmpleGUI upgrade', '\n Open GUI upgrade utility (same as psgupgrade)\n')