Skinnable/Stylable windows in wxPython?

Daniel Bickett dbickett at gmail.com
Wed Dec 22 16:19:59 EST 2004


> > Not only would this make it more multi-platform (I have no access to
> > a GTK machine so I don't know if this works. Could someone please
> > check?)
> 
> Looks like it works (I had to change frame.Show() to frame.Show(1)
> though, but that could be because it's an old version).

No, I think that was a slip on my part when copying the code from one
screen to the next :)

> One odd thing
> though: the Windows version doesn't react to clicking or dragging the
> mouse, which seems to be the expected behavior.

I noted in my second post that the functionality of the window
(clicking and dragging et al) was, even in the wxPopupWindow demo,
implemented by using the EVT macros. Copied from the demo, the code is
as follows:

def OnMouseLeftDown(self, evt):
    self.ldPos = evt.GetEventObject().ClientToScreen(evt.GetPosition())
    self.wPos = self.GetPosition()
    self.CaptureMouse()

def OnMouseMotion(self, evt):
    if evt.Dragging() and evt.LeftIsDown():
        dPos = evt.GetEventObject().ClientToScreen(evt.GetPosition())
        nPos = (self.wPos.x + (dPos.x - self.ldPos.x),
                self.wPos.y + (dPos.y - self.ldPos.y))
        self.Move(nPos)

def OnMouseLeftUp(self, evt):
    self.ReleaseMouse()

def OnRightUp(self, evt):
    self.Show(False)
    self.Destroy()

> The GTK version can be
> moved by dragging the mouse; even just clicking the mouse moves the
> window somewhat down and to the left.

That's interesting... I wonder if using those methods would conflict
at all. Also, while I'm on that note, when double clicking on the
resulting window (after binding those events), double click causes a
non-fatal, yet annoying, traceback saying that "the mouse could not be
released because it has not yet been caught blah blah", so I just
wrapped the contents of OnMouseLeftUp in a try..except..pass.

Daniel Bickett



More information about the Python-list mailing list