Add border to table in pygtk - python

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).

Related

QTableView - how to highlight only text with color (not entire cell)

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.

Tkinter Treeview - Conditional Formatting - Individual cell colours

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

Tkinter - Scrollable list with images and editable text

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

Creating a Legend Using ObjectListView

I am trying to create a legend of sorts using ObjectListView in Python.
I am able to accomplish this, using wx.PaintDC, DrawText, and DrawRectangle in wxPython, but it doesn't look very good because it is all free hand.
Is it possible to create a square image, say a 10x10 pixel square, using wxPython or another package and then insert that image into a column on ObjectListView while changing the fill of that square for each row.
For example:
CheckBox||State||Population||Legend Color
Yes||Massachusetts||6.5million||Red Filled Square Image
No||Illinois||12.9million||Blue Filled Square Image
Thanks in advance.
Chris
You should be able to add different images to different rows with the ObjectListView widget, if I understand the question correctly. Alternatively, you might want to take a look at the UltimateListCtrl, which was written in pure Python and can have any widget put into it. I think there's a new list control widget in 2.9 too, but I don't remember what new features it added.

Automatic DrawingArea scaling on resize with (Py)GTK

How can i scale the gtk.DrawingArea on window resize? I'm writing a code that will draw some colors in DrawingArea that will be added to an gtk.Table cell. I just need, that the image will be stretched in all of space of the cell.
sorry for my english.
thx
First create the table with homogeneous turned off:
table = gtk.Table(rows=1, columns=1, homogeneous=False)
If homogeneous is not turned off, every table cell will be as wide and tall as your DrawingArea.
To attach the DrawingArea to the table:
table.attach(child, left_attach, right_attach, top_attach, bottom_attach,
xoptions=EXPAND|FILL, yoptions=EXPAND|FILL, xpadding=0, ypadding=0)
Leave xoptions and yoptions as EXPAND|FILL to make the DrawingArea expand. If the table is also set to expand, the default when doing toplevelWindow.add(table), then the DrawingArea should automatically resize when the window is.
See this site for more info: pygtk table documentation

Categories

Resources