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 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#Boa:Dialog:PathsMappingDlg
import pprint
import wx
from PathsPanel import PathsPanel
def create(parent):
return PathsMappingDlg(parent)
[wxID_PATHSMAPPINGDLG, wxID_PATHSMAPPINGDLGCANCELBTN,
wxID_PATHSMAPPINGDLGOKBTN, wxID_PATHSMAPPINGDLGPATHSPANEL,
] = [wx.NewId() for _init_ctrls in range(4)]
class PathsMappingDlg(wx.Dialog):
_custom_classes = {'wx.Panel': ['PathsPanel'],}
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Dialog.__init__(self, id=wxID_PATHSMAPPINGDLG,
name='PathsMappingDlg', parent=prnt, pos=wx.Point(345, 257),
size=wx.Size(489, 293), style=wx.DEFAULT_DIALOG_STYLE,
title='Edit client/sever paths mapping')
self.SetClientSize(wx.Size(481, 266))
self.pathsPanel = PathsPanel(id=wxID_PATHSMAPPINGDLGPATHSPANEL,
name='pathsPanel', parent=self, pos=wx.Point(0, 0),
size=wx.Size(480, 216), style=wx.TAB_TRAVERSAL)
self.okBtn = wx.Button(id=wx.ID_OK, label='OK', name='okBtn',
parent=self, pos=wx.Point(320, 232), size=wx.Size(75, 23),
style=0)
self.okBtn.Bind(wx.EVT_BUTTON, self.OnOkbtnButton,
id=wxID_PATHSMAPPINGDLGOKBTN)
self.cancelBtn = wx.Button(id=wx.ID_CANCEL, label='Cancel',
name='cancelBtn', parent=self, pos=wx.Point(400, 232),
size=wx.Size(75, 23), style=0)
def __init__(self, parent, paths):
self._init_ctrls(parent)
self.pathsPanel.init_paths(paths)
import Utils
self.conf = Utils.createAndReadConfig('Explorer')
self.writeConfig = Utils.writeConfig
def OnOkbtnButton(self, event):
if self.conf:
paths = self.pathsPanel.read_paths()
if self.conf.has_section('debugger.remote'):
self.conf.set('debugger.remote', 'paths', pprint.pformat(paths))
self.writeConfig(self.conf)
self.EndModal(wx.ID_OK)
def showPathsMappingDlg(parent, paths):
dlg = PathsMappingDlg(parent, paths)
try:
if dlg.ShowModal() != wx.ID_OK:
return None
else:
return dlg.pathsPanel.read_paths()
finally:
dlg.Destroy()
if __name__ == '__main__':
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
print showPathsMappingDlg(None, [('1', '2'), ('3', '4')])
app.MainLoop()
|