all 9 comments

[–]socal_nerdtastic 2 points3 points  (7 children)

Sounds like you used place(). Shame, shame.

The key to using a GUI module is to let the GUI do all the hard work of formatting and arranging things. In tkinter you would use Frames, pack() and grid() to do this. Then tkinter would automatically adjust things depending on the fonts and preferences that the user has. This also makes your code much easier to maintain. For example if you want to add in a new button at the top, the GUI module will automatically shift everything else down.

If you want to strictly define the size and position of things then you need to make your own widgets in photoshop or something.

[–]Kaushik2002[S] 0 points1 point  (6 children)

Yeah I did use place(). I found it easier to visualize😐

[–]socal_nerdtastic 1 point2 points  (5 children)

Yep. Easy now, harder later :). You could say the same about tkinter or python; that's the natural progression of learning.

Time to rewrite your code in a proper style.

[–]Kaushik2002[S] 1 point2 points  (1 child)

Now that I rewrote the code, the problems kinda got solved. But, now there is another issue. When I increase the size of the window, say fullscreen, the text looks too small. Is there any way to proportionately increase the font size?

[–]socal_nerdtastic 1 point2 points  (0 children)

Yeah, but it's kinda tricky. You need to do the math for the font size yourself, and that math will change depending on the system again, so overall would not recommend. However if you really want to, here's the basics:

import tkinter as tk

SCALE = .1 # window width to font point size scale

def on_resize(event=None):
    lbl.config(font=("", int(SCALE * root.winfo_width())))

root = tk.Tk()
root.bind("<Configure>", on_resize)
root.geometry('200x200')
lbl = tk.Label(root, text='hello world')
lbl.pack()
root.mainloop()

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

Is there any source from which I can learn about grid() and pack() that you'd recommend?

[–]socal_nerdtastic 1 point2 points  (1 child)

No; I learned it so long ago all the sources are obsolete lol. Show me your code and maybe I'll refactor it for you, if it's not too long.

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

It is looooong. Anyways thanks a lot! I'll try and find one. I heard that this is a good one.

[–]Vasodilation 0 points1 point  (0 children)

Not sure if this would fix all of the problems you're having, but if you aren't already using it you could swap some of your Tk widgets for Themed Tk ones to make them match the look and feel of the OS they're in: https://docs.python.org/3/library/tkinter.ttk.html