WxWidget/WxPython; 3 column resizable layout - python

I'm trying to figure out how i can have a 3 column layout where the (smaller) left and right columns are resizable with a draggable separator on each side of the center/main area. I've tried using splitwindow but that seems to only split in two parts.
Hope someone can give me pointers on how it can be done.

I susggest that you create three panels, side by side. When one of the panels is resized by the user, you will have to adjust the size of the other panels to compensate - so that there are no gaps or overlaps. You can do this by handling the resize event, probably in the parent windows of the three panels.
Another way, which requires you to write less code, would be to use wxGrid with one row and three columns and zero width labels for columns and rows. You will lose the flexibility of panels, but wxGrid will look after the resizing of the column widths for you.

Related

QTableWidget Expand Columns to Fill With Last Column Fixed Width

I'm attempting something that I thought would be simple, but just cannot find a way to do this.
The supplied image demonstrates what I'm after. It's essentially just a QTableWidget with the following behaviour:
Fill the available space.
A fixed width column on the right.
The rest of the columns I'd like to be able to resize manually (so they'd have to stretch proportionally so that all space is filled).
Things I have tried:
Setting setStretchLastSection(True). This fills up the space, but you have no control over its width if this is set.
Overriding the resizeEvent and calculating and setting everything manually. This seems like a very messy way of doing things, which usually means there's a simpler way.
Is there a simple way of achieving this?
You can always ResizeToContents all columns with self.my_table.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) and then apply your fixed width to the last one
I managed to get something that works
self.myTable.horizontalHeader().setSectionResizeMode(0, QtWidgets.QHeaderView.Interactive)
self.myTable.horizontalHeader().setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
self.myTable.horizontalHeader().setSectionResizeMode(2, QtWidgets.QHeaderView.Fixed)
The general rule is to set all of the headers to Interactive, the penultimate to Stretch, and final to Fixed.

Make width of various widgets correspond with treeview columns

As an example, I have an entry, and several optionmenus located below a treeview widget. I am using the grid manager, and the treeview has a columnspan equal to all the widgets along it's lower side.
Since specifying the width of an entry or an optionmenu is in characters (the width in px of those characters is in turn based on the font size/family chosen for the widgets), and specifying the width of a column in a treeview is in pixels, how can I calculate the lengths of both a column and the widget underneath it so that they are visually linked by their positions (the length being the same)?
I found a great example of treeview. It might help to provide some insight. Here is the link
Create a table using treeview with control of column widths

How to make matplotlib:pyplot resizeable with the Tkinter window in Python?

I am trying to build a grid of frames in each there is a matplotlib figure.
When I resize the window the figure remain with fix size and are not resizing to fit the empty space.
Is there a way to make the figure change its size according to the canvas (hopefully that it does change with the window size)?
This is how I do the embedding in each frame:
self._figure = pyplot.figure(figsize=(4,4))
self._axes = self._figure.add_subplot(111)
self._canvas = FigureCanvasTkAgg(self._figure, master=self._root)
self._canvas.get_tk_widget().grid(row=1,column=1,rowspan = 4)
This is most likely related to this question. The gist is that there are two parts to making a Tk grid cell grow:
Use the sticky keyword when applying grid to your widget, e.g., widget.grid(..., sticky=Tkinter.NSEW (Python 2.7) to make widget be able to grow in all four directions. See this documentation for more details.
Tell the parent/master to make the respective column/row grow when resizing by calling parent.grid_columnconfigure(...) and/or parent.grid_rowconfigure(...) with the desired row, column, and weight keyword. E.g., parent.grid_columnconfigure(col=0, weight=1) makes the first column take all available space (as long as there are no other columns, or they have not been similary configured). See the grid_columnconfigure documentation and the grid_rowconfigure documentation for more details, e.g., about how the weights affect multiple columns/rows.
This page contains many more details about grid layouts.

wxPython: how to lay one panel over another

This is about wxPython.
I would like to have 2 Panels laying one over the other:
PanelBG should be some sort of a "background", with its own GridBagSizer with subPanels, StaticTexts and so on;
PanelFG should be the "foreground" panel, also with its own GridBagSizer with some StaticTexts, Buttons... but a transparent background, in such a way that PanelBG is visible wherever PanelFG doesn't lay widgets.
I need both Panels to stretch to all the sides of the frame, even when resizing the window, though never changing the reciprocal proportions, that's why I'm not sure if there's a way to use absolute positioning.
In case you are wondering, the reason why I don't want to use a single Panel is that merging the 2 GridBoxSizers would require me to place many many more cells in the sizer, because rows and columns of foreground and background don't always coincide, and I should split them in many cells, with grid dimensions growing up to hundreds**2.
Since the content I want to put in the foreground needs to be updated and refreshed quite often, this would require redrawing all the cells every time, which would take 10 - 20 seconds to complete the operation (tested). Updating only the foreground would require just some hundredths of a second instead.
Thank you!
This would be at least partially a change of direction, but it might be worth examining what other rendering options you have.
In particular, I'm thinking of wxWebKit (http://wxwebkit.kosoftworks.com/), which would let you do layering, etc. using the WebKit browser rendering engine. I'm not sure whether it's at a stage that would provide everything you need since I haven't actually used it, but even if it doesn't work then it may be an approach worth trying - using HTML/CSS for part of your display, while wrapping the whole in a wxPython app.
As I understand it, this is a calendar with rectangles for the days containing the events for the days.
The simple thing would be to use a wxGrid, with seven columns and four or five rows, to represent the months. You would then place the events into the grid cell for the correct date. The wxGrid widget would look after the details of refreshing everything properly.
Using wxGrid you might lose a little control over the exact appearance, though wxGrid is very flexible and feature rich once you learn its many methods, but you would save yourself having to write large amounts of code that would require significant effort to debug.

How to make two elements in gtk have the same size?

I'm using pyGTK. I want to layout a large element with 2 smaller ones on each side. For aesthetic reasons, I want the 2 smaller ones to be the same size. As it is, they differ by a few pixels, and the middle element is not centered as a result.
I tried using gtk.Table with 3 cells, but having homogeneous=True doesn't have the desired effect. I tried messing with it by making 8 cells, and then having the center one take up more cells, but it doesn't work well. Is there any way to do this?
You should use GtkSizeGroup for this. Create a GtkSizeGroup, add both widgets to it. This will ensure that both widgets have the same size. If you want that widget have the same size in only one direction (width or height), set the "mode" property of SizeGroup.

Categories

Resources