]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/ShapedWindow.py
Updated version number
[wxWidgets.git] / wxPython / demo / ShapedWindow.py
index e484f96aad872834c2a40c86c0c436e993672f26..98d969a2e2d80569a4706cb86d95cf709e21a2cb 100644 (file)
@@ -1,68 +1,68 @@
 
 
-from wxPython.wx import *
-import images
+import  wx
+import  images
 
 #----------------------------------------------------------------------
 
 
 #----------------------------------------------------------------------
 
-class TestFrame(wxFrame):
+class TestFrame(wx.Frame):
     def __init__(self, parent, log):
         self.log = log
     def __init__(self, parent, log):
         self.log = log
-        wxFrame.__init__(self, parent, -1, "Shaped Window",
+        wx.Frame.__init__(self, parent, -1, "Shaped Window",
                          style =
                          style =
-                           wxFRAME_SHAPED
-                         | wxSIMPLE_BORDER
-                         | wxFRAME_NO_TASKBAR
-                         | wxSTAY_ON_TOP
+                           wx.FRAME_SHAPED
+                         | wx.SIMPLE_BORDER
+                         | wx.FRAME_NO_TASKBAR
+                         | wx.STAY_ON_TOP
                          )
 
         self.hasShape = False
                          )
 
         self.hasShape = False
-        self.delta = wxPoint(0,0)
+        self.delta = (0,0)
 
 
-        EVT_LEFT_DCLICK(self, self.OnDoubleClick)
-        EVT_LEFT_DOWN(self, self.OnLeftDown)
-        EVT_LEFT_UP(self, self.OnLeftUp)
-        EVT_MOTION(self, self.OnMouseMove)
-        EVT_RIGHT_UP(self, self.OnExit)
-        EVT_PAINT(self, self.OnPaint)
+        self.Bind(wx.EVT_LEFT_DCLICK,   self.OnDoubleClick)
+        self.Bind(wx.EVT_LEFT_DOWN,     self.OnLeftDown)
+        self.Bind(wx.EVT_LEFT_UP,       self.OnLeftUp)
+        self.Bind(wx.EVT_MOTION,        self.OnMouseMove)
+        self.Bind(wx.EVT_RIGHT_UP,      self.OnExit)
+        self.Bind(wx.EVT_PAINT,         self.OnPaint)
 
         self.bmp = images.getTuxBitmap()
         w, h = self.bmp.GetWidth(), self.bmp.GetHeight()
         self.SetClientSize( (w, h) )
 
 
         self.bmp = images.getTuxBitmap()
         w, h = self.bmp.GetWidth(), self.bmp.GetHeight()
         self.SetClientSize( (w, h) )
 
-        if wxPlatform != "__WXMAC__":
+        if wx.Platform != "__WXMAC__":
             # wxMac clips the tooltip to the window shape, YUCK!!!
             self.SetToolTipString("Right-click to close the window\n"
                                   "Double-click the image to set/unset the window shape")
 
             # wxMac clips the tooltip to the window shape, YUCK!!!
             self.SetToolTipString("Right-click to close the window\n"
                                   "Double-click the image to set/unset the window shape")
 
-        if wxPlatform == "__WXGTK__":
+        if wx.Platform == "__WXGTK__":
             # wxGTK requires that the window be created before you can
             # set its shape, so delay the call to SetWindowShape until
             # this event.
             # wxGTK requires that the window be created before you can
             # set its shape, so delay the call to SetWindowShape until
             # this event.
-            EVT_WINDOW_CREATE(self, self.SetWindowShape)
+            self.Bind(wx.EVT_WINDOW_CREATE, self.SetWindowShape)
         else:
             # On wxMSW and wxMac the window has already been created, so go for it.
             self.SetWindowShape()
 
         else:
             # On wxMSW and wxMac the window has already been created, so go for it.
             self.SetWindowShape()
 
-        dc = wxClientDC(self)
+        dc = wx.ClientDC(self)
         dc.DrawBitmap(self.bmp, (0,0), True)
 
 
     def SetWindowShape(self, *evt):
         # Use the bitmap's mask to determine the region
         dc.DrawBitmap(self.bmp, (0,0), True)
 
 
     def SetWindowShape(self, *evt):
         # Use the bitmap's mask to determine the region
-        r = wxRegionFromBitmap(self.bmp)
+        r = wx.RegionFromBitmap(self.bmp)
         self.hasShape = self.SetShape(r)
 
 
     def OnDoubleClick(self, evt):
         if self.hasShape:
         self.hasShape = self.SetShape(r)
 
 
     def OnDoubleClick(self, evt):
         if self.hasShape:
-            self.SetShape(wxRegion())
+            self.SetShape(wx.Region())
             self.hasShape = False
         else:
             self.SetWindowShape()
 
 
     def OnPaint(self, evt):
             self.hasShape = False
         else:
             self.SetWindowShape()
 
 
     def OnPaint(self, evt):
-        dc = wxPaintDC(self)
+        dc = wx.PaintDC(self)
         dc.DrawBitmap(self.bmp, (0,0), True)
 
     def OnExit(self, evt):
         dc.DrawBitmap(self.bmp, (0,0), True)
 
     def OnExit(self, evt):
@@ -71,11 +71,11 @@ class TestFrame(wxFrame):
 
     def OnLeftDown(self, evt):
         self.CaptureMouse()
 
     def OnLeftDown(self, evt):
         self.CaptureMouse()
-        pos = self.ClientToScreen(evt.GetPosition())
-        origin = self.GetPosition()
-        dx = pos.x - origin.x
-        dy = pos.y - origin.y
-        self.delta = wxPoint(dx, dy)
+        x, y = self.ClientToScreen(evt.GetPosition())
+        originx, originy = self.GetPosition()
+        dx = x - originx
+        dy = y - originy
+        self.delta = ((dx, dy))
 
 
     def OnLeftUp(self, evt):
 
 
     def OnLeftUp(self, evt):
@@ -85,8 +85,8 @@ class TestFrame(wxFrame):
 
     def OnMouseMove(self, evt):
         if evt.Dragging() and evt.LeftIsDown():
 
     def OnMouseMove(self, evt):
         if evt.Dragging() and evt.LeftIsDown():
-            pos = self.ClientToScreen(evt.GetPosition())
-            fp = (pos.x - self.delta.x, pos.y - self.delta.y)
+            x, y = self.ClientToScreen(evt.GetPosition())
+            fp = (x - self.delta[0], y - self.delta[1])
             self.Move(fp)
 
 
             self.Move(fp)
 
 
@@ -118,5 +118,5 @@ sensitive to the mouse in those areas either.
 if __name__ == '__main__':
     import sys,os
     import run
 if __name__ == '__main__':
     import sys,os
     import run
-    run.main(['', os.path.basename(sys.argv[0])])
+    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])