wxformBuilder

wxpython新手向教程

∥☆過路亽.° 提交于 2020-10-22 11:22:52
wxpython教程 手写wxpython会有各种问题,可以去 下载 wxformbuilder布局管理器 然后去百度一下这个布局管理器的教程,这里太多了不多赘述。 两种创建窗口方式:class MyFrame(wx.Frame)和class MyPanel(wx.Panel)来继承wx.Frame和wx.Panel,但是用wxformbuilder来创建布局和窗口会自动帮忙写好。 继承wx.Frame的结尾是 app=wx.App() frm=MyFrame() frm.Show() app.MainLoop() Show中的参数为True/False,False则不可见窗口 继承wx.Panel的结尾是 app = wx.App() frame = wx.Frame(None) panel = MyPanel(frame) frame.Show() app.MainLoop() MainLoop为每个继承类都要填写,否则无法运行 基本的控件TextCtrl,Button,StaticText TextCtrl 基本的属性Clear()(清空TextCtrl中的内容),AppendText()(在末尾添加文本) 排列布局在wxformbuilder中都有举几个列子(wx.TE_MULTILNE为可以进行多行输入,wx.TE_LEFT为左对齐,可以用 |

20183215 实验三《Python程序设计》实验报告

╄→гoц情女王★ 提交于 2020-08-16 14:24:04
20183215 2019-2020-2 《Python程序设计》实验三报告 课程:《Python程序设计》 班级: 1832 姓名: 董振龙 学号: 20183215 实验教师:王志强 实验日期:2020年5月16日 必修/选修:公选课 1.实验内容 1.创建服务端和客户端,选择一个通信端口,用Python语言编程实现通信演示程序; 2.要求包含文件的基本操作,例如打开和读写操作。 3.要求发送方从文件读取内容,加密后并传输;接收方收到密文并解密,保存在文件中。 4.程序代码托管到码云。 2. 实验过程及结果 实验开始之前,我设想了一下实验结束后的效果,总觉得光秃秃的控制台缺乏美感(尽管是pycharm),于是,我打算加入GUI图形界面,既然追求美感,就贯彻到底咯。 首先,我打开了一个软件: wxFormBuilder (这里我参考了一个 大佬的博客 ),打开后的界面是这样的: 我们先选择Forms点击Frame,然后再建立几个boxsizer,加入一些必备控件textctrl、button,如图,其中,设置bsizer5的proportion为9,使其看上去更加和谐 最后进行一些细节上的设置,例如按钮名称以及事件绑定。最终效果如图: 其中三个按钮分别绑定事件: 保存之后可以导出对应的 .py文件 ,基本重复上述操作,可以得到客户端的图形界面和对应的 .py文件

Python: variable only works when print statement is present

血红的双手。 提交于 2020-06-29 08:21:18
问题 I have an extremely strange problem that has stumped me for about the past day. import wx, gui, threading, time, pyodbc from OrderNumEntry import entryID, plyID, stationID from main import strPlyDB from Op1Login import eID1 global eID1 class MainFrame1(gui.MainFrame1Op): def __init__(self, parent): gui.MainFrame1Op.__init__(self, parent) self.m_textCtrl3.SetValue(eID1) # print eID1 def checkClick1(self, event): if threading.activeCount() < 2: t1 = threading.Thread(target = self.checkAdvance1)

Python: variable only works when print statement is present

孤街浪徒 提交于 2020-06-29 08:20:27
问题 I have an extremely strange problem that has stumped me for about the past day. import wx, gui, threading, time, pyodbc from OrderNumEntry import entryID, plyID, stationID from main import strPlyDB from Op1Login import eID1 global eID1 class MainFrame1(gui.MainFrame1Op): def __init__(self, parent): gui.MainFrame1Op.__init__(self, parent) self.m_textCtrl3.SetValue(eID1) # print eID1 def checkClick1(self, event): if threading.activeCount() < 2: t1 = threading.Thread(target = self.checkAdvance1)

Python GUI开发环境的搭建(wxPython)

别等时光非礼了梦想. 提交于 2020-04-28 02:58:00
最近对Python的开发又来了兴趣,对于Python的开发一直停留在一个表面层的认识。 Python的入手简单,语法让人爱不释手,在网络通信方面自带有成熟的类库,还有第三方开发的开源包。 在GUI的开发上,Python自身带有TKinter库,还有第三方的库 (比如wxPython, Qt)等等, 今天就来简单介绍下wxPython开发的环境搭建。 wxPython是一个Python包装wxWidgets(这是用 C++ 编写),一个流行的跨平台GUI工具包。由Robin Dunn以及Harri Pasanen开发,wxPython是作为一个Python扩展模块。就像wxWidgets,wxPython也是一个免费的软件。可以从官方网站下载它。 在wxPython API主要模块包括一个核心模块。它由 wxObject 类,这是基础 API 的所有类。控制模块包含了所有 GUI 应用程序开发中使用的部件,例如,wx.Button,wx.StaticText(类似于一个标签),wx.TextCtrl(可编辑的文本控制)等。 wxPython 的API有GDI(图形设备接口)模块。这是一组用于在部件中的绘图类。 如字体,颜色,画笔等类就是其中的一部分。所有的容器窗口类是由 Windows 模块定义。 wxPython 官方网站也主持 Phoenix 工程计划 – 为Python3.*

How do I add a label to wxWidgets wxBitmapButton?

拈花ヽ惹草 提交于 2019-12-31 01:54:10
问题 How do I create a button using wxWidgets that has both a label(text) and an image or icon. If I select wxBitmapButton there is a field called "label". But whenever I write anything in that field it doesn't update code in the wxFormBuilder. I have also tried wxButton->SetLabel() but no luck. Any help or suggestions would be appreciated. 回答1: You can only do this in wxWidgets 2.9.1 or greater and can use either a wxBitmapButton or wxButton. To quote from the documentation: Since version 2.9.1

wxPython/ReportLab: How to create and open a .pdf file on button clicked

不羁岁月 提交于 2019-12-24 12:43:50
问题 Good day all, For about 3days I have been trying hardest to get my way around this! I have a perfectly working wxFrame as well as a perfectly working ReportLab pdf script. See the code files below respectively (Note: data1.py is the GUI while data2.py is the running pdf script). My problems are:- 1) I want the pdf script to run only after I press the “Save To PDF” button 2) The value of the name field (as stored in a variable “NameString”) should be added to the generated pdf file. At the

How to write wxPython textCtrl focus event

 ̄綄美尐妖づ 提交于 2019-12-24 03:10:12
问题 I'm trying to fire a line of code when the user clicks on a textCtrl. The end goal is to highlight the contents of the box when it is clicked on. I am aware that this is possible with wx.EVT_SET_FOCUS, but it's either buggy or I'm implementing it wrong. Here's my code: self.m_textCtrl1 = wx.TextCtrl(self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(100,-1), wx.TE_LEFT) self.m_textCtrl1.SetMaxLength(8) self.m_textCtrl1.SetMinSize(wx.Size(100,-1)) self.m_textCtrl1.SetMaxSize

avoid windows resizing with wxFormBuilder

╄→尐↘猪︶ㄣ 提交于 2019-12-23 04:22:11
问题 Working with wxFormBuilder under windows 7, Is there any way to set my main wxFrame to a fixed size avoiding resizing? Thanks 回答1: I don't know how to do it specifically with wxFB, but you need to remove the wxRESIZE_BORDER style from your frame. As it is used by default, you may need to explicitly specify the flags you do want to use, e.g. wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX) . 回答2: Yes, you can avoid a wxFrame resizng in wxFormBuilder by simple specifying you frame

How do I add a label to wxWidgets wxBitmapButton?

狂风中的少年 提交于 2019-12-01 20:33:47
How do I create a button using wxWidgets that has both a label(text) and an image or icon. If I select wxBitmapButton there is a field called "label". But whenever I write anything in that field it doesn't update code in the wxFormBuilder. I have also tried wxButton->SetLabel() but no luck. Any help or suggestions would be appreciated. You can only do this in wxWidgets 2.9.1 or greater and can use either a wxBitmapButton or wxButton. To quote from the documentation : Since version 2.9.1 wxButton supports showing both text and an image (currently only when using wxMSW, wxGTK or wxOSX/Cocoa