Package nltk :: Package draw :: Class CanvasFrame
[hide private]
[frames] | no frames]

Class CanvasFrame

source code

object --+
         |
        CanvasFrame

A Tkinter frame containing a canvas and scrollbars. CanvasFrame uses a ScrollWatcherWidget to ensure that all of the canvas widgets contained on its canvas are within its scrollregion. In order for CanvasFrame to make these checks, all canvas widgets must be registered with add_widget when they are added to the canvas; and destroyed with destroy_widget when they are no longer needed.

If a CanvasFrame is created with no parent, then it will create its own main window, including a "Done" button and a "Print" button.

Instance Methods [hide private]
 
__init__(self, parent=None, **kw)
Create a new CanvasFrame.
source code
 
_find_room(self, widget, desired_x, desired_y)
Try to find a space for a given widget.
source code
 
_init_menubar(self) source code
 
add_widget(self, canvaswidget, x=None, y=None)
Register a canvas widget with this CanvasFrame.
source code
Tkinter.Canvas
canvas(self)
Returns: The canvas managed by this CanvasFrame.
source code
 
destroy(self, *e)
Destroy this CanvasFrame.
source code
 
destroy_widget(self, canvaswidget)
Remove a canvas widget from this CanvasFrame.
source code
 
mainloop(self, *args, **kwargs)
Enter the Tkinter mainloop.
source code
 
pack(self, cnf={}, **kw)
Pack this CanvasFrame.
source code
None
print_to_file(self, filename=None)
Print the contents of this CanvasFrame to a postscript file.
source code
 
remove_widget(self, canvaswidget) source code
4-tuple of int
scrollregion(self)
Returns: The current scroll region for the canvas managed by this CanvasFrame.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent=None, **kw)
(Constructor)

source code 

Create a new CanvasFrame.

Parameters:
  • parent (Tkinter.BaseWidget or Tkinter.Tk) - The parent Tkinter widget. If no parent is specified, then CanvasFrame will create a new main window.
  • kw - Keyword arguments for the new Canvas. See the documentation for Tkinter.Canvas for more information.
Overrides: object.__init__

add_widget(self, canvaswidget, x=None, y=None)

source code 

Register a canvas widget with this CanvasFrame. The CanvasFrame will ensure that this canvas widget is always within the Canvas's scrollregion. If no coordinates are given for the canvas widget, then the CanvasFrame will attempt to find a clear area of the canvas for it.

Parameters:
  • canvaswidget (CanvasWidget) - The new canvas widget. canvaswidget must have been created on this CanvasFrame's canvas.
  • x (int) - The initial x coordinate for the upper left hand corner of canvaswidget, in the canvas's coordinate space.
  • y (int) - The initial y coordinate for the upper left hand corner of canvaswidget, in the canvas's coordinate space.

canvas(self)

source code 
Returns: Tkinter.Canvas
The canvas managed by this CanvasFrame.

destroy(self, *e)

source code 

Destroy this CanvasFrame. If this CanvasFrame created a top-level window, then this will close that window.

destroy_widget(self, canvaswidget)

source code 

Remove a canvas widget from this CanvasFrame. This deregisters the canvas widget, and destroys it.

mainloop(self, *args, **kwargs)

source code 

Enter the Tkinter mainloop. This function must be called if this frame is created from a non-interactive program (e.g. from a secript); otherwise, the frame will close as soon as the script completes.

pack(self, cnf={}, **kw)

source code 

Pack this CanvasFrame. See the documentation for Tkinter.Pack for more information.

print_to_file(self, filename=None)

source code 

Print the contents of this CanvasFrame to a postscript file. If no filename is given, then prompt the user for one.

Parameters:
  • filename (string) - The name of the file to print the tree to.
Returns: None

scrollregion(self)

source code 
Returns: 4-tuple of int
The current scroll region for the canvas managed by this CanvasFrame.