File: wxXrcPanel.py

package info (click to toggle)
boa-constructor 0.3.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,188 kB
  • ctags: 8,857
  • sloc: python: 54,163; sh: 66; makefile: 36
file content (62 lines) | stat: -rw-r--r-- 2,412 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#Boa:Frame:wxFrame1

""" This example demonstrates how to load .xrc files created e.g. by XRCed.

Support only allows creating/linking the components. The contents of the
xcr file is not displayed at design-time and can certainly not be managed in 
the Designer.

Note that the XRCSupport plug-in must be installed. """ 

from wxPython.wx import *
from wxPython.xrc import *

def create(parent):
    return wxFrame1(parent)

[wxID_WXFRAME1, wxID_WXFRAME1BOAXRCPANEL, wxID_WXFRAME1BUTTON1, wxID_WXFRAME1PANEL1] = map(lambda _init_ctrls: wxNewId(), range(4))

class wxFrame1(wxFrame):
    def _init_utils(self):
        # generated method, don't edit
        self.xmlResource1 = wxXmlResource(filemask = 'Input.xrc')

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wxFrame.__init__(self, id = wxID_WXFRAME1, name = '', parent = prnt, pos = wxPoint(250, 248), size = wxSize(240, 165), style = wxDEFAULT_FRAME_STYLE, title = 'wxFrame1')
        self._init_utils()
        self.SetClientSize(wxSize(232, 138))

        self.panel1 = wxPanel(id = wxID_WXFRAME1PANEL1, name = 'panel1', parent = self, pos = wxPoint(0, 0), size = wxSize(232, 138), style = wxTAB_TRAVERSAL)

        self.boaXrcPanel = self.xmlResource1.LoadPanel(name = 'boaXrcPanel', parent = self.panel1)
        self.boaXrcPanel.SetSize(wxSize(216, 88))
        self.boaXrcPanel.SetPosition(wxPoint(8, 8))

        self.button1 = wxButton(id = wxID_WXFRAME1BUTTON1, label = 'OK', name = 'button1', parent = self.panel1, pos = wxPoint(144, 104), size = wxSize(75, 23), style = 0)
        EVT_BUTTON(self.button1, wxID_WXFRAME1BUTTON1, self.OnButton1Button)

    def __init__(self, parent):
        self._init_ctrls(parent)

        # to reference an xrc control
        self.xrcLabel = XRCCTRL(self, 'inputLbl')
        self.xrcTextCtrl = XRCCTRL(self, 'inputCtrl')
        self.xrcCheck = XRCCTRL(self, 'inputCheck')
        # to bind an event to an xrc control
        EVT_CHECKBOX(self, self.xrcCheck.GetId(), self.OnCheckbox)

    def OnButton1Button(self, event):
        print 'Entered %s'%self.xrcTextCtrl.GetValue()
        self.Close()

    def OnCheckbox(self, event):
        print 'Checkbox clicked'


if __name__ == '__main__':
    app = wxPySimpleApp()
    wxInitAllImageHandlers()
    frame = create(None)
    frame.Show()
    app.MainLoop()