Hi there,
Consider the small example of ToasterBox below. It opens a frame,
waits 3 seconds, and then pops up a toasterbox. When the toaster pops
up, the frame looses focus. In my real app this means that the frame
can no longer get keyboard input.
But this is exactly what i want to do: have a toaster box pop up while
the app can still get keyboard input. Is that possible at all?
When i looked in the toasterbox source code, there was one place where
a self.SetFocus() is called, that is in the ScrollUp function of the
class ToasterBoxWindow. Commenting out this function call does not
seem to
have any effect.
Calling SetFocus on the app immediately after the toasterbox appears
also does not seem to have any effect. I am confused because when i
call AcceptsFocus() on the ToasterBoxWindow it tells me that the it
can never have focus.
But how can i then prevent the app from loosing its focus when the
toasterbox appears ?
I am sure there is a simple, rational explanation for all of
this.
Any ideas welcome!
Cheers
Maarten
ps: my system runs:
Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
wxPython 2.8.10.1
Fedora 10, Gnome 2.24.3
----------------------------------Beginning of Code
#!/usr/bin/python
# demoToasterBox-FocusProblem.py
import wx
import wx.lib.agw.toasterbox as toasterbox
class ToasterBoxFocusProblem(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
self.Show(True)
timerid = wx.NewId()
self.showtime = wx.Timer(self, timerid)
self.showtime.Start(3000, True) # one shot timer
self.Bind(wx.EVT_TIMER, self.RunToaster, id=timerid)
def RunToaster(self, event):
self.toaster = toasterbox.ToasterBox(self,
tbstyle=toasterbox.TB_COMPLEX)
self.toaster.SetPopupPauseTime(3000)
tbpanel = self.toaster.GetToasterBoxWindow()
panel = wx.Panel(tbpanel, -1)
sizer = wx.BoxSizer(wx.VERTICAL)
toasterButton = wx.Button(panel, wx.ID_ANY, 'Your logo here.')
sizer.Add(toasterButton, 0, wx.EXPAND)
sizer.Layout()
panel.SetSizer(sizer)
self.toaster.AddPanel(panel)
self.toaster.Play()
app = wx.App()
ToasterBoxFocusProblem(None, -1, 'ToasterBoxFocusProblem')
app.MainLoop()
----------------------------------End of Code