Getting started w/ Python on the desktop - python

I'm interested in getting started w/ developing Python based applications for a desktop environment and have a few (seemingly simple) questions:
What is the best method for developing GUI applications? I've seen several frameworks but the indexes I've found are a bit convoluted and mix (what seem to be) legacy packages. In your opinion, what is the best approach in this regard?
I've been reading a few books I recently picked up, but have been having trouble finding (rather, recognizing) a decent 'getting started' tutorial that focuses on Python apps for the desktop. Do you have any recommendations?
Thanks very much in advance! :)

wxPython is the best GUI framework.
The official docs are the best resource. They helped me quite a bit.

Have you considered Iron Python as an option? It's basically the Python language on top of the .NET Framework. Having been fortunate enough to work with the .NET Framework in the past on desktop-applications, I can attest to its depth of excellent.

wxPython is a phenomenal GUI toolkit for developing native applications. I highly recommend it. Also, if you combine it with py2exe you can create .exe files for running on Windows.

easyGUI and Tkinter are VERY easy libraries that can be used with Python to make GUIs. Further, as stealthdragon has suggested, you can use py2exe to compile your GUIs into EXEs for your PC. There are also other compilers such as pyc.
As Jonathan Sampson suggests, you might consider using IronPython and use it to wield the full power of the .NET framework. The IronPython Cookbook, which among other things shows you how to make a basic Twitter Client.

Related

Which is the best Python version and IDE for me to use?

Based on my project, which is the best version of Python to use? Which is the best IDE to use that runs on Linux (Ubuntu) and Windows? Here is the background for these questions:
I'm building a small application GUI that features "drill-down" views and direct manipulation on personalized calendars. Should I use Python 3, the newest version, or an older version is better at this GUI task? I've heard that some of the old GUI libraries do not support the new version yet, but not quite sure if this will matter a lot. Could you please name the libraries that might be relevant? Even better if you could suggest your preferred IDE either under Windows or Ubuntu. Many thanks.
You can use vim as IDE.Start program with 2.7 version with 3.0 in mind.Have a look at this python 2 or 3
Depends a bit on which GUI you use. If you're using PyQt, it supports v3. wxPython, however, does not.
As a rule of thumb, for now, you can pretty much use python 3.0 syntax in 2.7, and keep things compatible going forward. I'd say, except for print statements, the differences aren't that mind-blowingly different between 2-3. IDE's pretty much support both - and gnud's links are pretty good for that.
Popularity
When selecting a framework to learn, popularity is a reasonable gauge of how good a framework is, and how easy it will be to get support when you run into problems. The tags on stackoverflow are a quick way to get a ballpark idea.
Environment
Start with what you're the most familiar with. When learning something new, there is so much to absorb, that having something familiar really helps.
For example, when I taught myself python a year ago, I used pydev in eclipse, because I've been a cross-platform java developer using eclipse for quite some time. Made life much easier.
If you're starting from ground zero, it doesn't matter very much. Pick something popular that you feel comfortable in and start coding. As you become familiar with what you're doing, you'll be able to compare other packages and determine if it's right to switch.
The popular IDE's are cross-platform. Graphics packages too, although usually one is stronger on unix or windows.
SublimeText2 has excellent Python support.
Also you can use PyDev for Eclipse.
About versions: I think you should write 2.7-compatible code, but be ready( and know how) to update it to 3.2 or later.
I'd recommend starting with 2.7 since most libraries work with it. The differences between both are not too big, so you might even be able to switch if you want to in the future. But before you choose Python 3 and you find a library you really want to use and it's not available for Python 3 you would regret choosing.
wxPython and PyQt are pretty popular. wxPython doesnt support 3 yet...
I prefer PyCharm it's not free but it's so great and it has so many features...
One of the best code-completion i ever had for Python.
P.S.: if its really simple you mgiht even consider using tkinter.

implement a database application with GUI for Windows, written with Linux

I have the following data scheme that I want to turn into an application. A regular desktop GUI would probably the best.
UML Diagram http://img217.imageshack.us/img217/341/56836587.jpg
big version
The whole thing would be developed on a Linux (Ubuntu, Gnome) machine, and then used on a Windows Vista computer. If Windows is a problem, I might be able to just run it in a Linux VM later.
My programming language of choice would be Python. I have only used Qt for a two hour project, I have pretty much no experience with GUI. Would Qt work easily on Windows and not look to out of place there? Is GTK a way better option, or is that merely preference issue?
From talking on the #python channel, I gathered that storing the data in a SQLite database would be a good option, and accessing this data via the SQLAlchemy ORM would be better than writing SQL statements by hand. The latter is my usual approach, I want to use this project to learn something better.
Can I just design the dialogues in Qt Designer and use them with my Python objects?
You might want to check out Dabo.
Dabo is a 3-tier, cross-platform application development framework, written in Python atop the wxPython GUI toolkit
Camelot
If you are set on using Python them I think Qt would be am excellent choice. It's a fantastic framework that looks good and runs on many platforms. You won't be limited to Windows. Qt can be a bit intimidating but you won't be limited in terms of functionality. The Qt designer works well with Python.
SQLAlchemy works on all common desktop platforms, including Windows.

How to get started building a Mac application

I am a Python/web programmer.
Now, I would like to transition to building applications for the Mac.
Please tell me--what do I have to learn to get started?
What books would you recommend?
Assuming that you included the "python" tag after considering that it will be interpreted as applying to the question and not the questioner, you must be interested in writing Python applications for the Mac, right? After all, you didn't include "web" as one of the tags too.
If that's true, I'm not sure what more you need to know already, other than perhaps picking a GUI framework, if you want to write GUI applications.
I use wxPython quite successfully for applications which run on OS X (and Windows). Very few Mac-specific issues have cropped up to cause trouble, primarily because both Python and wxPython are remarkably cross-platform. The few that have come up are by and large documented and have known workarounds, or the resolution is fairly simple to find.
I've needed no books on the subject, and really know very little about Macs. It really hasn't been a problem so far.
The programming language of choice for building OS X gui applications is Objective-C with Cocoa, I would recommend that you check out some books on that. There are python bindings for Cocoa but they are not optimal.
You should check out previous questions looking for books on Obj-C and Cocoa.

Applications of Python

What are some applications for Python that relative amateur programmers can get into?
For example, Ruby has Rails for building web applications. What are some cool applications of Python?
Thanks.
Google App Engine has excellent support for developing -- and especially for deploying -- web applications in Python (with several possible frameworks, of which Django may be the most suitable one for "relative amateurs"). Apart from web apps, Blender lets you use Python for 3D graphics, Poser for apps involving moving human-like figures, SPSS for statistics, scipy and many other tools included in Enthought's distribution support Python use in scientific programming and advanced visualization, etc, etc -- the sky's the limit.
"cool" is a state of mind. Hence cool applications depends on your definition of cool. A Ant colony simulation is cool, if you want to implement the theory.
Python, with its own and 3rd party libraries (batteries) has been applied in possibly all domains of day to day programming. My advise is, decide on the cool app you want to write and then see, what Python has to offer in that domain. If you are sufficiently satisfied, you can start coding. Good Luck!
You can build web applications in Python. See the Django framework.
Besides that, here's a nice list.
Not particularly relevant, but interesting, is the fact that NASA uses Python.
I wasn't a programming amateur at the time, but using pygame was my first intro to Python.
Python is a general purpose programming language much like Ruby. It can be used for systems programming, embedded programming, desktop programming, and web programming. In short, it has about as much potential for "cool" projects as any other general purpose language.
One of the first bits of Python programming I ever did was to hack on the nicotine client for the Soulseek peer-to-peer network to add a '/g [query]' chat command to open the default browser and search Google.
Probably not the most general purpose example, but I learned Python when AutoDesk Maya adopted it as a secondary programming language to complement MEL (Maya Expression Language). By comparison, it was a god-sent.
I like:
Django, for web development
PyQt4 for GUI programming
pygame for games, input management etc
PIL - python imaging library, it's not huge application, but really helpful and library imo
also, Blender is an application scriptable in Python, so if you'd be into some 3D graphics, here you got it.
If you're making applications for windows and want to ship them easily, you can also look at stuff like py2exe.

PyWinAuto still useful?

I've been playing with PyWinAuto today and having fun automating all sorts GUI tests. I was wondering if it is still state of the art or if there might be something else (also free) which does windows rich client automation better.
pywinauto is great because it's Python.
Perhaps a bit more full featured is AutoIT, which has a COM server that you can automate (from Python using win32com), and some cool tools, like a "Window Info" utility, which will give you the text (title), class, size, status-bar text, and so on for the window currently under the mouse cursor.
There are some cases where pywinauto is a bit harder to use than AutoIt, and seems a little less polished. One example is automating Inno Setup programs. The Inno Setup "setup.exe" program launches a separate application that actually performs the install, and it's a pain to track this down with pywinauto, but AutoIt makes it easy.
I used to do test automation on our projects with AutoIt but switched over to pywinauto 3 months ago and have been very happy with that decision. There are some rough edges, but I've been able to fill them in with my own supplementary test functions. In addition I find that coding tests and support code in Python is much easier and more manageable compared to AutoIt. With Python I have way more powerful options for logging, debugging, documentation, process management and test configuration. For me it was absolutely the right way to go.
I am going the same way, bit by bit and I have to say that python + pywinauto is good stuff!
New pywinauto 0.6.0 has introduced MS UI Automation support under the hood. So that WinForms, WPF, Qt, Store apps etc. could be automated almost the same way as an old native Win32 application.
Moreover it's possible to use mouse and keyboard modules out of a window/control context. These modules work on Linux as well!
New module win32_hooks is inspired by pyHook and similar libraries, but it doesn't require compilation.
Yeah, this post is a kind of ad. But I just wanna say pywinauto is still useful and I believe it will be even more useful in the future. The developers community currently consists of 2 mature developers and 3 talented students and we have long term plans on Linux and Mac OS X.
P.S. There are some more open source tools:
similar tools overview in the pywinauto docs
UI Automation tools rating by GitHub stars and SO stats.

Categories

Resources