Reputation: 71
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
Upvotes: 3
Views: 2675
Reputation: 385890
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:
place
except in very rare circumstances. While place
supports relative positioning and sizing, it requires more work than pack
and grid
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 spacepack
make sure you use expand
and fill
properlyUpvotes: 2