]> git.saurik.com Git - wxWidgets.git/blame - wxPython/misc/wxprojview.py
corrected WXDLLIMPEXP_ declaration for wxEventBlocker: it's part of core, not base
[wxWidgets.git] / wxPython / misc / wxprojview.py
CommitLineData
4617be08 1#!/usr/bin/env python
a1da78b3
RD
2#----------------------------------------------------------------------
3#
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.
7#
8#----------------------------------------------------------------------
4617be08
RD
9
10import wx
11import wx.lib.stattext as st
12import os
12251225 13import sys
4617be08
RD
14
15class MyFrame(wx.Frame):
12251225 16 def __init__(self, style=0):
4617be08 17 wx.Frame.__init__(self, None, title="wx Active Project",
12251225
RD
18 style=wx.FRAME_NO_TASKBAR | style
19 ,name="wxprojview"
4617be08 20 )
12251225 21 p = wx.Panel(self)
4617be08
RD
22
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())
31
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)
37
38 cfg = wx.Config.Get()
39 cfg.SetPath("/")
40 if cfg.Exists("Pos"):
41 pos = eval(cfg.Read("Pos"))
42 # TODO: ensure this position is on-screen
43 self.SetPosition(pos)
44
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)
50
51
52 def OnUpdateVersion(self, evt):
a1da78b3 53 ver = '?.?'
4617be08 54 if 'wxMSW' in wx.PlatformInfo:
a1da78b3
RD
55 info = open("c:/wxcurenv").read()
56 p1 = info.find("WXCUR=") + 6
57 p2 = info.find("\n", p1)
58 ver = info[p1:p2]
4617be08
RD
59 else:
60 link = '/opt/wx/current'
61 if os.path.islink(link):
62 rp = os.path.realpath(link)
63 ver = os.path.split(rp)[1]
64 label = 'wx %s' % ver
65 if label != self.label.GetLabel():
66 self.label.SetLabel(label)
67 self.label.GetContainingSizer().Layout()
68
69
70 def OnClose(self, evt):
71 cfg = wx.Config.Get()
72 cfg.SetPath("/")
73 cfg.Write("Pos", str(self.GetPosition().Get()))
74 self.timer.Stop()
75 evt.Skip()
76
77
78
79 def OnLeftDown(self, evt):
80 win = evt.GetEventObject()
81 win.CaptureMouse()
82 self.capture = win
83 pos = win.ClientToScreen(evt.GetPosition())
84 origin = self.GetPosition()
85 dx = pos.x - origin.x
86 dy = pos.y - origin.y
87 self.delta = wx.Point(dx, dy)
88
89 def OnLeftUp(self, evt):
90 if self.capture.HasCapture():
91 self.capture.ReleaseMouse()
92
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)
98 self.Move(fp)
99
100 def OnRightUp(self, evt):
101 self.Close()
102
103
104
105app = wx.PySimpleApp()
106app.SetAppName("wxprojview")
107app.SetVendorName("Robin Dunn")
12251225
RD
108style = wx.STAY_ON_TOP
109if len(sys.argv) > 1 and sys.argv[1] == 'nostayontop':
110 style=0
111frm = MyFrame(style)
4617be08
RD
112frm.Show()
113app.MainLoop()