wxPython学习
来源:互联网 发布:公司网络屏蔽了视频 编辑:程序博客网 时间:2024/05/16 08:44
#-*- coding:gbk -*-'''Created on 2012-3-18@author: Administrator'''import wximport Constansimport MyUtil#-*- coding:gbk -*-'''Created on 2012-3-18@author: Administrator'''import wximport Constansimport MyUtilclass MyFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, Constans.main_window_title, size=(Constans.main_window_width, Constans.main_window_height)) panel = wx.Panel(self, -1) panel.Bind(wx.EVT_MOTION, self.onMouse) wx.StaticText(panel, -1, "Position", pos=(6, 12)) self.posCtrl = wx.TextCtrl(panel, -1, "", pos=(50, 10)) menuBar = wx.MenuBar() menul = wx.Menu() menul.Append(wx.NewId(), "&Open", "Open") menuBar.Append(menul, "&File") menul2 = wx.Menu() menul2.Append(wx.NewId(), "&Copy", "Copy") menul2.AppendSeparator() menul2.Append(wx.NewId(), "&Cut", "Cut") menuBar.Append(menul2, "&Edit") stats = wx.StatusBar(self) stats.SetStatusText(Constans.main_window_status_txt+MyUtil.getDefaultLocalDate()) self.SetStatusBar(stats) self.SetMenuBar(menuBar) def onMouse(self, event): pos = event.GetPosition() self.posCtrl.SetValue("%s,%s" % (pos.x, pos.y))if __name__ == '__main__': try: app = wx.PySimpleApp() frame = MyFrame() frame.Center() frame.Show() app.MainLoop() except Exception, e: print e Constans.py--------------------------------------------------------------------#-*- coding:gbk -*-'''Created on 2012-3-19@author: Administrator'''main_window_title="MySQL 客户端"main_window_width=700main_window_height=600main_window_status_txt="当前时间:"MyUtil.py--------------------------------------------#coding:gbk'''Created on 2012-3-19@author: Administrator'''import time_formatStr = "%Y-%m-%d %H:%M:%S"def __init__(self): passdef getLocalDate(timeArg): return time.strftime(_formatStr, timeArg)''' 获取格式化的时间'''def getDefaultLocalDate(): return time.strftime(_formatStr, time.localtime())