I wanted to set multiple icons in a single item in my QcomboBox. I think this can be implemented using the QAbstractItemDelegate, but I need some PyQt examples. The following link does give me an idea but I couldn't get in running with Python :
How to custome QCombobox with multiple comlumns
Thank you for the help.
Related
This question already has an answer here:
How to change window/widget with PyQt5 using .ui files?
(1 answer)
Closed 1 year ago.
So I am trying to create an application with multiple pages. I would like to have some kind of menu, that the user could use to navigate between different "pages" the application has.
I looked at QStackedWidget, but it seemed like in this case (using uic to load the ui) I would have to write the whole business logic (for all the pages) in a single class, and even if I managed to separate them to some degree, it just seems not that good of a solution. I would also not like to create a new window for every page, would be better to keep them on a single page and just switch on certain events.
I took a look at custom widgets, but I imagine the ideal usecase for those would be for reusability and not for a "page" in an application like this.
What would you recommend?
I managed to solve the problem with the help of this question. I was confused since the widget I added to the StackedWidget just wouldn't appear.
I am working on a small project using PyQt5 (Python 3) and I want a widget where a user can select/modify a file, somewhat akin to the left-hand side of file explorer on Windows:
This cannot be done with QFileDialog as I want to display files that are not on the user's drive.
I have tried writing my own, however I am a beginner and I lack the skills to do it correctly (hence the reason why I'm trying to learn). I can provide the code if that would be useful.
Is there such a thing built in to pyqt? Has anyone created one before, with source code available?
Thanks in advance.
EDIT: More specifically I don't want a way to access remote files, just a widget that displays entries (along with icons, preferably) and subentries in a sort of drop-down menu, like the section of file explorer mentioned above. It doesn't necessarily have to be to do with files, consider it a drop-down menu if that helps.
I know this is old but for anyone looking for an answer it's the QTreeView widget.
I've been using Bokeh's datatable, but there are a few things I'd like to do that I don't know how to accomplish using the DataTable class. For example, I don't think it's possible add icons (or any images) to different rows, or setting the table to single selection only. So, I've been thinking about implementing just a HTML table, and writing it with the DIV widget.
However, I'd still like to add interactive features to the table, like buttons, or the icons mentioned above. Then, when an event is generated (e.g. onClick), that event is captured by the Bokeh server, and I can write the handlers in Python to do things such as modifying the data in ColumnDataSource, for example.
Is this possible? Or is there a better way to accomplish this?
Thanks!
I think the approprate way to achieve what you want is to create a custom widget:
Extending Bokeh Documentation
Custom Widget Example
I do not paste here the complete example because it is too long.
I'm new to PyQt and I'm trying to do some specyfic stuff but without luck :(
I'm trying to create a expandable tree of items (treeview) with pyqt, but I want, that on the left of each name there will be a non-exclusive checkbox.
I found some codes but for now the best result was tree with only checkboxes :(
Does somebody have some minimal example how to achive this effect?
Thank you very much!
Qt's ItemViews draw checkboxes next to the text, if the ItemIsUserCheckable flag is set for the item in the model. If you write your own model you must implement QAbstractItemModel::flags, if you use QTreeWidget you can set the flags for each QTreeWidgetItem.
Qt4 has support for Drag & Drop actions and I've used them like in the tutorial. Now I want to be able to drag external elements (files) into the GUI form and perform actions based on that (like get the full path and copy it somewhere).
I'm not sure whether this is a limitation like something Qt cannot do. Does someone know how you can do that with Qt? Simply drag a file into a GUI...
Thanks,
Marius
Most file managers provide drag-and-drop data using the text/uri-list target.
Regarding the linked tutorial, first you need to set the widget to accept dropping text/uri-list data, then you can retrieve the URIs by calling event.mimeData().urls(). The return value is a list of QUrl objects.