Python Forum
[Tkinter] Forms' expansion
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Forms' expansion
#4
(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!
Reply


Messages In This Thread
Forms' expansion - by Gupi - May-22-2019, 04:01 PM
RE: Forms' expansion - by heiner55 - May-22-2019, 05:17 PM
RE: Forms' expansion - by Yoriz - May-22-2019, 06:59 PM
RE: Forms' expansion - by Gupi - May-23-2019, 04:40 AM
RE: Forms' expansion - by Yoriz - May-23-2019, 05:27 AM
RE: Forms' expansion - by Gupi - May-23-2019, 05:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Question about data grid for forms - desktop program Everest 5 3,579 Apr-18-2019, 11:04 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020