I have a vbox in main window. Within the vbox is a menu and a fix. The fix is used to load image. I should change the size of main window according to the size of image. But I cannot find a way to get the size of menu bar. So the bottom part of the image cannot be displayed(I set the window unresizable).
I don't explicitly set the size of the menu. So it seems that all the functions ending with 'request' return -1.
How can I get the actual size of the menu bar? Or how can I display the image entirely?
Related
I have a layout question for python with qt5.
So, there is a main window with a normal vertical layout with 2 widgets.
The first one is a widget with a scrollarea which has a minimumSize & maximumSize set.
The second one is another widget with yet another scrollarea widget.
My goal is this. I load some content in the first widget and depending on the content it should either shrink or grow to the set min/max sizes and if it gets bigger than maxsize the scrollarea should take effect.
The second widget should always take all the rest of the available space.
I've tried all kinds of sizePolicy combinations but can't get it to quite to work. The second widget has a sizePolicy of Prefered/Prefered with vertical stretch set to 1, so it takes all the available space for itself.
The 1st widget has a miniumSize of 100 and a maximumSize of 250. So ideally it should shrink to something between 100-250 if the content is less and it should grow to 250 and activate the scrollbar if the content is getting bigger.
If I update the content of widget one (i.e. by clicking on a button) it should 1. resize/shrink/grow so the content fits, but not smaller than 100 and not larger than 250. If I have less content I should not be able to make widget one reszie to 250 - it shoudl always just take the exact needed height.
Any idea on how to do that?
example layout
Your scrollarea isn't going to change size, because it's a scrollarea. It doesn't need to size itself to its content, because the size of the contents of a scrollarea is basically unbounded. You can just scroll more. If you want to change the size of the first scrollarea, you're going to have to set its height manually.
I'm developping a text editor with PyQt5 and I want to create my own "title bar".
I've created my own title bar and I have something just like the image above. The only problem is the window's frame. So far I've been using:
setWindowFlags(Qt.FramelessWindowHint)
But I just realised that with this flag there is no frame (cause it's "Frameless") and without the frame I can't resize my window by dragging the border.
I've tried CustomizeWindowHint flag but the title bar is still there, just without icon, name and buttons.
A temporary solution is to detect whenenver the mouse enter the window by installing eventFilter, get its positions, if it's on the border then we have to change the cursor icon (up, left, down, left-up, left-down,...) and if the user drags then calculate and resize window.
Another solution is to set 8 QSizegrip at every corner of the window but we will have to somehow hide those grips and make sure that they don't take any space because we will add 3 grips at the TOP of the title bar so it will be ugly.
But I don't really like these solutions. So is there anyway that I can hide the title bar and keep the frame?
I am using a python 2.5 + pygtk.
I have added a text area in a scrolled window. Text area buffer will be updates with program output.
I want to set scrolledwindow->vscrollbar at the bottom.
I tried different options given in pygtk docs. But no success..
Any suggestion what needs to do???
You have to fetch the vertical adjustment of your scrolled window, then set its value to its upper bound:
adjustment = yourScrolledWindow.get_vadjustment()
adjustment.set_value(adjustment.get_upper())
I have a simple pygtk/glade window with a menu and a 3x3 grid. Each row of the grid consists on: two labels and a button.
When the Window is resized, the labels holds the same font size, but the buttons get resized, and they could become HUGE if the windows gets very big.
How could I manage to keep my buttons with the same size always (the "standar" size of a button, just like they are when the interface is just opened) no matter if the Window is resized?
You just have to set the fill and expand parameters of the Buttons to False (uncheck them in the Glade interface).
You would also want to put each button at the center of a 3x3 GtkTable, so it will appear centered and not aligned at the top of the cell
I'm creating an app where I drag button widgets into a panel. I would like to have a visible grid in the panel where i drop the widgets so the widgets will be aligned to the grid.
I guess it isn't hard making a grid where the squares are 15x15 pixels using a GridBagSizer(since the widgets will span between multiple cells), but how can the number of squares be made dynamically according to the size of the panel?
Do I have to calculate how many squares i need to fill the panel on init and on each resize?
Using python and wxpython btw.
Oerjan Pettersen
Don't use a sizer at all for this. Just position the buttons yourself, with whatever co-ordinate rounding you like. (using wxWindow::SetSize()).
(The point of a sizer is that the buttons will get moved and/or resized when the window is resized. As you don't want that behaviour, then you shouldn't use a sizer.)