Py之wxPython:wxPython的简介、安装、使用方法之详细攻略

目录

wxPython的简介

wxPython的安装

wxPython的使用方法


wxPython的简介

wxPython是Phoenix项目!Phoenix是改进的下一代wxPython,“比以前更好、更强、更快”。这个新的实现主要关注于提高速度、可维护性和可扩展性。就像“经典”的WXPython一样,菲尼克斯封装了WxWistGe+C++工具包,并提供了对WxWistGeAPI API的用户界面部分的访问,使Python应用程序在Windows、MACS或UNIX系统上具有本地GUI,具有本地的外观和感觉,并且需要非常少的(如果有的话)特定于平台的代码。
           实用工具wxdocs和wxdemo将使用wxget(如果必要)下载适当的文件,解压缩它们(如果必要),并启动相应项的适当版本。(文档在默认浏览器中启动,演示用python启动)。
          wxPython是Python语言的跨平台GUI工具箱。使用wxPython,软件开发人员可以为他们的Python应用程序创建真正的本地用户界面,这些应用程序在Windows、Mac和Linux或其他类unix系统上很少或没有修改的情况下运行。

wxPython pypi
wxPython官网

wxPython的安装

pip install wxPython

wxPython的使用方法

wx.Frame.SetBackgroundColour(self,'green')  #给窗口设置背景颜色

1、example 一

# First things, first. Import the wxPython package.
import wx# Next, create an application object.
app = wx.App()# Then a frame.
frm = wx.Frame(None, title="Hello World")# Show it.
frm.Show()# Start the event loop.
app.MainLoop()

2、example 二

#!/bin/python
"""
Hello World, but with more meat.
"""import wxclass HelloFrame(wx.Frame):"""A Frame that says Hello World"""def __init__(self, *args, **kw):# ensure the parent's __init__ is calledsuper(HelloFrame, self).__init__(*args, **kw)# create a panel in the framepnl = wx.Panel(self)# and put some text with a larger bold font on itst = wx.StaticText(pnl, label="Hello World!", pos=(25,25))font = st.GetFont()font.PointSize += 10font = font.Bold()st.SetFont(font)# create a menu barself.makeMenuBar()# and a status barself.CreateStatusBar()self.SetStatusText("Welcome to 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 = HelloFrame(None, title='Hello World 2')frm.Show()app.MainLoop()

更多案例应用

Py之wxPython:利用wxPython设计GUI界面(图片背景+简单按钮)

Py之wxPython:wxPython的简介、安装、使用方法之详细攻略相关推荐

  1. Py之matplotlib.pyplot:matplotlib.pyplot的plt.legend函数的简介、使用方法之详细攻略

    Py之matplotlib.pyplot:matplotlib.pyplot的plt.legend函数的简介.使用方法之详细攻略 目录 matplotlib.pyplot的plt.legend函数的简 ...

  2. Py之glob: glob库文件名模式匹配+返回所有匹配的文件路径列表库的简介、使用方法之详细攻略

    Py之glob: glob库文件名模式匹配+返回所有匹配的文件路径列表库的简介.使用方法之详细攻略 目录 glob库的简介 glob库的使用方法 1.单个字符通配符:用问号(?)匹配任何单个的字符.

  3. Python之 sklearn:sklearn中的RobustScaler 函数的简介及使用方法之详细攻略

    Python之 sklearn:sklearn中的RobustScaler 函数的简介及使用方法之详细攻略 目录 sklearn中的RobustScaler 函数的简介及使用方法 sklearn中的R ...

  4. sklearn之XGBModel:XGBModel之feature_importances_、plot_importance的简介、使用方法之详细攻略

    sklearn之XGBModel:XGBModel之feature_importances_.plot_importance的简介.使用方法之详细攻略 目录 feature_importances_ ...

  5. Python语言学习:Python常用自带库(imageio、pickle)简介、使用方法之详细攻略

    Python语言学习:Python常用自带库(imageio.pickle)简介.使用方法之详细攻略 目录 imageio简介及其常见使用方法 pickle简介及其常见使用方法 简介 使用方法 简介及 ...

  6. sklearn:sklearn.preprocessing.StandardScaler函数的fit_transform、transform、inverse_transform简介、使用方法之详细攻略

    sklearn:sklearn.preprocessing.StandardScaler函数的fit_transform.transform.inverse_transform简介.使用方法之详细攻略 ...

  7. Computer:互联网开放平台项目知识补充之开发-运维-网络-网关等术语(DMZ、负载均衡、F5、Nginx、容器)的简介、使用方法之详细攻略

    Computer:互联网开放平台项目知识补充之开发-运维-网络-网关等术语(DMZ.负载均衡.F5.Nginx.容器)的简介.使用方法之详细攻略 目录 DMZ(隔离区)的简介及其使用方法 1.DMZ区 ...

  8. Python编程语言学习:包导入和模块搜索路径简介、使用方法之详细攻略

    Python编程语言学习:包导入和模块搜索路径简介.使用方法之详细攻略 目录 包导入和模块搜索路径简介 1.Pyhon搜索模块路径的机制 2.自定义配置搜索路径

  9. Python之 sklearn:sklearn.preprocessing中的StandardScaler函数的简介及使用方法之详细攻略

    Python之 sklearn:sklearn.preprocessing中的StandardScaler函数的简介及使用方法之详细攻略 目录 sklearn.preprocessing中的Stand ...

  10. Python之 sklearn:sklearn中的train_test_split函数的简介及使用方法之详细攻略

    Python之 sklearn:sklearn中的train_test_split函数的简介及使用方法之详细攻略 目录 sklearn中的train_test_split函数的简介 train_tes ...

最新文章

  1. cookie、session总结
  2. 将NumPy数组转储到csv文件中
  3. Java 流(Stream)、文件(File)和IO -- Java ByteArrayOutputStream类
  4. 科技推动时代发展,浅谈IT技术如何改善数据中心运维管理
  5. 好程序员Web前端分享程序的三大结构(二)while循环
  6. 有关 Conversion to Dalvik format failed with error 1
  7. 【渝粤题库】国家开放大学2021春2238个案工作题目
  8. 95-910-335-源码-FlinkSQL-Calcite-FlinkSQL解析
  9. 计算机辅助管理与制造,计算机辅助设计与制造,对产品的设备进行管理,完成产品加工制造...
  10. 基于Python的《庆余年》评论分析
  11. videojs中文文档详解
  12. RHEL7修改root密码
  13. Android 退出登录功能
  14. OpenHarmony轻量系统开发【8】其它驱动开发示例
  15. CCProxy + Proxifier 通过另一台电脑访问网络
  16. 前阿里政委张丽俊:人,是CEO最重要的一课
  17. 日内趋势票如何把握?
  18. Android中动画类别及优缺点,安卓培训学习:注册广播及其优缺点
  19. threejs模型点击选中
  20. Android线性布局和相对布局的详解和区别

热门文章

  1. Lucene下载及测试
  2. Network device support
  3. 139. Word Break
  4. git checkout -b mybranch和git checkout mybranch
  5. windows 7 PowerShell 笔记
  6. Java 8系列之Lambda表达式
  7. Fabio技术手册(1):概述和快速上手
  8. 框架:HTTP请求的表单提交的几种方式
  9. 多线程:Immutable对象?如何创建Immutable对象?
  10. Android --- Android Studio 错误: 非法字符: ‘\ufeff’