Skip to content

Commit db7e196

Browse files
authored
Merge pull request PySimpleGUI#5320 from PySimpleGUI/Dev-latest
Addition of tooltip_offset parm to set_options call (major hack to ge…
2 parents 4b02326 + 07bb93d commit db7e196

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

PySimpleGUI.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python3
22

3-
version = __version__ = "4.57.0.29 Unreleased"
3+
version = __version__ = "4.57.0.31 Unreleased"
44

55
_change_log = """
66
Changelog since 4.57.0 released to PyPI on 13-Feb-2022
@@ -78,6 +78,10 @@
7878
Removed the need for tk.scrolledtext.ScrolledText by adding a vertical scrollbar to a Text widget. Getting ready for addtion of ttk scrollbars!
7979
4.57.0.29
8080
Backed out changes accidently checked in that will crash on Linux (DOH! SORRY!!!)
81+
4.57.0.30
82+
Withdraw window during creation in addition to setting alpha to 0
83+
4.57.0.31
84+
Added tooltip_offset parameter to set_options as a way to hack around the 8.6.12 problem of missing events following a tooltip
8185
"""
8286

8387
__version__ = version.split()[0] # For PEP 396 and PEP 345
@@ -16189,27 +16193,27 @@ def _convert_window_to_tk(window):
1618916193
:type window: (Window)
1619016194

1619116195
"""
16192-
root = window.TKroot
16193-
root.title(window.Title)
16196+
master = window.TKroot
16197+
master.title(window.Title)
1619416198
InitializeResults(window)
1619516199

16196-
PackFormIntoFrame(window, root, window)
16200+
PackFormIntoFrame(window, master, window)
1619716201

1619816202
window.TKroot.configure(padx=window.Margins[0], pady=window.Margins[1])
1619916203

1620016204
# ....................................... DONE creating and laying out window ..........................#
1620116205
if window._Size != (None, None):
16202-
root.geometry("%sx%s" % (window._Size[0], window._Size[1]))
16203-
screen_width = root.winfo_screenwidth() # get window info to move to middle of screen
16204-
screen_height = root.winfo_screenheight()
16206+
master.geometry("%sx%s" % (window._Size[0], window._Size[1]))
16207+
screen_width = master.winfo_screenwidth() # get window info to move to middle of screen
16208+
screen_height = master.winfo_screenheight()
1620516209
if window.Location != (None, None):
1620616210
x, y = window.Location
1620716211
elif DEFAULT_WINDOW_LOCATION != (None, None):
1620816212
x, y = DEFAULT_WINDOW_LOCATION
1620916213
else:
16210-
root.update_idletasks() # don't forget to do updates or values are bad
16211-
win_width = root.winfo_width()
16212-
win_height = root.winfo_height()
16214+
master.update_idletasks() # don't forget to do updates or values are bad
16215+
win_width = master.winfo_width()
16216+
win_height = master.winfo_height()
1621316217
x = screen_width / 2 - win_width / 2
1621416218
y = screen_height / 2 - win_height / 2
1621516219
if y + win_height > screen_height:
@@ -16222,14 +16226,15 @@ def _convert_window_to_tk(window):
1622216226
y += window.RelativeLoction[1]
1622316227

1622416228
move_string = '+%i+%i' % (int(x), int(y))
16225-
root.geometry(move_string)
16229+
master.geometry(move_string)
1622616230
window.config_last_location = (int(x), (int(y)))
1622716231
window.TKroot.x = int(x)
1622816232
window.TKroot.y = int(y)
1622916233
window.starting_window_position = (int(x), (int(y)))
16230-
root.update_idletasks() # don't forget
16231-
root.geometry(move_string)
16232-
root.update_idletasks() # don't forget
16234+
master.update_idletasks() # don't forget
16235+
master.geometry(move_string)
16236+
master.update_idletasks() # don't forget
16237+
1623316238
_no_titlebar_setup(window)
1623416239

1623516240
return
@@ -17117,8 +17122,7 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
1711717122
window_location=(None, None), error_button_color=(None, None), tooltip_time=None, tooltip_font=None, use_ttk_buttons=None, ttk_theme=None,
1711817123
suppress_error_popups=None, suppress_raise_key_errors=None, suppress_key_guessing=None,warn_button_key_duplicates=False, enable_treeview_869_patch=None,
1711917124
enable_mac_notitlebar_patch=None, use_custom_titlebar=None, titlebar_background_color=None, titlebar_text_color=None, titlebar_font=None,
17120-
titlebar_icon=None, user_settings_path=None, pysimplegui_settings_path=None, pysimplegui_settings_filename=None, keep_on_top=None, dpi_awareness=None, scaling=None,
17121-
disable_modal_windows=None):
17125+
titlebar_icon=None, user_settings_path=None, pysimplegui_settings_path=None, pysimplegui_settings_filename=None, keep_on_top=None, dpi_awareness=None, scaling=None, disable_modal_windows=None, tooltip_offset=(None, None)):
1712217126
"""
1712317127
:param icon: Can be either a filename or Base64 value. For Windows if filename, it MUST be ICO format. For Linux, must NOT be ICO. Most portable is to use a Base64 of a PNG file. This works universally across all OS's
1712417128
:type icon: bytes | str
@@ -17228,6 +17232,8 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
1722817232
:type scaling: (float)
1722917233
:param disable_modal_windows: If True then all windows, including popups, will not be modal windows
1723017234
:type disable_modal_windows: (bool)
17235+
:param tooltip_offset: Offset to use for tooltips as a tuple. These values will be added to the mouse location when the widget was entered.
17236+
:type tooltip_offset: ((None, None) | (int, int))
1723117237
:return: None
1723217238
:rtype: None
1723317239
"""
@@ -17284,6 +17290,7 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
1728417290
global DEFAULT_KEEP_ON_TOP
1728517291
global DEFAULT_SCALING
1728617292
global DEFAULT_MODAL_WINDOWS_ENABLED
17293+
global DEFAULT_TOOLTIP_OFFSET
1728717294
global _pysimplegui_user_settings
1728817295
# global _my_windows
1728917296

@@ -17462,6 +17469,8 @@ def set_options(icon=None, button_color=None, element_size=(None, None), button_
1746217469
if disable_modal_windows is not None:
1746317470
DEFAULT_MODAL_WINDOWS_ENABLED = not disable_modal_windows
1746417471

17472+
if tooltip_offset != (None, None):
17473+
DEFAULT_TOOLTIP_OFFSET = tooltip_offset
1746517474

1746617475
return True
1746717476

0 commit comments

Comments
 (0)