]>
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
15 class MyFrame(wx
.Frame
):
16 def __init__(self
, style
=0):
17 wx
.Frame
.__init
__(self
, None, title
="wx Active Project",
18 style
=wx
.FRAME_NO_TASKBAR | style
23 p
.SetBackgroundColour("sky blue")
24 self
.label
= st
.GenStaticText(p
, -1, "wx XXX")
25 self
.label
.SetBackgroundColour("sky blue")
26 self
.label
.SetFont(wx
.Font(14, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
27 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
28 sizer
.Add(self
.label
, 1, wx
.ALIGN_CENTER|wx
.ALL
, 2)
29 p
.SetSizerAndFit(sizer
)
30 self
.SetClientSize(p
.GetSize())
32 for obj
in [p
, self
.label
]:
33 obj
.Bind(wx
.EVT_LEFT_DOWN
, self
.OnLeftDown
)
34 obj
.Bind(wx
.EVT_LEFT_UP
, self
.OnLeftUp
)
35 obj
.Bind(wx
.EVT_MOTION
, self
.OnMouseMove
)
36 obj
.Bind(wx
.EVT_RIGHT_UP
, self
.OnRightUp
)
41 pos
= eval(cfg
.Read("Pos"))
42 # TODO: ensure this position is on-screen
45 self
.Bind(wx
.EVT_CLOSE
, self
.OnClose
)
46 self
.Bind(wx
.EVT_TIMER
, self
.OnUpdateVersion
)
47 self
.timer
= wx
.Timer(self
)
48 self
.timer
.Start(5000)
49 self
.OnUpdateVersion(None)
52 def OnUpdateVersion(self
, evt
):
54 if 'wxMSW' in wx
.PlatformInfo
:
55 info
= open("c:/wxcurenv").read()
56 p1
= info
.find("WXCUR=") + 6
57 p2
= info
.find("\n", p1
)
60 link
= '/opt/wx/current'
61 if os
.path
.islink(link
):
62 rp
= os
.path
.realpath(link
)
63 ver
= os
.path
.split(rp
)[1]
65 if label
!= self
.label
.GetLabel():
66 self
.label
.SetLabel(label
)
67 self
.label
.GetContainingSizer().Layout()
70 def OnClose(self
, evt
):
73 cfg
.Write("Pos", str(self
.GetPosition().Get()))
79 def OnLeftDown(self
, evt
):
80 win
= evt
.GetEventObject()
83 pos
= win
.ClientToScreen(evt
.GetPosition())
84 origin
= self
.GetPosition()
87 self
.delta
= wx
.Point(dx
, dy
)
89 def OnLeftUp(self
, evt
):
90 if self
.capture
.HasCapture():
91 self
.capture
.ReleaseMouse()
93 def OnMouseMove(self
, evt
):
94 if evt
.Dragging() and evt
.LeftIsDown():
95 win
= evt
.GetEventObject()
96 pos
= win
.ClientToScreen(evt
.GetPosition())
97 fp
= (pos
.x
- self
.delta
.x
, pos
.y
- self
.delta
.y
)
100 def OnRightUp(self
, evt
):
105 app
= wx
.PySimpleApp()
106 app
.SetAppName("wxprojview")
107 app
.SetVendorName("Robin Dunn")
108 style
= wx
.STAY_ON_TOP
109 if len(sys
.argv
) > 1 and sys
.argv
[1] == 'nostayontop':