def __init__(self, parent, title, defaultvalue, defaultchkvalue): wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE, title=title) self.pref = Globals.pref self.sizer = sizer = ui.VBox( namebinding='widget').create(self).auto_layout() box = sizer.add(ui.VGroup(tr('Lua interpreter'))) h = box.add(ui.HBox()) h.add(ui.Label(tr('Select:'))) interpreters = dict(self.pref.lua_interpreter) default_lua_interpreter = self.pref.default_lua_interpreter if not default_lua_interpreter in interpreters: default_lua_interpreter = self.pref.default_lua_interpreter[0][0] h.add(ui.SingleChoice(default_lua_interpreter, sorted(interpreters.keys())), name='interpreter').bind(wx.EVT_COMBOBOX, self.OnChanged) h.add(ui.Label(tr('Parameters:'))) h.add(ui.Text( self.pref.lua_default_paramters.get(default_lua_interpreter, '')), name='parameter') h = self.sizer.add(ui.HBox()) h.add(ui.Label(tr('Parameters of script:'))) h.add(ui.Text(defaultvalue), name='command_line').tooltip( "$file will be replaced with the filename of the current document\n" "$path will be replaced with the filename's directory of the current document" ) self.sizer.add(ui.Check(defaultchkvalue, tr('Redirect input and output')), name='redirect') self.sizer.add(ui.Check( self.pref.lua_show_args, tr('Show the Select Arguments dialog at Lua program run')), name='show_args') sizer.add(ui.simple_buttons(), flag=wx.ALIGN_CENTER | wx.BOTTOM) self.sizer.bind('btnOk', 'click', self.OnOK) self.btnOk.SetDefault() sizer.auto_fit(1)
def __init__(self, title=tr('Select Encoding'), style = wx.DEFAULT_DIALOG_STYLE): wx.Dialog.__init__(self, Globals.mainframe, -1, title=title, style = style) self.sizer = box = ui.VBox(namebinding='widget').create(self).auto_layout() grid = box.add(ui.Grid) grid.add((0, 0), ui.Radio(label=tr('Encoding:')), name='rdo_encoding').bind(wx.EVT_RADIOBUTTON, self.OnRadio) grid.add((0, 1), ui.SingleChoice(None, self.EncodingList), name='encoding') grid.add((1, 0), ui.Radio(label=tr('Custom Encoding:')), name='rdo_cus_encoding').bind(wx.EVT_RADIOBUTTON, self.OnRadio) grid.add((1, 1), ui.Text, name='cus_encoding') self.encoding.Enable(True) self.cus_encoding.Enable(False) box.add(ui.simple_buttons(), flag=wx.ALIGN_CENTER|wx.BOTTOM) self.btnOk.SetDefault() box.auto_fit(2)
def addItem(self, page, kind, prefname, prefvalue, message, extern): # if self.execplugin("additem", self, page, kind, prefname, prefvalue, message, extern): # return # obj = None label = message kwargs = None if not isinstance(kind, str): obj = kind kwargs = extern else: if kind == 'check': obj = ui.Check(prefvalue, label=message) label = '' # elif kind == 'num': # obj = ui.IntSpin(prefvalue, max=100000, min=1, size=(60, -1)) elif kind in ('num', 'int'): obj = ui.Int(prefvalue) elif kind == 'choice': obj = ui.SingleChoice(prefvalue, choices=extern) elif kind == 'text': obj = ui.Text(prefvalue) elif kind == 'password': obj = ui.Password(prefvalue) elif kind == 'openfile': obj = ui.OpenFile(prefvalue) elif kind == 'opendir': obj = ui.Dir(prefvalue) elif kind == 'button': label = '' func = getattr(self, extern) obj = ui.Button(message).bind('click', func) if not kwargs: if isinstance(extern, dict): span = extern.get('span', True) else: if label: span = False else: span = True page.box.add(label, obj, name=prefname, span=span) else: page.box.add(label, obj, name=prefname, **kwargs)