def GetCurrentHandler(self): """Get the currently selected file type handler @return: handlers.FileTypeHandler """ ftype = self.FindWindowById(ID_LANGUAGE).GetStringSelection() return handlers.GetHandlerByName(ftype)
def OnChoice(self, evt): """Handle the choice selection events""" e_id = evt.GetId() e_obj = evt.GetEventObject() e_val = e_obj.GetStringSelection() if e_id == ID_LANGUAGE: handler = handlers.GetHandlerByName(e_val) elist = self.FindWindowById(ID_EXECUTABLES) elist.DeleteAllItems() def_ch = self.FindWindowById(wx.ID_DEFAULT) def_ch.SetItems(handler.GetAliases()) def_ch.SetStringSelection(handler.GetDefault()) self.SetListItems(handler.GetCommands()) elif e_id == wx.ID_DEFAULT: handler = self.GetCurrentHandler() handler.SetDefault((e_val, handler.GetCommand(e_val))) else: evt.Skip()
def __DoLayout(self): """Layout the controls""" msizer = wx.BoxSizer(wx.VERTICAL) lsizer = wx.BoxSizer(wx.HORIZONTAL) ftype = wx.GetApp().GetCurrentBuffer().GetLangId() ftype = handlers.GetHandlerById(ftype) hname = ftype.GetName() util.Log("[Launch][info] ConfigPanel: %s" % hname) htypes = sorted(syntax.SyntaxNames()) lang_ch = wx.Choice(self, ID_LANGUAGE, choices=htypes) if ftype != handlers.DEFAULT_HANDLER: lang_ch.SetStringSelection(hname) else: lang_ch.SetStringSelection(htypes[0]) lsizer.AddMany([(wx.StaticText(self, label=_("File Type") + u":"), 0, wx.ALIGN_CENTER_VERTICAL), ((5, 5), 0), (lang_ch, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)]) # Main area sbox = wx.StaticBox(self, label=_("Executables")) boxsz = wx.StaticBoxSizer(sbox, wx.VERTICAL) # Default exe dsizer = wx.BoxSizer(wx.HORIZONTAL) chandler = handlers.GetHandlerByName(lang_ch.GetStringSelection()) cmds = chandler.GetAliases() def_ch = wx.Choice(self, wx.ID_DEFAULT, choices=cmds) if chandler.GetName() != handlers.DEFAULT_HANDLER: def_ch.SetStringSelection(chandler.GetDefault()) elif len(cmds): def_ch.SetStringSelection(cmds[0]) else: pass dsizer.AddMany([(wx.StaticText(self, label=_("Default") + u":"), 0, wx.ALIGN_CENTER_VERTICAL), ((5, 5), 0), (def_ch, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)]) # Executables List exelist = CommandListCtrl(self, ID_EXECUTABLES, style=wx.LC_EDIT_LABELS|\ wx.BORDER|wx.LC_REPORT|\ wx.LC_SINGLE_SEL) self.SetListItems(chandler.GetCommands()) bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_ADD), wx.ART_MENU) self.addbtn = wx.BitmapButton(self, wx.ID_ADD, bmp) self.addbtn.SetToolTipString(_("Add a new executable")) bmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_REMOVE), wx.ART_MENU) self.delbtn = wx.BitmapButton(self, wx.ID_REMOVE, bmp) self.delbtn.SetToolTipString(_("Remove selection from list")) btnsz = wx.BoxSizer(wx.HORIZONTAL) self.infotxt = wx.StaticText(self, label=_("Transient XML Handler")) self.infotxt.Hide() btnsz.AddMany([(self.addbtn, 0), ((2, 2), 0), (self.delbtn, 0), ((5, 2), 0), (self.infotxt, 0, wx.ALIGN_CENTER_VERTICAL)]) # Box Sizer Layout boxsz.AddMany([((5, 5), 0), (dsizer, 0, wx.ALIGN_CENTER | wx.EXPAND), ((5, 5), 0), (wx.StaticLine(self), 0, wx.EXPAND), ((8, 8), 0), (exelist, 1, wx.EXPAND), ((5, 5), 0), (btnsz, 0, wx.ALIGN_LEFT)]) # Setup the main sizer msizer.AddMany([((10, 10), 0), (lsizer, 0, wx.EXPAND), ((10, 10), 0), (wx.StaticLine(self), 0, wx.EXPAND), ((10, 10), 0), (boxsz, 1, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL), ((10, 10), 0)]) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.AddMany([((8, 8), 0), (msizer, 1, wx.EXPAND), ((8, 8), 0)]) self.SetSizer(hsizer) self.UpdateForHandler()
def __DoLayout(self): """Layout the controls""" msizer = wx.BoxSizer(wx.VERTICAL) lsizer = wx.BoxSizer(wx.HORIZONTAL) ftype = wx.GetApp().GetCurrentBuffer().GetLangId() ftype = handlers.GetHandlerById(ftype).GetName() htypes = GetHandlerTypes() lang_ch = wx.Choice(self, ID_LANGUAGE, choices=htypes) if ftype != handlers.DEFAULT_HANDLER: lang_ch.SetStringSelection(ftype) else: lang_ch.SetStringSelection(htypes[0]) lsizer.AddMany([(wx.StaticText(self, label=_("File Type") + ":"), 0, wx.ALIGN_CENTER_VERTICAL), ((5, 5), 0), (lang_ch, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL)]) # Main area sbox = wx.StaticBox(self, label=_("Executables")) boxsz = wx.StaticBoxSizer(sbox, wx.VERTICAL) # Default exe dsizer = wx.BoxSizer(wx.HORIZONTAL) chandler = handlers.GetHandlerByName(lang_ch.GetStringSelection()) cmds = chandler.GetAliases() def_ch = wx.Choice(self, wx.ID_DEFAULT, choices=cmds) if chandler.GetName() != handlers.DEFAULT_HANDLER: def_ch.SetStringSelection(chandler.GetDefault()) elif len(cmds): def_ch.SetStringSelection(cmds[0]) else: pass dsizer.AddMany([(wx.StaticText(self, label=_("Default") + ":"), 0, wx.ALIGN_CENTER_VERTICAL), ((5, 5), 0), (def_ch, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL)]) # Executables List exelist = CommandListCtrl(self, ID_EXECUTABLES, style=wx.LC_EDIT_LABELS|\ wx.BORDER|wx.LC_REPORT|\ wx.LC_SINGLE_SEL) # exelist.SetToolTipString(_("Click on an item to edit")) # exelist.InsertColumn(0, _("Alias")) # exelist.InsertColumn(1, _("Executable Commands")) self.SetListItems(chandler.GetCommands()) addbtn = wx.BitmapButton(self, wx.ID_ADD, GetPlusBitmap()) addbtn.SetToolTipString(_("Add a new executable")) delbtn = wx.BitmapButton(self, wx.ID_REMOVE, GetMinusBitmap()) delbtn.SetToolTipString(_("Remove selection from list")) btnsz = wx.BoxSizer(wx.HORIZONTAL) btnsz.AddMany([(addbtn, 0), ((2, 2), 0), (delbtn, 0)]) # Box Sizer Layout boxsz.AddMany([((5, 5), 0), (dsizer, 0, wx.ALIGN_CENTER|wx.EXPAND), ((5, 5), 0), (wx.StaticLine(self), 0, wx.EXPAND), ((8, 8), 0), (exelist, 1, wx.EXPAND), ((5, 5), 0), (btnsz, 0, wx.ALIGN_LEFT)]) # Setup the main sizer msizer.AddMany([((10, 10), 0), (lsizer, 0, wx.EXPAND), ((10, 10), 0), (wx.StaticLine(self), 0, wx.EXPAND), ((10, 10), 0), (boxsz, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL), ((10, 10), 0)]) hsizer = wx.BoxSizer(wx.HORIZONTAL) hsizer.AddMany([((8, 8), 0), (msizer, 1, wx.EXPAND), ((8, 8), 0)]) self.SetSizer(hsizer) self.SetAutoLayout(True)