python精要(80)-wxpython(2)-helloworld
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 22 08:35:42 2021
@author: myhaspl
"""import wx
class MyHelloFrame(wx.Frame):"""框架"""def __init__(self, *args, **kw):# 调用父类构造函数super(MyHelloFrame, self).__init__(*args, **kw)# 在frame中创建Panel面板pnl = wx.Panel(self)# 使用较大的粗体字体设置静态文本控件st = wx.StaticText(pnl, label="粗体,较大字体!")font = st.GetFont()font.PointSize += 10font = font.Bold()st.SetFont(font)# 创建一个sizer管理子widget层sizer = wx.BoxSizer(wx.VERTICAL)sizer.Add(st, wx.SizerFlags().Border(wx.TOP|wx.LEFT, 25))pnl.SetSizer(sizer)# 创建菜单栏self.makeMenuBar()# 创建状态栏self.CreateStatusBar()self.SetStatusText("欢迎学习wxpython!")def makeMenuBar(self):"""A menu bar is composed of menus, which are composed of menu items.This method builds a set of menus and binds handlers to be calledwhen the menu item is selected."""# Make a file menu with Hello and Exit itemsfileMenu = wx.Menu()# The "\t..." syntax defines an accelerator key that also triggers# the same eventhelloItem = fileMenu.Append(-1, "&Hello...\tCtrl-H","Help string shown in status bar for this menu item")fileMenu.AppendSeparator()# When using a stock ID we don't need to specify the menu item's# labelexitItem = fileMenu.Append(wx.ID_EXIT)# Now a help menu for the about itemhelpMenu = wx.Menu()aboutItem = helpMenu.Append(wx.ID_ABOUT)# Make the menu bar and add the two menus to it. The '&' defines# that the next letter is the "mnemonic" for the menu item. On the# platforms that support it those letters are underlined and can be# triggered from the keyboard.menuBar = wx.MenuBar()menuBar.Append(fileMenu, "&File")menuBar.Append(helpMenu, "&Help")# Give the menu bar to the frameself.SetMenuBar(menuBar)# Finally, associate a handler function with the EVT_MENU event for# each of the menu items. That means that when that menu item is# activated then the associated handler function will be called.self.Bind(wx.EVT_MENU, self.OnHello, helloItem)self.Bind(wx.EVT_MENU, self.OnExit, exitItem)self.Bind(wx.EVT_MENU, self.OnAbout, aboutItem)def OnExit(self, event):"""Close the frame, terminating the application."""self.Close(True)def OnHello(self, event):"""Say hello to the user."""wx.MessageBox("Hello again from wxPython")def OnAbout(self, event):"""Display an About Dialog"""wx.MessageBox("This is a wxPython Hello World sample","About Hello World 2",wx.OK|wx.ICON_INFORMATION)if __name__ == '__main__':# When this module is run (not imported) then create the app, the# frame, show it, and start the event loop.app = wx.App()frm = MyHelloFrame(None, title='复杂的hello,world')frm.Show()app.MainLoop()
wx.Panel面板是放置控件的窗口
python精要(80)-wxpython(2)-helloworld相关推荐
- Python精讲Numpy基础,大牛笔记详细解释
https://www.toutiao.com/a6664936105076326920/ 总认为Numpy是渣渣,直到深入接触以后才知道功能这么强大.堪比Matlab啊.果然是人生苦短,我用Pyth ...
- 学python分析双色球_我通过使用Python分析了80多个工作拒绝而学到的东西
学python分析双色球 by Conor Dewey 由Conor Dewey 我通过使用Python分析了80多个工作拒绝而学到的东西 (What I learned from analyzing ...
- 【Python】无法安装wxPython 奇葩原因
[Python]无法安装wxPython 奇葩原因 原因 解决办法 原因 当我想要安装wxPython包来给女朋友画爱心的时候,pycharm怎么也安装不上.用cmd也没有办法安装 错误具体如下: 使 ...
- python精要(82)-wxpython(3)-静态文本控件与状态栏
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 22 08:35:42 202 ...
- 面试题之第一部分(Python基础篇) 80题
第一部分(python基础篇)80题 为什么学习Python?==*== # 1. python应用于很多领域,比如后端,前端,爬虫,机器学习(人工智能)等方面,几乎能涵盖各个开发语言的领域,同时它相 ...
- python算公倍数的案例_【71页】关于python经典的80个案例操作(附源码解析)
1.Python Hello World 实例 # -*- coding: UTF-8 -*- # Filename : helloworld.py # author by : www.runoob. ...
- Python基础01-Python环境搭建与HelloWorld
目录 从今天开始学习Python Python环境搭建 安装gcc Python源码包安装 开始Python第一个代码HelloWorld! 从今天开始学习Python 为啥选择Python,可能是跟 ...
- 不是python中用于开发用户界面的第三方库-Python三方库:wxPython(GUI图形用户界面)...
wxPython是一套基于Python的第三方GUI插件,可用Python制作丰富的图形化界面程序. 安装:pip install wxPython 或者 网站下载安装https://pypi.org ...
- python3精要(37)-wxPython(3)-安装
1.pip pip install -U wxpython 2.源码编译安装 https://pypi.org/project/wxPython/#files wget https://files.p ...
最新文章
- 处理问题的方法--抽象和特例化
- R语言boxplot绘制箱线图
- 一步一步教你实现简单的自定义错误跟踪
- js数组与字符串的相互转换方法
- Python安装、配置图文详解
- STM32的CAN总线的接收双FIFO使用方法
- 操作系统使用户和计算机的接口 对吗,计算机操作系统教程--核心与设计原理习题10答案...
- mysql ldf文件太大_Linux_数据库清除日志文件(LDF文件过大),清除日志: 复制代码 代码如 - phpStudy...
- HttpStatusCode
- 产品经理必懂技术术语(后台类)
- 江苏省高邮2021年高考成绩查询,2021年江苏高考成绩排名及一分一段表
- Java反射异常处理之InvocationTargetException
- CodeforcesRound#498 (Div.3)E题Military Problem
- Possible missing firmware
- 易语言教你制作onoQQ机器人
- 手机app测试流程和要点
- 计算机网络教程网线制作,网线水晶头制作过程详解(视频+图文教程)
- 蓝牙运动耳机什么牌子好,分享六款好用的运动耳机
- leetcode总结无止境系列之链表
- 一加官方证实保留耳机插孔,全面屏新品命名一加5T