I am new to Python and Tkinter.
I am practicing on the use of Frames, Canvas, and Scrollbars and I got a problem:
I have a Canvas that acts as my Master and a Frame that is on the specific coordinate of Canvas.
I will put Buttons and labels in the frame so I chose not to use listbox.
Now, how do I make the scrollbar on the frame in such that if the label in the frame exceeds more than 5 (Each label are put in vertical way), then ScrollBar will appear?
Here is the sample Code:
from Tkinter import *
class GUI():
def __init__(self):
self.namelist = ["Mark","Anna","Jason","Lenna","Leo","Zucharich","Robinson","AReallyLongNameThatMightExist"]
self.canvas = Canvas(width=1200,height=700)
self.canvas.pack(expand=YES,fill=BOTH)
def Friends(self):
controlframe = Frame(self.canvas)
controlframe.place(x=600,y=300)
#Frame for showing names of friends
for x in self.namelist:
frame = Frame(controlframe)
frame.pack()
Name = Label(frame,text="%s "%x).pack(side=LEFT)
chatButton = Button(frame,text="Chat").pack(side=LEFT)
delButton = Button(frame,text="Delete").pack(side=LEFT)
setcloseButton = Button(frame,text="Set Close").pack(side=LEFT)
setgroupButton = Button(frame,text="Set Group").pack(side=LEFT)
mainloop()
GUI = GUI()
GUI.Friends()