import wx
# -------- new: we need os module to handle path, dir stuffs-----------
import os
# ------- new: make our own id numbers --------------
ID_OPEN = 100
ID_SAVE = 101
ID_EXIT = 102
ID_ABOUT = 200
class SimpleEditor(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size = (700, 600))
# ---------------------create a text area ----------------------
self.text = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
# ---------------------create a status bar ---------------------
self.CreateStatusBar()
# ---------------------create a menu bar -----------------------
menuBar = wx.MenuBar()
# ---------------------create a menu ---------------------------
# making two new menus
menuFile = wx.Menu()
menuHelp = wx.Menu()
# ------------- Changed: use our own id instead wx.ID_ANY ------------------
#menuFile.Append(wx.ID_ANY, '&Open', 'open a file')
#menuFile.Append(wx.ID_ANY, '&Save', 'save the file')
menuFile.Append(ID_OPEN, '&Open', 'open a file')
menuFile.Append(ID_SAVE, '&Save', 'save the file')
# ----------------------------------------------------------------------
# adding a separator to separate the menu list
menuFile.AppendSeparator()
# ------------- Changed: use our own id instead wx.ID_ANY ------------------
#menuFile.Append(wx.ID_ANY, 'E&xit', 'terminate the program')
#menuHelp.Append(wx.ID_ANY, 'A&bout', 'info about this program')
menuFile.Append(ID_EXIT, 'E&xit', 'terminate the program')
menuHelp.Append(ID_ABOUT, 'A&bout', 'info about this program')
# -------------------------------------------------------------------------
# add the menu list we made to menu bar
# This will show 'File' on the menu bar
menuBar.Append(menuFile, '&File')
# This will show 'Help' on the menu bar
menuBar.Append(menuHelp, '&Help')
# Last step, set the menu bar
self.SetMenuBar(menuBar)
# ------------------------- new: 4 events handler -------------------------------
wx.EVT_MENU(self, ID_OPEN, self.OnOpen)
wx.EVT_MENU(self, ID_SAVE, self.OnSave)
wx.EVT_MENU(self, ID_EXIT, self.OnExit)
wx.EVT_MENU(self, ID_ABOUT, self.OnAbout)
# ---------------------- new: Declare 4 functions for the events--------------------------
# open file when you click File -> open
def OnOpen(self, event):
# open a file using wx.FileDialog
# wx.FileDialog(self, parent, message = FileSelectorPromptStr, defaultDir = EmptyString, defaultFile = EmptyString,
# wildcard = FileSelectorDefaultWildcardStr, style = FD_DEFAULT_STYLE, pos = DefaultPosition)
dlg = wx.FileDialog(self, message = 'Choose a file', defaultDir = '',
defaultFile = '', wildcard = '*.*', style = wx.OPEN)
# if we click 'OK' button it do something
if dlg.ShowModal() == wx.ID_OK:
# get the file name and directory
self.filename = dlg.GetFilename()
self.dirname = dlg.GetDirectory()
# add the directory path and file name
f = open(os.path.join(self.dirname, self.filename),'r')
# read the file , show on the text area
self.text.SetValue(f.read())
f.close()
dlg.Destroy()
# save file when you click File -> save
def OnSave(self, event):
# get the current value from text area
itcontains = self.text.GetValue()
# overwrite the same file with current value
f = open(os.path.join(self.dirname, self.filename), 'w')
f.write(itcontains)
f.close()
# exit program when you click File -> exit
def OnExit(self, event):
# close the frame
self.Close(True)
# about this program Help -> About
def OnAbout(self, event):
# make a message dialog
# wx.MessageDialog(self, parent, message, caption=MessageBoxCaptionStr,
# style=wxOK|wxCANCEL|wxCENTRE, pos=DefaultPosition)
dlg = wx.MessageDialog(self, message = 'A simple editor created by wxPython!\n'
'author : eookoo \n date : Apr 4, 2007', caption = 'About this program', style = wx.OK)
# show the message dialog
dlg.ShowModal()
# we destroy it when finished
dlg.Destroy()
# ----------------------------------------------------------------------------------------------
if __name__=='__main__':
app = wx.PySimpleApp()
frame = SimpleEditor(None, wx.ID_ANY, 'Simple Editor')
frame.Show()
app.MainLoop()
相关推荐
UE4_UE5 自定义简单水材质(UE材质图表大全1)
首先是材质的颜色节点、粗糙度节点、透明度节点。(1/2/3/4键+右键空白处,可创建一/二/三/四维节点)接着是两个法线波动节点的叠加。最后是折射节点,将fresnel菲涅尔节点连接到材质结果节点的折射输入端。到这里,你基本已经实现了一个波纹流动的水材质。后续我会更新加上海面浪花的水面材质,可以到我的专栏中寻找。有问题随时私信沟通,加油❤。
wxpython学习笔记之wx.Frame
当创建wx.Frame的子类时,类应该调用其父类的构造器 wx.Frame.__init__()。wx.Frame的构造器所要求的参数如下: wx.Frame(parent, id=-1, title=” ”, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE,name=”frame”) 参数说明: parent:框架的父类,对于顶层窗口(SetTopW...
CAN接受和发送失败的原因有哪些---之前调试MCP2515驱动时,数据一直发不出去,三个发送邮箱都被占满.至今未解决,读寄存器-总线错误
0.CAN总线错误分析与解决–讲的最精辟的放在最前面 我们知道CAN总线上的每个节点往总线上发送数据的同时会同时读取总线上的数据,并与自己发送的数据作对比。—CAN仲裁??? CAN总线错误分别有发送和接收错误计数,计数达到一定的累计以后就会产生CAN BUS OFF, 这说明CAN总线上出现了严重的错误。如下图CAN总线产生错误后的状态转换机制 如果出现了BUS OFF,总线上的节点需要做一些动作,例如重启CAN控制器或是重新上电,但是这些都只是一些补救措施,最根本的还是需要找到引起BUS OFF的根源
wxPython 一个很好的窗口、菜单创建例子
import wx # -------- new: we need os module to handle path, dir stuffs----------- import os # ------- new: make our own id numbers -------------- ID_OPEN = 100 ID_SAVE = 101 I
SAP CO-PA数据传送避坑指南:销售开票与FI/MM记账的日常配置实操(含KEKF/KE4I/KEI2)
本文深入解析SAP CO-PA数据传送中的常见配置问题,特别是销售开票与FI/MM记账环节的实操避坑指南。通过KEKF/KE4I/KEI2等关键配置点的详细说明,帮助用户避免数据失真和重复记录,提升获利能力分析的准确性。文章结合实战案例,揭示官方文档未提及的'数据黑洞'形成机制,为SAP顾问提供实用的排雷手册。
wxpython_GUI学习笔记(5)——wx.Frame学习
【转载博主麦兜搞IT :http://blog.sina.com.cn/s/blog_4b5039210100ez54.html】 因为笔记主要是摘自《wxpython in action》,很多名词我怕翻译不准,就直接用英文原文来代替,就像今天的top-level window object 和subwindow object ,这里暂时叫顶层窗口对象和子窗口对象。 首先看
CPD (Coherent Point Drift) 算法实现点云配准 C++版
作为和icp并列的点集配准算法cpd为什么没有icp火,等我把整个方案跑完才明白。 首先下载cpd https://github.com/gadomski/cpd 包含的fgt https://github.com/gadomski/fgt 下载到win10的解压后 运行cmake来进行编译 这个时候会提醒缺少eigen3 fgt python 这几个都安装排除后 在build文件夹下会生成vs2017的源码,右键全部生成后在 .\cpd-master\build\Debug 下会生成一个cpd.li
Python实例讲解 -- wxpython 基本的控件 (按钮)
使用按钮工作 在wxPython 中有很多不同类型的按钮。这一节,我们将讨论文本按钮、位图按钮、开关按钮(toggle buttons )和通用(generic )按钮。 如何生成一个按钮? 在第一部分(part 1)中,我们已经说明了几个按钮的例子,所以这里我们只简短的涉及它的一些基本的东西。图7.4显示了一个简单的按钮。 图7.4 ...
5.4 GTT BO的内存分配分析
本文分析了AMD GPU驱动中的GTT技术实现。GTT作为GPU页表,负责管理主机内存与GPU虚拟地址的映射,支持大容量内存访问和统一寻址。文章详细介绍了GTT的核心数据结构amdgpu_gtt_mgr、初始化流程,以及BO(Buffer Object)创建时GTT区间的分配与释放机制。GTT管理通过TTM框架实现分层设计,提供内存统计、兼容性检查等接口,并支持动态迁移、多进程隔离等高级特性。该机制为AMD GPU提供了高效灵活的内存管理基础。
YOLOv9改进策略【Neck】| GSConv+Slim Neck:混合深度可分离卷积和标准卷积的轻量化网络设计
实时检测器架构的轻量级设计GsConv。
Python 自学笔记之wxPython模块
通过Tkinter模块,可以进行简单的图像界面开发,但是我们可以发现很多人在开发的时候还会选择wxPython模块,它是一个比较成熟且特性比较丰富的模块,它和Tkinter类似,也要引入窗口、按钮、文本框等内容,但是又有它独特的用法。下图为程序与窗口的关系: 然后我们通过一个最简单的wxPython程序来对应一下相关结构,代码如下: import wx app = wx.App() win = wx.Frame(None,title = '小程序',size = (30...
【人工智能】AI 智能体驾驭工程(Harness Engineering)全解析
OpenAI将Harness定义为让Agent能完成有用工作的系统工程,Harness Engineering则是持续设计、实现、迭代这套系统的方法论;Anthropic将其概括为「让模型真正成为可靠Agent的基础设施」;Martin Fowler/Thoughtworks则将其定义为「控制Agent各层循环的规格、质量检查与工作流指导体系」。强大的AI模型是一匹爆发力极强的烈马;Prompt Engineering是「对马喊话的技巧」,Context Engineering是「给马看的地图」;
wxpython菜单的位置_wxPython中菜单、按钮学习
---恢复内容开始---wx.Window 是一个基类,许多构件从它继承。包括 wx.Frame 构件。技术上这意味着,我们可以在所有的子类中使用 wx.Window 的方法。我们这里介绍它的几种方法:* SetTitle( string title ) —— 设置窗口标题。只可用于框架和对话框。* SetToolTip( wx.ToolTip tip ) —— 为窗口添加提示。* SetSize...
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
Camera2Demo
在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作
wxpython多窗口怎么写_wxpython 学习之 --窗口分割
#coding:utf-8importwximportosclassMyApp(wx.App):def __init__(self):super(MyApp,self).__init__()classMyFrame(wx.Frame):def __init__(self,title='test',size=wx.DefaultSize):super(MyFrame,self).__init__(N...
假人有限元模型
假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用
wxpython 调用子窗口_wxPython - 复选菜单项和上下文菜单
实战wxPython系列-007复选菜单项菜单项有三种样式:常规样式(normal item)复选样式(check item)单选样式(radio item)在下面的例子中,我们将演示复选菜单项。复选菜单项由菜单中的对勾直观表示。importwximportosclassExample(wx.Frame):def__init__(self,*args,**kwargs):...
锂电池充电器电路设计 里面有电路
锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。
wxpython控件隐藏_[Python]wxPython菜单栏控件学习总结
1、总结1、大体创建过程1、创建一个 菜单栏: menuBar =wx.MenuBar()相当于这个白色地方,没有File这个菜单2、创建 菜单 : fileMenu = wx.Menu()这两个不是直接“用的”,叫菜单。既用来分类其他 菜单项 的文件夹样3、创建 菜单项 : newItem = wx.MenuItem()例如上图的 New Copy Cut Paste Radio_One 等等...
wxpython菜单的创建
0 环境准备 wxPython坏境的安装(wxPython当前也支持Python3.X版本),在已经配置好的python下,在dos中:pip install wxpython即可,本程序是在win10系统环境下实现。 1 代码详解 #导包 import wx #自定义一个窗口类MyFrame class MyFrame(wx.Frame): def __init__(sel...
Python wxpython常用指令
里面的函数似乎用的都是大驼峰命名 实例化 app = wx.App() 建立并显示新窗口 frame = wx.Frame(None, title='Simple application')【此处none表示parent不存在】 frame.Show() wx.Frame has the following constructor: wx.Frame(wx.Window par...
wxpython使窗口重新显示_wxPython 窗口
创建窗口wx.Frame.__init__(parent, id, title, pos, size, style, name)parent : 父窗口,顶级窗口值:None,多文档界面的情况下,子窗口被限制为只能在父窗口中移动和缩放id : 新窗口的wxPythonID,每个框架内必须唯一,传递-1时wxPython会自动生成一个新的IDtitle : 窗口标题pos : 一个wx.Size对象...
活学活用wxPython -> 给你的wxPython程序一个稳固的基础
关于所要求的对象我们需要知道些什么? 让我们来说明一下这两个基础对象。应用程序对象管理主事件循环,主事件循环是你的wxPython程序的动力。启动主事件循环是应用程序对象的工作。没有应用程序对象,你的wxPython应用程序将不能运行。 顶级窗口通常管理最重要的数据,控制并呈现给用户。例如,在词处理程序中,主窗口是文档的显示部分,并很可能管理着该文档的一些数据。类似地,你的web
python 菜单调用_python之wxPython菜单使用详解
import wxAPP_EXIT=1 #定义一个控件IDclass Example(wx.Frame):def __init__(self, parent, id, title):super(Example,self).__init__(parent, id, title) #调用你类的初始化self.InitUI() #调用自身的函数def InitUI(self): #自...
【Python图形化】对wxPython的初步认识和使用
从0开始学习wxPython时边学边写的笔记,主要是对于wxPython的初步认识。
wxpython菜单的位置_python之wxPython菜单使用详解
本文实例讲述了python中wxPython菜单的使用方法,分享给大家供大家参考。具体如下:先来看看下面这段代码:import wxAPP_EXIT=1 #定义一个控件IDclass Example(wx.Frame):def __init__(self, parent, id, title):super(Example,self).__init__(parent, id, title) ...
wxpython中文教程入门_wxPython中文教程入门实例
wxPython中文教程入门实例wx.Window 是一个基类,许多构件从它继承。包括 wx.Frame 构件。可以在所有的子类中使用 wx.Window 的方法。wxPython的几种方法:* SetTitle( string title ) ―― 设置窗口标题。只可用于框架和对话框。* SetToolTip( wx.ToolTip tip ) ―― 为窗口添加提示。* SetSize( wx....
wxPython中文教程 简单入门加实例
wx.Window 是一个基类,许多构件从它继承。包括 wx.Frame 构件。技术上这意味着,我们可以在所有的 子类中使用 wx.Window 的方法。我们这里介绍它的几种方法: * SetTitle( string title ) —— 设置窗口标题。只可用于框架和对话框。 * SetToolTip( wx.ToolTip tip ) —— ...
1986



被折叠的 条评论
为什么被折叠?



