python - Centering label in a frame -
i'm having trouble trying center label inside frame. i'm using grid geometry manager , i've tried sorts of things such using 'sticky' , re-arranging way frame works. heres screenshot of looks now:
i'm trying 'even' text centered in frame. here current code:
the_frame = frame(the_window, width= 400, height = 150, relief = 'groove', borderwidth = 2) the_frame.grid_propagate(false) the_text = label(the_frame, text = 'even') alpha_check = checkbutton(the_window, text = 'alpha', variable = boxtick0, command = oddoreven) beta_check = checkbutton(the_window, text = 'beta', variable = boxtick1, command = oddoreven) gamma_check = checkbutton(the_window, text = 'gamma', variable = boxtick2, command = oddoreven) margin = 5 the_frame.grid(padx = margin, pady = margin, row = 1, column = 1, columnspan = 3) the_text.grid(padx = margin, pady = margin, row = 2, column = 2, sticky=w+e+n+s) alpha_check.grid(padx = 5, pady = 5, row = 2, column = 1) beta_check.grid(padx = 5, pady = 5, row = 2, column = 2) gamma_check.grid(padx = 5, pady = 5, row = 2, column = 3)
you aren't assigning weights rows , columns. causes rows , columns big enough hold contents. if there room in gui, go unallocated. in case, column contains label wide enough fit label, , space right goes unused.
you can give column 0 , row 0 positive weight instruct grid
give space row , column this:
the_frame.grid_rowconfigure(1, weight=1) the_frame.grid_columnconfigure(1, weight=1)
also, you're putting label @ row one, column one, row , column numbering start @ zero. it's harmless since rows , columns don't contain take no space (unless give them weight).
Comments
Post a Comment