user
user

Reputation: 1

Python tkinter : how to resize widgets when i resize the screen

I'm beginner... When the code below is executed, how do I make the widgets inside increase when the screen size is increased to width? but, it couldn't resized..

Does it matter if I use either pack or grid?

i can't solve it....

  from tkinter import *
  from tkinter import ttk


  class program: 
      def __init__(self): 
          self.root = Tk() 
          self.root.title("Python") 
          self.root.resizable(True, True) 
          self.create_project()

      def create_project(self):
          Topic_Label = ttk.Label(self.root, text="program")
          Topic_Label.pack(side="top")

          Record_LabelFrame = LabelFrame(self.root, text="Record information") 
          Record_LabelFrame.pack(side="top", anchor=W, padx=10)

          date = ttk.Label(Record_LabelFrame, text="date")
          date.grid(column=0, row=0, sticky=W)

          Topic_Label_Entry1 = ttk.Entry(Record_LabelFrame)
          Topic_Label_Entry1.grid(column=0, row=1)

          time = ttk.Label(Record_LabelFrame, text="time")
          time.grid(column=1, row=0, sticky=W)

          Topic_Label_Combo1 = ttk.Combobox(Record_LabelFrame)
          Topic_Label_Combo1.grid(column=1, row=1)

          recorder = ttk.Label(Record_LabelFrame, text="record")
          recorder.grid(column=2, row=0, sticky=W)
 
          Topic_Label_Entry2 = ttk.Entry(Record_LabelFrame)
          Topic_Label_Entry2.grid(column=2, row=1)

          loc = ttk.Label(Record_LabelFrame, text="location")
          loc.grid(column=0, row=2, sticky="W")

          RadioVar = IntVar()

          Radio_Frame = Frame(Record_LabelFrame)
          Radio_Frame.grid(column=0, row=3, sticky=W)

          Topic_Label_Radio1 = ttk.Radiobutton(Radio_Frame, text="A", variable=RadioVar, value=1)
          Topic_Label_Radio1.grid(column=0, row=0)

          Topic_Label_Radio2 = ttk.Radiobutton(Radio_Frame, text="B", variable=RadioVar, value=2)
          Topic_Label_Radio2.grid(column=1, row=0)

          Topic_Label_Radio3 = ttk.Radiobutton(Radio_Frame, text="C", variable=RadioVar, value=3)
          Topic_Label_Radio3.grid(column=2, row=0)

          count = ttk.Label(Record_LabelFrame, text="count")
          count.grid(column=1, row=2, sticky="W")

          Topic_Label_Combo2 = ttk.Combobox(Record_LabelFrame)
          Topic_Label_Combo2.grid(column=1, row=3)

          seed_name = ttk.Label(Record_LabelFrame, text="seed")
          seed_name.grid(column=2, row=2, sticky="W")

          Topic_Label_Entry4 = ttk.Entry(Record_LabelFrame)
          Topic_Label_Entry4.grid(column=2, row=3)

  mt = program() 
  mt.root.mainloop()

I want to print like this that widget resize automatically when i resize the screen

https://i.sstatic.net/iSbaJ.png https://i.sstatic.net/mzv9R.png

Upvotes: 0

Views: 130

Answers (0)

Related Questions