~ubuntu-branches/ubuntu/trusty/boa-constructor/trusty

« back to all changes in this revision

Viewing changes to Debugger/PathsPanel.py

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2007-01-23 21:32:29 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070123213229-1d9lxp9c4dutjwv5
Add a .desktop file (Closes: #349081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#Boa:FramePanel:PathsPanel
2
 
 
3
 
from wxPython.wx import *
4
 
from wxPython.grid import *
5
 
 
6
 
[wxID_PATHSPANEL, wxID_PATHSPANELADD_BTN, wxID_PATHSPANELGRID, 
7
 
 wxID_PATHSPANELREMOVE_BTN, wxID_PATHSPANELSTATICBOX1, 
8
 
] = map(lambda _init_ctrls: wxNewId(), range(5))
9
 
 
10
 
class PathsPanel(wxPanel):
11
 
    def _init_coll_staticBoxSizer1_Items(self, parent):
12
 
        # generated method, don't edit
13
 
 
14
 
        parent.AddWindow(self.grid, 1, border=8, flag=wxALL | wxGROW)
15
 
        parent.AddSizer(self.boxSizer1, 0, border=0, flag=wxALIGN_RIGHT)
16
 
 
17
 
    def _init_coll_boxSizer1_Items(self, parent):
18
 
        # generated method, don't edit
19
 
 
20
 
        parent.AddWindow(self.add_btn, 0, border=8, flag=wxALL | wxALIGN_RIGHT)
21
 
        parent.AddWindow(self.remove_btn, 0, border=8,
22
 
              flag=wxBOTTOM | wxTOP | wxRIGHT)
23
 
 
24
 
    def _init_sizers(self):
25
 
        # generated method, don't edit
26
 
        self.staticBoxSizer1 = wxStaticBoxSizer(box=self.staticBox1,
27
 
              orient=wxVERTICAL)
28
 
 
29
 
        self.boxSizer1 = wxBoxSizer(orient=wxHORIZONTAL)
30
 
 
31
 
        self._init_coll_staticBoxSizer1_Items(self.staticBoxSizer1)
32
 
        self._init_coll_boxSizer1_Items(self.boxSizer1)
33
 
 
34
 
        self.SetSizer(self.staticBoxSizer1)
35
 
 
36
 
    def _init_ctrls(self, prnt):
37
 
        # generated method, don't edit
38
 
        wxPanel.__init__(self, id=wxID_PATHSPANEL, name='PathsPanel',
39
 
              parent=prnt, pos=wxPoint(316, 277), size=wxSize(523, 274),
40
 
              style=wxTAB_TRAVERSAL)
41
 
        self.SetClientSize(wxSize(515, 247))
42
 
 
43
 
        self.staticBox1 = wxStaticBox(id=wxID_PATHSPANELSTATICBOX1,
44
 
              label='Sever to client filepath mappings', name='staticBox1',
45
 
              parent=self, pos=wxPoint(0, 0), size=wxSize(515, 247), style=0)
46
 
 
47
 
        self.grid = wxGrid(id=wxID_PATHSPANELGRID, name='grid', parent=self,
48
 
              pos=wxPoint(13, 21), size=wxSize(489, 173),
49
 
              style=wxSUNKEN_BORDER)
50
 
        self.grid.SetDefaultRowSize(20)
51
 
        self.grid.SetColLabelSize(20)
52
 
        self.grid.SetRowLabelSize(0)
53
 
 
54
 
        self.add_btn = wxButton(id=wxID_PATHSPANELADD_BTN, label='Add',
55
 
              name='add_btn', parent=self, pos=wxPoint(344, 210),
56
 
              size=wxSize(75, 24), style=0)
57
 
        EVT_BUTTON(self.add_btn, wxID_PATHSPANELADD_BTN, self.OnAdd_btnButton)
58
 
 
59
 
        self.remove_btn = wxButton(id=wxID_PATHSPANELREMOVE_BTN, label='Remove',
60
 
              name='remove_btn', parent=self, pos=wxPoint(427, 210),
61
 
              size=wxSize(75, 24), style=0)
62
 
        EVT_BUTTON(self.remove_btn, wxID_PATHSPANELREMOVE_BTN,
63
 
              self.OnRemove_btnButton)
64
 
 
65
 
        self._init_sizers()
66
 
 
67
 
    def __init__(self, parent, id, pos, size, style, name):
68
 
        self._init_ctrls(parent)
69
 
 
70
 
        self.SetDimensions(pos.x, pos.y, size.x, size.y)
71
 
        
72
 
    def init_paths(self, paths):
73
 
        self.paths = paths
74
 
        numRows = len(self.paths)
75
 
        self.grid.CreateGrid(numRows, 2)
76
 
        self.grid.SetColLabelValue(0, 'Map server filenames starting with')
77
 
        self.grid.SetColLabelValue(1, 'To client filenames starting with')
78
 
        colWidth = self.grid.GetClientSize().x/2
79
 
        self.grid.SetColSize(0, colWidth)
80
 
        self.grid.SetColSize(1, colWidth)
81
 
        
82
 
        for row, (svr, clnt) in zip(range(numRows), self.paths):
83
 
            self.grid.SetCellValue(row, 0, svr)
84
 
            self.grid.SetCellValue(row, 1, clnt)
85
 
        self.grid.ForceRefresh()
86
 
    
87
 
    def read_paths(self):
88
 
        self.grid.SaveEditControlValue()
89
 
        return  [(self.grid.GetCellValue(row, 0), self.grid.GetCellValue(row, 1))
90
 
                 for row in range(self.grid.GetNumberRows())]
91
 
 
92
 
    def OnAdd_btnButton(self, event):
93
 
        self.grid.AppendRows(1)
94
 
 
95
 
    def OnRemove_btnButton(self, event):
96
 
        row = self.grid.GetGridCursorRow()
97
 
        if row != -1:
98
 
            self.grid.DeleteRows(row, 1)
99
 
 
 
1
#Boa:FramePanel:PathsPanel
 
2
 
 
3
import wx
 
4
import wx.grid
 
5
 
 
6
[wxID_PATHSPANEL, wxID_PATHSPANELADD_BTN, wxID_PATHSPANELGRID, 
 
7
 wxID_PATHSPANELREMOVE_BTN, wxID_PATHSPANELSTATICBOX1, 
 
8
] = [wx.NewId() for _init_ctrls in range(5)]
 
9
 
 
10
class PathsPanel(wx.Panel):
 
11
    def _init_coll_staticBoxSizer1_Items(self, parent):
 
12
        # generated method, don't edit
 
13
 
 
14
        parent.AddWindow(self.grid, 1, border=8, flag=wx.ALL | wx.GROW)
 
15
        parent.AddSizer(self.boxSizer1, 0, border=0, flag=wx.ALIGN_RIGHT)
 
16
 
 
17
    def _init_coll_boxSizer1_Items(self, parent):
 
18
        # generated method, don't edit
 
19
 
 
20
        parent.AddWindow(self.add_btn, 0, border=8,
 
21
              flag=wx.ALL | wx.ALIGN_RIGHT)
 
22
        parent.AddWindow(self.remove_btn, 0, border=8,
 
23
              flag=wx.BOTTOM | wx.TOP | wx.RIGHT)
 
24
 
 
25
    def _init_sizers(self):
 
26
        # generated method, don't edit
 
27
        self.staticBoxSizer1 = wx.StaticBoxSizer(box=self.staticBox1,
 
28
              orient=wx.VERTICAL)
 
29
 
 
30
        self.boxSizer1 = wx.BoxSizer(orient=wx.HORIZONTAL)
 
31
 
 
32
        self._init_coll_staticBoxSizer1_Items(self.staticBoxSizer1)
 
33
        self._init_coll_boxSizer1_Items(self.boxSizer1)
 
34
 
 
35
        self.SetSizer(self.staticBoxSizer1)
 
36
 
 
37
    def _init_ctrls(self, prnt):
 
38
        # generated method, don't edit
 
39
        wx.Panel.__init__(self, id=wxID_PATHSPANEL, name='PathsPanel',
 
40
              parent=prnt, pos=wx.Point(316, 277), size=wx.Size(523, 274),
 
41
              style=wx.TAB_TRAVERSAL)
 
42
        self.SetClientSize(wx.Size(515, 247))
 
43
 
 
44
        self.staticBox1 = wx.StaticBox(id=wxID_PATHSPANELSTATICBOX1,
 
45
              label='Sever to client filepath mappings', name='staticBox1',
 
46
              parent=self, pos=wx.Point(0, 0), size=wx.Size(515, 247), style=0)
 
47
 
 
48
        self.grid = wx.grid.Grid(id=wxID_PATHSPANELGRID, name='grid',
 
49
              parent=self, pos=wx.Point(13, 25), size=wx.Size(489, 169),
 
50
              style=wx.SUNKEN_BORDER)
 
51
        self.grid.SetDefaultRowSize(20)
 
52
        self.grid.SetColLabelSize(20)
 
53
        self.grid.SetRowLabelSize(0)
 
54
 
 
55
        self.add_btn = wx.Button(id=wxID_PATHSPANELADD_BTN, label='Add',
 
56
              name='add_btn', parent=self, pos=wx.Point(344, 210),
 
57
              size=wx.Size(75, 24), style=0)
 
58
        self.add_btn.Bind(wx.EVT_BUTTON, self.OnAdd_btnButton,
 
59
              id=wxID_PATHSPANELADD_BTN)
 
60
 
 
61
        self.remove_btn = wx.Button(id=wxID_PATHSPANELREMOVE_BTN,
 
62
              label='Remove', name='remove_btn', parent=self, pos=wx.Point(427,
 
63
              210), size=wx.Size(75, 24), style=0)
 
64
        self.remove_btn.Bind(wx.EVT_BUTTON, self.OnRemove_btnButton,
 
65
              id=wxID_PATHSPANELREMOVE_BTN)
 
66
 
 
67
        self._init_sizers()
 
68
 
 
69
    def __init__(self, parent, id, pos, size, style, name):
 
70
        self._init_ctrls(parent)
 
71
 
 
72
        self.SetDimensions(pos.x, pos.y, size.x, size.y)
 
73
 
 
74
    def init_paths(self, paths):
 
75
        self.paths = paths
 
76
        numRows = len(self.paths)
 
77
        self.grid.CreateGrid(numRows, 2)
 
78
        self.grid.SetColLabelValue(0, 'Map server filenames starting with')
 
79
        self.grid.SetColLabelValue(1, 'To client filenames starting with')
 
80
        colWidth = self.grid.GetClientSize().x/2
 
81
        self.grid.SetColSize(0, colWidth)
 
82
        self.grid.SetColSize(1, colWidth)
 
83
 
 
84
        for row, (svr, clnt) in zip(range(numRows), self.paths):
 
85
            self.grid.SetCellValue(row, 0, svr)
 
86
            self.grid.SetCellValue(row, 1, clnt)
 
87
        self.grid.ForceRefresh()
 
88
 
 
89
    def read_paths(self):
 
90
        self.grid.SaveEditControlValue()
 
91
        return  [(self.grid.GetCellValue(row, 0), self.grid.GetCellValue(row, 1))
 
92
                 for row in range(self.grid.GetNumberRows())]
 
93
 
 
94
    def OnAdd_btnButton(self, event):
 
95
        self.grid.AppendRows(1)
 
96
 
 
97
    def OnRemove_btnButton(self, event):
 
98
        row = self.grid.GetGridCursorRow()
 
99
        if row != -1:
 
100
            self.grid.DeleteRows(row, 1)