Python3: get current window name? - python

I want to develop a script that would dump me some statistics over the application usage on my machine. The script should run in background, get events when user switches active windows, and dump information over apps time usage.
What documentation should I refer for that? I have no idea about X11 programming, and I have little idea about GUI toolkits on Linux, and how do they work. Most solutions that I've found on the google tend to use wmctrl or xprop, which is not what I want.

My guess is the best way to approach this problem is by using your Desktop Environment's plugin system--if it has one.
Gnome
KDE
All of the major DE's should have Python bindings.
Good luck!

Related

How to do Relative GUI Development in Python?

I am used to making android applications and I would like to also make desktop applications. I would prefer to use Python. Is there a module that allows relative layout to better fit all monitors? I have tried pyside, but I could only get absolute. I saw the Kivy module as well, but I didn't want to devote a lot of time to it if it isn't what I need. I am developing on a windows platform for windows, but plan to possibly port it to linux and mac as well. I also would prefer to use Python 3.
I would personally recommend Tkinter. It works on Windows, Linux, and Mac, and is simple enough such that you can pick it up in a weekend. There is plenty of support and documentation as well.
Consider wxPython as well--it would satisfy your needs.

GUI builder Python for Linux and OSX

I just want something that is easiest to use for building a relatively simple GUI that
ports easily to OSX and Ubuntu Linux.
More than anything, I just want to get cracking on the App rather than getting caught up in
making something super polished, etc.
GLADE comes up a lot but doesn't strike me as the easiest, though, if someone suggests otherwise I'm open.
Again, main criteria is ease of use and portability to OSX and Linux.
There a quite a few options that you have:
PyQt is one : here is an intro : http://www.rkblog.rk.edu.pl/w/p/introduction-pyqt4/
PyGTK http://pygtk.org/ heard some good reviews for it but have not played with it.
wxPython is another : http://wxpython.org/what.php
I would suggest the wxPython but its totally up to you.
Have a look at their documentation and then pick.
Enjoy

Deploying Python Qt application cross-platform: Win, OSX, Linux

We are designing open source UI controller application for Plone CMS. The application itself would be just simple start/stop dialog window for Plone daemon process, mainly aimed for Windows users.
However we are hoping to use the same app for OSX and Linux.
We can create the code for Python Qt application, but we feel unsure about the deployment process. In the optimal case we'd hope to create static builds (.exe for Windows, .dmg for OSX) all megabyte so Qt included for our tiny Python script, just to maximize the ease for the end user.
Are there any examples, scripts, etc. to build Qt friendly installers cross-platform? What other best practices we should consider?
PyInstaller is a nice one to create executables and it comes with full PyQt support. It says it can create executables for Windows, OsX and Linux but I've never used it for anything other than Windows. For Windows, it was quite painless and easy.
This doesn't address the packaging/deployment component of your question, but might be a useful side note.... If you haven't already, you may want to consider PySide for your Python bindings, instead of PyQt. The licensing terms are more permissive (LGPL) than PyQt, and may be more appropriate unless you're commercially licensed.
FWIW, I have successfully used py2app with PySide/Qt4 on the Mac, but don't know if it goes cross platform.

Is wxPython Needed on the End User's Computer

I am making programs that solve and show work for math problems. I would like to add a GUI, and I think wxPython will be best. If I use wxPython for the GUI, will the end user need wxPython on their computer in order to use the program with the GUI? If not, what would should I use?
These apps will be used on mostly Windows, but I would also like them to work on Macs and Linux. I'm not for sure if any Python GUI elements will work on Android through SL4A, but if you know any, that would be appreciated.
Also, I know Tkinter is bundled with Python, but is it a dying technique, as I have read?
Thanks!
There are tools for packaging a python program and its libraries into an executable that can run on its own. I keep this list handy:
http://www.freehackers.org/Packaging_a_python_program
I'm sure at least one of those tools will handle wxPython, because I did it a few years ago. (Sorry, but I don't remember which one.)
Yes, tkinter's popularity has been waning for years. See this question for some more options:
higher level Python GUI toolkit, e.g. pass dict for TreeView/Grid
If your software is mostly about the complicated processing, with a fairly simple UI, tkinter is probably fine
I am using cx_freeze for this without any problems. Worked for me on Windows and Linux.
Tkinter comes with Python, so it can be handier in some respects just because of that. On the other hand, wxPython uses the native widgets of the OS (which has it's own set of pros and cons). I personally prefer wxPython. But no, Tkinter is not dead to my knowledge.
You can use py2exe to bundle up your app on Windows or you could use cx_freeze or bb_freeze. There's also PyInstaller, which I think can create some kind of Linux bundle, but the docs are kind of confusing. For Mac, see py2app.
I'm not aware of any specific Python GUI toolkits for Android.
PyInstaller.
install and run.
cmd -> python pyinstaller.py NAMEOFSCRIPT.py --onefile --noconsole.
easy as 123.

Best way to build a cross-platform and custom-skinned application with Python

Features needed:
A framework, allowing me to build tab-based application with custom design (like in Hotot twitter client), keeping the native os window frame.
Compatible with Python.
My application will be running under Win/OsX/Linux/.
No Flash/Flex/AIR.
I also would like to ask if PySide does meet my requirements and is it worse or better than wxPython and Tkinter mentioned already?
Use Tkinter. It works on every platform that Python supports, is relatively easy to program in, looks pretty good on most platforms, and has the features you want. It's also built-in for most versions of Python, so your users (in many cases) will not have to install any external dependencies.
I find that Tkinter looks best on Mac OSX and Windows, and slightly outdated on some Gnome desktops. The most important feature, however, is that the API is extremely clean and easy to use and it is very lightweight. PyQt has a similar feature set, but, in my experience, its performance is significantly degraded when compared to Tkinter.
PySide is Nokia's Qt binding for Python. I'm not aware of what the differences are between it and PyQt. Ultimately, most GUI toolkits for Python are going to be cross platform and support the functionality you need. I suggest Tkinter because I feel it is the easiest and most pleasurable way to program GUI applications in Python.
I am the author of Hotot.
according to your requirements, the key for you to choose a framework is the UI framework should be able to access webview conveniently.
Hotot has several wrappers for different platforms. On Linux, we have both Qt and GTK version, on Windows, we provide a Qt version, on Mac, we have a Cocoa version, and of course we have a Chrome version. In a word, all they can easily access webkit.
PS: XULRunner is another good choice for native appearance.
Additionally to the advices given by other people, I suggest you to use PyQt which is a Python binding to Qt framework. It's widely used, cross-platform and feature-full.
Take a look at wxPython (based on wxWidgets). If you want to make it web-based, look into using Django.
Well, you mentioned PyHotOt, and it says (on its web site) that it uses pywebkitgtk, and PyGTK. PyGTK/PyWebKitGTK exists for windows. Did you check it out? I think OS X would be the weak link on GTK, but maybe it's pretty good too.

Categories