In Progress: Tkinter 3000 WCK MiniViews

Updated August 19, 2003 | Fredrik Lundh

Some WCK widgets support pluggable subviews, called “miniviews”.

Other widgets can display a number of miniviews in a single master widget; for example, the BlockList widget displays a list of flowing, variable-height miniviews in a scrollable list.

A typical miniview implements the following methods:

class MyView:

    def config(self, view):
        # ... parent view was reconfigured ...

    def resize(self, view, size):
        # ... parent view was resized ...
        self.size = size

    def reflow(self, view, width):
        # ... alternative resize for flowing containers ...
        self.size = size
        return height

    def repair(self, view, bbox, draw):
        # ... parent view needs updating ...

    def destroy(self, view):
        # ... the miniview is about to be destroyed ...

Here’s a sample view wrapper (untested):

class View(Widget):

    def __init__(self, master, view, **options):
        self.view = view
        self.ui_init(master, options)

    def ui_handle_config(self):
        self.view.config(self)

    def ui_handle_resize(self, width, height):
        self.view.resize(self, (width, height))

    def ui_handle_repair(self, draw, x0, y0, x1, y1):
        self.view.repair(self, (x0, y0, x1, y1), draw)

    def ui_handle_destroy(self):
        self.view.destroy(self)
 

A Django site. rendered by a django application. hosted by webfaction.