I am having problems with the fact that the canvas / window does not just expand to the size of the information that I put in the widget. I want to add scrollbars and limit the size of the canvas. This is for a popup in a larger program. Here is my code
from Tkinter import *
import os
import tkMessageBox
class ClusterDialog(Toplevel):
def __init__(self, parent, displayClass, clusterInfo, title = None):
Toplevel.__init__(self, parent)
self.transient(parent)
if title:
self.title(title)
self.parent = parent
self.dClass = displayClass
self.clusterInfo = clusterInfo
self.varList = None
self.boxList = None
self.name = None
self.frameTopLevel = Frame(self,bd=2, width = 200,height=300)
self.frameTopLevel.pack()
self.buttonbox(self.frameTopLevel)
self.frame = Frame(self.frameTopLevel, width = 200,height=300)
self.frame.grid(row=0,column=0)
self.frame.pack()
self.canvas=Canvas(self.frame,bg='#FFFFFF',width=300,height=300,scrollregion=(0,0,500,1000))
hbar = Scrollbar(self.frame,orient=HORIZONTAL)
hbar.pack(side=BOTTOM,fill=X)
hbar.config(command=self.canvas.xview)
vbar=Scrollbar(self.frame,orient=VERTICAL)
vbar.pack(side=RIGHT,fill=Y)
vbar.config(command=self.canvas.yview)
self.canvas.config(width=300,height=300)
self.canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
self.canvas.pack(side=LEFT,expand=True,fill=BOTH)
self.frame.config(height = 100)
self.body(self.canvas)
self.canvas.config(width=300,height=300)
self.grab_set()
Basically I am trying to create a topLevel frame with a frame inside it that contains the scroll bar and canvas. self.buttonbox (self.frameTopLevel) adds a few buttons, and self.body (self.canvas) adds a bunch of flags to manipulate the user.
, , , , . ? , , .