wxpython not showing the entire grid - grid

I have a wxpython csv reader. I am displaying results on a grid. The grid will take about half of my screen. I would like to display 100 rows at a time. I assign there to be 100 rows but I can not scroll to the bottom 50. I have proved that the rows are there by writing to the rows that I can not see then copying the whole column and pasting in excel. What I am expecting to see is a scroll bar that allows me to scroll to the bottom 50. I allowed editing of size of column. When I increase the height of the column, the scroll bar appears,but still only allows me to view the top 50 columns. (if user makes column height a inch bigger than normal, my scroll adds an inch) My best guess is there is something wrong with the way I am initiating/getting the best size of the combinations of sizers,panels,and the grid. I have cut out the code that not needed but the layout panel and box are my overall/main panel and box.
import wx.grid as grd
import wx
self.layoutPanel = wx.Panel(self)
self.layoutBox = wx.BoxSizer(wx.VERTICAL)
self.previewPanel = wx.Panel(self.layoutPanel)
self.previewBox = wx.BoxSizer(wx.VERTICAL)
self.resultGrid = grd.Grid.__init__(self, self.previewPanel,0)
self.resultGrid.CreateGrid(105,20)
self.previewBox.Add(self.resultGrid,0, wx.GROW)
self.resultGrid.SetSize(self.resultGrid.GetBestSize())
self.previewPanel.SetSizer(self.previewBox)
self.layoutBox.Add(self.previewPanel,0, wx.ALL)
self.layoutPanel.SetSizerAndFit(self.layoutBox)
self.layoutPanel.Layout()

The problem was nested somewhere in having 2 panels in side one another. This is normally "ok" to do but it is a little more complicated with the grid. I got rid of the previewPanel and previewBox completely and that solved the problem. However another problem was the FIT. The fit makes the panel as small as possible which is not what I wanted to happen. In code not shown I had re-sizes occurring and when I did this I had setSizeAndFit which took the scroll away. I changed it to setSize and the scroll bar stayed.

Related

resizing Div via a python callback in Bokeh

I have a plot where I would like to dynamically populate a div on user tap of data points in the first plot and automatically move the second plot downwards. I have tried setting the sizing_mode on the layout but The plots do not render. This may be an interaction with the tab widget. So far the python callback is correctly trigger on tap but the Div's height remains the same and text gets cut off.
The call back is as follows,
def update_plot_points_select(attr, old, new):
#function to change Divs if points are selected
#tap can either be a tap or untap, 1 or more points
#Show chosen word in text box
if len(new['1d']['indices']) > 0:
#update search text input field
text_input_word_search_in_documents.value = source.data['term'][new['1d']['indices'][0]]
#update Div's
text_display_category_div.update(text=source.data['term'][new['1d']['indices'][0]]+'<br/>'+'line')
text_display_category_div.update(height=600)
text_display_not_category_div.update(text=source.data['term'][new['1d']['indices'][0]]+'<br/>'+'line')
text_display_not_category_div.update(height=600)
category_scatter_graph_layout.children[0].children[1].children[1].children[0].height = 600
category_scatter_graph_layout.children[0].children[1].children[1].children[1].height = 600
else:
text_input_word_search_in_documents.value = ''
text_display_category_div.update(text='')
text_display_category_div.update(height=0)
text_display_not_category_div.update(text='')
text_display_not_category_div.update(height=0)
category_scatter_graph_layout.children[0].children[1].children[1].children[0].height = 0
category_scatter_graph_layout.children[0].children[1].children[1].children[1].height = 0
As you can see I am trying to set both the Div and parent widgetbox's height back forth from 0 to 600 but the plot does not update. Perhaps I can solve this problem in the html of the div.text. Any ideas would be helpful.
The cut off text of the Div is shown below.
I figured out one possible solution. Setting the layout with a non fixed sizing mode messed up the plots but wrapping the individual Divs inside a widgetbox inside my layout with a sizing_mode of scale_height achieved the solution I needed.
widgetbox([text_display_category_div,text_display_not_category_div],sizing_mode = 'scale_height')

Is possible to do a flex layout with Qt?

I want to make something like a gridlayout but the layout must decide how many elements can be fitted in a row, and when the row is full continue with the next row.
QtGridLayout also fixes the columns width.
I want to something like this (this pictures was manually organised in Horizontals and verticals grids)
When the image size changes one of the buttons goes to first row.
((In this compositions both images looks with the same size, but actually second one is wider than first one).
Some one answer this question but remove it, so the credits are for my unknown friend.
Qt have an example named Flow Layout Example for a widget based form and another for Graphics View widget.

Layout fails to adjust screen size in Qt

I am trying to make a GUI similar to the layout in Image attached.
The problem starts when I add the three frames besides the stacked widget.
Frame one contains some labels for status.
Frame two contains some buttons and two sliders.
Frame three contains a tab widget.
I am adding suitable layouts at every stage. The layout fails to adjust to screen size and the window goes outside the limited size. I tried setting maximum size for the frames and stacked widget but the problem stays.
Can some one tell me if I am missing out on something.
Thank You
You should to understand, what is Layout is. And especially Layout stretching. Have you seen it?

Qt layout is larger than it should be

I had a layout all nicely designed in Qt, but as soon as I clicked on the parent window and set it to a grid layout, things got all wonky. I've read every tutorial I can find as well as the Qt designer manual and just cannot figure out why this is happening. I have attached a screenshot to show the problem:
As you can see, the vertical layout on the left insists on being wider than the children it contains. Both the label and the treeview are set to sizePolicy maximum, and the maximum width is set to 260px. The children themselves stay the correct size, but the vertical layout that contains them doesn't.
The vertical layout in the middle is set to expanding, and the one on the far right is setup the same as the one on the left, only that one appears to work. How do I make the first vertical layout conform to it's children's width?
Also, if I may sneak a second question in, I have a QTextEdit inside the tab widget in the lower right, but it will not fill to take up the space of the full tab view. You can't see that in the screenshot, but if I pull the tabview up, the textedit within it doesn't stretch with it. How do I make it conform to the size of the tab? It's already set to sizePolicy expanding, but that doesn't seem to help.
The problem is most likely that you need to experiment with "stretching" the layout. Stretch sets the size of layout cells in relation to each other. The default is 0, which means no stretching occurs.
In your case, I believe you want to set the stretch of the first column (column 0) to 0, and the stretch of the second and third columns to 1. This means that the first column will always be as small as possible, and the second and third columns will try to be equally wide.
You can set the stretch programmatically quite easily; for example, to set the first column to stretch 0:
layout->setColumnStretch(0, 0);
In Qt Designer you can access column and row stretches as any normal properties.

How to vertically align multiple tables or graphics in Lyx

What I wanted to do is that I had multiple tables and/or images of different heights and wanted them positioned on the page side by side, so that the tops of the objects were aligned.
I couldn't figure this out, it didn't matter whether I put these 'in-line' or in separate Boxes (Minipages) (that seemed to be aligned the way I wanted in the editor), in output Lyx always seemed to align these objects somehow around the center of their height and not the top.
Finally, (after several hours of googling and trying to figure this out) I have the answer, so I'm posting it below, because I hope someone like me will find it useful in the future.
The way I solved this is relatively easy.
For each image/table I created a Box (Minipage). In each Box I put, on the first line, Vertical Space (Insert -> Formatting -> Vertical Space) and set the size to 0 in. After the Vertical Space I inserted the graphic/table. This way, if you put several boxes next to each other (for example by setting their width to 25% page width, or whatever you desire), they will be aligned by the top in the output.
You can also do Ctrl+Space (to insert a 'protected space') and then Enter, which seems to work the exact same way.
Hope this helps.

Resources