Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Attributes
turtle.ScrolledCanvas Class Reference

List of all members.

Public Member Functions

def __init__
def reset
def adjustScrolls
def onResize
def bbox
def cget
def config
def bind
def unbind
def focus_force

Public Attributes

 height
 canvheight
 bg
 hscroll
 vscroll
 canvwidth

Private Attributes

 _rootwindow
 _canvas

Detailed Description

Modeled after the scrolled canvas class from Grayons's Tkinter book.

Used as the default canvas, which pops up automatically when
using turtle graphics functions or the Turtle class.

Definition at line 329 of file turtle.py.


Constructor & Destructor Documentation

def turtle.ScrolledCanvas.__init__ (   self,
  master,
  width = 500,
  height = 350,
  canvwidth = 600,
  canvheight = 500 
)

Definition at line 336 of file turtle.py.

00336 
00337                                           canvwidth=600, canvheight=500):
00338         TK.Frame.__init__(self, master, width=width, height=height)
00339         self._rootwindow = self.winfo_toplevel()
00340         self.width, self.height = width, height
00341         self.canvwidth, self.canvheight = canvwidth, canvheight
00342         self.bg = "white"
00343         self._canvas = TK.Canvas(master, width=width, height=height,
00344                                  bg=self.bg, relief=TK.SUNKEN, borderwidth=2)
00345         self.hscroll = TK.Scrollbar(master, command=self._canvas.xview,
00346                                     orient=TK.HORIZONTAL)
00347         self.vscroll = TK.Scrollbar(master, command=self._canvas.yview)
00348         self._canvas.configure(xscrollcommand=self.hscroll.set,
00349                                yscrollcommand=self.vscroll.set)
00350         self.rowconfigure(0, weight=1, minsize=0)
00351         self.columnconfigure(0, weight=1, minsize=0)
00352         self._canvas.grid(padx=1, in_ = self, pady=1, row=0,
00353                 column=0, rowspan=1, columnspan=1, sticky='news')
00354         self.vscroll.grid(padx=1, in_ = self, pady=1, row=0,
00355                 column=1, rowspan=1, columnspan=1, sticky='news')
00356         self.hscroll.grid(padx=1, in_ = self, pady=1, row=1,
00357                 column=0, rowspan=1, columnspan=1, sticky='news')
00358         self.reset()
00359         self._rootwindow.bind('<Configure>', self.onResize)

Here is the caller graph for this function:


Member Function Documentation

Adjust scrollbars according to window- and canvas-size.

Definition at line 378 of file turtle.py.

00378 
00379     def adjustScrolls(self):
00380         """ Adjust scrollbars according to window- and canvas-size.
00381         """
00382         cwidth = self._canvas.winfo_width()
00383         cheight = self._canvas.winfo_height()
00384         self._canvas.xview_moveto(0.5*(self.canvwidth-cwidth)/self.canvwidth)
00385         self._canvas.yview_moveto(0.5*(self.canvheight-cheight)/self.canvheight)
00386         if cwidth < self.canvwidth or cheight < self.canvheight:
00387             self.hscroll.grid(padx=1, in_ = self, pady=1, row=1,
00388                               column=0, rowspan=1, columnspan=1, sticky='news')
00389             self.vscroll.grid(padx=1, in_ = self, pady=1, row=0,
00390                               column=1, rowspan=1, columnspan=1, sticky='news')
00391         else:
00392             self.hscroll.grid_forget()
00393             self.vscroll.grid_forget()

Here is the caller graph for this function:

def turtle.ScrolledCanvas.bbox (   self,
  args 
)
'forward' method, which canvas itself has inherited...

Definition at line 398 of file turtle.py.

00398 
00399     def bbox(self, *args):
00400         """ 'forward' method, which canvas itself has inherited...
00401         """
00402         return self._canvas.bbox(*args)

def turtle.ScrolledCanvas.bind (   self,
  args,
  kwargs 
)
'forward' method, which canvas itself has inherited...

Definition at line 413 of file turtle.py.

00413 
00414     def bind(self, *args, **kwargs):
00415         """ 'forward' method, which canvas itself has inherited...
00416         """
00417         self._canvas.bind(*args, **kwargs)

Here is the caller graph for this function:

def turtle.ScrolledCanvas.cget (   self,
  args,
  kwargs 
)
'forward' method, which canvas itself has inherited...

Definition at line 403 of file turtle.py.

00403 
00404     def cget(self, *args, **kwargs):
00405         """ 'forward' method, which canvas itself has inherited...
00406         """
00407         return self._canvas.cget(*args, **kwargs)

def turtle.ScrolledCanvas.config (   self,
  args,
  kwargs 
)
'forward' method, which canvas itself has inherited...

Definition at line 408 of file turtle.py.

00408 
00409     def config(self, *args, **kwargs):
00410         """ 'forward' method, which canvas itself has inherited...
00411         """
00412         self._canvas.config(*args, **kwargs)

'forward' method, which canvas itself has inherited...

Definition at line 423 of file turtle.py.

00423 
00424     def focus_force(self):
00425         """ 'forward' method, which canvas itself has inherited...
00426         """
00427         self._canvas.focus_force()
00428 
00429 __forwardmethods(ScrolledCanvas, TK.Canvas, '_canvas')
00430 

Here is the call graph for this function:

def turtle.ScrolledCanvas.onResize (   self,
  event 
)
self-explanatory

Definition at line 394 of file turtle.py.

00394 
00395     def onResize(self, event):
00396         """self-explanatory"""
00397         self.adjustScrolls()

Here is the call graph for this function:

def turtle.ScrolledCanvas.reset (   self,
  canvwidth = None,
  canvheight = None,
  bg = None 
)
Adjust canvas and scrollbars according to given canvas size.

Definition at line 360 of file turtle.py.

00360 
00361     def reset(self, canvwidth=None, canvheight=None, bg = None):
00362         """Adjust canvas and scrollbars according to given canvas size."""
00363         if canvwidth:
00364             self.canvwidth = canvwidth
00365         if canvheight:
00366             self.canvheight = canvheight
00367         if bg:
00368             self.bg = bg
00369         self._canvas.config(bg=bg,
00370                         scrollregion=(-self.canvwidth//2, -self.canvheight//2,
00371                                        self.canvwidth//2, self.canvheight//2))
00372         self._canvas.xview_moveto(0.5*(self.canvwidth - self.width + 30) /
00373                                                                self.canvwidth)
00374         self._canvas.yview_moveto(0.5*(self.canvheight- self.height + 30) /
00375                                                               self.canvheight)
00376         self.adjustScrolls()
00377 

Here is the caller graph for this function:

def turtle.ScrolledCanvas.unbind (   self,
  args,
  kwargs 
)
'forward' method, which canvas itself has inherited...

Definition at line 418 of file turtle.py.

00418 
00419     def unbind(self, *args, **kwargs):
00420         """ 'forward' method, which canvas itself has inherited...
00421         """
00422         self._canvas.unbind(*args, **kwargs)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 342 of file turtle.py.

Definition at line 338 of file turtle.py.

Definition at line 341 of file turtle.py.

Definition at line 340 of file turtle.py.

Definition at line 363 of file turtle.py.

Definition at line 339 of file turtle.py.

Definition at line 344 of file turtle.py.

Definition at line 346 of file turtle.py.


The documentation for this class was generated from the following file: