]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/misc/wxprojview.py
5b002df75e18b1b242714f81553dec8e28618a46
4 import wx
.lib
.stattext
as st
7 class MyFrame(wx
.Frame
):
9 wx
.Frame
.__init
__(self
, None, title
="wx Active Project",
10 style
=wx
.FRAME_NO_TASKBAR|wx
.STAY_ON_TOP
,
13 p
= wx
.Panel(self
)#, style=wx.SIMPLE_BORDER)
15 p
.SetBackgroundColour("sky blue")
16 self
.label
= st
.GenStaticText(p
, -1, "wx XXX")
17 self
.label
.SetBackgroundColour("sky blue")
18 self
.label
.SetFont(wx
.Font(14, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
19 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
20 sizer
.Add(self
.label
, 1, wx
.ALIGN_CENTER|wx
.ALL
, 2)
21 p
.SetSizerAndFit(sizer
)
22 self
.SetClientSize(p
.GetSize())
24 for obj
in [p
, self
.label
]:
25 obj
.Bind(wx
.EVT_LEFT_DOWN
, self
.OnLeftDown
)
26 obj
.Bind(wx
.EVT_LEFT_UP
, self
.OnLeftUp
)
27 obj
.Bind(wx
.EVT_MOTION
, self
.OnMouseMove
)
28 obj
.Bind(wx
.EVT_RIGHT_UP
, self
.OnRightUp
)
33 pos
= eval(cfg
.Read("Pos"))
34 # TODO: ensure this position is on-screen
37 self
.Bind(wx
.EVT_CLOSE
, self
.OnClose
)
38 self
.Bind(wx
.EVT_TIMER
, self
.OnUpdateVersion
)
39 self
.timer
= wx
.Timer(self
)
40 self
.timer
.Start(5000)
41 self
.OnUpdateVersion(None)
44 def OnUpdateVersion(self
, evt
):
46 if 'wxMSW' in wx
.PlatformInfo
:
49 link
= '/opt/wx/current'
50 if os
.path
.islink(link
):
51 rp
= os
.path
.realpath(link
)
52 ver
= os
.path
.split(rp
)[1]
54 if label
!= self
.label
.GetLabel():
55 self
.label
.SetLabel(label
)
56 self
.label
.GetContainingSizer().Layout()
59 def OnClose(self
, evt
):
62 cfg
.Write("Pos", str(self
.GetPosition().Get()))
68 def OnLeftDown(self
, evt
):
69 win
= evt
.GetEventObject()
72 pos
= win
.ClientToScreen(evt
.GetPosition())
73 origin
= self
.GetPosition()
76 self
.delta
= wx
.Point(dx
, dy
)
78 def OnLeftUp(self
, evt
):
79 if self
.capture
.HasCapture():
80 self
.capture
.ReleaseMouse()
82 def OnMouseMove(self
, evt
):
83 if evt
.Dragging() and evt
.LeftIsDown():
84 win
= evt
.GetEventObject()
85 pos
= win
.ClientToScreen(evt
.GetPosition())
86 fp
= (pos
.x
- self
.delta
.x
, pos
.y
- self
.delta
.y
)
89 def OnRightUp(self
, evt
):
94 app
= wx
.PySimpleApp()
95 app
.SetAppName("wxprojview")
96 app
.SetVendorName("Robin Dunn")