-1

I'm trying to figure out how I could place a tkinter "Checkbuton" exactly where I want in my frame in x and y "place" method doesn't seem to work with "Checbuttons". Any solution ?

1 Answers1

1

Tkinter place() Method : This geometry manager organizes widgets by placing them in a specific position in the parent widget.

Syntax:

widget.place( place_options )

Here is the list of possible options −

anchor − The exact spot of widget other options refer to: may be N, E, S, W, NE, NW, SE, or SW, compass directions indicating the corners and sides of widget; default is NW (the upper left corner of widget)

bordermode − INSIDE (the default) to indicate that other options refer to the parent's inside (ignoring the parent's border); OUTSIDE otherwise.

height, width − Height and width in pixels.

relheight, relwidth − Height and width as a float between 0.0 and 1.0, as a fraction of the height and width of the parent widget.

relx, rely − Horizontal and vertical offset as a float between 0.0 and 1.0, as a fraction of the height and width of the parent widget.

x, y − Horizontal and vertical offset in pixels.

example:

class GUI:
    def __init__(self, master):
        self.master = master
        CheckVar1 = IntVar()
        C1 = Checkbutton(master, text="Select", variable=CheckVar1, \
                         onvalue=1, offvalue=0)
        C1.place(x=60, y=50)

root = Tk()
my_gui = GUI(root)
root.mainloop()
ncica
  • 7,015
  • 1
  • 15
  • 37