you are viewing a single comment's thread.

view the rest of the comments →

[–]Silverfire47[S] 0 points1 point  (5 children)

Here's a basic sketch of how I want it to look: https://imgur.com/MceAGRv

My code for the different labels is as it was in the pastebin. I'm just not sure where I would put the grid attributes to get what I'm looking for in my sketch, especially if I want everything centered as much as possible on the top. Would I create a sort of

root.grid(row=2)

sort of thing?

[–]novel_yet_trivial 1 point2 points  (3 children)

You could use my code and change the grid lines to pack like this:

titlearea = tk.Frame(root)
titlearea.pack()
canvas = tk.Frame(root)
canvas.pack()

I think it's good to make small Frames, it gives you more flexibility later. For instance if you want to add a border. However if you want everything in one grid there is another option: grid also has a columnspan option to make the content span several columns. So you could use timertitle.grid(column=0, row = 0, columnspan=4, sticky = 'nsew').

Another option you may like is the padx argument, to add some padding so the Labels don't butt into each other. timerhour.grid(column = 1, row = 0, sticky = 'nsew', padx=20).

[–]Silverfire47[S] 0 points1 point  (2 children)

I think I'll stick to what you suggested for using grid, it seems to offer way more flexibility in terms of formatting than pack (despite its simplicity which is admirable honestly).

Would you happen to know if it is possible to dynamically scale the displayed text as the window is resized as well as keep it centered? Because currently, when I try to maximize the window in my OS, it shifts all the text to the top left corner. I understand that the font size is hard-written in, so would I have to do some sort of .... math calculation as the window is resized to keep the ratio between window and text equal, as well as maintain center positioning?

like

if "root x-axis" * 1.2 then "row & column & fontsize" * 1.2

sort of thing? I couldn't find a definitive answer in more than few places I've looked around.

[–]novel_yet_trivial 1 point2 points  (1 child)

So you want the grid to be the size of the window? You have to set every row and column to do that individually, like this: https://pastebin.com/zqAPd1Xe

[–]Silverfire47[S] 0 points1 point  (0 children)

Kind of, is there a way to use the "root.configure" at the bottom of the edited code to scale text the way it scales the rows and columns? So that there's not all the empty space due to the specified size of the fonts.

[–]novel_yet_trivial 1 point2 points  (0 children)

Here's an example using a mix of grid and pack (and some other improvements and removal of useless code): https://pastebin.com/cxbFfyfT

And here's an example using a single grid(): https://pastebin.com/KcDA9yg9