]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/misc/wxprojview.py
2 #----------------------------------------------------------------------
4 # A little app I use on my system to help me remember which version of
5 # wx I am corrently working on. I don't expect this to work for anybody
6 # else as it uses things that are specific to my setup.
8 #----------------------------------------------------------------------
11 import wx
.lib
.stattext
as st
14 class MyFrame(wx
.Frame
):
16 wx
.Frame
.__init
__(self
, None, title
="wx Active Project",
17 style
=wx
.FRAME_NO_TASKBAR|wx
.STAY_ON_TOP
,
20 p
= wx
.Panel(self
)#, style=wx.SIMPLE_BORDER)
22 p
.SetBackgroundColour("sky blue")
23 self
.label
= st
.GenStaticText(p
, -1, "wx XXX")
24 self
.label
.SetBackgroundColour("sky blue")
25 self
.label
.SetFont(wx
.Font(14, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
26 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
27 sizer
.Add(self
.label
, 1, wx
.ALIGN_CENTER|wx
.ALL
, 2)
28 p
.SetSizerAndFit(sizer
)
29 self
.SetClientSize(p
.GetSize())
31 for obj
in [p
, self
.label
]:
32 obj
.Bind(wx
.EVT_LEFT_DOWN
, self
.OnLeftDown
)
33 obj
.Bind(wx
.EVT_LEFT_UP
, self
.OnLeftUp
)
34 obj
.Bind(wx
.EVT_MOTION
, self
.OnMouseMove
)
35 obj
.Bind(wx
.EVT_RIGHT_UP
, self
.OnRightUp
)
40 pos
= eval(cfg
.Read("Pos"))
41 # TODO: ensure this position is on-screen
44 self
.Bind(wx
.EVT_CLOSE
, self
.OnClose
)
45 self
.Bind(wx
.EVT_TIMER
, self
.OnUpdateVersion
)
46 self
.timer
= wx
.Timer(self
)
47 self
.timer
.Start(5000)
48 self
.OnUpdateVersion(None)
51 def OnUpdateVersion(self
, evt
):
53 if 'wxMSW' in wx
.PlatformInfo
:
54 info
= open("c:/wxcurenv").read()
55 p1
= info
.find("WXCUR=") + 6
56 p2
= info
.find("\n", p1
)
59 link
= '/opt/wx/current'
60 if os
.path
.islink(link
):
61 rp
= os
.path
.realpath(link
)
62 ver
= os
.path
.split(rp
)[1]
64 if label
!= self
.label
.GetLabel():
65 self
.label
.SetLabel(label
)
66 self
.label
.GetContainingSizer().Layout()
69 def OnClose(self
, evt
):
72 cfg
.Write("Pos", str(self
.GetPosition().Get()))
78 def OnLeftDown(self
, evt
):
79 win
= evt
.GetEventObject()
82 pos
= win
.ClientToScreen(evt
.GetPosition())
83 origin
= self
.GetPosition()
86 self
.delta
= wx
.Point(dx
, dy
)
88 def OnLeftUp(self
, evt
):
89 if self
.capture
.HasCapture():
90 self
.capture
.ReleaseMouse()
92 def OnMouseMove(self
, evt
):
93 if evt
.Dragging() and evt
.LeftIsDown():
94 win
= evt
.GetEventObject()
95 pos
= win
.ClientToScreen(evt
.GetPosition())
96 fp
= (pos
.x
- self
.delta
.x
, pos
.y
- self
.delta
.y
)
99 def OnRightUp(self
, evt
):
104 app
= wx
.PySimpleApp()
105 app
.SetAppName("wxprojview")
106 app
.SetVendorName("Robin Dunn")