Hello everyone
How can i make the button be on the left side or right side please
Part of the code

Button(self, text = "start", command = self.launch).grid(row = 7, column = 0, columnspan = 1,)

Thanks in advance

Recommended Answers

All 3 Replies

assuming this is tkinter, you could use pack instead of grid and -side left or -side right.

You can also use the stick attribute

Button(self,text="Start",command=self.launch).grid(row = 7, column = 0, columnspan = 1, sticky=E)

But sticky attribute can be really messy. Just experiment with the positioning. Other values for sticky are N and W and S. You can also use them in combination

You could potentially us a label as a spacer:

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

root = tk.Tk()
root['bg'] = 'yellow'

# use label as spacer, match background color
spacer = tk.Label(root, width=20, bg='yellow')
spacer.grid(row=1, column=1)

button = tk.Button(root, text="Button1")
# puts button to the right of label spacer
button.grid(row=1, column=2)

root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.