アプリケーションの起動時に画像を表示する
wxPythonのデモを起動すると、画面の中央に数秒間ロゴが表示される。それと同じものを自分のコードの中でもやろうとして、demo/Main.pyからその部分を適当に取り出してきた。作成したのが、以下のOpenLogo.py。写真のように表示できた。
なんか、ShowMainの部分で引っかかるのでpassとした...。
wxSplashScreenのリファレンスで確認する必要あり。
import wx import os class MySplashScreen(wx.SplashScreen): def __init__(self): bmp = wx.Image("floatcanvas.png").ConvertToBitmap() wx.SplashScreen.__init__(self,bmp, wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT, 5000, None, -1) self.Bind(wx.EVT_CLOSE, self.OnClose) self.fc = wx.FutureCall(2000, self.ShowMain) def OnClose(self, evt): evt.Skip() self.Hide() if self.fc.IsRunning(): self.fc.Stop() self.ShowMain() def ShowMain(self): pass class MyApp(wx.PySimpleApp): def OnInit(self): self.Frm = wx.Frame(None, -1, "wxPython") menuBar = wx.MenuBar() menu1 = wx.Menu() menu1.Append(101, "&Show log", "") menu1.AppendSeparator() menu1.Append(103, "&Close", "Close this frame") menuBar.Append(menu1, "WORK") self.Frm.SetMenuBar(menuBar) self.splash = MySplashScreen() self.splash.Show() self.Frm.Show() return True app = MyApp() app.MainLoop()