(original) (raw)
import Tkinter as Tk def scrollable(Widget, master, *a, **kw): frame = Tk.Frame(master) frame.grid_columnconfigure(0, weight=1) frame.grid_rowconfigure(0, weight=1) widget = Widget(frame, *a, **kw) widget.grid(row=0, column=0, sticky="news") scroll_x = Tk.Scrollbar(frame, command=widget.xview, orient=Tk.HORIZONTAL) scroll_x.grid(row=1, column=0, sticky="news") scroll_y = Tk.Scrollbar(frame, command=widget.yview, orient=Tk.VERTICAL) scroll_y.grid(row=0, column=1, sticky="news") widget.configure(xscrollcommand=scroll_x.set, yscrollcommand=scroll_y.set) for name in ("pack", "grid", "place"): setattr(widget, name, getattr(frame, name)) return widget import Tix root = Tix.Tk() grid = scrollable(Tix.Grid, root) grid.pack(fill=Tix.BOTH, expand=True) for y in xrange(30): for x in xrange(6): grid.set(x, y, text=repr((x, y))) root.mainloop()