I'm currently using Tkinter's Treeview to display a table of data in my GUI, and would like to apply conditional formatting in the Treeview widget so that the background colour of a cell depends on that cell's value (e.g. 0 would be red, and 1-6 are green). Very much like Excel's conditional formatting.
My program reads a CSV file and converts it to a Pandas DataFrame, and I use the Treeview widget to display that data. I also have buttons in my GUI that lets the user filter the data depending on which button is clicked.
I haven't been able to find or think of an easy solution. Would anyone know of a possible work-around or an alternative please?
Desired example output
Related
I would like to for some of the columns in my QTableView give color highlight to the text without filling the rest of the cell with color. This image shows exactly what I want:
What is the best way to do this? One option is to create each text value as an image externally and then set it as an icon (I know how to do that from other SO posts). But is there a better way?
I will do this for quite many tables / columns with many different values so I would need to create many images if I use icons. So it would be great if there is a way to instead write the text in the QTableView and somehow apply the color background so that it covers the text only.
Is it possible to e.g. paint that background using an item delegate somehow? Has someone done something similar with item delegates before and that can share an example of how it's done? I'm very new to Qt.
I'm using PyQt6.
Actually the title contains all information needed. Is there an easy function like tableview.resizeColumnsToContents() that allows the maximization of all column widths within the widget size? My columns are narrow so the table looks very compact.
If you want the columns to expand uniformly, you could also set the resize mode
tableview.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
In pyqt5 setResizeMode is no longer available. Instead, use setSectionResizeMode and QHeaderView in the QtWidgets module.
See resizeColumnsToContents.
There's also a stretchLastSection property that can be used (see QTableView).
I'm trying to create a search feature in my pyside program that shows results based on a user input. Currently, I have a QLineEdit setup for the user to make an entry. When the user enters a match, the results should appear in the QLineEdit as it will expand. The program is divided into two frames: A top frame (where the search bar is located) and a content frame which shows the raw content.
My issue is that when I am trying to expand the QLineEdit, it doesn't allow itself to overlap into the content frame and becomes hidden. Here's an image of what I would like to happen.
Before:
After:
I understand that I have horizontal policies setup on both frames with a "No-frame" frame shape, would this have an impact on the output?
Using Tkinter I want to create a scrollable list(rows and columns) with images and editable text. The first column should contain images and the second column should contain tags(text) for the respective images in the previous column.
Hence a row should contain an image in a column and text in the next column.
Please let me know, what widget i need to use in Tkinter in order to achieve this.
Thanks for any help.
I would use a single frame for the images and editable text. You can use a text widget for the editable text, and align them using grid.
Then, place the frame in a canvas so that it can be scrolled. There are many questions and answers on this site related to scrolling a frame. See, for example, this answer: https://stackoverflow.com/a/16198198/7432
I am trying to use gtk table in one of my projects(GUI based) to show a pair of columns and its values. Since gtk table doesn't have borders by default, my GUI is not coming up well.
So,
Is there anyway I can add borders to gtk table and its cells?
If no can I create a customized widget with borders by extending gtk Table?
How can I create a customized widget in pygtk?
P.S: I have tried gtk Treeview and gtk Frames and thats not what I want. Also I have created a gtk treeview for each pair of columns and its values but the GUI works very very slow.
Assuming you want five pixels of spacing, if you would like to have space between the different cells of your table, you can try table.set_row_spacings(5); table.set_col_spacings(5); If you would like to have space around the entire table, you can do table.set_padding(5).