Tkinter button widget can't be placed on Grid row

Viewed 26

I have code to create a GUI, I want to have a submit button at the bottom of the GUI to submit information. But the button seems fixed on a particular row and no amount of modification seems to change where I am able to place the button on the row, column seems to be working ok but row is not. I have used an oo approach to the gui where the main function calls a UI function which creates a root which is then passed into a defined Window function where a Frame is initialized. I have shown a snipped of code here from the overall project that hopefully shows the important information.

# Here, we are creating our class, Window, and inheriting from the Frame
# class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
class Window(tk.Frame):

 def __init__(self, master=None):
    
    tk.Frame.__init__(self, master)
    self.master = master
    
    # Changing the title of our master widget      
    self.master.title(TITLE)        
          
    self.submit = ttk.Button(self, text = 'SUBMIT', command = show_values)
    self.submit.grid(row = 5, column = 2, padx = 2, pady = 2)

def displayUI():

  root = tk.Tk()

  root.columnconfigure(3, weight=1) 
  root.rowconfigure(10, weight=1)

  # Size of GUI screen
  window_width = 600
  window_height = 600
    
  screen_width = root.winfo_screenwidth()
  screen_height = root.winfo_screenheight()

  center_x = int(screen_width/2 - window_width / 2)
  center_y = int(screen_height/2 - window_height / 2)

  root.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')

  #creation of an instance
  app = Window(root)
  app.pack()

  #mainloop 
  root.mainloop() 

if __name__ == "__main__":

displayUI()
0 Answers
Related