简体   繁体   English

Python GUI(tkinter; pygtk + glade),py2exe

[英]Python GUI(tkinter; pygtk+glade), py2exe

I'm new with python programming and GUI. 我是python编程和GUI的新手。 I search on internet about GUI programming and see that there are a lot of ways to do this. 我在网上搜索有关GUI编程的信息,发现有很多方法可以做到这一点。 I see that easiest way for GUI in python might be tkinter(which is included in Python, and it's just GUI library not GUI builder)? 我看到python中GUI的最简单方法可能是tkinter(包含在Python中,它只是GUI库而不是GUI构建器)? I also read a lot about GLADE+PyGTK(and XML format), what is there so special(glade is GUI builder)? 我也读了很多关于GLADE + PyGTK(和XML格式)的东西,有什么特别之处(glade是GUI builder)?

Can anyone make some "personal opinion" about this choices? 任何人都可以对此选择发表一些“个人看法”吗?

I have python code, I need to make simple GUI(2 button's-open-close-read-write,and some "print" work) and then make some .exe file (is there best choice py2exe=?). 我有python代码,我需要制作简单的GUI(2按钮的-open-close-read-write,并进行一些“打印”工作),然后制作一些.exe文件(最好选择py2exe =?)。 Is there a lot of changes in code to make GUI? 做GUI的代码有很多更改吗?

Many thanks 非常感谢

I really like PyQt bindings for Qt library. 我真的很喜欢Qt库的PyQt绑定。 What is PyQt? 什么是PyQt?

Qt itself is a very nice framework - rich, powerfull, elegant (for my taste, at least). Qt本身是一个非常好的框架-丰富,强大,优雅(至少就我的口味而言)。 And PyQt does a very nice job of exposing that functionality to a scripting environment. 而且PyQt在将功能暴露给脚本环境方面做得非常好。

Plus, there is a very nice book about PyQt development - Rapid GUI Programming with Python and Qt - working through it helped me a lot. 另外,有一本关于PyQt开发的非常不错的书- 使用Python和Qt进行快速GUI编程 -通过它工作对我有很大帮助。

If your GUI is really that simple, you should go with the built-in tkinter. 如果您的GUI确实如此简单,则应使用内置的tkinter。

There's a Hello, Tkinter tutorial that you can follow, it's pretty straightforward. 您可以按照下面的方法编写Hello Hello Tkinter教程,非常简单。 Concerning the creation of executables, py2exe should work without problems in most cases (though I haven't tried with tkinter). 关于可执行文件的创建,在大多数情况下py2exe应该可以正常工作(尽管我还没有尝试过tkinter)。 Another way to create an executable is to add a special parameter to your "setup.py" file: 创建可执行文件的另一种方法是在“ setup.py”文件中添加一个特殊参数:

setup(...,
      entry_points = {"gui_scripts" : ['name-of-executable = name_of_package.launcher:main']})

This would, for example, create an executable that can be run by typing "name-of-executable" into a terminal (even on Windows if Python's "scripts" path is in the PATH ^^). 例如,这将创建一个可执行文件,该可执行文件可以通过在终端中键入“可执行文件名”来运行(即使在Windows上,如果python的“脚本”路径位于PATH ^^中也是如此)。 It runs the function "main" in the module called "name_of_package". 它在名为“ name_of_package”的模块中运行函数“ main”。 That way, you don't have to use py2exe but can create a Windows installer, or a Debian package, for instance. 这样,您不必使用py2exe,而是可以创建Windows安装程序或Debian软件包。

For more complex projects, I can absolutely recommend PyGTK with Glade as interface designer. 对于更复杂的项目,我绝对可以推荐Glade作为界面设计师的PyGTK It requires several Python packages to be installed, plus a GTK+ installation (which is not always that easy on Windows). 它需要安装多个Python软件包,以及一个GTK +安装(在Windows上并不总是那么容易)。 The API is awesome, well-documented and Glade is very easy to use, once you get used to the layouting concepts of GTK. 一旦您习惯了GTK的布局概念,该API就很棒, 文档齐全,而且Glade非常易于使用。 But my opinion is kind of biased because I've done multiple projects in PyGTK. 但是我的观点有点偏颇,因为我在PyGTK中完成了多个项目。 wxWidgets or PyQT are good alternatives. wxWidgets或PyQT是不错的选择。 For example, bazaar explorer is written using QT. 例如, 集市浏览器是使用QT编写的。

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

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