def add_pref(preflist): def _get(name): def _f(name=name): from modules import Globals return getattr(Globals.pref, name) return _f from modules import meide as ui box = ui.VGroup(tr('Network')) grid = ui.SimpleGrid() grid.add('', ui.Check(_get('use_proxy'), tr('Use a proxy')), name='use_proxy', span=True) grid.add(tr('IP address:'), ui.Text(_get('proxy')), name='proxy') grid.add(tr('Port number:'), ui.Int(_get('proxy_port')), name='proxy_port') grid.add(tr('Username:'******'proxy_user')), name='proxy_user') grid.add(tr('Password:'******'proxy_password')), name='proxy_password') box.add(grid) # preflist.extend([ # (tr('Network'), 100, 'check', 'use_proxy', tr('Use proxy'), None), # (tr('Network'), 110, 'text', 'proxy', tr('Proxy URL:'), None), # (tr('Network'), 120, 'text', 'proxy_user', tr('Proxy User:'******'Network'), 130, 'password', 'proxy_password', tr('Proxy Password:'******'Network'), 100, box, '', '', { 'span': True }), ])
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)
def __init__(self, parent, ftpname, user, password): wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE, title=tr("FTP site: %s") % ftpname, size=(200, 50)) self.sizer = box = ui.SimpleGrid( namebinding='widget').create(self).auto_layout() box.add(tr('Username:'******'txtUser') box.add(tr('Password:'******'txtPassword') box.add('', ui.simple_buttons(), flag=wx.ALIGN_CENTER | wx.BOTTOM, span=True) self.btnOk.SetDefault() box.auto_fit(2) box.bind('btnOk', wx.EVT_UPDATE_UI, self.OnUpdateUI)
def __init__(self, parent, mainframe): self.initmixin() self.parent = parent self.mainframe = mainframe self.pref = self.mainframe.pref wx.Panel.__init__(self, parent, -1) self.alive = False self.running = False self.box = box = ui.VBox( namebinding='widget').create(self).auto_layout() box1 = box.add(ui.HBox) box1.add(ui.Label(tr('Sites:'))) box1.add(ui.ComboBox("", self.mainframe.pref.ftp_sites), name='cmbSite').bind(wx.EVT_COMBOBOX, self.OnSiteChanged) box1.add(ui.Label(tr('Username:'******'', size=(100, -1)), name='txtUser') box1.add(ui.Label(tr('Password:'******'', size=(100, -1)), name='txtPassword') box1.add(ui.Button(tr('Connect')), name='btnConnect').bind('click', self.OnConnect) box1.add(ui.Button(tr('Disconnect')), name='btnDisconnect').bind('click', self.OnDisconnect) box.add(ui.List(columns=[ (tr("Name"), 500, 'left'), (tr("Size"), 80, 'right'), (tr("Format"), 80, 'left'), ], style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL), name='list') box2 = box.add(ui.HBox) box2.add(ui.Label(tr('Encoding:'))) box2.add(ui.ComboBox("Default", ['Default', 'UTF-8', 'Custom'], size=(100, -1)), name='txtEncoding') box2.add(ui.Label(tr('Remote path:'))) box2.add(ui.ComboBox("", self.mainframe.pref.remote_paths), name='txtPath') box2.add(ui.Button(tr('Refresh')), name='btnRefresh').bind('click', self.OnRefresh) box2.add(ui.Button(tr('Set FTP site...')), name='btnSite').bind('click', self.OnSite) self.load() self.initlist() box.bind('btnConnect', wx.EVT_UPDATE_UI, self.OnUpdateUI) box.bind('btnDisconnect', wx.EVT_UPDATE_UI, self.OnUpdateUI) box.bind('btnRefresh', wx.EVT_UPDATE_UI, self.OnUpdateUI) box.bind('btnSite', wx.EVT_UPDATE_UI, self.OnUpdateUI) box.bind('list', wx.EVT_LIST_ITEM_ACTIVATED, self.OnEnter) #@add_menu menulist self.callplugin_once('add_menu', Ftp.popmenulist) #make popup menu if self.popmenulist: self.popmenu = makemenu.makepopmenu(self, self.popmenulist, self.imagelist) wx.EVT_LIST_ITEM_RIGHT_CLICK(self.list, self.list.GetId(), self.OnRClick) wx.EVT_RIGHT_UP(self.list, self.OnRClick)