开发者

Python GUI(tkinter; pygtk+glade), py2exe

开发者 https://www.devze.com 2023-01-30 18:30 出处:网络
I\'m new with python programming and GUI. I search on internet about GUI programming and see that there are a lot of ways to do this. I see that easiest way for GUI in python might be tkinter(which is

I'm new with python programming and GUI. I search on internet about GUI programming and see that there are a lot of ways to do this. 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)? I also read a lot about GLADE+PyGTK(and XML format), what is there so special(glade is 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 "prin开发者_StackOverflow中文版t" work) and then make some .exe file (is there best choice py2exe=?). Is there a lot of changes in code to make GUI?

Many thanks


If your GUI is really that simple, you should go with the built-in tkinter.

There's a Hello, Tkinter tutorial that you can follow, it's pretty straightforward. Concerning the creation of executables, py2exe should work without problems in most cases (though I haven't tried with tkinter). Another way to create an executable is to add a special parameter to your "setup.py" file:

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 ^^). It runs the function "main" in the module called "name_of_package". That way, you don't have to use py2exe but can create a Windows installer, or a Debian package, for instance.

For more complex projects, I can absolutely recommend PyGTK with Glade as interface designer. It requires several Python packages to be installed, plus a GTK+ installation (which is not always that easy on Windows). The API is awesome, well-documented and Glade is very easy to use, once you get used to the layouting concepts of GTK. But my opinion is kind of biased because I've done multiple projects in PyGTK. wxWidgets or PyQT are good alternatives. For example, bazaar explorer is written using QT.


I really like PyQt bindings for Qt library. What is PyQt?

Qt itself is a very nice framework - rich, powerfull, elegant (for my taste, at least). And PyQt does a very nice job of exposing that functionality to a scripting environment.

Plus, there is a very nice book about PyQt development - Rapid GUI Programming with Python and Qt - working through it helped me a lot.

0

精彩评论

暂无评论...
验证码 换一张
取 消