WX 小工具学习
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version 3.10.1-0-g8feb16b3)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
###########################################################################
# from datetime import time
import datetime
import wx
import wx.xrc
import wx.adv
###########################################################################
## Class mainFrame
###########################################################################
TRAY_ICON = 'tray.ico'
class mainFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"常用功能展示", pos=wx.DefaultPosition, size=wx.Size(1053, 596),
style=wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.TAB_TRAVERSAL)
self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU))
gbSizer = wx.GridBagSizer(0, 0)
gbSizer.SetFlexibleDirection(wx.BOTH)
gbSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
self.filePath_textCtrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(200, -1), 0)
gbSizer.Add(self.filePath_textCtrl, wx.GBPosition(1, 0), wx.GBSpan(1, 1), wx.ALL, 5)
self.openApp_button = wx.Button(self, wx.ID_ANY, u"打开应用程序", wx.DefaultPosition, wx.DefaultSize, 0)
gbSizer.Add(self.openApp_button, wx.GBPosition(1, 1), wx.GBSpan(1, 1), wx.ALL, 5)
self.content_textCtrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
gbSizer.Add(self.content_textCtrl, wx.GBPosition(1, 2), wx.GBSpan(1, 1), wx.ALL, 5)
self.time_staticText = wx.StaticText(self, wx.ID_ANY, u"当前时间:", wx.DefaultPosition, wx.DefaultSize, 0)
self.time_staticText.Wrap(-1)
self.time_staticText.SetFont(
wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "宋体"))
self.time_staticText.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU))
gbSizer.Add(self.time_staticText, wx.GBPosition(1, 4), wx.GBSpan(1, 1), wx.ALL, 5)
fileSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"操作文件"), wx.VERTICAL)
self.readFile_button = wx.Button(fileSbSizer.GetStaticBox(), wx.ID_ANY, u"读取文件", wx.DefaultPosition,
wx.DefaultSize, 0)
fileSbSizer.Add(self.readFile_button, 0, wx.ALL, 5)
self.saveFile_button = wx.Button(fileSbSizer.GetStaticBox(), wx.ID_ANY, u"保存文件", wx.DefaultPosition,
wx.DefaultSize, 0)
fileSbSizer.Add(self.saveFile_button, 0, wx.ALL, 5)
gbSizer.Add(fileSbSizer, wx.GBPosition(3, 0), wx.GBSpan(1, 1), wx.EXPAND, 5)
self.field_textCtrl = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(160, 100),
wx.HSCROLL | wx.TE_MULTILINE)
self.field_textCtrl.SetFont(
wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, "宋体"))
gbSizer.Add(self.field_textCtrl, wx.GBPosition(3, 1), wx.GBSpan(1, 1), wx.ALL, 5)
windowSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"操作窗口"), wx.VERTICAL)
self.topMost_button = wx.Button(windowSbSizer.GetStaticBox(), wx.ID_ANY, u"窗口置顶", wx.DefaultPosition,
wx.DefaultSize, 0)
windowSbSizer.Add(self.topMost_button, 0, wx.ALL, 5)
self.hideWindow_button = wx.Button(windowSbSizer.GetStaticBox(), wx.ID_ANY, u"窗口隐藏", wx.DefaultPosition,
wx.DefaultSize, 0)
windowSbSizer.Add(self.hideWindow_button, 0, wx.ALL, 5)
self.windowSetting_button = wx.Button(windowSbSizer.GetStaticBox(), wx.ID_ANY, u"窗口设置", wx.DefaultPosition,
wx.DefaultSize, 0)
windowSbSizer.Add(self.windowSetting_button, 0, wx.ALL, 5)
self.windowSwitch_button = wx.Button(windowSbSizer.GetStaticBox(), wx.ID_ANY, u"窗口切换", wx.DefaultPosition,
wx.DefaultSize, 0)
windowSbSizer.Add(self.windowSwitch_button, 0, wx.ALL, 5)
self.windowBreatheOut_button = wx.Button(windowSbSizer.GetStaticBox(), wx.ID_ANY, u"F9窗口呼出", wx.DefaultPosition,
wx.DefaultSize, 0)
windowSbSizer.Add(self.windowBreatheOut_button, 0, wx.ALL, 5)
self.windowMove_button = wx.Button(windowSbSizer.GetStaticBox(), wx.ID_ANY, u"窗口移动", wx.DefaultPosition,
wx.DefaultSize, 0)
windowSbSizer.Add(self.windowMove_button, 0, wx.ALL, 5)
self.windowJitter_button = wx.Button(windowSbSizer.GetStaticBox(), wx.ID_ANY, u"窗体抖动", wx.DefaultPosition,
wx.DefaultSize, 0)
windowSbSizer.Add(self.windowJitter_button, 0, wx.ALL, 5)
gbSizer.Add(windowSbSizer, wx.GBPosition(4, 0), wx.GBSpan(1, 1), wx.EXPAND, 5)
mouseOperSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"操作鼠标"), wx.VERTICAL)
self.moveMouse_button = wx.Button(mouseOperSbSizer.GetStaticBox(), wx.ID_ANY, u"移动鼠标", wx.DefaultPosition,
wx.DefaultSize, 0)
mouseOperSbSizer.Add(self.moveMouse_button, 0, wx.ALL, 5)
self.leftClick_button = wx.Button(mouseOperSbSizer.GetStaticBox(), wx.ID_ANY, u"左键点击", wx.DefaultPosition,
wx.DefaultSize, 0)
mouseOperSbSizer.Add(self.leftClick_button, 0, wx.ALL, 5)
self.rightClick_button = wx.Button(mouseOperSbSizer.GetStaticBox(), wx.ID_ANY, u"右键点击", wx.DefaultPosition,
wx.DefaultSize, 0)
mouseOperSbSizer.Add(self.rightClick_button, 0, wx.ALL, 5)
self.doubleClick_button = wx.Button(mouseOperSbSizer.GetStaticBox(), wx.ID_ANY, u"鼠标双击", wx.DefaultPosition,
wx.DefaultSize, 0)
mouseOperSbSizer.Add(self.doubleClick_button, 0, wx.ALL, 5)
self.mouseCoordinate_button = wx.Button(mouseOperSbSizer.GetStaticBox(), wx.ID_ANY, u"鼠标坐标", wx.DefaultPosition,
wx.DefaultSize, 0)
mouseOperSbSizer.Add(self.mouseCoordinate_button, 0, wx.ALL, 5)
self.mouseDrag_button = wx.Button(mouseOperSbSizer.GetStaticBox(), wx.ID_ANY, u"鼠标拖动", wx.DefaultPosition,
wx.DefaultSize, 0)
mouseOperSbSizer.Add(self.mouseDrag_button, 0, wx.ALL, 5)
self.mouseStyle_button = wx.Button(mouseOperSbSizer.GetStaticBox(), wx.ID_ANY, u"鼠标样式", wx.DefaultPosition,
wx.DefaultSize, 0)
mouseOperSbSizer.Add(self.mouseStyle_button, 0, wx.ALL, 5)
gbSizer.Add(mouseOperSbSizer, wx.GBPosition(4, 1), wx.GBSpan(1, 1), wx.EXPAND, 5)
keybordSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"键盘操作"), wx.VERTICAL)
self.single_button = wx.Button(keybordSbSizer.GetStaticBox(), wx.ID_ANY, u"单个按键", wx.DefaultPosition,
wx.DefaultSize, 0)
keybordSbSizer.Add(self.single_button, 0, wx.ALL, 5)
self.combination_button = wx.Button(keybordSbSizer.GetStaticBox(), wx.ID_ANY, u"组合按键", wx.DefaultPosition,
wx.DefaultSize, 0)
keybordSbSizer.Add(self.combination_button, 0, wx.ALL, 5)
self.inputChar_button = wx.Button(keybordSbSizer.GetStaticBox(), wx.ID_ANY, u"输入字符", wx.DefaultPosition,
wx.DefaultSize, 0)
keybordSbSizer.Add(self.inputChar_button, 0, wx.ALL, 5)
self.lockKeyboard_button = wx.Button(keybordSbSizer.GetStaticBox(), wx.ID_ANY, u"锁定键盘", wx.DefaultPosition,
wx.DefaultSize, 0)
keybordSbSizer.Add(self.lockKeyboard_button, 0, wx.ALL, 5)
self.lockMouse_button = wx.Button(keybordSbSizer.GetStaticBox(), wx.ID_ANY, u"锁定鼠标", wx.DefaultPosition,
wx.DefaultSize, 0)
keybordSbSizer.Add(self.lockMouse_button, 0, wx.ALL, 5)
self.singleKeyDown_button = wx.Button(keybordSbSizer.GetStaticBox(), wx.ID_ANY, u"单键按下", wx.DefaultPosition,
wx.DefaultSize, 0)
keybordSbSizer.Add(self.singleKeyDown_button, 0, wx.ALL, 5)
self.singleKeyUp_button = wx.Button(keybordSbSizer.GetStaticBox(), wx.ID_ANY, u"单键弹起", wx.DefaultPosition,
wx.DefaultSize, 0)
keybordSbSizer.Add(self.singleKeyUp_button, 0, wx.ALL, 5)
gbSizer.Add(keybordSbSizer, wx.GBPosition(4, 2), wx.GBSpan(1, 1), wx.EXPAND, 5)
threadOperSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"线程操作"), wx.VERTICAL)
self.m_button45 = wx.Button(threadOperSbSizer.GetStaticBox(), wx.ID_ANY, u"开启线程", wx.DefaultPosition,
wx.DefaultSize, 0)
threadOperSbSizer.Add(self.m_button45, 0, wx.ALL, 5)
self.m_button46 = wx.Button(threadOperSbSizer.GetStaticBox(), wx.ID_ANY, u"停止线程", wx.DefaultPosition,
wx.DefaultSize, 0)
threadOperSbSizer.Add(self.m_button46, 0, wx.ALL, 5)
self.m_button47 = wx.Button(threadOperSbSizer.GetStaticBox(), wx.ID_ANY, u"任务监听", wx.DefaultPosition,
wx.DefaultSize, 0)
threadOperSbSizer.Add(self.m_button47, 0, wx.ALL, 5)
self.m_button6 = wx.Button(threadOperSbSizer.GetStaticBox(), wx.ID_ANY, u"任务调用", wx.DefaultPosition,
wx.DefaultSize, 0)
threadOperSbSizer.Add(self.m_button6, 0, wx.ALL, 5)
self.m_button48 = wx.Button(threadOperSbSizer.GetStaticBox(), wx.ID_ANY, u"任务管理", wx.DefaultPosition,
wx.DefaultSize, 0)
threadOperSbSizer.Add(self.m_button48, 0, wx.ALL, 5)
self.m_button49 = wx.Button(threadOperSbSizer.GetStaticBox(), wx.ID_ANY, u"线程同步", wx.DefaultPosition,
wx.DefaultSize, 0)
threadOperSbSizer.Add(self.m_button49, 0, wx.ALL, 5)
self.m_button50 = wx.Button(threadOperSbSizer.GetStaticBox(), wx.ID_ANY, u"线程锁定", wx.DefaultPosition,
wx.DefaultSize, 0)
threadOperSbSizer.Add(self.m_button50, 0, wx.ALL, 5)
gbSizer.Add(threadOperSbSizer, wx.GBPosition(4, 3), wx.GBSpan(1, 1), wx.EXPAND, 5)
tipsSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"消息操作"), wx.VERTICAL)
self.tips_button = wx.Button(tipsSbSizer.GetStaticBox(), wx.ID_ANY, u"通知消息", wx.DefaultPosition, wx.DefaultSize,
0)
tipsSbSizer.Add(self.tips_button, 0, wx.ALL, 5)
self.tipsStyle_button = wx.Button(tipsSbSizer.GetStaticBox(), wx.ID_ANY, u"消息样式", wx.DefaultPosition,
wx.DefaultSize, 0)
tipsSbSizer.Add(self.tipsStyle_button, 0, wx.ALL, 5)
gbSizer.Add(tipsSbSizer, wx.GBPosition(3, 2), wx.GBSpan(1, 1), wx.EXPAND, 5)
progressBarSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"操作进度条"), wx.VERTICAL)
self.startProgressBar_button = wx.Button(progressBarSbSizer.GetStaticBox(), wx.ID_ANY, u"开启进度条",
wx.DefaultPosition, wx.DefaultSize, 0)
progressBarSbSizer.Add(self.startProgressBar_button, 0, wx.ALL, 5)
self.progressBarStyle_button = wx.Button(progressBarSbSizer.GetStaticBox(), wx.ID_ANY, u"进度条样式",
wx.DefaultPosition, wx.DefaultSize, 0)
progressBarSbSizer.Add(self.progressBarStyle_button, 0, wx.ALL, 5)
gbSizer.Add(progressBarSbSizer, wx.GBPosition(3, 3), wx.GBSpan(1, 1), wx.EXPAND, 5)
icoAudioGbSizer = wx.GridBagSizer(0, 0)
icoAudioGbSizer.SetFlexibleDirection(wx.BOTH)
icoAudioGbSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
icoSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"图标操作"), wx.HORIZONTAL)
self.windowIco_button = wx.Button(icoSbSizer.GetStaticBox(), wx.ID_ANY, u"窗体图标", wx.DefaultPosition,
wx.DefaultSize, 0)
icoSbSizer.Add(self.windowIco_button, 0, wx.ALL, 5)
self.statusIco_button = wx.Button(icoSbSizer.GetStaticBox(), wx.ID_ANY, u"状态栏图标", wx.DefaultPosition,
wx.DefaultSize, 0)
icoSbSizer.Add(self.statusIco_button, 0, wx.ALL, 5)
self.taskbarIco_button = wx.Button(icoSbSizer.GetStaticBox(), wx.ID_ANY, u"任务栏图标", wx.DefaultPosition,
wx.DefaultSize, 0)
icoSbSizer.Add(self.taskbarIco_button, 0, wx.ALL, 5)
self.imageRecognition_button = wx.Button(icoSbSizer.GetStaticBox(), wx.ID_ANY, u"图片识别", wx.DefaultPosition,
wx.DefaultSize, 0)
icoSbSizer.Add(self.imageRecognition_button, 0, wx.ALL, 5)
icoAudioGbSizer.Add(icoSbSizer, wx.GBPosition(0, 4), wx.GBSpan(1, 1), wx.EXPAND, 5)
audioSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"音频操作"), wx.HORIZONTAL)
self.musicPlay_button = wx.Button(audioSbSizer.GetStaticBox(), wx.ID_ANY, u"音乐播放", wx.DefaultPosition,
wx.DefaultSize, 0)
audioSbSizer.Add(self.musicPlay_button, 0, wx.ALL, 5)
self.musicStop_button = wx.Button(audioSbSizer.GetStaticBox(), wx.ID_ANY, u"音乐暂停", wx.DefaultPosition,
wx.DefaultSize, 0)
audioSbSizer.Add(self.musicStop_button, 0, wx.ALL, 5)
self.radioSwitch_button = wx.Button(audioSbSizer.GetStaticBox(), wx.ID_ANY, u"广播切换", wx.DefaultPosition,
wx.DefaultSize, 0)
audioSbSizer.Add(self.radioSwitch_button, 0, wx.ALL, 5)
self.AudioManagement_button = wx.Button(audioSbSizer.GetStaticBox(), wx.ID_ANY, u"音频管理", wx.DefaultPosition,
wx.DefaultSize, 0)
audioSbSizer.Add(self.AudioManagement_button, 0, wx.ALL, 5)
icoAudioGbSizer.Add(audioSbSizer, wx.GBPosition(1, 4), wx.GBSpan(1, 1), wx.EXPAND, 5)
gbSizer.Add(icoAudioGbSizer, wx.GBPosition(3, 4), wx.GBSpan(1, 1), wx.EXPAND, 5)
systemOperGbSizer = wx.GridBagSizer(0, 0)
systemOperGbSizer.SetFlexibleDirection(wx.BOTH)
systemOperGbSizer.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)
systemSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"系统操作"), wx.VERTICAL)
self.systemTime_button = wx.Button(systemSbSizer.GetStaticBox(), wx.ID_ANY, u"系统时间", wx.DefaultPosition,
wx.DefaultSize, 0)
systemSbSizer.Add(self.systemTime_button, 0, wx.ALL, 5)
self.ipAddress_button = wx.Button(systemSbSizer.GetStaticBox(), wx.ID_ANY, u"本机IP地址", wx.DefaultPosition,
wx.DefaultSize, 0)
systemSbSizer.Add(self.ipAddress_button, 0, wx.ALL, 5)
self.macAddress_button = wx.Button(systemSbSizer.GetStaticBox(), wx.ID_ANY, u"MAC地址", wx.DefaultPosition,
wx.DefaultSize, 0)
systemSbSizer.Add(self.macAddress_button, 0, wx.ALL, 5)
self.ddl_interface_button = wx.Button(systemSbSizer.GetStaticBox(), wx.ID_ANY, u"DDL调用", wx.DefaultPosition,
wx.DefaultSize, 0)
systemSbSizer.Add(self.ddl_interface_button, 0, wx.ALL, 5)
self.netTest_button = wx.Button(systemSbSizer.GetStaticBox(), wx.ID_ANY, u"网络测试", wx.DefaultPosition,
wx.DefaultSize, 0)
systemSbSizer.Add(self.netTest_button, 0, wx.ALL, 5)
self.timingStart_button = wx.Button(systemSbSizer.GetStaticBox(), wx.ID_ANY, u"定时启动", wx.DefaultPosition,
wx.DefaultSize, 0)
systemSbSizer.Add(self.timingStart_button, 0, wx.ALL, 5)
self.beepTimer_button = wx.Button(systemSbSizer.GetStaticBox(), wx.ID_ANY, u"定时提醒", wx.DefaultPosition,
wx.DefaultSize, 0)
systemSbSizer.Add(self.beepTimer_button, 0, wx.ALL, 5)
systemOperGbSizer.Add(systemSbSizer, wx.GBPosition(0, 0), wx.GBSpan(1, 1), wx.EXPAND, 5)
screenSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"屏幕操作"), wx.VERTICAL)
self.screenshot_button = wx.Button(screenSbSizer.GetStaticBox(), wx.ID_ANY, u"屏幕截图", wx.DefaultPosition,
wx.DefaultSize, 0)
screenSbSizer.Add(self.screenshot_button, 0, wx.ALL, 5)
self.currentResolution_button = wx.Button(screenSbSizer.GetStaticBox(), wx.ID_ANY, u"当前分辨率", wx.DefaultPosition,
wx.DefaultSize, 0)
screenSbSizer.Add(self.currentResolution_button, 0, wx.ALL, 5)
self.coordinate_area_button = wx.Button(screenSbSizer.GetStaticBox(), wx.ID_ANY, u"坐标域色值", wx.DefaultPosition,
wx.DefaultSize, 0)
screenSbSizer.Add(self.coordinate_area_button, 0, wx.ALL, 5)
self.stopMove_button = wx.Button(screenSbSizer.GetStaticBox(), wx.ID_ANY, u"暂停移动", wx.DefaultPosition,
wx.DefaultSize, 0)
screenSbSizer.Add(self.stopMove_button, 0, wx.ALL, 5)
self.pauseMove_button = wx.Button(screenSbSizer.GetStaticBox(), wx.ID_ANY, u"恢复移动", wx.DefaultPosition,
wx.DefaultSize, 0)
screenSbSizer.Add(self.pauseMove_button, 0, wx.ALL, 5)
self.resumeMvoe_button = wx.Button(screenSbSizer.GetStaticBox(), wx.ID_ANY, u"停止移动", wx.DefaultPosition,
wx.DefaultSize, 0)
screenSbSizer.Add(self.resumeMvoe_button, 0, wx.ALL, 5)
systemOperGbSizer.Add(screenSbSizer, wx.GBPosition(0, 1), wx.GBSpan(1, 1), wx.EXPAND, 5)
problemSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"问题反馈"), wx.VERTICAL)
self.checkUpdate_button = wx.Button(problemSbSizer.GetStaticBox(), wx.ID_ANY, u"检查更新", wx.DefaultPosition,
wx.DefaultSize, 0)
problemSbSizer.Add(self.checkUpdate_button, 0, wx.ALL, 5)
self.problemFeedback_button = wx.Button(problemSbSizer.GetStaticBox(), wx.ID_ANY, u"反馈问题", wx.DefaultPosition,
wx.DefaultSize, 0)
problemSbSizer.Add(self.problemFeedback_button, 0, wx.ALL, 5)
self.uploadImage_button = wx.Button(problemSbSizer.GetStaticBox(), wx.ID_ANY, u"上传图片", wx.DefaultPosition,
wx.DefaultSize, 0)
problemSbSizer.Add(self.uploadImage_button, 0, wx.ALL, 5)
systemOperGbSizer.Add(problemSbSizer, wx.GBPosition(0, 2), wx.GBSpan(1, 1), wx.EXPAND, 5)
otherOperSbSizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, u"其他操作"), wx.VERTICAL)
self.frameInterface_button = wx.Button(otherOperSbSizer.GetStaticBox(), wx.ID_ANY, u"窗体交互", wx.DefaultPosition,
wx.DefaultSize, 0)
otherOperSbSizer.Add(self.frameInterface_button, 0, wx.ALL, 5)
self.openBaidu_button = wx.Button(otherOperSbSizer.GetStaticBox(), wx.ID_ANY, u"打开百度", wx.DefaultPosition,
wx.DefaultSize, 0)
otherOperSbSizer.Add(self.openBaidu_button, 0, wx.ALL, 5)
self.changeStyle_button = wx.Button(otherOperSbSizer.GetStaticBox(), wx.ID_ANY, u"变幻样式", wx.DefaultPosition,
wx.DefaultSize, 0)
otherOperSbSizer.Add(self.changeStyle_button, 0, wx.ALL, 5)
systemOperGbSizer.Add(otherOperSbSizer, wx.GBPosition(0, 3), wx.GBSpan(1, 1), wx.EXPAND, 5)
gbSizer.Add(systemOperGbSizer, wx.GBPosition(4, 4), wx.GBSpan(1, 1), wx.EXPAND, 5)
self.SetSizer(gbSizer)
self.Layout()
self.notice_statusBar = self.CreateStatusBar(1, wx.STB_SIZEGRIP, wx.ID_ANY)
self.Centre(wx.BOTH)
# 动态显示时间
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.show_time, self.timer)
self.timer.Start(1000)
self.windowIco_button.Bind(wx.EVT_BUTTON, self.setting_tools_ico)
# wx.Frame.__init__(self)
# MyTaskBarIcon() # 显示系统托盘图标
TaskBarIcon() # 显示系统托盘图标
# self.set_icon(TRAY_ICON)
def show_time(self, event):
# 动态显示时间
time_now_second = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.time_staticText.SetLabel(f"当前时间:{time_now_second}")
event.Skip
def setting_tools_ico(self, event):
# 设置图标
ico = wx.Icon(TRAY_ICON, wx.BITMAP_TYPE_ICO)
self.SetIcon(ico)
event.Skip
def __del__(self):
pass
class TaskBarIcon(wx.adv.TaskBarIcon):
ICON = "tray.ico" # 图标地址
ID_ABOUT = wx.NewId() # 菜单选项“关于”的ID
ID_EXIT = wx.NewId() # 菜单选项“退出”的ID
ID_SHOW_WEB = wx.NewId() # 菜单选项“显示页面”的ID
TITLE = "二维码发送程序" #鼠标移动到图标上显示的文字
def __init__(self):
wx.adv.TaskBarIcon.__init__(self)
self.SetIcon(wx.Icon(self.ICON), self.TITLE) # 设置图标和标题
self.Bind(wx.EVT_MENU, self.onAbout, id=self.ID_ABOUT) # 绑定“关于”选项的点击事件
self.Bind(wx.EVT_MENU, self.onExit, id=self.ID_EXIT) # 绑定“退出”选项的点击事件
self.Bind(wx.EVT_MENU, self.onShowWeb, id=self.ID_SHOW_WEB) # 绑定“显示页面”选项的点击事件
# “关于”选项的事件处理器
def onAbout(self, event):
wx.MessageBox('程序作者:JethroCup\n最后更新日期:2017-8-13', "关于")
# “退出”选项的事件处理器
def onExit(self, event):
wx.Exit()
# “显示页面”选项的事件处理器
def onShowWeb(self, event):
pass
# 创建菜单选项
def CreatePopupMenu(self):
menu = wx.Menu()
for mentAttr in self.getMenuAttrs():
menu.Append(mentAttr[1], mentAttr[0])
return menu
# 获取菜单的属性元组
def getMenuAttrs(self):
return [('进入程序', self.ID_SHOW_WEB),
('关于', self.ID_ABOUT),
('退出', self.ID_EXIT)]
if __name__ == '__main__':
app = wx.App(False)
mainFrame(None).Show()
app.MainLoop()