May-23-2019, 04:40 AM
(May-22-2019, 06:59 PM)Yoriz Wrote: Something like this ?Thank you! This is exactly what I was looking for.
I've tried ".place" method for forms, but "relheight" is a constant value.
Could you please explain the code, so I could understand what's what?
The list of what I don't understand is:
1. Why did you give name for Tkinter in the beginning? In my code it worked better
2. What did you use class for?
3. What does "__init__" function do and why is it called so?
4. Purpose of the condition in the end of code and how does it work?
My code is written below:
from tkinter import * root = Tk() root.geometry("640x480") root.minsize(640, 480) frame_main = Frame(root, bg="blue", width=(root.winfo_width()), height=(root.winfo_height()*0.95)) frame_bottom = Frame(root, bg="yellow", width=(root.winfo_width()), height=(root.winfo_height() * 0.05)) frame_left = Frame(frame_main, bg="red", width=(frame_main.winfo_width()/2), height=(root.winfo_height())) frame_right = Frame(frame_main, bg="green", width=(frame_main.winfo_width()/2), height=(root.winfo_height())) def framemain(): frame_main.pack() frame_main.place(relwidth=1, relheight=0.95) def framebottom(): frame_bottom.pack() frame_bottom.place(relwidth=1, relheight=0.05, relx=0, rely=0.95) def frameleft(): frame_left.pack() frame_left.place(relwidth=0.5, relheight=1) def frameright(): frame_right.pack() frame_right.place(relwidth=0.5, relheight=1, relx=0.5) menu = Menu(root) root.config(menu=menu) menu.add_command(label="Check") def drawforms(): root.update_idletasks() framemain() framebottom() frameleft() frameright() drawforms() root.mainloop()Thanks in advance for reply!