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