#!/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相关推荐

  1. Python精讲Numpy基础,大牛笔记详细解释

    https://www.toutiao.com/a6664936105076326920/ 总认为Numpy是渣渣,直到深入接触以后才知道功能这么强大.堪比Matlab啊.果然是人生苦短,我用Pyth ...

  2. 学python分析双色球_我通过使用Python分析了80多个工作拒绝而学到的东西

    学python分析双色球 by Conor Dewey 由Conor Dewey 我通过使用Python分析了80多个工作拒绝而学到的东西 (What I learned from analyzing ...

  3. 【Python】无法安装wxPython 奇葩原因

    [Python]无法安装wxPython 奇葩原因 原因 解决办法 原因 当我想要安装wxPython包来给女朋友画爱心的时候,pycharm怎么也安装不上.用cmd也没有办法安装 错误具体如下: 使 ...

  4. python精要(82)-wxpython(3)-静态文本控件与状态栏

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 22 08:35:42 202 ...

  5. 面试题之第一部分(Python基础篇) 80题

    第一部分(python基础篇)80题 为什么学习Python?==*== # 1. python应用于很多领域,比如后端,前端,爬虫,机器学习(人工智能)等方面,几乎能涵盖各个开发语言的领域,同时它相 ...

  6. python算公倍数的案例_【71页】关于python经典的80个案例操作(附源码解析)

    1.Python Hello World 实例 # -*- coding: UTF-8 -*- # Filename : helloworld.py # author by : www.runoob. ...

  7. Python基础01-Python环境搭建与HelloWorld

    目录 从今天开始学习Python Python环境搭建 安装gcc Python源码包安装 开始Python第一个代码HelloWorld! 从今天开始学习Python 为啥选择Python,可能是跟 ...

  8. 不是python中用于开发用户界面的第三方库-Python三方库:wxPython(GUI图形用户界面)...

    wxPython是一套基于Python的第三方GUI插件,可用Python制作丰富的图形化界面程序. 安装:pip install wxPython 或者 网站下载安装https://pypi.org ...

  9. python3精要(37)-wxPython(3)-安装

    1.pip pip install -U wxpython 2.源码编译安装 https://pypi.org/project/wxPython/#files wget https://files.p ...

最新文章

  1. 处理问题的方法--抽象和特例化
  2. R语言boxplot绘制箱线图
  3. 一步一步教你实现简单的自定义错误跟踪
  4. js数组与字符串的相互转换方法
  5. Python安装、配置图文详解
  6. STM32的CAN总线的接收双FIFO使用方法
  7. 操作系统使用户和计算机的接口 对吗,计算机操作系统教程--核心与设计原理习题10答案...
  8. mysql ldf文件太大_Linux_数据库清除日志文件(LDF文件过大),清除日志: 复制代码 代码如 - phpStudy...
  9. HttpStatusCode
  10. 产品经理必懂技术术语(后台类)
  11. 江苏省高邮2021年高考成绩查询,2021年江苏高考成绩排名及一分一段表
  12. Java反射异常处理之InvocationTargetException
  13. CodeforcesRound#498 (Div.3)E题Military Problem
  14. Possible missing firmware
  15. 易语言教你制作onoQQ机器人
  16. 手机app测试流程和要点
  17. 计算机网络教程网线制作,网线水晶头制作过程详解(视频+图文教程)
  18. 蓝牙运动耳机什么牌子好,分享六款好用的运动耳机
  19. leetcode总结无止境系列之链表
  20. 一加官方证实保留耳机插孔,全面屏新品命名一加5T

热门文章

  1. flask 上下文管理
  2. 做一个有梦想的咸鱼!
  3. CSS3特效之转化(transform)和过渡(transition)
  4. MIN()与MAX()函数 的注意事项
  5. Windows控制台程序“选定模式”的问题
  6. 把Eclipse项目转换成Maven项目
  7. 代码动态创建checkbox
  8. 微信公众开发api接口
  9. linux 命令提示符 时间,在LINUX的命令提示符及CMD命令提示符中显示时间
  10. 树复制替换id_程序员的进阶课-架构师之路(12)-2-3-4树