简体   繁体   English

使用wxpython构建独立的桌面GUI应用

[英]Building standalone desktop GUI app using wxpython

I have created a python script using Mechanize and BeautifulSoup, to login to a website and hardcoded credentials and url in the script. 我已经使用Mechanize和BeautifulSoup创建了python脚本,以登录网站并在脚本中使用硬编码的凭证和URL。 It worked fine. 工作正常。

My requirement now is to build a standalone desktop GUI app using wxpython or any other on which an user can input URL and credentials which can then call the python script. 现在,我的要求是使用wxpython或用户可以在其上输入URL和凭据的任何其他组件构建一个独立的桌面GUI应用程序,然后可以调用python脚本。

I started learning wxpython, but not exactly sure how to proceed on this. 我开始学习wxpython,但不确定如何进行此操作。

Can anyone brief me a prototype for this requirement and guide me in building GUI. 任何人都可以向我介绍此要求的原型,并指导我构建GUI。

GUI requires. GUI要求。 3 Input Textboxes 1 submit button which invokes python script 3个输入文本框1个提交按钮,可调用python脚本

Thanks 谢谢

wxPython has all the widgets you need. wxPython具有您需要的所有小部件。 I highly recommend downloading the wxPython demo package to see how they all work. 我强烈建议下载wxPython演示程序包,以查看它们如何工作。 What you will want to look at are the following elements: 您将要看的是以下元素:

  • wx.TextCtrl wx.TextCtrl
  • wx.Button wx.Button
  • wx.BoxSizer (optional, but recommended) wx.BoxSizer(可选,但推荐)

The BoxSizer will allow you to resize your application and have the widgets adjust their size accordingly. BoxSizer将允许您调整应用程序的大小,并使小部件相应地调整其大小。 There are many tutorials available that demonstrate these concepts as well as a friendly wxPython Google Group and IRC channel. 有许多可用的教程来演示这些概念,以及一个友好的wxPython Google Group和IRC频道。

After entering the text in your text controls, you will want to have bound your button widget to an event handler that will call Mechanize or BeautifulSoup or whatever. 在文本控件中输入文本后,您将需要将按钮小部件绑定到事件处理程序,该事件处理程序将调用Mechanize或BeautifulSoup或其他任何方法。 You can also do some data validation in the button event before using the data if you want to. 如果需要,还可以在使用按钮之前在按钮事件中进行一些数据验证。

If your target audience isn't going to have Python installed, then you will need to look into how to create apks and exes. 如果您的目标受众不会安装Python,那么您将需要研究如何创建apk和exe。 There are many Python packages that can help with that such as: 有许多Python软件包可以帮助解决这些问题,例如:

  • py2exe py2exe
  • py2app py2app
  • PyInstaller PyInstaller
  • Briefcase 公文包
  • cx_freeze cx_freeze

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM