| 12 | 'field':TableField, 'hist':HistCanvas, 'cmap':ColorMap} |
| 13 | |
| 14 | class ParaDialog (wx.Dialog): |
| 15 | def __init__( self, parent, title): |
| 16 | wx.Dialog.__init__ (self, parent, -1, title, style = wx.DEFAULT_DIALOG_STYLE) |
| 17 | self.lst = wx.BoxSizer( wx.VERTICAL ) |
| 18 | self.tus = [] |
| 19 | |
| 20 | self.on_ok = self.on_cancel = self.on_help = None |
| 21 | self.ctrl_dic = {} |
| 22 | boxBack = wx.BoxSizer() |
| 23 | boxBack.Add(self.lst, 0, wx.ALL, 10) |
| 24 | self.SetSizer( boxBack ) |
| 25 | self.Layout() |
| 26 | #self.handle = self.handle_ |
| 27 | |
| 28 | def commit(self, state): |
| 29 | self.Destroy() |
| 30 | if state=='ok' and self.on_ok:self.on_ok() |
| 31 | if state=='cancel' and self.on_cancel:self.on_cancel() |
| 32 | |
| 33 | def add_confirm(self, modal=True): |
| 34 | # self.lst.AddStretchSpacer(1) |
| 35 | sizer = wx.BoxSizer( wx.HORIZONTAL ) |
| 36 | self.btn_ok = wx.Button( self, wx.ID_OK, 'OK', wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT ) |
| 37 | sizer.Add( self.btn_ok, 0, wx.ALIGN_RIGHT|wx.ALL, 5 ) |
| 38 | |
| 39 | self.btn_cancel = wx.Button( self, wx.ID_CANCEL, 'Cancel', wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT ) |
| 40 | sizer.Add( self.btn_cancel, 0, wx.ALIGN_RIGHT|wx.ALL, 5 ) |
| 41 | |
| 42 | self.btn_help = wx.Button( self, wx.ID_HELP, 'Help', wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT ) |
| 43 | sizer.Add( self.btn_help, 0, wx.ALIGN_RIGHT|wx.ALL, 5 ) |
| 44 | self.lst.Add(sizer, 0, wx.ALIGN_RIGHT, 5 ) |
| 45 | self.btn_help.Bind(wx.EVT_BUTTON, lambda e: self.on_help and self.on_help()) |
| 46 | if not modal: |
| 47 | self.btn_ok.Bind( wx.EVT_BUTTON, lambda e:self.commit('ok')) |
| 48 | self.btn_cancel.Bind( wx.EVT_BUTTON, lambda e:self.commit('cancel')) |
| 49 | |
| 50 | #self.lst.Add() |
| 51 | |
| 52 | def init_view(self, items, para, preview=False, modal = True): |
| 53 | self.para = para |
| 54 | for item in items: |
| 55 | self.add_ctrl_(widgets[item[0]], item[1], item[2:]) |
| 56 | if preview:self.add_ctrl_(Check, 'preview', ('preview',)) |
| 57 | self.reset(para) |
| 58 | self.add_confirm(modal) |
| 59 | self.pack() |
| 60 | self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) |
| 61 | print('bind close') |
| 62 | |
| 63 | |
| 64 | def OnDestroy( self, event ): |
| 65 | self.set_handle(None) |
| 66 | del self.ctrl_dic |
| 67 | |
| 68 | def parse(self, para) : |
| 69 | self.add_ctrl_(widgets[para[0]], *para[1:]) |
| 70 | |
| 71 | def add_ctrl_(self, Ctrl, key, p): |
no outgoing calls
no test coverage detected