Python PyQT gestures - python

I want to enable use of PyQT gestures in my application. Anybody has an example or some short code that could demonstrate use of gesture control in PyQT application?
I tried googling around but could find only one post about customizing the gesture... I am not that far yet at all, I just want to see how to bind the gesture and callback in Python QT app.
thanks

I'm working the same problem. No reason why it shouldn't work, by simply translating some of the C++ examples, but its bleeding edge.
For example, won't work on Linux desktop (just Windows) without Qt 5 or a lot of work. See http://qt-project.org/forums/viewthread/12664. If I get Qt 5 installed, I hope to post a Python example.
I am using PySide, and the QtGraphicsFramework and have a small test program. Another more sophisticated test, of custom gestures, is crashing, not just throwing exceptions, and I'm suspecting the Python binding.
There are plenty of nuances. If any platform is good for learning, it should be Qt and Python. Go figure why there are no examples yet.

Related

How to use platform specific "ports" for wxPython (e.g. wxMSW)?

I wish to use the wxPython class NotificationMessage in Windows. If doing so from a "TaskBarIcon" (i.e. a system tray app), there is an ugly glitch which is apparently resolved in the MSW port (via a preemptive function call to patch this special context). Here's some wxPython documentation indicating this:
https://docs.wxpython.org/wx.adv.NotificationMessage.html#wx.adv.NotificationMessage.UseTaskBarIcon
The problem I have, is the only instructions I see regarding how one employs the MSW port, is only seemingly in regards to the C++ wx library? https://docs.wxwidgets.org/trunk/page_port.html#page_port_wxmsw
I see nothing explaining how any of these platform specific ports are integrated into the wxPython library, as opposed to using them in C++ projects. Do I need to build wxPython from source, perhaps, with this "port" / flavor somehow? Or, would I need to include the dlls (or .so's) in my python project and make calls into them directly?
Overall this library, and it's documentation, is really excellent but I'm tripped up by this point.
I was able to solve my immediate problem by using the TaskBarIcon function ShowBalloon() instead. It does the exact same thing, without the glitch.
That said, I still would very much like to know what the answer is to the original question, before I encounter another platform specific situation like this, requiring one of these wx "ports"...

GUI development for my c application . How to proceed?

I have developed an application in C which works on command line interface. I want to make my code display data over GUI, and I would also want to provide a window waiting for user input.
I need some directions on how to proceed. I came across a few sites saying libraries in python will serve the purpose.: WxPython, TKinter, PyQt
How to start abt? How do I link my C application to the GUI? And should I develop a GUI application, too, and then link it to my C application?
I am a beginner. Please help.
Thanks.
I recommend using GTK+ or Qt for your application.
They are popular, cross-platform and both have extensive documentation and great community.
Take a look at Cython for easily connecting the C world with the Python world if you decide to link your C code with the UI, it's highly convenient as a glue language.
Depending on your application, it might be a good option to keep it as a command line application that you call from a python program. The subprocess module is the usual route here, but there are some tools that can help even more -- like commandwrapper.
As for the GUI, apart from the already mentioned (perfectly viable) alternatives in other answers, Kivy is an interesting newcomer, and pyFLTK is a lightweight, easy-to-learn, old-school approach. These are a bit exotic, but it's good to know they exist.
Finally, QT5 was recently released and it shows a lot of promise. You might want to consider it if you don't mind writing C++, it's various language wrappers are not ready yet.
You'll need to install the libraries for whichever GUI framework you want to use. WxWidgets is available for C, as well as Python, so you don't really need to link to the Python library. Other options (as indicated by Intelis) are GTK+ and QT.
If you're developing in Windows, then you may also use the Windows API to create your GUI application. Alternatively, you might consider using C++ (Either managed C++ or MFC).
Once you have installed the appropriate libraries, you will need to include them in your C source by using the #include <...> directive.
Take a look at these sites:
WxWidgets Tutorial.
GTK+ Tutorials
QT Tutorial

Python custom GUI

I googled and search stackoverflow before asking this question
Answers that I don't expect:
wxWidgets is the best Python GUIUse TkInter (BIM) for GUI development.
Q. How to make a GUI without using any module/library? i.e make a GUI from scratch. Modules like tkinter not allowed.
I've made several GUIs from scratch using SDL which is a low level drawing library. The advantage of doing that is that it will look exactly the same on any platform down to the pixel and you can get it to work on embedded systems. Full screen GUIs are really easy too. Disadvantages are that it is a lot of work.
In python the pygame library wraps SDL so you would use that, and in fact that is how I made the GUI for a lab instrument which had a large colour LCD screen. The controller ran linux, but not X-windows.
pygame is an extra library, yes, but I can't think of a way of making a GUI with only what python provides.
The easiest GUI to make without "module/library" is a web-based one. I.e. generate HTML with Javascript from your Python code, and let the Javascript interact via AJAX with your Python app. This can be implemented without too much effort with just the standard Python library (and some JS code, of course), or with modules that don't require "heavy" installation of platform-specific extensions.

wxPython GUI - can it be compared to Java GUI or Visual Studio GUI?

I have a two years of experience in programming of enterprise application's with Java and Visual Studio, and I'm new in Python and wxPython. So my question is: Can wxPython provide me enough rich GUI to create those same app's? My reason if using Python is in it's diversity, simplicity and fast development of app's. Thank you!
I think it depends on your definition of "rich." I use it and like to think it can make some fairly useful GUIs. Here's a screenshot of a wxPython app to work with sensor data I'm writing right now - not the most elaborate or complicated in the world, but so far it seems fairly intuitive for users:
I find the wxPython docs to be a little sparse at times, but as long as you've got the demo installed and the wxWidgets docs open it's a good toolkit to use.
wxGlade will give you the GUI skeleton. You will still need a separate text editor (I recommend Geany) to fill in the handlers.
I would certainly suggest using Python and its GUI libraries, but only you can really make the decision as to wether you think its better than visual studio or Java. The syntax of Python is very basic and I think many people can agree its a plesure to use when you get your head around it (no curly brackets etc). Python Tkinter is quite a simple GUI library and its ideal for making a basic application. WxPython on the other hand is far more advanced than Tkinter hence a richer user experience. The only problem I have had while using Wx is not being able to find suitable examples on the web to demonstarte how some things are done. Good luck, hope you find what your looking for. Karl
The wxPython demo shows most of the widgets that are available. I suggest that you take a look at this and see whether it will do what you need.

Writing a lockscreen for Linux?

I've been looking around for a nice lockscreen to use with my XFCE system, but it seems like there are any slim lock screens around. I'm currently using slock, but it's just a blank screen with absolutely no interface whatsoever.
I'm looking to code a lockscreen in Python. I looked at the source code for slock, and it seems like I have to interface with Xorg somehow.
Does anybody know anything about writing lockscreens?
If you want to go low-level, you can use python xcb bindings.
If you want to use higher level bindings, you may find this tutorial on writing a screen saver with Qt useful. Porting it to PyQt should be quite straightforward. I'm pretty sure similar resources exist for GTK.

Categories