Добрый день. У меня проблема с рамкой прокрутки. Я использую готовое решение (http://effbot.org/zone/tkinter-autoscrollbar.htm)
Но я не знаю, как развернуть LabelFrame ("контакты") окном? Извините за мой английский
#prevzato z http://effbot.org/zone/tkinter-autoscrollbar.htm
from Tkinter import *
class AutoScrollbar(Scrollbar):
# a scrollbar that hides itself if it's not needed. only
# works if you use the grid geometry manager.
def set(self, lo, hi):
if float(lo) <= 0.0 and float(hi) >= 1.0:
# grid_remove is currently missing from Tkinter!
self.tk.call("grid", "remove", self)
else:
self.grid()
Scrollbar.set(self, lo, hi)
def pack(self, **kw):
raise TclError, "cannot use pack with this widget"
def place(self, **kw):
raise TclError, "cannot use place with this widget"
root = Tk()
master = Frame(root)
master.grid(row=0, column=0, sticky=N+S+E+W)
vscrollbar = AutoScrollbar(master)
vscrollbar.grid(row=0, column=1, sticky=N+S)
hscrollbar = AutoScrollbar(master, orient=HORIZONTAL)
hscrollbar.grid(row=1, column=0, sticky=E+W)
master.rowconfigure(0, weight=1)
master.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
root.columnconfigure(0, weight=1)
canvas = Canvas(master,
yscrollcommand=vscrollbar.set,
xscrollcommand=hscrollbar.set, bg = "red", width = 200, height = 400)
canvas.grid(row=0, column=0, sticky=N+S+E+W)
canvas.rowconfigure(0, weight=1)
canvas.columnconfigure(0, weight=1)
vscrollbar.config(command=canvas.yview)
hscrollbar.config(command=canvas.xview)
# make the canvas expandable
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
#
# create canvas contents
kontakty = LabelFrame(canvas, width = 600, height =400, text = "Skupina" )
kontakty.grid(row=0, column=0, sticky=N+S+E+W)
kontakty.rowconfigure(0, weight=1)
kontakty.columnconfigure(0, weight=1)
canvas.create_window(0, 0, anchor=NW, window=kontakty)
kontakty.update_idletasks()
canvas.config(scrollregion=canvas.bbox("all"))
root.mainloop()