TipProvider
时间:2007-04-19 来源:wxPhoenix
overview = """\
Just as its name implies, tip you some tips!
"""
import wx
class Frame(wx.Frame):
def __init__(
self, parent=None, id=wx.ID_ANY, title='wx.TipProvider', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.SetIcon(wx.Icon('wxWidgets.ico', wx.BITMAP_TYPE_ICO))
# Good!
wx.CallAfter(self.CheckTips)
def CheckTips(self):
try:
tipConfig = open('tipConfig.txt').read()
# Here, eval comes!
showTip, tipIndex = eval(tipConfig)
except IOError:
showTip, tipIndex = True, 0
if showTip:
tipProvider = wx.CreateFileTipProvider('tips.txt', tipIndex)
showTip = wx.ShowTip(self, tipProvider)
tipIndex = tipProvider.GetCurrentTip()
open('tipConfig.txt', 'w').write(str((showTip, tipIndex)))
def TestFrame():
app = wx.PySimpleApp()
frame = Frame()
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
import wx
class Frame(wx.Frame):
def __init__(
self, parent=None, id=wx.ID_ANY, title='wx.TipProvider', pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE
):
wx.Frame.__init__(self, parent, id, title, pos, size, style)
self.SetIcon(wx.Icon('wxWidgets.ico', wx.BITMAP_TYPE_ICO))
# Good!
wx.CallAfter(self.CheckTips)
def CheckTips(self):
try:
tipConfig = open('tipConfig.txt').read()
# Here, eval comes!
showTip, tipIndex = eval(tipConfig)
except IOError:
showTip, tipIndex = True, 0
if showTip:
tipProvider = wx.CreateFileTipProvider('tips.txt', tipIndex)
showTip = wx.ShowTip(self, tipProvider)
tipIndex = tipProvider.GetCurrentTip()
open('tipConfig.txt', 'w').write(str((showTip, tipIndex)))
def TestFrame():
app = wx.PySimpleApp()
frame = Frame()
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == '__main__':
TestFrame()
相关阅读 更多 +