def __init__(self, *args, **kwargs): self.__art = {} self.__image_list = wx.ImageList(16, 16) self.__args = args self.__kwargs = kwargs
def ReCreateFoldPanel(self, fpb_flags): # delete earlier panel self._leftWindow1.DestroyChildren() # recreate the foldpanelbar self._pnl = fpb.FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition, wx.Size(-1,-1), agwStyle=fpb_flags) Images = wx.ImageList(16,16) Images.Add(GetExpandedIconBitmap()) Images.Add(GetCollapsedIconBitmap()) item = self._pnl.AddFoldPanel("Caption Colours", collapsed=False, foldIcons=Images) self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Adjust The First Colour"), fpb.FPB_ALIGN_WIDTH, 5, 20) # RED colour spin control self._rslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider1, fpb.FPB_ALIGN_WIDTH, 2, 20) # GREEN colour spin control self._gslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider1, fpb.FPB_ALIGN_WIDTH, 0, 20) # BLUE colour spin control self._bslider1 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider1, fpb.FPB_ALIGN_WIDTH, 0, 20) self._pnl.AddFoldPanelSeparator(item) self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Adjust The Second Colour"), fpb.FPB_ALIGN_WIDTH, 5, 20) # RED colour spin control self._rslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._rslider2, fpb.FPB_ALIGN_WIDTH, 2, 20) # GREEN colour spin control self._gslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._gslider2, fpb.FPB_ALIGN_WIDTH, 0, 20) # BLUE colour spin control self._bslider2 = wx.Slider(item, -1, 0, 0, 255) self._pnl.AddFoldPanelWindow(item, self._bslider2, fpb.FPB_ALIGN_WIDTH, 0, 20) self._pnl.AddFoldPanelSeparator(item) button1 = wx.Button(item, wx.ID_ANY, "Apply To All") button1.Bind(wx.EVT_BUTTON, self.OnExpandMe) self._pnl.AddFoldPanelWindow(item, button1) # read back current gradients and set the sliders # for the colour which is now taken as default style = self._pnl.GetCaptionStyle(item) col = style.GetFirstColour() self._rslider1.SetValue(col.Red()) self._gslider1.SetValue(col.Green()) self._bslider1.SetValue(col.Blue()) col = style.GetSecondColour() self._rslider2.SetValue(col.Red()) self._gslider2.SetValue(col.Green()) self._bslider2.SetValue(col.Blue()) # put down some caption styles from which the user can # select to show how the current or all caption bars will look like item = self._pnl.AddFoldPanel("Caption Style", False, foldIcons=Images) self.ID_USE_VGRADIENT = wx.NewId() self.ID_USE_HGRADIENT = wx.NewId() self.ID_USE_SINGLE = wx.NewId() self.ID_USE_RECTANGLE = wx.NewId() self.ID_USE_FILLED_RECTANGLE = wx.NewId() currStyle = wx.RadioButton(item, self.ID_USE_VGRADIENT, "&Vertical Gradient") self._pnl.AddFoldPanelWindow(item, currStyle, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) currStyle.SetValue(True) radio1 = wx.RadioButton(item, self.ID_USE_HGRADIENT, "&Horizontal Gradient") radio2 = wx.RadioButton(item, self.ID_USE_SINGLE, "&Single Colour") radio3 = wx.RadioButton(item, self.ID_USE_RECTANGLE, "&Rectangle Box") radio4 = wx.RadioButton(item, self.ID_USE_FILLED_RECTANGLE, "&Filled Rectangle Box") currStyle.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio1.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio2.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio3.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) radio4.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange) self._pnl.AddFoldPanelWindow(item, radio1, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio2, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio3, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelWindow(item, radio4, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) self._pnl.AddFoldPanelSeparator(item) self._single = wx.CheckBox(item, -1, "&Only This Caption") self._pnl.AddFoldPanelWindow(item, self._single, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) # one more panel to finish it cs = fpb.CaptionBarStyle() cs.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE) item = self._pnl.AddFoldPanel("Misc Stuff", collapsed=True, foldIcons=Images, cbstyle=cs) button2 = wx.Button(item, wx.NewId(), "Collapse All") self._pnl.AddFoldPanelWindow(item, button2) self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Enter Some Comments"), fpb.FPB_ALIGN_WIDTH, 5, 20) self._pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, -1, "Comments"), fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe) self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4] self._leftWindow1.SizeWindows()
def __InitUI(self): self.SetMinSize(wx.Size(500, 500)) # 创建上方菜单栏 self.menuBar = MyMenu(self) self.SetMenuBar(self.menuBar) # 创建下方状态栏 self.statusBar = MyStatusBar(self) self.SetStatusBar(self.statusBar) # 创建上方设备连接状态工具栏 self.deviceToolBar = MyToolBar(self) # 创建左侧文件目录树面板 self.fileTreePanel = MyFileTreePanel( self, (self.width * 0.25, self.high * 0.6)) # 创建右侧 Notebook self.nootBook = MyNotebook(self, -1, style=wx.CLIP_CHILDREN) imgList_nootBook = wx.ImageList(16, 16) # 设置图标 imgList_nootBook.Add(images.PyIcon.GetBitmap()) imgList_nootBook.Add(images.Excel.GetBitmap()) self.nootBook.AssignImageList(imgList_nootBook) self.codePage = MyCodePage(self.nootBook, (self.width * 0.75, self.high * 0.6)) self.casePage = MyCasePage(self.nootBook, (self.width * 0.75, self.high * 0.6)) self.nootBook.AddPage(self.codePage, "Python代码", True, imageId=0) self.nootBook.AddPage(self.casePage, "用例同步", False, imageId=1) # 创建下方日志 窗口 self.logger = wx.TextCtrl(self, size=(self.width, self.high * 0.25), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) self.userAction = wx.TextCtrl(self, size=(self.width, self.high * 0.25), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) # AUI管理 self._mgr.AddPane( self.deviceToolBar, aui2.AuiPaneInfo().Name("deviceToolBar").Caption( "设备连接状态").ToolbarPane().Top()) self._mgr.AddPane( self.fileTreePanel, aui2.AuiPaneInfo().Name("fileTreePanel").Caption( "工程目录").Left().MinSize((200, -1)).Floatable(False)) self._mgr.AddPane(self.nootBook, aui2.AuiPaneInfo().Name("Notebook").CenterPane()) self._mgr.AddPane( self.userAction, aui2.AuiPaneInfo().Name("userAction").Caption("用户操作记录").Bottom()) self._mgr.AddPane( self.logger, aui2.AuiPaneInfo().Name("logger").Caption("系统行为日志").Bottom(), target=self._mgr.GetPane("userAction"))
def __init__(self, parent, title): AbstractFrame.AbstractFrame.__init__(self, parent, title) mainMenuBar=MainMenuBar.MainMenuBar() self.SetMenuBar(mainMenuBar) mainToolBar=MainToolBar.MainToolBar(self,-1) self.SetToolBar(mainToolBar) mainToolBar.Realize() sizer=wx.BoxSizer(wx.VERTICAL) actionPanel = wx.Panel(self,-1) self.__headerControl = HeaderPanel.HeaderPanel(actionPanel, -1,"NoOra Project","") self.__notebook = FlatNoteBook.FlatNotebook(actionPanel,-1,style=FlatNoteBook.FNB_FF2) style=self.__notebook.GetWindowStyleFlag() style|=FlatNoteBook.FNB_VC8 self.__notebook.SetAGWWindowStyleFlag(style) images=wx.ImageList(16, 16) image=MainArtProvider.MainArtProvider.GetBitmap(Settings.ART_CONSOLE, wx.ART_TOOLBAR, (16, 16)) images.Add(image) image=MainArtProvider.MainArtProvider.GetBitmap(Settings.ART_ACTION, wx.ART_TOOLBAR, (16, 16)) images.Add(image) self.__notebook.SetImageList(images) self.__actionControl = ActionPanel.ActionPanel(self.__notebook,-1) self.__console = wx.TextCtrl(self.__notebook,-1,style=wx.TE_MULTILINE) self.__console.SetEditable(False) self.__notebook.AddPage(self.__actionControl,'Action',True,1) self.__notebook.AddPage(self.__console,'Console',True,0) self.__notebook.SetSelection(0) redirect=Redirect.Redirect(self.__console) sys.stdout=redirect sys.stderr=redirect sizer.Add(self.__headerControl,0,wx.EXPAND) sizer.Add(self.__notebook,1,wx.EXPAND) actionPanel.SetSizer(sizer) self.Bind(wx.EVT_BUTTON, self.onOpenProject, id=Settings.ID_OPEN_PROJECT) self.Bind(wx.EVT_MENU, self.onOpenProject, id=Settings.ID_OPEN_PROJECT) self.Bind(wx.EVT_MENU, self.onNewProject, id=Settings.ID_NEW_PROJECT) self.Bind(wx.EVT_MENU, self.onAbout, id=wx.ID_ABOUT) self.Bind(wx.EVT_MENU, self.onExit, id=wx.ID_EXIT) self.Bind(wx.EVT_MENU, self.onEditProject, id=Settings.ID_EDIT_PROJECT) self.Bind(wx.EVT_MENU, self.onShowActionView, id=Settings.ID_SHOW_ACTION_VIEW) self.Bind(wx.EVT_MENU, self.onShowConsoleView, id=Settings.ID_SHOW_CONSOLE_VIEW) self.Bind(wx.EVT_TOOL, self.onOpenProject, id=Settings.ID_OPEN_PROJECT) self.Bind(wx.EVT_TOOL, self.onNewProject, id=Settings.ID_NEW_PROJECT) self.Bind(wx.EVT_TOOL, self.onExecute, id=Settings.ID_EXECUTE) self.Bind(wx.EVT_TOOL, self.onClear, id=Settings.ID_CLEAR) self.Connect(Settings.ID_OPEN_PROJECT, -1, Settings.EVT_PLUGIN_FINISHED, self.openProject) self.Bind(wx.EVT_COMBOBOX, self.onCommandChanged, id=Settings.ID_COMMAND) #self.Bind(Settings.EVT_PLUGIN_FINISHED, self.openProject, id=Settings.ID_OPEN_PROJECT) self.Bind(wx.EVT_CLOSE, self.onClose) self.__statusBar = self.CreateStatusBar(); self.__statusBar.SetStatusText("To create a new project, click on New Project in the Project menu")
def Remplissage(self): listeTracks = self.Importation() il = wx.ImageList(16, 16) self.imgVert = il.Add( wx.Bitmap( Chemins.GetStaticPath("Images/16x16/Ventilation_vert.png"), wx.BITMAP_TYPE_PNG)) self.imgRouge = il.Add( wx.Bitmap( Chemins.GetStaticPath("Images/16x16/Ventilation_rouge.png"), wx.BITMAP_TYPE_PNG)) self.imgOrange = il.Add( wx.Bitmap( Chemins.GetStaticPath("Images/16x16/Ventilation_orange.png"), wx.BITMAP_TYPE_PNG)) self.imgAttente = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Attente.png"), wx.BITMAP_TYPE_PNG)) self.imgOk = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Ok.png"), wx.BITMAP_TYPE_PNG)) self.imgNon = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Interdit.png"), wx.BITMAP_TYPE_PNG)) self.AssignImageList(il) # Création des branches for track in listeTracks: # Niveau 1 regroupement = self.AppendItem(self.root, track.dateComplete) self.SetPyData(regroupement, None) ## self.SetItemBold(regroupement, True) ## self.SetItemBackgroundColour(regroupement, COULEUR_FOND_REGROUPEMENT) self.SetItemText(regroupement, track.nom_mode, 1) self.SetItemText(regroupement, track.nom_emetteur, 2) self.SetItemText(regroupement, track.numero_piece, 3) self.SetItemText(regroupement, track.nom_payeur, 4) self.SetItemText(regroupement, track.montant_str, 5) self.SetItemText(regroupement, track.montant_ventilation_str, 6) self.SetItemText(regroupement, track.date_depot_str, 7) imageVentilation = track.GetImageVentilation() if imageVentilation == "vert": regroupement.SetImage(6, self.imgVert, which=wx.TreeItemIcon_Normal) if imageVentilation == "orange": regroupement.SetImage(6, self.imgOrange, which=wx.TreeItemIcon_Normal) if imageVentilation == "rouge": regroupement.SetImage(6, self.imgRouge, which=wx.TreeItemIcon_Normal) imageDepot = track.GetImageDepot() if imageDepot == "ok": regroupement.SetImage(7, self.imgOk, which=wx.TreeItemIcon_Normal) if imageDepot == "attente": regroupement.SetImage(7, self.imgAttente, which=wx.TreeItemIcon_Normal) if imageDepot == "non": regroupement.SetImage(7, self.imgNon, which=wx.TreeItemIcon_Normal) # Niveau 2 prestations = self.AppendItem(regroupement, "") self.SetPyData(prestations, track.IDreglement) # Liste des prestations ctrl_prestations = OL_Prestations_repartition.ListView( self.GetMainWindow(), -1, IDfamille=self.IDfamille, size=(-1, -1), style=wx.LC_REPORT | wx.SUNKEN_BORDER) ctrl_prestations.SetFiltre("ventilation.IDreglement", track.IDreglement) largeur = 840 hauteur = 35 + len(ctrl_prestations.donnees) * 18 ctrl_prestations.SetSize((largeur, hauteur)) self.SetItemWindow(prestations, ctrl_prestations, 0) track.ctrl_prestations = ctrl_prestations ## self.ExpandAllChildren(self.root) # Pour éviter le bus de positionnement des contrôles self.GetMainWindow().CalculatePositions() self.listeTracks = listeTracks
def __init__(self, parent, frame): wx.Panel.__init__(self, parent, -1, style=wx.BORDER_NONE) self.parent = parent self.coder = frame self.currentPath = None self.selectedItem = None self.isSubDir = False self.pathData = {} # Set background for Directory bar self.SetBackgroundColour(wx.Colour(cs['tab_active'])) self.SetForegroundColour(wx.Colour(cs['brws_txt'])) # get graphics for toolbars and tree items rc = self.coder.paths['resources'] join = os.path.join # handles for icon graphics in the image list self.fileImgExt = { "..": 'dirup16.png', "\\": 'folder16.png', ".?": 'fileunknown16.png', ".csv": 'filecsv16.png', ".xlsx": 'filecsv16.png', ".xls": 'filecsv16.png', ".tsv": 'filecsv16.png', ".png": 'fileimage16.png', ".jpeg": 'fileimage16.png', ".jpg": 'fileimage16.png', ".bmp": 'fileimage16.png', ".tiff": 'fileimage16.png', ".tif": 'fileimage16.png', ".ppm": 'fileimage16.png', ".gif": 'fileimage16.png', ".py": 'coderpython16.png' } self.fileImgInds = {} self.fileImgList = wx.ImageList(16, 16) for key in self.fileImgExt: self.fileImgInds[key] = self.fileImgList.Add( wx.Bitmap(join(rc, self.fileImgExt[key]), wx.BITMAP_TYPE_PNG)) # icons for toolbars gotoBmp = wx.Bitmap(join(rc, 'goto16.png'), wx.BITMAP_TYPE_PNG) newFolder = wx.Bitmap(join(rc, 'foldernew16.png'), wx.BITMAP_TYPE_PNG) # copyBmp = wx.Bitmap(join(rc, 'copy16.png'), wx.BITMAP_TYPE_PNG) deleteBmp = wx.Bitmap(join(rc, 'delete16.png'), wx.BITMAP_TYPE_PNG) renameBmp = wx.Bitmap(join(rc, 'rename16.png'), wx.BITMAP_TYPE_PNG) # self.SetDoubleBuffered(True) # create the toolbar szrToolbar = wx.BoxSizer(wx.HORIZONTAL) self.toolBar = wx.ToolBar( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, aui.AUI_TB_HORZ_LAYOUT | aui.AUI_TB_HORZ_TEXT | wx.BORDER_NONE | wx.TB_FLAT | wx.TB_NODIVIDER) self.toolBar.AdjustForLayoutDirection(16, 300, 300) self.toolBar.SetToolBitmapSize((21, 16)) self.toolBar.SetBackgroundColour(cs['tab_active']) self.toolBar.SetForegroundColour(cs['brws_txt']) self.newFolderTool = self.toolBar.AddTool( wx.ID_ANY, 'New Folder', newFolder, "Create a new folder in the current folder", wx.ITEM_NORMAL) self.renameTool = self.toolBar.AddTool( wx.ID_ANY, 'Rename', renameBmp, "Rename the selected folder or file", wx.ITEM_NORMAL) # self.copyTool = self.toolBar.AddTool( # wx.ID_ANY, # 'Copy', # copyBmp, # "Create a copy of the selected file.", # wx.ITEM_NORMAL) self.deleteTool = self.toolBar.AddTool( wx.ID_ANY, 'Delete', deleteBmp, "Delete the selected folder or file", wx.ITEM_NORMAL) self.gotoTool = self.toolBar.AddTool(wx.ID_ANY, 'Goto', gotoBmp, "Jump to another folder", wx.ITEM_DROPDOWN) self.toolBar.Realize() self.Bind(wx.EVT_TOOL, self.OnBrowse, self.gotoTool) self.Bind(aui.EVT_AUITOOLBAR_TOOL_DROPDOWN, self.OnGotoMenu, self.gotoTool) self.Bind(wx.EVT_TOOL, self.OnNewFolderTool, self.newFolderTool) self.Bind(wx.EVT_TOOL, self.OnDeleteTool, self.deleteTool) # self.Bind(wx.EVT_TOOL, self.OnCopyTool, self.copyTool) self.Bind(wx.EVT_TOOL, self.OnRenameTool, self.renameTool) self.Bind(wx.EVT_MENU, self.OnBrowse, id=ID_GOTO_BROWSE) self.Bind(wx.EVT_MENU, self.OnGotoCWD, id=ID_GOTO_CWD) self.Bind(wx.EVT_MENU, self.OnGotoFileLocation, id=ID_GOTO_FILE) szrToolbar.Add(self.toolBar, 1, flag=wx.ALL | wx.EXPAND) # create an address bar self.lblDir = wx.StaticText(self, label="Directory:") self.txtAddr = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER) # create the source tree control self.flId = wx.NewIdRef() self.fileList = FileBrowserListCtrl(self, self.flId, pos=(0, 0), size=wx.Size(300, 300), style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.BORDER_NONE | wx.LC_NO_HEADER) self.fileList.SetImageList(self.fileImgList, wx.IMAGE_LIST_SMALL) # bind events for list control self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.fileList) self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.fileList) self.Bind(wx.EVT_TEXT_ENTER, self.OnAddrEnter, self.txtAddr) # do layout szrAddr = wx.BoxSizer(wx.HORIZONTAL) szrAddr.Add(self.lblDir, 0, flag=wx.RIGHT | wx.ALIGN_CENTRE_VERTICAL, border=5) szrAddr.Add(self.txtAddr, 1, flag=wx.ALIGN_CENTRE_VERTICAL) szr = wx.BoxSizer(wx.VERTICAL) szr.Add(szrToolbar, 0, flag=wx.EXPAND | wx.ALL) szr.Add(szrAddr, 0, flag=wx.EXPAND | wx.ALL, border=5) szr.Add(self.fileList, 1, flag=wx.EXPAND) self.SetSizer(szr) # create the dropdown menu for goto self.gotoMenu = wx.Menu() item = self.gotoMenu.Append( wx.ID_ANY, "Browse ...", "Browse the file system for a directory to open") self.Bind(wx.EVT_MENU, self.OnBrowse, id=item.GetId()) self.gotoMenu.AppendSeparator() item = self.gotoMenu.Append(wx.ID_ANY, "Current working directory", "Open the current working directory") self.Bind(wx.EVT_MENU, self.OnGotoCWD, id=item.GetId()) item = self.gotoMenu.Append( wx.ID_ANY, "Editor file location", "Open the directory the current editor file is located") self.Bind(wx.EVT_MENU, self.OnGotoFileLocation, id=item.GetId()) #self.toolBar.SetDropdownMenu(self.gotoTool.GetId(), self.gotoMenu) self.gotoTool.SetDropdownMenu(self.gotoMenu) # add columns self.fileList.InsertColumn(0, "Name") self.fileList.InsertColumn(1, "Size", wx.LIST_FORMAT_LEFT) #self.fileList.InsertColumn(2, "Modified") self.fileList.SetColumnWidth(0, 280) self.fileList.SetColumnWidth(1, 80) #self.fileList.SetColumnWidth(2, 100) self.gotoDir(os.getcwd())
def PopulateList(self): self.paramList.InsertColumn(0, "Attribute") self.paramList.InsertColumn(1, "Value") self.paramList.SetColumnWidth(1, 150) self.paramList.setResizeColumn(1) self.imageList = wx.ImageList(16, 16) self.paramList.SetImageList(self.imageList, wx.IMAGE_LIST_SMALL) names = list(self.attrValues.iterkeys()) names.sort() idNameMap = {} idCount = 0 for name in names: info = self.attrInfo.get(name) att = self.attrValues[name] val = getattr(att, "value", None) value = val if val is not None else att if info and info.displayName and self.toggleView == 1: attrName = info.displayName else: attrName = name if info: if info.icon is not None: iconFile = info.icon.iconFile icon = bitmapLoader.getBitmap(iconFile, "pack") if icon is None: icon = bitmapLoader.getBitmap("transparent16x16", "icons") attrIcon = self.imageList.Add(icon) else: attrIcon = self.imageList.Add( bitmapLoader.getBitmap("07_15", "pack")) else: attrIcon = self.imageList.Add( bitmapLoader.getBitmap("07_15", "pack")) index = self.paramList.InsertImageStringItem( sys.maxint, attrName, attrIcon) idNameMap[idCount] = attrName self.paramList.SetItemData(index, idCount) idCount += 1 if self.toggleView != 1: valueUnit = str(value) elif info and info.unit: valueUnit = self.TranslateValueUnit(value, info.unit.displayName, info.unit.name) else: valueUnit = formatAmount(value, 3, 0, 0) self.paramList.SetStringItem(index, 1, valueUnit) self.paramList.SortItems( lambda id1, id2: cmp(idNameMap[id1], idNameMap[id2])) self.paramList.RefreshRows() self.totalAttrsLabel.SetLabel("%d attributes. " % idCount) self.Layout()
def __init__(self): self.EnableCheckBoxes(True) self.AssignImageList(wx.ImageList(16, 16), wx.IMAGE_LIST_SMALL)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) self.log = log tID = wx.NewId() sizer = wx.BoxSizer(wx.VERTICAL) if wx.Platform == "__WXMAC__" and \ hasattr(wx.GetApp().GetTopWindow(), "LoadDemo"): self.useNative = wx.CheckBox(self, -1, "Use native listctrl") self.useNative.SetValue( not wx.SystemOptions.GetOptionInt("mac.listctrl.always_use_generic") ) self.Bind(wx.EVT_CHECKBOX, self.OnUseNative, self.useNative) sizer.Add(self.useNative, 0, wx.ALL | wx.ALIGN_RIGHT, 4) self.il = wx.ImageList(16, 16) self.idx1 = self.il.Add(images.Smiles.GetBitmap()) self.sm_up = self.il.Add(images.SmallUpArrow.GetBitmap()) self.sm_dn = self.il.Add(images.SmallDnArrow.GetBitmap()) self.list = TestListCtrl(self, tID, style=wx.LC_REPORT #| wx.BORDER_SUNKEN | wx.BORDER_NONE | wx.LC_EDIT_LABELS #| wx.LC_SORT_ASCENDING # disabling initial auto sort gives a #| wx.LC_NO_HEADER # better illustration of col-click sorting #| wx.LC_VRULES #| wx.LC_HRULES #| wx.LC_SINGLE_SEL ) self.list.SetImageList(self.il, wx.IMAGE_LIST_SMALL) sizer.Add(self.list, 1, wx.EXPAND) self.PopulateList() # Now that the list exists we can init the other base class, # see wx/lib/mixins/listctrl.py self.itemDataMap = musicdata listmix.ColumnSorterMixin.__init__(self, 3) #self.SortListItems(0, True) self.SetSizer(sizer) self.SetAutoLayout(True) self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.list) self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected, self.list) self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self.list) self.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnItemDelete, self.list) self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list) self.Bind(wx.EVT_LIST_COL_RIGHT_CLICK, self.OnColRightClick, self.list) self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.OnColBeginDrag, self.list) self.Bind(wx.EVT_LIST_COL_DRAGGING, self.OnColDragging, self.list) self.Bind(wx.EVT_LIST_COL_END_DRAG, self.OnColEndDrag, self.list) self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list) self.list.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick) self.list.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) # for wxMSW self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightClick) # for wxGTK self.list.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
def __init__(self, parent): """""" wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) self.Bind(wx.EVT_SIZE, self.OnSize) # self.tree = gizmos.TreeListCtrl(self, -1, style = # wx.TR_DEFAULT_STYLE # | wx.TR_FULL_ROW_HIGHLIGHT # ) isz = (16, 16) il = wx.ImageList(isz[0], isz[1]) fldridx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) fldropenidx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, isz)) fileidx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz)) bulbidx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_TIP, wx.ART_OTHER, isz)) self.tree.SetImageList(il) self.il = il # create some columns self.tree.AddColumn("Main column") self.tree.AddColumn("Column 1") self.tree.AddColumn("Column 2") self.tree.SetMainColumn(0) # the one with the tree in it... self.tree.SetColumnWidth(0, 175) self.root = self.tree.AddRoot("The Root Item") self.tree.SetItemText(self.root, "col 1 root", 1) self.tree.SetItemText(self.root, "col 2 root", 2) self.tree.SetItemImage(self.root, fldridx, which=wx.TreeItemIcon_Normal) self.tree.SetItemImage(self.root, fldropenidx, which=wx.TreeItemIcon_Expanded) for x in range(15): txt = "Item %d" % x child = self.tree.AppendItem(self.root, txt) self.tree.SetItemText(child, txt + "(c1)", 1) self.tree.SetItemText(child, txt + "(c2)", 2) self.tree.SetItemImage(child, fldridx, which=wx.TreeItemIcon_Normal) self.tree.SetItemImage(child, fldropenidx, which=wx.TreeItemIcon_Expanded) for y in range(5): txt = "item %d-%s" % (x, chr(ord("a") + y)) last = self.tree.AppendItem(child, txt) self.tree.SetItemText(last, txt + "(c1)", 1) self.tree.SetItemText(last, txt + "(c2)", 2) self.tree.SetItemImage(last, fldridx, which=wx.TreeItemIcon_Normal) self.tree.SetItemImage(last, fldropenidx, which=wx.TreeItemIcon_Expanded) for z in range(5): txt = "item %d-%s-%d" % (x, chr(ord("a") + y), z) item = self.tree.AppendItem(last, txt) self.tree.SetItemText(item, txt + "(c1)", 1) self.tree.SetItemText(item, txt + "(c2)", 2) self.tree.SetItemImage(item, fileidx, which=wx.TreeItemIcon_Normal) self.tree.SetItemImage(item, bulbidx, which=wx.TreeItemIcon_Selected) self.tree.Expand(self.root) self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate)
def __init__(self, parent, id=-1, IDpersonne=0): wx.Notebook.__init__( self, parent, id, style=wx.BK_DEFAULT #wx.BK_TOP #wx.BK_BOTTOM #wx.BK_LEFT #wx.BK_RIGHT # | wx.NB_MULTILINE ) self.IDpersonne = IDpersonne # ImageList pour le NoteBook il = wx.ImageList(16, 16) self.img1 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Identite.png"), wx.BITMAP_TYPE_PNG)) self.img2 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/BlocNotes.png"), wx.BITMAP_TYPE_PNG)) self.img3 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Document.png"), wx.BITMAP_TYPE_PNG)) self.img4 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Presences.png"), wx.BITMAP_TYPE_PNG)) self.img5 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Scenario.png"), wx.BITMAP_TYPE_PNG)) self.img6 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Calculatrice.png"), wx.BITMAP_TYPE_PNG)) self.img7 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Candidature.png"), wx.BITMAP_TYPE_PNG)) self.img8 = il.Add( wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Document2.png"), wx.BITMAP_TYPE_PNG)) self.AssignImageList(il) # Page Généralités self.pageGeneralites = CTRL_Page_generalites.Panel_general( self, -1, IDpersonne=self.IDpersonne) self.AddPage(self.pageGeneralites, _(u"Généralités")) self.SetPageImage(0, self.img1) # Enregistre la fiche si nouvelle personne et détermination du nouvel IDpersonne if self.IDpersonne == 0: self.GetGrandParent().nouvelleFiche = True self.pageGeneralites.Sauvegarde() self.IDpersonne = self.pageGeneralites.IDpersonne else: self.GetGrandParent().nouvelleFiche = False # Page Questionnaire self.pageQuestionnaire = CTRL_Page_questionnaire.Panel( self, -1, IDpersonne=self.IDpersonne) self.AddPage(self.pageQuestionnaire, _(u"Questionnaire")) self.SetPageImage(1, self.img8) # Page Qualifications self.pageStatut = CTRL_Page_qualifications.Panel_Statut( self, -1, IDpersonne=self.IDpersonne) self.AddPage(self.pageStatut, _(u"Qualifications")) self.SetPageImage(2, self.img2) # Page Contrats self.pageContrats = CTRL_Page_contrats.Panel_Contrats( self, -1, IDpersonne=self.IDpersonne) self.AddPage(self.pageContrats, _(u"Contrats")) self.SetPageImage(3, self.img3) # Page Présences self.pagePresences = CTRL_Page_presences.Panel( self, IDpersonne=self.IDpersonne) self.AddPage(self.pagePresences, _(u"Présences")) self.SetPageImage(4, self.img4) # Page Scénarios self.pageScenarios = CTRL_Page_scenarios.Panel( self, IDpersonne=self.IDpersonne) self.AddPage(self.pageScenarios, _(u"Scénarios")) self.SetPageImage(5, self.img5) # Page Frais self.pageFrais = CTRL_Page_frais.Panel(self, IDpersonne=self.IDpersonne) self.AddPage(self.pageFrais, _(u"Frais")) self.SetPageImage(6, self.img6) # Page Candidatures self.pageCandidatures = CTRL_Page_candidatures.Panel( self, IDpersonne=self.IDpersonne) self.AddPage(self.pageCandidatures, _(u"Recrutement")) self.SetPageImage(7, self.img7) self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
def __init__(self, parent, IDfamille=None, dictIndividus={}, listeSelectionIndividus=[], selectionTous=False): ULC.UltimateListCtrl.__init__(self, parent, -1, agwStyle=wx.LC_ICON | wx.LC_ALIGN_LEFT) self.parent = parent self.IDfamille = IDfamille self.dictIndividus = dictIndividus ## self.EnableSelectionVista(True) self.SetFirstGradientColour(None) self.SetSecondGradientColour(None) #"#316AC5") self.EnableSelectionGradient(True) # Création de la liste d'individus à afficher listeIndividus = [] for IDindividu, dictIndividu in self.dictIndividus.iteritems(): nbreInscriptions = len(dictIndividu["inscriptions"]) age = dictIndividu["age"] prenom = dictIndividu["prenom"] if nbreInscriptions > 0: listeIndividus.append((prenom, IDindividu)) listeIndividus.sort() # liste images self.dictPhotos = {} taillePhoto = 64 il = wx.ImageList(taillePhoto, taillePhoto, True) for age, IDindividu in listeIndividus: dictIndividu = self.dictIndividus[IDindividu] IDcivilite = dictIndividu["IDcivilite"] nom = dictIndividu["nom"] prenom = dictIndividu["prenom"] nomFichier = Chemins.GetStaticPath( "Images/128x128/%s" % DICT_CIVILITES[IDcivilite]["nomImage"]) IDphoto, bmp = CTRL_Photo.GetPhoto(IDindividu=IDindividu, nomFichier=nomFichier, taillePhoto=(taillePhoto, taillePhoto), qualite=100) img = il.Add(bmp) self.dictPhotos[IDindividu] = img self.AssignImageList(il, wx.IMAGE_LIST_NORMAL) # Création des items index = 0 for age, IDindividu in listeIndividus: dictIndividu = self.dictIndividus[IDindividu] IDcivilite = dictIndividu["IDcivilite"] nom = dictIndividu["nom"] prenom = dictIndividu["prenom"] label = prenom if label == "": label = " " self.InsertImageStringItem(index, label, self.dictPhotos[IDindividu]) self.SetItemData(index, IDindividu) if IDindividu in listeSelectionIndividus or selectionTous == True: self.Select(index) self.SetDisabledTextColour(wx.Colour(255, 0, 0)) index += 1 ## self.Bind(ULC.EVT_LIST_ITEM_LEFT_CLICK, self.OnSelect) ## self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect) ## self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnDeselect) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
def __init__(self, parent, d, *args, **kwargs): """Initialize the dialog d - dictionary representing the tree. Keys form the dictionary labels, values are dictionaries of subtrees A leaf is marked with a dictionary entry whose key is None and whose value is True or False, depending on whether it is initially selected or not. """ wx.Dialog.__init__(self, parent, *args, **kwargs) self.bitmaps = [] self.parent_reflects_child = True sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) tree_style = wx.TR_DEFAULT_STYLE self.tree_ctrl = wx.TreeCtrl(self, style=tree_style) sizer.Add(self.tree_ctrl, 1, wx.EXPAND | wx.ALL, 5) image_list = wx.ImageList(16, 16) for i, state_flag in enumerate( (0, wx.CONTROL_CHECKED, wx.CONTROL_UNDETERMINED)): for j, selection_flag in enumerate((0, wx.CONTROL_CURRENT)): idx = image_list.Add( self.get_checkbox_bitmap(state_flag | selection_flag, 16, 16)) self.tree_ctrl.SetImageList(image_list) self.image_list = image_list image_index, selected_image_index = self.img_idx(d) root_id = self.tree_ctrl.AddRoot("All", image_index, selected_image_index, d) self.tree_ctrl.SetItemImage(root_id, image_index, wx.TreeItemIcon_Normal) self.tree_ctrl.SetItemImage(root_id, selected_image_index, wx.TreeItemIcon_Selected) self.tree_ctrl.SetItemImage(root_id, image_index, wx.TreeItemIcon_Expanded) self.tree_ctrl.SetItemImage(root_id, image_index, wx.TreeItemIcon_SelectedExpanded) self.root_id = root_id self.tree_ctrl.SetItemHasChildren(root_id, len(d) > 1) self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.on_expanding, self.tree_ctrl) self.tree_ctrl.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) self.tree_ctrl.Expand(root_id) table_sizer = wx.GridBagSizer() sizer.Add(table_sizer, 0, wx.EXPAND) table_sizer.Add(wx.StaticText(self, label="Key:"), (0, 0), flag=wx.LEFT | wx.RIGHT, border=3) for i, (bitmap, description) in enumerate(( (image_list.GetBitmap(0), "No subitems selected / not selected"), (image_list.GetBitmap(2), "All subitems selected / selected"), ( image_list.GetBitmap(4), "Some subitems selected. Open tree to see selections.", ), )): bitmap_ctrl = wx.StaticBitmap(self) bitmap_ctrl.SetBitmap(bitmap) table_sizer.Add(bitmap_ctrl, (i, 1), flag=wx.RIGHT, border=5) table_sizer.Add(wx.StaticText(self, label=description), (i, 2)) table_sizer.AddGrowableCol(2) sizer.Add(self.CreateStdDialogButtonSizer(wx.CANCEL | wx.OK), flag=wx.CENTER) self.Layout()
def clear_art(self): self.__art = {} self.__image_list = wx.ImageList(16, 16) self.SetImageList(self.image_list)
def __init__(self, parent): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL) self.charEditor = self.Parent.Parent # first parent is Notebook, second is Character Editor self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) pmainSizer = wx.BoxSizer(wx.VERTICAL) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0) i = self.clonesChoice.Append("Omega Clone", None) self.clonesChoice.SetSelection(i) hSizer.Add(self.clonesChoice, 5, wx.ALL | wx.EXPAND, 5) self.searchInput = PlaceholderTextCtrl(self, wx.ID_ANY, placeholder="Search...") hSizer.Add(self.searchInput, 1, wx.ALL | wx.EXPAND, 5) self.searchInput.Bind(wx.EVT_TEXT, self.delaySearch) sChar = Character.getInstance() self.alphaClones = sChar.getAlphaCloneList() char = self.charEditor.entityEditor.getActiveEntity() for clone in self.alphaClones: i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID) if clone.ID == char.alphaCloneID: self.clonesChoice.SetSelection(i) self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged) self.clonesChoice.SetToolTip( wx.ToolTip( "Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels." )) pmainSizer.Add(hSizer, 0, wx.EXPAND | wx.ALL, 5) # Set up timer for skill search self.searchTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.populateSkillTreeSkillSearch, self.searchTimer) tree = self.skillTreeListCtrl = TreeListCtrl( self, wx.ID_ANY, style=wx.dataview.TL_DEFAULT_STYLE) pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5) self.imageList = wx.ImageList(16, 16) tree.SetImageList(self.imageList) self.skillBookImageId = self.imageList.Add( wx.Icon(BitmapLoader.getBitmap("skill_small", "gui"))) self.skillBookDirtyImageId = self.imageList.Add( wx.Icon(BitmapLoader.getBitmap("skill_small_red", "gui"))) tree.AppendColumn("Skill") tree.AppendColumn("Level", align=wx.ALIGN_CENTER) # tree.SetMainColumn(0) self.root = tree.GetRootItem() # self.root = tree.AppendItem(root, "Skills") # # tree.SetItemText(self.root, 1, "Levels") # first one doesn't work right in Windows. Second one doesn't work right in GTK. Together, we make sure it works. # Gotta love wx tree.SetColumnWidth(0, 525) tree.SetColumnWidth(1, 100) self.btnSecStatus = wx.Button( self, wx.ID_ANY, "Sec Status: {0:.2f}".format(char.secStatus or 0.0)) self.btnSecStatus.Bind(wx.EVT_BUTTON, self.onSecStatus) self.populateSkillTree() tree.Bind(wx.dataview.EVT_TREELIST_ITEM_ACTIVATED, self.expand) tree.Bind(wx.dataview.EVT_TREELIST_ITEM_EXPANDING, self.expandLookup) tree.Bind(wx.dataview.EVT_TREELIST_ITEM_CONTEXT_MENU, self.spawnMenu) bSizerButtons = wx.BoxSizer(wx.HORIZONTAL) bSizerButtons.Add(self.btnSecStatus, 0, wx.ALL, 5) bSizerButtons.AddStretchSpacer() importExport = (("Import", wx.ART_FILE_OPEN, "from"), ("Export", wx.ART_FILE_SAVE_AS, "to")) for name, art, direction in importExport: bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON) btn = wx.BitmapButton(self, wx.ID_ANY, bitmap) btn.SetMinSize(btn.GetSize()) btn.SetMaxSize(btn.GetSize()) btn.Layout() setattr(self, "{}Btn".format(name.lower()), btn) btn.Enable(True) btn.SetToolTip("%s skills %s clipboard" % (name, direction)) bSizerButtons.Add( btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT | wx.ALL, 5) btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Skills".format(name.lower()))) pmainSizer.Add(bSizerButtons, 0, wx.EXPAND, 5) # bind the Character selection event self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged) self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree) # Context menu stuff self.idUnlearned = wx.NewId() self.levelIds = {} self.idLevels = {} self.levelIds[self.idUnlearned] = "Not learned" for level in range(6): id = wx.NewId() self.levelIds[id] = level self.idLevels[level] = id self.revertID = wx.NewId() self.saveID = wx.NewId() self.SetSizer(pmainSizer)
def initList(self): self.sizer.AddSpacer(3) from mainlogic import _ self.sizer.AddSpacer(5) hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.AddStretchSpacer() label = wx.StaticText(self, -1, _("Admission year") + ":") from datetime import date currentYear = date.today().year years = range(2010, currentYear + 1) self.yearChoice = wx.Choice(self, -1, size=wx.Size(100, -1), choices=[''] + [str(el) for el in years]) self.yearChoice.SetWindowVariant(GUI_WINDOW_VARIANT) #self.yearChoice.SetSelection(len(years)) self.yearChoice.Bind(wx.EVT_CHOICE, self.onQuickFiltersChanged) hbox.Add(label) hbox.AddSpacer(5) hbox.Add(self.yearChoice) hbox.AddStretchSpacer() label = wx.StaticText(self, -1, _("Core status") + ":") self.coreStatusChoice = wx.Choice( self, -1, choices=['', '1', '2', '3', '4', '5', '<3', '<4']) self.coreStatusChoice.SetWindowVariant(GUI_WINDOW_VARIANT) self.coreStatusChoice.Bind(wx.EVT_CHOICE, self.onQuickFiltersChanged) hbox.Add(label) hbox.AddSpacer(5) hbox.Add(self.coreStatusChoice) hbox.AddStretchSpacer() if 'petals' in psc.toolBarApplications: label = wx.StaticText(self, -1, _("Petal status") + ":") self.petalChoice = wx.Choice(self, -1, size=wx.Size(100, -1), choices=[''] + self.petalsCallback()) self.petalChoice.SetWindowVariant(GUI_WINDOW_VARIANT) self.petalChoice.Bind(wx.EVT_CHOICE, self.onQuickFiltersChanged) self.petalStatusChoice = wx.Choice( self, -1, choices=['', '1', '2', '3', '<3']) self.petalStatusChoice.SetWindowVariant(GUI_WINDOW_VARIANT) self.petalStatusChoice.Bind(wx.EVT_CHOICE, self.onQuickFiltersChanged) hbox.Add(label) hbox.AddSpacer(5) hbox.Add(self.petalChoice) hbox.AddSpacer(5) hbox.Add(self.petalStatusChoice) hbox.AddStretchSpacer() self.removeButton = wx.Button(self, -1, _("Remove quick filters")) self.removeButton.SetWindowVariant(GUI_WINDOW_VARIANT) self.removeButton.Bind(wx.EVT_BUTTON, self.onRemoveQuickFilters) hbox.Add(self.removeButton) hbox.AddSpacer(10) self.filterWarning = wx.StaticText(self, -1, _("The search filter is active"), style=wx.ALIGN_CENTRE) self.filterWarning.SetBackgroundColour('yellow') self.sizer.Add(self.filterWarning, 0, wx.EXPAND) self.sizer.Hide(self.filterWarning) self.yearWarning = wx.StaticText( self, -1, _("Only admissions for the current year are shown"), style=wx.ALIGN_CENTRE) self.yearWarning.SetBackgroundColour('light blue') self.sizer.Add(self.yearWarning, 0, wx.EXPAND) self.sizer.Hide(self.yearWarning) self.sizer.Add(hbox, 0, wx.EXPAND) vsizer = wx.BoxSizer(wx.HORIZONTAL) self.listView = PSList(self, self.centreCode, self.onOpenAdmission, self.shouldAnonymizeData) vsizer.Add(self.listView, 1, wx.EXPAND) self.sizer.Add(vsizer, 8, wx.EXPAND) il = wx.ImageList(16, 16, True) for name in glob.glob("smicon??.png"): bmp = wx.Bitmap(name, wx.BITMAP_TYPE_PNG) il_max = il.Add(bmp)
def __init__(self, parent, id, title, shortcut, isPrefix=False): wx.Frame.__init__(self, parent, -1, title, size=(700, 450), style=wx.CLOSE_BOX | wx.CAPTION | wx.MINIMIZE_BOX) self.SetIcon( wx.Icon(Variables.playonlinux_env + "/etc/playonlinux.png", wx.BITMAP_TYPE_ANY)) self.SetTitle( _('{0} configuration').format(os.environ["APPLICATION_TITLE"])) #self.panelFenp = wx.Panel(self, -1) self.splitter = wx.SplitterWindow(self, -1, style=wx.SP_NOBORDER) self.onglets = Onglets(self.splitter) if (isPrefix == True): self.onglets.s_isPrefix = True self.onglets.s_prefix = shortcut else: self.onglets.s_isPrefix = False self.onglets.s_title = shortcut self.images = wx.ImageList(16, 16) self.splitter_list = wx.SplitterWindow(self.splitter, -1, style=wx.SP_NOBORDER) self.list_game = wx.TreeCtrl(self.splitter_list, 900, size=wx.DefaultSize, style=wx.TR_HIDE_ROOT) self.control_game = wx.Panel(self.splitter_list, -1) self.AddPrefix = wx.Button( self.control_game, 1001, _("New"), pos=(0, 0), size=(95 + 10 * Variables.windows_add_playonmac, 30)) self.DelPrefix = wx.Button( self.control_game, 1002, _("Remove"), pos=(100, 0), size=(95 + 10 * Variables.windows_add_playonmac, 30)) wx.EVT_BUTTON(self, 1001, self.NewPrefix) wx.EVT_BUTTON(self, 1002, self.DeletePrefix) self.splitter_list.SplitHorizontally(self.list_game, self.control_game) self.splitter_list.SetSashPosition(423) self.splitter_list.SetSashGravity(0.94) self.list_game.SetSpacing(0) self.list_game.SetImageList(self.images) self.splitter.SplitVertically(self.splitter_list, self.onglets) self.splitter.SetSashPosition(200) self.onglets.General(_("General")) self.onglets.Wine("Wine") self.onglets.Packages(_("Install packages")) self.onglets.Display(_("Display")) self.onglets.Miscellaneous(_("Miscellaneous")) self.list_software() self.onglets.panelGeneral.Bind(wx.EVT_LEFT_UP, self.onglets.ReleaseTyping) wx.EVT_TREE_SEL_CHANGED(self, 900, self.change_program_to_selection) #self.change_program(shortcut,isPrefix) self.timer = wx.Timer(self, 1) self.Bind(wx.EVT_TIMER, self.AutoReload, self.timer) self.timer.Start(1000) self.oldreload = None self.oldimg = None self.oldpref = None
def __init__(self, parent, choices=None, drop_down_click=True, col_fetch=-1, col_search=0, hide_on_no_match=True, select_callback=None, entry_callback=None, match_function=None, **text_kwargs): """ Constructor works just like wx.TextCtrl except you can pass in a list of choices. You can also change the choice list at any time by calling SetChoices. When a choice is picked, or the user has finished typing, a EVT_COMMAND_ENTER is sent. """ text_kwargs['style'] = wx.TE_PROCESS_ENTER | wx.BORDER_NONE | text_kwargs.get('style', 0) super(SuggestTextCtrl, self).__init__(parent, **text_kwargs) # Some variables self._drop_down_click = drop_down_click self._choices = choices self._lastinsertionpoint = 0 self._hide_on_no_match = hide_on_no_match self._select_callback = select_callback self._entry_callback = entry_callback self._match_function = self._match_start_text if match_function is None else match_function self._screen_size = (wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X), wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)) # sort variable needed by listmix self.itemDataMap = dict() # Load and sort data if not self._choices: self._choices = [] # raise ValueError, "Pass me at least one of multiChoices OR choices" # widgets self.dropdown = wx.PopupWindow(self) # Control the style flags = wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_SORT_ASCENDING flags = flags | wx.LC_NO_HEADER # Create the list and bind the events self.dropdownlistbox = ChoiceListCtrl(self.dropdown, style=flags, pos=wx.Point(0, 0)) ln = 1 # else: ln = len(choices) listmix.ColumnSorterMixin.__init__(self, ln) # load the data # self.SetChoices(choices) gp = self while gp is not None: gp.Bind(wx.EVT_MOVE, self.onControlChanged, gp) gp.Bind(wx.EVT_SIZE, self.onControlChanged, gp) gp = gp.GetParent() self.Bind(wx.EVT_KILL_FOCUS, self.onControlChanged, self) self.Bind(wx.EVT_TEXT, self.onEnteredText, self) self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown, self) # If need drop down on left click if drop_down_click: self.Bind(wx.EVT_LEFT_DOWN, self.onClickToggleDown, self) self.Bind(wx.EVT_LEFT_UP, self.onClickToggleUp, self) self.dropdown.Bind(wx.EVT_LISTBOX, self.onListItemSelected, self.dropdownlistbox) self.dropdownlistbox.Bind(wx.EVT_LEFT_DOWN, self.onListClick) self.dropdownlistbox.Bind(wx.EVT_LEFT_DCLICK, self.onListDClick) # This causes the text the user is typing to directly auto-fill with # the closest possibility. # self.dropdown.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onListDClick) self.dropdownlistbox.Bind(wx.EVT_LIST_COL_CLICK, self.onListColClick) # TODO: needed? self.il = wx.ImageList(16, 16) self.dropdownlistbox.SetImageList(self.il, wx.IMAGE_LIST_SMALL) self._ascending = True
:undocumented: gIconCache, DISABLED_PIL, FOLDER_PIL, PLUGIN_PIL, ACTION_PIL """ import wx from base64 import b64decode from cStringIO import StringIO from os.path import abspath, join from PIL import Image # Local imports import eg IMAGES_PATH = eg.imagesDir gImageList = wx.ImageList(16, 16) DISABLED_PIL = Image.open(join(IMAGES_PATH, "disabled.png")) FOLDER_PIL = Image.open(join(IMAGES_PATH, "folder.png")).convert("RGBA") PLUGIN_PIL = Image.open(join(IMAGES_PATH, "plugin.png")) ACTION_PIL = Image.open(join(IMAGES_PATH, "action.png")).convert("RGBA") class IconBase(object): """ An object representing an icon with some memoization functionality. The icon is initialized by a file path (see PathIcon) or by a base64encoded string (see StringIcon). The object will not load/convert any data before an attribute is accessed. If for example the "pil" attribute is requested the first time, the object will load the underlying resource through the method self._pil() and store the result into self.pil for further requests. """
def __init__(self, parent=None): self.translationDict = None if Config.language is None: Config.language = eg.config.language wx.Frame.__init__(self, parent, -1, "Language Editor", pos=Config.position, size=Config.size) self.menuBar = self.CreateMenuBar() self.CreateStatusBar() splitter = wx.SplitterWindow(self, -1, style=wx.SP_LIVE_UPDATE) imageList = wx.ImageList(16, 16) for pathName in ( join(eg.corePluginDir, "EventGhost", "icons", "DisableItem.png"), join(eg.corePluginDir, "EventGhost", "icons", "EnableItem.png"), join(eg.imagesDir, "folder.png"), join(eg.imagesDir, "root.png"), join(eg.imagesDir, "new.png"), ): imageList.Add( wx.BitmapFromImage(wx.Image(pathName, wx.BITMAP_TYPE_PNG))) self.tree = tree = wx.TreeCtrl(splitter, -1, style=wx.TR_HAS_BUTTONS) tree.AssignImageList(imageList) self.rootId = tree.AddRoot("Language Strings", 3) tree.SetPyData(self.rootId, ["", None, None]) eg.Init.ImportAll() eg.actionThread.Start() def LoadPlugins(): for plugin in os.listdir(eg.corePluginDir): if not plugin.startswith("."): eg.pluginManager.OpenPlugin(plugin, plugin, ()).Close() eg.actionThread.CallWait(LoadPlugins) rightPanel = wx.Panel(splitter) self.disabledColour = rightPanel.GetBackgroundColour() languageNames = eg.Translation.languageNames self.langKeys = sorted(languageNames, key=languageNames.get) self.langNames = [languageNames[k] for k in self.langKeys] self.currentValueCtrl = wx.TextCtrl(rightPanel, style=wx.TE_MULTILINE | wx.TE_READONLY) self.enabledColour = self.currentValueCtrl.GetBackgroundColour() self.currentValueCtrl.SetBackgroundColour(self.disabledColour) self.currentValueCtrl.SetEditable(False) self.newValueCtrl = wx.TextCtrl(rightPanel, style=wx.TE_MULTILINE) staticBoxSizer1 = wx.StaticBoxSizer( wx.StaticBox(rightPanel, label="Original Text"), wx.VERTICAL) staticBoxSizer1.Add(self.currentValueCtrl, 1, wx.EXPAND) staticBoxSizer2 = wx.StaticBoxSizer( wx.StaticBox(rightPanel, label="Translated Text"), wx.VERTICAL) staticBoxSizer2.Add(self.newValueCtrl, 1, wx.EXPAND) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(staticBoxSizer1, 1, wx.EXPAND | wx.ALL, 5) sizer.Add((5, 5)) sizer.Add(staticBoxSizer2, 1, wx.EXPAND | wx.ALL, 5) rightPanel.SetSizer(sizer) splitter.SplitVertically(tree, rightPanel) splitter.SetMinimumPaneSize(120) splitter.SetSashGravity(0.0) splitter.SetSashPosition(Config.splitPosition) #width + 20) self.isDirty = False self.newValueCtrl.Bind(wx.EVT_TEXT, self.OnTextChange) tree.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnSelectionChanging) tree.Bind(wx.EVT_TREE_ITEM_COLLAPSING, self.OnItemCollapsing) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_MENU_OPEN, self.OnValidateMenus) self.LoadLanguage(Config.language) self.Show()
def PopulateTree(self): root = self.affectedBy.AddRoot("WINPWNZ0R") self.affectedBy.SetPyData(root, None) self.imageList = wx.ImageList(16, 16) self.affectedBy.SetImageList(self.imageList) cont = self.stuff.itemModifiedAttributes if self.item == self.stuff.item else self.stuff.chargeModifiedAttributes things = {} for attrName in cont.iterAfflictions(): # if value is 0 or there has been no change from original to modified, return if cont[attrName] == (cont.getOriginal(attrName) or 0): continue for fit, afflictors in cont.getAfflictions(attrName).iteritems(): for afflictor, modifier, amount, used in afflictors: if not used or afflictor.item is None: continue if afflictor.item.name not in things: things[afflictor.item.name] = [ type(afflictor), set(), [] ] info = things[afflictor.item.name] info[1].add(afflictor) # If info[1] > 1, there are two separate modules working. # Check to make sure we only include the modifier once # See GH issue 154 if len(info[1]) > 1 and (attrName, modifier, amount) in info[2]: continue info[2].append((attrName, modifier, amount)) order = things.keys() order.sort(key=lambda x: (self.ORDER.index(things[x][0]), x)) for itemName in order: info = things[itemName] afflictorType, afflictors, attrData = info counter = len(afflictors) baseAfflictor = afflictors.pop() if afflictorType == Ship: itemIcon = self.imageList.Add( bitmapLoader.getBitmap("ship_small", "icons")) elif baseAfflictor.item.icon: bitmap = bitmapLoader.getBitmap( baseAfflictor.item.icon.iconFile, "pack") itemIcon = self.imageList.Add(bitmap) if bitmap else -1 else: itemIcon = -1 child = self.affectedBy.AppendItem( root, "%s" % itemName if counter == 1 else "%s x %d" % (itemName, counter), itemIcon) if counter > 0: attributes = [] for attrName, attrModifier, attrAmount in attrData: attrInfo = self.stuff.item.attributes.get(attrName) displayName = attrInfo.displayName if attrInfo else "" if attrInfo: if attrInfo.icon is not None: iconFile = attrInfo.icon.iconFile icon = bitmapLoader.getBitmap(iconFile, "pack") if icon is None: icon = bitmapLoader.getBitmap( "transparent16x16", "icons") attrIcon = self.imageList.Add(icon) else: attrIcon = self.imageList.Add( bitmapLoader.getBitmap("07_15", "pack")) else: attrIcon = self.imageList.Add( bitmapLoader.getBitmap("07_15", "pack")) if attrModifier == "s*": attrModifier = "*" penalized = "(penalized)" else: penalized = "" attributes.append( (attrName, (displayName if displayName != "" else attrName), attrModifier, attrAmount, penalized, attrIcon)) attrSorted = sorted(attributes, key=lambda attribName: attribName[0]) for attr in attrSorted: attrName, displayName, attrModifier, attrAmount, penalized, attrIcon = attr if self.toggleView == 1: treeitem = self.affectedBy.AppendItem( child, "%s %s %.2f %s" % ((displayName if displayName != "" else attrName), attrModifier, attrAmount, penalized), attrIcon) self.affectedBy.SetPyData( treeitem, "%s %s %.2f %s" % (attrName, attrModifier, attrAmount, penalized)) else: treeitem = self.affectedBy.AppendItem( child, "%s %s %.2f %s" % (attrName, attrModifier, attrAmount, penalized), attrIcon) self.affectedBy.SetPyData( treeitem, "%s %s %.2f %s" % ((displayName if displayName != "" else attrName), attrModifier, attrAmount, penalized)) self.ExpandCollapseTree()
def Configure(self, parent, checkMultiLoad=True, title=None): if title is None: title = Text.title self.checkMultiLoad = checkMultiLoad if self.__class__.instance: self.__class__.instance.Raise() return self.__class__.instance = self self.resultData = None eg.TaskletDialog.__init__(self, parent, -1, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) splitterWindow = wx.SplitterWindow( self, style=(wx.SP_LIVE_UPDATE | wx.CLIP_CHILDREN | wx.NO_FULL_REPAINT_ON_RESIZE)) self.treeCtrl = treeCtrl = wx.TreeCtrl( splitterWindow, style=(wx.TR_SINGLE | wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT)) treeCtrl.SetMinSize((170, 200)) imageList = wx.ImageList(16, 16) imageList.Add(eg.Icons.PLUGIN_ICON.GetBitmap()) imageList.Add(eg.Icons.FOLDER_ICON.GetBitmap()) treeCtrl.SetImageList(imageList) root = treeCtrl.AddRoot("") typeIds = { KIND_TAGS[0]: treeCtrl.AppendItem(root, getattr(Text, KIND_TAGS[0] + "Plugins"), 1), KIND_TAGS[1]: treeCtrl.AppendItem(root, getattr(Text, KIND_TAGS[1] + "Plugins"), 1), KIND_TAGS[2]: treeCtrl.AppendItem(root, getattr(Text, KIND_TAGS[2] + "Plugins"), 1), KIND_TAGS[3]: treeCtrl.AppendItem(root, getattr(Text, KIND_TAGS[3] + "Plugins"), 1), } self.typeIds = typeIds itemToSelect = typeIds[KIND_TAGS[0]] for info in eg.pluginManager.GetPluginInfoList(): if info.kind in ("hidden", "core"): continue if info.icon and info.icon != eg.Icons.PLUGIN_ICON: idx = imageList.Add( eg.Icons.PluginSubIcon(info.icon).GetBitmap()) else: idx = 0 treeId = treeCtrl.AppendItem(typeIds[info.kind], info.name, idx) if not info.valid: treeCtrl.SetItemTextColour(treeId, eg.colour.pluginError) treeCtrl.SetPyData(treeId, info) if info.path == Config.lastSelection: itemToSelect = treeId for kind, treeId in typeIds.items(): if kind in Config.collapsed: treeCtrl.Collapse(treeId) else: treeCtrl.Expand(treeId) treeCtrl.ScrollTo(itemToSelect) def OnCmdExport(dummyEvent=None): info = self.treeCtrl.GetPyData(self.treeCtrl.GetSelection()) if info: eg.PluginInstall.Export(info) menu = wx.Menu() menuId = wx.NewId() menu.Append(menuId, eg.text.MainFrame.Menu.Export) self.Bind(wx.EVT_MENU, OnCmdExport, id=menuId) self.contextMenu = menu self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnItemRightClick) rightPanel = wx.Panel(splitterWindow) rightSizer = wx.BoxSizer(wx.VERTICAL) rightPanel.SetSizer(rightSizer) self.nameText = nameText = wx.StaticText(rightPanel) nameText.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.FONTWEIGHT_BOLD)) rightSizer.Add(nameText, 0, wx.EXPAND | wx.LEFT | wx.BOTTOM, 5) subSizer = wx.FlexGridSizer(2, 2) self.authorLabel = wx.StaticText(rightPanel, label=Text.author) subSizer.Add(self.authorLabel) self.authorText = wx.StaticText(rightPanel) subSizer.Add(self.authorText, 0, wx.EXPAND | wx.LEFT, 5) self.versionLabel = wx.StaticText(rightPanel, label=Text.version) subSizer.Add(self.versionLabel) self.versionText = wx.StaticText(rightPanel) subSizer.Add(self.versionText, 0, wx.EXPAND | wx.LEFT, 5) rightSizer.Add(subSizer, 0, wx.EXPAND | wx.LEFT | wx.BOTTOM, 5) staticBoxSizer = wx.StaticBoxSizer( wx.StaticBox(rightPanel, label=Text.descriptionBox)) self.descrBox = eg.HtmlWindow(rightPanel) staticBoxSizer.Add(self.descrBox, 1, wx.EXPAND) rightSizer.Add(staticBoxSizer, 1, wx.EXPAND | wx.LEFT, 5) splitterWindow.SplitVertically(self.treeCtrl, rightPanel) splitterWindow.SetMinimumPaneSize(60) splitterWindow.SetSashGravity(0.0) splitterWindow.UpdateSize() self.buttonRow = eg.ButtonRow(self, (wx.ID_OK, wx.ID_CANCEL), True) self.okButton = self.buttonRow.okButton self.okButton.Enable(False) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(splitterWindow, 1, wx.EXPAND | wx.ALL, 5) mainSizer.Add(self.buttonRow.sizer, 0, wx.EXPAND) self.SetSizerAndFit(mainSizer) #minSize = mainSizer.GetMinSize() #self.SetMinSize(minSize) self.SetSize(Config.size) splitterWindow.SetSashPosition(Config.splitPosition) if Config.position: self.SetPosition(Config.position) treeCtrl.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChanged) treeCtrl.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemActivated) treeCtrl.SelectItem(itemToSelect) # -------- This code is for setting the use GUID instead of XmlIdLink --------- self.click_count = 0 def on_left_down(evt): x, y = evt.GetPosition() width, height = self.GetClientSize() start_x = width - 20 stary_y = 0 stop_x = start_x + 20 stop_y = stary_y + 20 if stop_x > x > start_x and stop_y > y > stary_y: if not self.click_count: self.CaptureMouse() start_x = 0 stary_y = height - 20 stop_x = start_x + 20 stop_y = stary_y + 20 if stop_x > x > start_x and stop_y > y > stary_y: if self.click_count: self.CaptureMouse() evt.Skip() def on_left_up(evt): if self.HasCapture(): self.ReleaseMouse() self.click_count += 1 if self.click_count == 2: self.click_count = 0 dialog = eg.MessageDialog( parent=None, message= ('Warning: This process cannot be undone so make\n' ' a backup copy of your save file now.\n\n' 'This process will modify and save all EventGhost Data!!\n' 'Enable using GUID\'s?\n\n'), style=wx.YES_NO | wx.STAY_ON_TOP) if dialog.ShowModal() == wx.ID_YES: eg.useTreeItemGUID = True eg.document.SetIsDirty(True) eg.document.Save() eg.config.Save() dialog.Destroy() evt.Skip() if eg.useTreeItemGUID is False: self.Bind(wx.EVT_LEFT_DOWN, on_left_down) self.Bind(wx.EVT_LEFT_UP, on_left_up) # ----------------------------------------------------------------------------- while self.Affirmed(): if self.CheckMultiload(): self.SetResult(self.resultData) Config.size = self.GetSizeTuple() Config.position = self.GetPositionTuple() Config.splitPosition = splitterWindow.GetSashPosition() Config.collapsed = set(kind for kind, treeId in typeIds.items() if not treeCtrl.IsExpanded(treeId)) self.__class__.instance = None
def __init__(self, parent, var_type, controller): wx.Dialog.__init__(self, parent, title=_('Browse Locations'), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) main_sizer.AddGrowableCol(0) main_sizer.AddGrowableRow(1) locations_label = wx.StaticText(self, label=_('Locations available:')) main_sizer.AddWindow(locations_label, border=20, flag=wx.TOP | wx.LEFT | wx.RIGHT | wx.GROW) self.LocationsTree = wx.TreeCtrl( self, style=(wx.TR_HAS_BUTTONS | wx.TR_SINGLE | wx.SUNKEN_BORDER | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT)) self.LocationsTree.SetInitialSize(wx.Size(-1, 300)) self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated, self.LocationsTree) main_sizer.AddWindow(self.LocationsTree, border=20, flag=wx.LEFT | wx.RIGHT | wx.GROW) button_gridsizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) button_gridsizer.AddGrowableCol(1) button_gridsizer.AddGrowableCol(3) button_gridsizer.AddGrowableRow(0) main_sizer.AddSizer(button_gridsizer, border=20, flag=wx.BOTTOM | wx.LEFT | wx.RIGHT | wx.GROW) direction_label = wx.StaticText(self, label=_('Direction:')) button_gridsizer.AddWindow(direction_label, flag=wx.ALIGN_CENTER_VERTICAL) self.DirFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.DirFilterChoice) button_gridsizer.AddWindow(self.DirFilterChoice, flag=wx.GROW | wx.ALIGN_CENTER_VERTICAL) filter_label = wx.StaticText(self, label=_('Type:')) button_gridsizer.AddWindow(filter_label, flag=wx.ALIGN_CENTER_VERTICAL) self.TypeFilterChoice = wx.ComboBox(self, style=wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.OnFilterChoice, self.TypeFilterChoice) button_gridsizer.AddWindow(self.TypeFilterChoice, flag=wx.GROW | wx.ALIGN_CENTER_VERTICAL) button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE) self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) button_gridsizer.AddSizer(button_sizer, flag=wx.ALIGN_RIGHT) self.SetSizer(main_sizer) self.Controller = controller self.VarType = var_type self.BaseVarType = self.Controller.GetBaseType(self.VarType) self.VarTypeSize = LOCATION_SIZES[self.BaseVarType] self.Locations = self.Controller.GetVariableLocationTree() # Define Tree item icon list self.TreeImageList = wx.ImageList(16, 16) self.TreeImageDict = {} # Icons for items for imgname, itemtype in [("CONFIGURATION", LOCATION_CONFNODE), ("RESOURCE", LOCATION_MODULE), ("PROGRAM", LOCATION_GROUP), ("VAR_INPUT", LOCATION_VAR_INPUT), ("VAR_OUTPUT", LOCATION_VAR_OUTPUT), ("VAR_LOCAL", LOCATION_VAR_MEMORY)]: self.TreeImageDict[itemtype] = self.TreeImageList.Add( GetBitmap(imgname)) # Assign icon list to TreeCtrls self.LocationsTree.SetImageList(self.TreeImageList) # Set a options for the choice for option, filter in GetDirFilterChoiceOptions(): self.DirFilterChoice.Append(_(option)) self.DirFilterChoice.SetStringSelection(_("All")) for option in GetTypeFilterChoiceOptions(): self.TypeFilterChoice.Append(_(option)) self.TypeFilterChoice.SetStringSelection(_("All")) self.RefreshFilters() self.RefreshLocationsTree() self.Fit()
def __init__(self, parent, quote, filter=False, market=None, filterEnabled=True, tradableOnly=False): iTradeSizedDialog.__init__(self, parent, -1, message('quote_select_title'), size=(460, 460), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.m_parent = parent # init if quote: self.m_isin = quote.isin() self.m_ticker = quote.ticker() self.m_market = quote.market() self.m_place = quote.place() else: self.m_isin = '' self.m_ticker = '' self.m_market = market self.m_place = market2place(market) self.m_filter = filter self.m_qlist = QLIST_SYSTEM self.m_qlist_tradableOnly = tradableOnly self.m_editing = True tID = wx.NewId() self.m_imagelist = wx.ImageList(16, 16) self.sm_q = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'quote.png'))) self.sm_i = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'invalid.png'))) self.sm_up = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_up.png'))) self.sm_dn = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_down.png'))) # container container = self.GetContentsPane() container.SetSizerType("vertical") # resizable pane pane = sc.SizedPanel(container, -1) pane.SetSizerType("horizontal") pane.SetSizerProps(expand=True) # pane : ISIN or Name selection label = wx.StaticText(pane, -1, message('quote_select_isin')) label.SetSizerProps(valign='center') tID = wx.NewId() self.wxIsinCtrl = wx.TextCtrl(pane, tID, self.m_isin) self.wxIsinCtrl.SetSizerProps(expand=True) wx.EVT_TEXT(self, tID, self.OnISINEdited) label = wx.StaticText(pane, -1, message('quote_select_ticker')) label.SetSizerProps(valign='center') tID = wx.NewId() self.wxTickerCtrl = wx.TextCtrl(pane, tID, self.m_ticker) self.wxTickerCtrl.SetSizerProps(expand=True) wx.EVT_TEXT(self, tID, self.OnTickerEdited) # resizable pane pane = sc.SizedPanel(container, -1) pane.SetSizerType("horizontal") pane.SetSizerProps(expand=True) # pane : market & list filters self.wxLabelMarketCtrl = wx.StaticText(pane, -1, message('quote_select_market')) self.wxLabelMarketCtrl.SetSizerProps(valign='center') self.wxMarketCtrl = wx.ComboBox(pane, -1, "", style=wx.CB_DROPDOWN | wx.CB_READONLY) self.wxMarketCtrl.SetSizerProps(expand=True) wx.EVT_COMBOBOX(self, self.wxMarketCtrl.GetId(), self.OnMarket) count = 0 idx = 0 for eachCtrl in list_of_markets(bFilterMode=False): self.wxMarketCtrl.Append(eachCtrl, eachCtrl) if eachCtrl == self.m_market: idx = count count = count + 1 self.wxMarketCtrl.SetSelection(idx) self.wxLabelQListCtrl = wx.StaticText(pane, -1, message('quote_select_list')) self.wxLabelQListCtrl.SetSizerProps(valign='center') self.wxQListCtrl = wx.ComboBox(pane, -1, "", style=wx.CB_DROPDOWN | wx.CB_READONLY) self.wxQListCtrl.SetSizerProps(expand=True) wx.EVT_COMBOBOX(self, self.wxQListCtrl.GetId(), self.OnQuoteList) self.wxQListCtrl.Append(message('quote_select_alllist'), QLIST_ALL) self.wxQListCtrl.Append(message('quote_select_syslist'), QLIST_SYSTEM) self.wxQListCtrl.Append(message('quote_select_usrlist'), QLIST_USER) if not self.m_qlist_tradableOnly: self.wxQListCtrl.Append(message('quote_select_indiceslist'), QLIST_INDICES) self.wxQListCtrl.Append(message('quote_select_trackerslist'), QLIST_TRACKERS) self.wxQListCtrl.Append(message('quote_select_bondslist'), QLIST_BONDS) self.wxQListCtrl.SetSelection(self.m_qlist) # select traded or not tID = wx.NewId() self.wxFilterCtrl = wx.CheckBox(container, tID, message('quote_select_filterfield')) self.wxFilterCtrl.SetValue(self.m_filter) wx.EVT_CHECKBOX(self, tID, self.OnFilter) self.wxFilterCtrl.Enable(filterEnabled) # List self.m_list = iTradeSelectorListCtrl(container, tID, style=wx.LC_REPORT | wx.SUNKEN_BORDER, size=(440, 380)) self.m_list.SetSizerProps(expand=True) self.m_list.SetImageList(self.m_imagelist, wx.IMAGE_LIST_SMALL) # Now that the list exists we can init the other base class, # see wxPython/lib/mixins/listctrl.py wxl.ColumnSorterMixin.__init__(self, 5) wx.EVT_LIST_COL_CLICK(self, tID, self.OnColClick) wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated) wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected) # Last Row : OK and Cancel btnpane = sc.SizedPanel(container, -1) btnpane.SetSizerType("horizontal") btnpane.SetSizerProps(expand=True) # context help if wx.Platform != "__WXMSW__": btn = wx.ContextHelpButton(btnpane) # OK self.wxOK = wx.Button(btnpane, wx.ID_OK, message('valid')) self.wxOK.SetDefault() self.wxOK.SetHelpText(message('valid_desc')) wx.EVT_BUTTON(self, wx.ID_OK, self.OnValid) # CANCEL btn = wx.Button(btnpane, wx.ID_CANCEL, message('cancel')) btn.SetHelpText(message('cancel_desc')) # set the right filter and fit everything self.OnFilter() EVT_POSTINIT(self, self.OnPostInit) wx.PostEvent(self, PostInitEvent())
def __init__(self, parent, market): # context help pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) title = message('quote_list_title') pre.Create(parent, -1, title, size=(590, 460)) self.PostCreate(pre) self.m_parent = parent self.m_dirty = False self.m_market = market self.m_qlist = QLIST_SYSTEM tID = wx.NewId() self.m_imagelist = wx.ImageList(16, 16) self.sm_q = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'quote.png'))) self.sm_i = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'invalid.png'))) self.sm_up = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_up.png'))) self.sm_dn = self.m_imagelist.Add( wx.Bitmap(os.path.join(itrade_config.dirRes, 'sm_down.png'))) self.m_list = iTradeSelectorListCtrl(self, tID, style=wx.LC_REPORT | wx.SUNKEN_BORDER, size=(570, 380)) self.m_list.SetImageList(self.m_imagelist, wx.IMAGE_LIST_SMALL) # Now that the list exists we can init the other base class, # see wxPython/lib/mixins/listctrl.py wxl.ColumnSorterMixin.__init__(self, 7) wx.EVT_LIST_COL_CLICK(self, tID, self.OnColClick) wx.EVT_SIZE(self, self.OnSize) wx.EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnItemActivated) wx.EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected) sizer = wx.BoxSizer(wx.VERTICAL) # market selection box = wx.BoxSizer(wx.HORIZONTAL) label = wx.StaticText(self, -1, message('quote_select_market')) box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.wxMarketCtrl = wx.ComboBox(self, -1, "", size=wx.Size(200, -1), style=wx.CB_DROPDOWN | wx.CB_READONLY) box.Add(self.wxMarketCtrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_COMBOBOX(self, self.wxMarketCtrl.GetId(), self.OnMarket) count = 0 idx = 0 for eachCtrl in list_of_markets(bFilterMode=True): self.wxMarketCtrl.Append(eachCtrl, eachCtrl) if eachCtrl == self.m_market: idx = count count = count + 1 self.wxMarketCtrl.SetSelection(idx) # list selection label = wx.StaticText(self, -1, message('quote_select_list')) box.Add(label, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.wxQListCtrl = wx.ComboBox(self, -1, "", size=wx.Size(140, -1), style=wx.CB_DROPDOWN | wx.CB_READONLY) box.Add(self.wxQListCtrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_COMBOBOX(self, self.wxQListCtrl.GetId(), self.OnQuoteList) self.wxQListCtrl.Append(message('quote_select_alllist'), QLIST_ALL) self.wxQListCtrl.Append(message('quote_select_syslist'), QLIST_SYSTEM) self.wxQListCtrl.Append(message('quote_select_usrlist'), QLIST_USER) self.wxQListCtrl.Append(message('quote_select_indiceslist'), QLIST_INDICES) self.wxQListCtrl.Append(message('quote_select_trackerslist'), QLIST_TRACKERS) self.wxQListCtrl.Append(message('quote_select_bondslist'), QLIST_BONDS) self.wxQListCtrl.SetSelection(self.m_qlist) self.wxCount = wx.StaticText(self, -1, '--') box.Add(self.wxCount, 0, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.AddSizer(box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) box.Add(self.m_list, 0, wx.ALIGN_CENTRE | wx.ALL, 5) sizer.Add(box, 0, wx.ALIGN_CENTRE | wx.ALL, 5) box2 = wx.BoxSizer(wx.VERTICAL) self.wxNEW = wx.Button(self, wx.ID_NEW, message('listquote_new')) self.wxNEW.SetHelpText(message('listquote_new_desc')) box2.Add(self.wxNEW, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_BUTTON(self, wx.ID_NEW, self.OnNewQuote) self.wxPROP = wx.Button(self, wx.ID_PROPERTIES, message('listquote_edit')) self.wxPROP.SetHelpText(message('listquote_edit_desc')) box2.Add(self.wxPROP, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_BUTTON(self, wx.ID_PROPERTIES, self.OnEditQuote) self.wxDELETE = wx.Button(self, wx.ID_DELETE, message('listquote_delete')) self.wxDELETE.SetHelpText(message('listquote_delete_desc')) box2.Add(self.wxDELETE, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_BUTTON(self, wx.ID_DELETE, self.OnDeleteQuote) box.Add(box2, 0, wx.ALIGN_CENTRE | wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) # context help if wx.Platform != "__WXMSW__": btn = wx.ContextHelpButton(self) box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5) # CANCEL btn = wx.Button(self, wx.ID_CANCEL, message('close')) btn.SetHelpText(message('close_desc')) wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel) box.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5) # SAVE btn.SetDefault() self.wxSAVE = wx.Button(self, wx.ID_APPLY, message('listquote_save')) self.wxSAVE.SetHelpText(message('listquote_save_desc')) box.Add(self.wxSAVE, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_BUTTON(self, wx.ID_APPLY, self.OnSave) # DOWNLOAD self.wxOK = wx.Button(self, wx.ID_OK, '') self.wxOK.SetHelpText('') box.Add(self.wxOK, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_BUTTON(self, wx.ID_OK, self.OnDownload) # CLEAR self.wxCLEAR = wx.Button(self, wx.ID_CLEAR, '') self.wxCLEAR.SetHelpText('') box.Add(self.wxCLEAR, 0, wx.ALIGN_CENTRE | wx.ALL, 5) wx.EVT_BUTTON(self, wx.ID_CLEAR, self.OnClear) sizer.AddSizer(box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) self.SetAutoLayout(True) self.SetSizerAndFit(sizer) EVT_POSTINIT(self, self.OnPostInit) wx.PostEvent(self, PostInitEvent())
def CreateTreeListCtrl(self, isTreeList): if isTreeList: treeList = wx.gizmos.TreeListCtrl( self.notebook, style=wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT | wx.SUNKEN_BORDER | wx.TR_MULTIPLE, name="TreeList1") else: treeList = wx.TreeCtrl(self.split1, style=wx.TR_DEFAULT_STYLE | wx.SUNKEN_BORDER | wx.TR_MULTIPLE, name="TreeCtrl1") il = wx.ImageList(16, 16) fldridx = il.Add( wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16, 16))) smileidx = il.Add(images.Smiles.GetBitmap()) treeList.AssignImageList(il) if isTreeList: # create some columns treeList.AddColumn("Main column") treeList.AddColumn("Column 1") treeList.AddColumn("Column 2") treeList.SetMainColumn(0) # the one with the tree in it... treeList.SetColumnWidth(0, 175) root = treeList.AddRoot("The Root Item") if isTreeList: treeList.SetItemText(root, "col 1 root", 1) treeList.SetItemText(root, "col 2 root", 2) treeList.SetItemImage(root, fldridx) for x in range(15): txt = "Item %d" % x child = treeList.AppendItem(root, txt) treeList.SetItemImage(child, smileidx) if isTreeList: treeList.SetItemText(child, txt + "(c1)", 1) treeList.SetItemText(child, txt + "(c2)", 2) for y in range(5): txt = "item %d-%s" % (x, chr(ord("a") + y)) last = treeList.AppendItem(child, txt) treeList.SetItemImage(last, fldridx) if isTreeList: treeList.SetItemText(last, txt + "(c1)", 1) treeList.SetItemText(last, txt + "(c2)", 2) for z in range(5): txt = "item %d-%s-%d" % (x, chr(ord("a") + y), z) item = treeList.AppendItem(last, txt) treeList.SetItemImage(item, smileidx) if isTreeList: treeList.SetItemText(item, txt + "(c1)", 1) treeList.SetItemText(item, txt + "(c2)", 2) treeList.Expand(root) return treeList
def __init__(self, parent, id_num): """Initialize a notebook with a blank text control in it @param parent: parent window of the notebook @param id_num: this notebooks id """ style = aui.AUI_NB_DEFAULT_STYLE | \ aui.AUI_NB_WINDOWLIST_BUTTON | \ aui.AUI_NB_SMART_TABS | \ aui.AUI_NB_USE_IMAGES_DROPDOWN | \ aui.AUI_NB_TAB_EXTERNAL_MOVE | \ aui.AUI_NB_TAB_FIXED_WIDTH if wx.Platform == '__WXMAC__': style |= aui.AUI_NB_CLOSE_ON_TAB_LEFT aui.AuiNotebook.__init__(self, parent, id_num, agwStyle=style) # Notebook attributes self.LOG = wx.GetApp().GetLog() self._idletimer = wx.Timer(self, ID_IDLE_TIMER) self.DocMgr = ed_editv.EdEditorView.DOCMGR self._searchctrl = ed_search.SearchController(self, self.GetCurrentCtrl) self._searchctrl.SetLookinChoices(Profile_Get('SEARCH_LOC', default=list())) self._searchctrl.SetFileFilters(Profile_Get('SEARCH_FILTER', default='')) self.pg_num = -1 # Track new pages (aka untitled docs) self.mdown = -1 self.control = None self.frame = self.GetTopLevelParent() # MainWindow self._index = dict() # image list index self._ses_load = False self._menu = None # Setup Tab Navigator ed_icon = ed_glob.CONFIG['SYSPIX_DIR'] + u"editra.png" self.SetNavigatorIcon(wx.Bitmap(ed_icon, wx.BITMAP_TYPE_PNG)) # Setup the ImageList and the default image imgl = wx.ImageList(16, 16) txtbmp = wx.ArtProvider.GetBitmap(str(synglob.ID_LANG_TXT), wx.ART_MENU) self._index[synglob.ID_LANG_TXT] = imgl.Add(txtbmp) robmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_READONLY), wx.ART_MENU) self._index[ed_glob.ID_READONLY] = imgl.Add(robmp) self.SetImageList(imgl) # Set custom options self.SetSashDClickUnsplit(True) self.SetMinMaxTabWidth(125, 135) # Notebook Events self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGING, self.OnPageChanging) self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged) self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnPageClosing) self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSED, self.OnPageClosed) self.Bind(aui.EVT_AUINOTEBOOK_TAB_DCLICK, self.OnTabLeftDClick) self.Bind(aui.EVT_AUINOTEBOOK_BG_DCLICK, self.OnBGLeftDClick) self.Bind(aui.EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, self.OnMClickDown) self.Bind(aui.EVT_AUINOTEBOOK_TAB_MIDDLE_UP, self.OnMClickUp) self.Bind(aui.EVT_AUINOTEBOOK_TAB_RIGHT_UP, self.OnTabMenu) self.Bind(aui.EVT_AUINOTEBOOK_ALLOW_DND, self.OnAllowDnD) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnUpdatePageText) self.Bind(wx.EVT_MENU, self.OnMenu) self.Bind(wx.EVT_TIMER, self.OnIdle, id=ID_IDLE_TIMER) # Message handlers ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED) ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_NOTEBOOK) ed_msg.Subscribe(self.OnUpdatePosCache, ed_msg.EDMSG_UI_STC_POS_JUMPED) ed_msg.RegisterCallback(self.OnDocPointerRequest, ed_msg.EDREQ_DOCPOINTER) # Add a blank page self.NewPage() self._idletimer.Start(333) # Do idle checks 3 times a second
def __init__(self, parent, log): # Use the WANTS_CHARS style so the panel doesn't eat the Return key. wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS) self.Bind(wx.EVT_SIZE, self.OnSize) self.log = log tID = wx.NewId() self.tree = MyTreeCtrl( self, tID, wx.DefaultPosition, wx.DefaultSize, wx.TR_HAS_BUTTONS | wx.TR_EDIT_LABELS #| wx.TR_MULTIPLE #| wx.TR_HIDE_ROOT , self.log) isz = (16, 16) il = wx.ImageList(isz[0], isz[1]) fldridx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, isz)) fldropenidx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_FOLDER_OPEN, wx.ART_OTHER, isz)) fileidx = il.Add( wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz)) smileidx = il.Add(images.Smiles.GetBitmap()) self.tree.SetImageList(il) self.il = il # NOTE: For some reason tree items have to have a data object in # order to be sorted. Since our compare just uses the labels # we don't need any real data, so we'll just use None below for # the item data. self.root = self.tree.AddRoot("The Root Item") self.tree.SetItemData(self.root, None) self.tree.SetItemImage(self.root, fldridx, wx.TreeItemIcon_Normal) self.tree.SetItemImage(self.root, fldropenidx, wx.TreeItemIcon_Expanded) for x in range(15): child = self.tree.AppendItem(self.root, "Item %d" % x) self.tree.SetItemData(child, None) self.tree.SetItemImage(child, fldridx, wx.TreeItemIcon_Normal) self.tree.SetItemImage(child, fldropenidx, wx.TreeItemIcon_Expanded) for y in range(5): last = self.tree.AppendItem( child, "item %d-%s" % (x, chr(ord("a") + y))) self.tree.SetItemData(last, None) self.tree.SetItemImage(last, fldridx, wx.TreeItemIcon_Normal) self.tree.SetItemImage(last, fldropenidx, wx.TreeItemIcon_Expanded) for z in range(5): item = self.tree.AppendItem( last, "item %d-%s-%d" % (x, chr(ord("a") + y), z)) self.tree.SetItemData(item, None) self.tree.SetItemImage(item, fileidx, wx.TreeItemIcon_Normal) self.tree.SetItemImage(item, smileidx, wx.TreeItemIcon_Selected) self.tree.Expand(self.root) self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded, self.tree) self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, self.tree) self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree) self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.tree) self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnEndEdit, self.tree) self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate, self.tree) self.tree.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) self.tree.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown) self.tree.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
def __init__(self, parent, colNames=None, choices=None, multiChoices=None, showHead=True, dropDownClick=True, colFetch=-1, colSearch=0, hideOnNoMatch=True, selectCallback=None, entryCallback=None, matchFunction=None, **therest): ''' Constructor works just like wx.TextCtrl except you can pass in a list of choices. You can also change the choice list at any time by calling setChoices. ''' if 'style' in therest: therest['style'] = wx.TE_PROCESS_ENTER | therest['style'] else: therest['style'] = wx.TE_PROCESS_ENTER wx.TextCtrl.__init__(self, parent, **therest) #Some variables self._dropDownClick = dropDownClick self._colNames = colNames self._multiChoices = multiChoices self._showHead = showHead self._choices = choices self._lastinsertionpoint = 0 self._hideOnNoMatch = hideOnNoMatch self._selectCallback = selectCallback self._entryCallback = entryCallback self._matchFunction = matchFunction self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) #sort variable needed by listmix self.itemDataMap = dict() #Load and sort data if not (self._multiChoices or self._choices): raise ValueError, "Pass me at least one of multiChoices OR choices" #widgets self.dropdown = wx.PopupWindow(self) #Control the style flags = wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_SORT_ASCENDING if not (showHead and multiChoices): flags = flags | wx.LC_NO_HEADER #Create the list and bind the events self.dropdownlistbox = myListCtrl(self.dropdown, style=flags, pos=wx.Point(0, 0)) #initialize the parent if multiChoices: ln = len(multiChoices) else: ln = 1 #else: ln = len(choices) listmix.ColumnSorterMixin.__init__(self, ln) #load the data if multiChoices: self.SetMultipleChoices(multiChoices, colSearch=colSearch, colFetch=colFetch) else: self.SetChoices(choices) gp = self while gp != None: gp.Bind(wx.EVT_MOVE, self.onControlChanged, gp) gp.Bind(wx.EVT_SIZE, self.onControlChanged, gp) gp = gp.GetParent() self.Bind(wx.EVT_KILL_FOCUS, self.onControlChanged, self) self.Bind(wx.EVT_TEXT, self.onEnteredText, self) self.Bind(wx.EVT_KEY_DOWN, self.onKeyDown, self) #If need drop down on left click if dropDownClick: self.Bind(wx.EVT_LEFT_DOWN, self.onClickToggleDown, self) self.Bind(wx.EVT_LEFT_UP, self.onClickToggleUp, self) self.dropdown.Bind(wx.EVT_LISTBOX, self.onListItemSelected, self.dropdownlistbox) self.dropdownlistbox.Bind(wx.EVT_LEFT_DOWN, self.onListClick) self.dropdownlistbox.Bind(wx.EVT_LEFT_DCLICK, self.onListDClick) self.dropdownlistbox.Bind(wx.EVT_LIST_COL_CLICK, self.onListColClick) self.il = wx.ImageList(16, 16) self.sm_dn = self.il.Add(getSmallDnArrowBitmap()) self.sm_up = self.il.Add(getSmallUpArrowBitmap()) self.dropdownlistbox.SetImageList(self.il, wx.IMAGE_LIST_SMALL) self._ascending = True
def __init__(self, parent, id_num): """Initialize a notebook with a blank text control in it @param parent: parent window of the notebook @param id_num: this notebooks id """ FNB.FlatNotebook.__init__( self, parent, id_num, style=FNB.FNB_FF2 | FNB.FNB_X_ON_TAB | FNB.FNB_SMART_TABS | FNB.FNB_DROPDOWN_TABS_LIST | FNB.FNB_ALLOW_FOREIGN_DND) # Notebook attributes self.LOG = wx.GetApp().GetLog() self._idletimer = wx.Timer(self, ID_IDLE_TIMER) self.DocMgr = ed_editv.EdEditorView.DOCMGR self._searchctrl = ed_search.SearchController(self, self.GetCurrentCtrl) self._searchctrl.SetLookinChoices( Profile_Get('SEARCH_LOC', default=list())) self._searchctrl.SetFileFilters( Profile_Get('SEARCH_FILTER', default='')) self.pg_num = -1 # Track new pages (aka untitled docs) self.control = None self.frame = self.GetTopLevelParent() # MainWindow self._index = dict() # image list index self._ses_load = False self._menu = None # Set Additional Style Parameters self.SetNonActiveTabTextColour(wx.Colour(102, 102, 102)) ed_icon = ed_glob.CONFIG['SYSPIX_DIR'] + u"editra.png" self.SetNavigatorIcon(wx.Bitmap(ed_icon, wx.BITMAP_TYPE_PNG)) # Setup the ImageList and the default image imgl = wx.ImageList(16, 16) txtbmp = wx.ArtProvider.GetBitmap(str(synglob.ID_LANG_TXT), wx.ART_MENU) self._index[synglob.ID_LANG_TXT] = imgl.Add(txtbmp) robmp = wx.ArtProvider.GetBitmap(str(ed_glob.ID_READONLY), wx.ART_MENU) self._index[ed_glob.ID_READONLY] = imgl.Add(robmp) self.SetImageList(imgl) # Notebook Events self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGING, self.OnPageChanging) self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged) self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnPageClosing) self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CLOSED, self.OnPageClosed) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnUpdatePageText) self._pages.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self._pages.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) self._pages.Bind(wx.EVT_MIDDLE_UP, self.OnMClick) self.Bind(FNB.EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU, self.OnTabMenu) self.Bind(wx.EVT_MENU, self.OnMenu) self.Bind(wx.EVT_TIMER, self.OnIdle, id=ID_IDLE_TIMER) # Message handlers ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_CHANGED) ed_msg.Subscribe(self.OnThemeChanged, ed_msg.EDMSG_THEME_NOTEBOOK) ed_msg.Subscribe(self.OnUpdatePosCache, ed_msg.EDMSG_UI_STC_POS_JUMPED) ed_msg.RegisterCallback(self.OnDocPointerRequest, ed_msg.EDREQ_DOCPOINTER) # Add a blank page self.NewPage() self._idletimer.Start(333) # Do idle checks 3 times a second