PyQt4 Custom Widgets - python

Are there any good PyQt4 custom widgets like at Qt-Apps.org?
I would like to start making PyQt custom widgets but online resources that I find don't seem to be clear
For example, Trolltech's and Zetcode's don't seem to be related in any way at all.
Thanks for any input :)

There should be PyQt examples of all C++ Qt examples in your PyQt4 distribution. I have them here: /usr/share/doc/python-qt4-doc/examples. Theye are quite good for the start. When you understand them, it should also be fairly easy for you to port some C++ examples to PyQt code or turn C++ custom widgets to C++.

online resources about PyQt aren't really that rampant, so any information/projects would be welcomed. Don't hesitate to post links to your upcoming widgets or anything else.
I would be really glad to work on that with you as i'm learning more about pyqt as well.

Are you looking for tutorials on making custom PyQt widgets, or looking for a library of them?
I've been developing a library of reusable custom widgets if that's what you're looking for - at somepoint will be getting to the tutorials, but they aren't there yet.
Check out projexsoftware.com, specifically the ProjexUI framework:
http://dev.projexsoftware.com/projects/projexui
http://docs.projexsoftware.com/sdk-reference/projexui-sdk
In looking at it, I'll need to get some images up there...but there's a Calendar widget, Gantt Chart, View plugin system, Node view, Chart widgets, along with a number of extensions to the base Qt widget classes.
Also the easiest way to see the majority of the widgets is in the Qt Designer - so if you have it setup to work with PyQt plugins, wherever you install the projexui library you can add the /path/to/projexui/designer/build to your PYQTDESIGNERPATH and it'll load designer with our plugins.

Related

Python PyQt6 (6.4.0) QML Difficulty in Applying Style to Qt.QWidgets

I am in the research/education phase now, and am not seeing a lot of info on the web about applying a Qml-based style to QWidgets. This implies it's difficult or not possible. I doubt it's impossible, but I am curious what the options are for doing that?
Ideally, what I want to do is use the system (user-chosen) theme in my application. I'm on Linux, and it uses GTK and GNOME for themes. I want to support Linux in general (maybe one day, other platforms), so would like to make the app theme cross-distro.
I don't know if this is a tall order. But, is it extremely involved to make PyQt6 QWidgets styled from a QML style? Can widgets use the system theme?

tkinter custom widget collecting

I'm searching for a tkinter custom widget collection that I can include in a application designer I'm writing in 100% Python but haven't had much luck yet. I figured out a way to do a table for instance, but would like to save myself the work if there's a good implementation out there.
I found a couple of packages for pure Python custom widget creation with a little more searching online. One is Python megawidgets, at pmw.sourceforge.net, which, according to their documentation:
"is a toolkit for building high-level compound widgets in Python using the Tkinter module. It consists of a set of base classes and a library of flexible and extensible megawidgets built on this foundation. These megawidgets include notebooks, comboboxes, selection widgets, panes widgets, scrollable widgets, and dialog windows."
A different approach is writing custom widgets yourself using the Widget Construction Kit, at effbot.org/zone/wck.htm. This provides a base Widget class with primitive drawing methods, such as for borders, text, and colors, along with a basic but complete set of event definitions for binding your event handlers to your custom widgets. It has some good advice on doing animated widgets, such as drag and drop.
If anybody knows of any other packages of widgets or construction toolkit APIs, feel free to post it here. Developers will appreciate having a larger selection in a single location.

Pyside QItemDelegates in QListView

I've been searching the internet far and wide for a tutorial on creating custom items for QListView using PySide. I find some usage using PyQt but I find them really strange to me. I would like to recreate using PySide the appearance of the items of the list shown in this link since I'm creating a desktop version of this web application. Any help/idea/sample code is greatly appreciated.
This question is pretty broad considering that you haven't shared any code. Nonetheless, let me point you to a good resource I found very useful getting into MVC programming in PyQt/PySide:
http://www.yasinuludag.com/blog/?p=98
He touches on ListView here and that may give you a better idea of how you can implement custom models and views.
He uses PySide from my recollection. Either ways, PyQt and PySide code are pretty much identical.
Another approach would be to not use QListView but use a QScrollArea and throw in the list items as widgets inside it. Each widget would be standard Qt widgets with a layout, sub widgets and styled as you need. Check this out for a similar scenario: PyQt: How can I create a custom scroll area?
Hope this helps.

Custom Qt Widgets with python for Qt Designer

I am trying to write a custom widget for the Qt Designer using only Python. I was following a couple of tutorials I found online but none of them were working or anything close to what I would call to be a minimum working example.
So my questions are:
What steps are involved to make a a custom widget appear in the Widget Box of Qt Designer?
If you can spare the time: Please provide a minimum working example (like a widget with a label in it saying "A truly minimal working Qt custom widget example").
Or is it maybe not possible at all to include a custom widget using only python?
There are very few examples available on how to make a custom widget in pyqt. I wrote this article with a working example: Making a Custom Widget in PyQt
Here is the answer to your question #3: How do I use promote to in Qt Designer in pyqt4?
I am using PySide and it works the same way. This method works directly with your Python custom widget code. You do not need to write any separate plugin code.
After you have promoted your custom widget, you can right click on it and add your signals with "Change signals/slots..."
I would recommend putting all you widgets in a YourCostumWidgetsPack.UI file, and then when you load this file in Qt Designer, in addition to the UI you are working. It will load all your custom widget information.
I found this article to be your answer: https://doc.qt.io/archives/qq/qq26-pyqtdesigner.html
But, I haven't been able to install it in Qt Designer though :D

Something like Explorer's icon grid view in a Python GUI

I am making a Python gui project that needs to duplicate the look of a Windows gui environment (ie Explorer). I have my own custom icons to draw but they should be selectable by the same methods as usual; click, ctrl-click, drag box etc. Are any of the gui toolkits going to help with this or will I have to implement it all myself. If there aren't any tools to help with this advice would be greatly appreciated.
edit I am not trying to recreate explorer, that would be madness. I simply want to be able to take icons and lay them out in a scrollable window. Any number of them may be selected at once. It would be great if there was something that could select/deselect them in the same (appearing at least) way that Windows does. Then all I would need is a list of all the selected icons.
Python has extensions for accessing the Win32 API, but good luck trying to re-write explorer in that by yourself. Your best bet is to use a toolkit like Qt, but you'll still have to write the vast majority of the application from scratch.
Is there any way you can re-use explorer itself in your project?
Updated for edited question:
GTK+ has an icon grid widget that you could use. See a reference for PyGTK+: gtk.IconView
In wxPython there's a plethora of ready-made list and tree controls (CustomTreeCtrl, TreeListCtrl, and others), a mixture of which you can use to create a simple explorer in minutes. The wxPython demo even has a few relevant examples (see the demo of MVCTree).
I'll assume you're serious and suggest that you check out the many wonderful GUI libraries available for Python.

Categories