I have written a guizero code that creates a new window with different amounts of information on it depending on what is selected. I was just wondering if there is a function to resize the window to fit all of the information. I am currently just making the window big enough to fit the largest amount of information but I would rather have it so it resizes it automatically.
And also is there a simple function so that if the window size is changed all of the widgets inside of it change size as well?
I think is not possible to automaticly resize the window but you can count the number of lines and resize the window.
numLines*defaultHeightByLine + height of the other elements
Related
So Qt Designer has this feature where you can resize the window you're working on. And that's fine and dandy, but every now and then, I accidentally drag it, and the window gets larger or smaller than I wanted it to be. The undo action doesn't undo the resizing, so that's a bummer. Also setting max and min sizes for the central widget doesn't do anything to fix this issue.
Is there a way I can have the window size locked?
Here's a demo:
Use QWidget::setFixedSize(w, h) for explicitly set width and height or QLayout::setSizeConstraint(QLayout::SetFixedSize) if you want the fixed size to be determined automatically based on content.
im doing an tkinter app in a computer, im using the grid() method to place the widgets. At first of the program i use this code to make the window size like the screen size:
an = self.root.winfo_screenwidth()
al = self.root.winfo_screenheight()
self.tam = '%dx%d'%(an,al)
self.root.geometry(self.tam)
And it works, but this app will be used through a remote desktop with different devices (different screen sizes).
How can I do that the widgets fill on the window like the original design? Thanks
Without any concrete examples of your code, there's no way to give more specific advice than to say that the solution is to design your program so that it resizes well.
Tkinter excels at making widgets fit, so as long as you use the options at your disposal (fill and expand for pack, row and column weights and other options for grid), and you don't hard-code any widths and heights, your GUI will easily work on a variety of systems.
Concrete pieces of advice:
don't use place except in very rare circumstances. While place supports relative positioning and sizing, it requires more work than pack and grid
design the GUI to work on the smallest display possible, and then make sure that when you manually resize the window it behaves properly
When using grid, make sure you always have at least one row and one column with a non-zero weight so that it knows how to allocate extra space
When using pack make sure you use expand and fill properly
Don't turn off the ability for the user to resize the window
I'm making a game with Tkinter canvas, and I'm planning to expand it (for UI) using grid.
Problem I'm facing is, that as it is, game window takes up bit more than the height of my screen. If I add anything on top, some parts will be completely off-screen. I can not change resolution of the canvas, as some parts move on pixel-basis. Thus I want to change size of the whole 'image' that Tkinter renders(canvas + other possible labels), that is the whole window.
Is there a way to do so?
window snapshot for reference
I want to test the appearance of a window on a smaller monitor than the one I'm using on the development machine.
I tried with set_geometry_hints() (setting minimum and maximum width and height), set_resizable(False), set_default_size(), and set_size_request(). However every time the window is bigger, because child widgets request a bigger size.
I noticed on a smaller monitor with a resolution smaller than the request size, the widgets are truncated. I have to be sure this doesn't happen refactoring the GUI layout, so I want to simulate on my monitor.
How can I make the window smaller without truncating widgets?
Setting the window size request should be sufficient. If your UI makes the window larger that is the same as your widgets becoming truncated on a smaller monitor.
To prevent this you'll need to put widgets that grows your UI inside scrollable windows. Watch out for labels. You will need to get them to wrap properly.
Is it possible that when a Tkinter window is made bigger or larger, everyhting in the window is scaled?
So all the proportions stay the same but their sizes vary.
Now when the window is resized all the buttons etc stay the same so I disabled resize because there is no point, it just looks bad.
No, it is likely not possible, depending on what you mean by "everything" and what you mean by "scaled". Any widget can be made to stretch to fill its allotted space. Text widgets and canvas widgets, for example, scale nicely. A button or label will fill the space it's in, but the text inside the widget won't change (that is also true of text and canvas widgets).
It's possible to organize your GUI so that when the window resizes, everything remains in its proper place at its original size. Having buttons that automatically scale is not something most people would expect. Disabling resizing usually results in a poor user experience -- users should have the ability to make a window larger or smaller.