Tkinter and window manager

Michael P. Reilly arcege at shore.net
Wed Sep 1 11:12:15 EDT 1999


Stephane Conversy <conversy at lri.fr> wrote:
: Fredrik Lundh wrote:

:> Stephane Conversy <conversy at lri.fr> wrote:
:> > I want the window manager to notify me when a window is raised
:> > (typically when I click on the bar...)
:> >
:> > How to do this ?
:>
:> here's one (portable) way: look for <FocusIn> events
:> on the toplevel window.
:>
:> </F>

: mmm not exactly. Basically I have a tool palette and a multiple
: documents interface
: and I want the action triggered onto the palette to have its effect on
: the top document
: window. <FocusIn> happens when I only fly over a window, which doesn't
: make it
: go on top of the window stack...

True, but one a FocusIn event, you could make palette rise above the
other windows.
  def coconut_dropped(self, event):
    event.widget.tkraise()

But if you are asking "how can I have one window affect the widgets
in another window?"  That's is much more of a design issue.  I would
suggest having an "application" object which abstracts what you need
done and calling methods on that object from the palette.

  class DrawApp:
    def __init__(self, *args):
      self.process_arguments(args)
      self.current_operation = 'pointer'
    def change_to_pen(self):
      self.current_operation = 'drawWithPen'
    def change_to_brush(self):
      self.current_operation = 'drawWithBrush'
    def start_polygon(self):
      self.current_operation = 'drawPolygon'
      self.operation_data = []
      self.op_state = 'waitingForFirstPoint'
    ...

This makes the palette definition seperate from the implimentation of
the canvas operations.

This approach can also work with multiwindow focus: the palette affects
the last/current window (different "DrawApp" objects) with the focus.

:     stef

  -Arcege





More information about the Python-list mailing list