Python - Tkinter Scrollbar

0

I would like to put the buttons in an organized way from top to bottom, in order, but they are either above the Canvas, or in the middle, or below, not having a sequence.

Next I created Canvas and two scrollbar on the right and bottom. Here is the code:

from tkinter import *
root=Tk()
frame=Frame(root,width=300,height=300)
frame.grid(row=1,column=0)
canvas=Canvas(frame,bg='#FFFFFF',width=300,height=300,scrollregion=(0,0,500,500))
hbar=Scrollbar(frame,orient=HORIZONTAL)
hbar.pack(side=BOTTOM,fill=X)
hbar.config(command=canvas.xview)
vbar=Scrollbar(frame,orient=VERTICAL)
vbar.pack(side=RIGHT,fill=Y)
vbar.config(command=canvas.yview)
canvas.config(width=300,height=500)
canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
canvas.pack(side=LEFT,expand=True,fill=BOTH)

#with a circle in the center
def _create_circle(self, x, y, r, **kwargs):
    return self.create_oval(x-r, y-r, x+r, y+r, **kwargs)
Canvas.create_circle = _create_circle
canvas.create_circle(100, 100, 50, fill="blue", outline="#DDD", width=4)
#############################
"""
b = Button(text="hi there")
b.grid(row=1, column=2)
##b.pack(side="top")
c = Button(text="hi there1")
c.grid(row=2, column=2)
d = Button(text="hi there2")
d.grid(row=3, column=2)
root.mainloop()
"""
MyButton1 = Button(text="BUTTON1", width=10)
MyButton1.grid(column=1)
#MyButton1.pack(side=TOP,fill=Y)

MyButton2 = Button(text="BUTTON2", width=10)
MyButton2.grid(column=1)
#MyButton2.pack(side=RIGHT,fill=Y)

MyButton3 = Button(text="BUTTON3", width=10)
MyButton3.grid(column=1)

#MyButton3.pack(side=RIGHT,fill=Y)
    
asked by anonymous 01.03.2018 / 22:04

0 answers