Skip to content

Commit 31584f6

Browse files
ameltedmarcelstoer
authored andcommitted
Fix Windows hovering issue with popup (#104)
1 parent f22d785 commit 31584f6

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Main.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,15 @@ def on_pick_file(event):
207207

208208
panel = wx.Panel(self)
209209

210+
# Fix popup that never goes away.
211+
def onHover(event):
212+
global hovered
213+
if(len(hovered) != 0 ):
214+
hovered[0].Dismiss()
215+
hovered = []
216+
217+
panel.Bind(wx.EVT_MOTION,onHover)
218+
210219
hbox = wx.BoxSizer(wx.HORIZONTAL)
211220

212221
fgs = wx.FlexGridSizer(7, 2, 10, 10)
@@ -287,15 +296,19 @@ def add_erase_radio_button(sizer, index, erase_before_flash, label, value):
287296
flashmode_label = wx.StaticText(panel, label="Flash mode")
288297

289298
def on_info_hover(event):
290-
from HtmlPopupTransientWindow import HtmlPopupTransientWindow
291-
win = HtmlPopupTransientWindow(self, wx.SIMPLE_BORDER, __flash_help__, "#FFB6C1", (410, 140))
299+
global hovered
300+
if(len(hovered) == 0):
301+
from HtmlPopupTransientWindow import HtmlPopupTransientWindow
302+
win = HtmlPopupTransientWindow(self, wx.SIMPLE_BORDER, __flash_help__, "#FFB6C1", (410, 140))
303+
304+
image = event.GetEventObject()
305+
image_position = image.ClientToScreen((0, 0))
306+
image_size = image.GetSize()
307+
win.Position(image_position, (0, image_size[1]))
292308

293-
image = event.GetEventObject()
294-
image_position = image.ClientToScreen((0, 0))
295-
image_size = image.GetSize()
296-
win.Position(image_position, (0, image_size[1]))
309+
win.Popup()
310+
hovered = [win]
297311

298-
win.Popup()
299312

300313
icon = wx.StaticBitmap(panel, wx.ID_ANY, images.Info.GetBitmap())
301314
icon.Bind(wx.EVT_MOTION, on_info_hover)
@@ -391,6 +404,8 @@ def log_message(self, message):
391404
# ---------------------------------------------------------------------------
392405
class MySplashScreen(wx.adv.SplashScreen):
393406
def __init__(self):
407+
global hovered
408+
hovered = []
394409
wx.adv.SplashScreen.__init__(self, images.Splash.GetBitmap(),
395410
wx.adv.SPLASH_CENTRE_ON_SCREEN | wx.adv.SPLASH_TIMEOUT, 2500, None, -1)
396411
self.Bind(wx.EVT_CLOSE, self._on_close)

0 commit comments

Comments
 (0)