def __init__(self, parent, items, prfx): self.items = items style = wxCAPTION | wxSYSTEM_MENU | wxRESIZE_BORDER wxDialog.__init__(self, parent, wxNewId(), "Properties " + prfx, size=wxSize(750,400), style=style) sizer = RowColSizer() self.sizer = sizer self.SetSizer(sizer) self.SetAutoLayout(true) btn = wxButton(self, wxNewId(), "OK") EVT_BUTTON(self, btn.GetId(), lambda e, self=self: self.Destroy()) bsizer = wxBoxSizer(wxVERTICAL) for t in ("Show MD5 sums", "Same units"): b = wxButton(self, wxNewId(), t) b.Enable(false) bsizer.Add(b, 0, wxEXPAND, 0) self.PopulateList() flags = wxEXPAND | wxALL bb = 10 sizer.Add(self.list, row=1, col=1, flag=flags) sizer.Add(btn, row=3, col=1, flag=wxALIGN_CENTRE, colspan=2) sizer.Add(bsizer, row=1, col=2) sizer.AddGrowableCol(1) sizer.AddGrowableRow(1) sizer.AddSpacer(10,10, pos=(2,1))
def __init__(self, path, ilist): wxMenu.__init__(self) self.path = path self.pathList = [] # this creates circular reference but it doesn't seem to matter with wxPython # all is cleaned up at the end, even Python-side __del__() methods are called self.ilist = ilist self.btnMv = wxNewId() self.btnCp = wxNewId() self.btnCancel = wxNewId() if not path: self.menus = [[-1, "Home", "~"], [-1, "/", "/"]] for p in self.menus: mid = wxNewId() p[0] = mid pth = os.path.expanduser(p[2]) p[2] = pth menu = FSMenu(pth, ilist) self.AppendMenu(mid, p[1], menu) p.append(menu) else: self.menus = [] mid = wxNewId() self.Append(mid, "Move/Copy Here") self.AppendSeparator() EVT_MENU(self, mid, self.moveCopy) EVT_MENU_OPEN(self, self.OnMenuOpen) EVT_MENU_CLOSE(self, self.OnMenuClose) EVT_MENU_HIGHLIGHT(self, -1, self.OnMenuHighlight) EVT_MENU_HIGHLIGHT_ALL(self, self.OnMenuHighlightAll)
def __init__(self, parent, ID, title, pos, size, pm, paths): wxFrame.__init__(self, parent, ID, title, pos, size, wxWANTS_CHARS|wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE, title) self.procMngr = pm if 0: #self.SetIcon(wxIcon(d, 16, 16)) bmp = TheArtProvider.GetBitmap(TheArtProvider.SM, wxART_FRAME_ICON, (16, 16)) ico = wxIcon("",16) ico.CopyFromBitmap(bmp) self.SetIcon(ico) self.SetIcons(smicons.GetIconBundle()) self.refreshStr = " Refresh the display" self.goUpStr = " Go up to parent item" self.goBackStr = " Go to previous item in history" self.goForwardStr = " Go to next item in history" self.goHomeStr = " Go to home directory" self.copyStr = " Copy selected items to clipboard" self.cutStr = " Cut selected items to clipboard" self.pasteStr = " Paste from clipboard" self.deleteStr = " Delete selected items" self.setupToolbar() self.setupMenus() self.splitterId = wxNewId() self.splitter = wxSplitterWindow(self, self.splitterId) # validity of 'paths' newPaths = [] for path in paths: path = os.path.abspath(os.path.expanduser(path)) if not os.path.exists(path) or not os.path.isdir(path): continue newPaths.append(path) if not newPaths: # no valid paths newPaths.append("/") paths = newPaths self.ntbook = smNotebook(self.splitter, wxNewId(), self.statusBar, self.OnItemSelected, self.ShowHidden, paths) self.dirCtrl = smDirCtrl(self.splitter, false, self.OnDirSelected, paths[0]) self.splitter.SetMinimumPaneSize(20) self.splitter.SplitVertically(self.dirCtrl, self.ntbook) self.splitter.SetSashPosition(100) # let the menus and accelerator tables do the work #EVT_KEY_DOWN(self, self.OnKeyDown) # I cannot get these to work through menu accelerators (aka keyboard shortcuts) # It interferes with label editing: steals keystrokes! aTable = wxAcceleratorTable([(wxACCEL_NORMAL, WXK_BACK, self.goUpId), (wxACCEL_ALT, WXK_LEFT, self.goBackId), (wxACCEL_ALT, WXK_RIGHT, self.goForwardId), (wxACCEL_NORMAL, WXK_DELETE, self.deleteId)]) self.dirCtrl.SetAcceleratorTable(aTable) self.ntbook.SetAcceleratorTable(aTable)
def OnInit(self): frame = wxFrame(None, wxNewId(), "wxApp") frame.Show(true) self.frame = frame self.SetTopWindow(frame) btn = wxButton(frame, wxNewId(), "Click to Start") EVT_BUTTON(self, btn.GetId(), self.OnClick) return true
def PopulateList(self): self.list = wxListCtrl(self, wxNewId(), style=wxLC_REPORT) i = 0 for t in (("Name", wxLIST_FORMAT_LEFT), ("Size", wxLIST_FORMAT_RIGHT), ("Size on disk", wxLIST_FORMAT_RIGHT), ("Permissions", wxLIST_FORMAT_LEFT), ("User", wxLIST_FORMAT_LEFT), ("Group", wxLIST_FORMAT_LEFT), ("Modification time", wxLIST_FORMAT_LEFT)): n, f = t self.list.InsertColumn(i, n, f) #self.list.SetColumnWidth(i, wxLIST_AUTOSIZE) i = i + 1 for i in range(len(self.items)): path = self.items[i] name = os.path.basename(path) size, diskSize = self.PathSizes(path) self.list.InsertStringItem(i, name) try: self.list.SetStringItem(i, 1, size) self.list.SetStringItem(i, 2, diskSize) self.list.SetStringItem(i, 3, PermsFromPath(path)) self.list.SetStringItem(i, 4, UserFromPath(path)) self.list.SetStringItem(i, 5, GroupFromPath(path)) self.list.SetStringItem(i, 6, mtime(path)) except OSError: pass
def __init__(self, parent, items, prfx): self.items = items style = wxCAPTION | wxSYSTEM_MENU | wxRESIZE_BORDER wxDialog.__init__(self, parent, wxNewId(), "Properties " + prfx, size=wxSize(750, 400), style=style) sizer = RowColSizer() self.sizer = sizer self.SetSizer(sizer) self.SetAutoLayout(true) btn = wxButton(self, wxNewId(), "OK") EVT_BUTTON(self, btn.GetId(), lambda e, self=self: self.Destroy()) bsizer = wxBoxSizer(wxVERTICAL) for t in ("Show MD5 sums", "Same units"): b = wxButton(self, wxNewId(), t) b.Enable(false) bsizer.Add(b, 0, wxEXPAND, 0) self.PopulateList() flags = wxEXPAND | wxALL bb = 10 sizer.Add(self.list, row=1, col=1, flag=flags) sizer.Add(btn, row=3, col=1, flag=wxALIGN_CENTRE, colspan=2) sizer.Add(bsizer, row=1, col=2) sizer.AddGrowableCol(1) sizer.AddGrowableRow(1) sizer.AddSpacer(10, 10, pos=(2, 1))
def moveCopy(self, event): print "Moving" destPath = self.path frame = wxFrame(self.ilist, wxNewId(), "Move/Copy Items?") mSizer = wxBoxSizer(wxVERTICAL) frame.SetAutoLayout(true) frame.SetSizer(mSizer) count = self.ilist.GetSelectedItemCount() # number of selected items mSizer.Add(30, 10, 0, wxEXPAND) mSizer.Add( wxStaticText(frame, wxNewId(), "Move/Copy %d item(s)?" % count), 0, 0) mSizer.Add(30, 10, 0, wxEXPAND) bSizer = wxBoxSizer(wxHORIZONTAL) mSizer.Add(bSizer, 0, 0) mSizer.Add(30, 10, 0, wxEXPAND) btnMv = wxButton(frame, self.btnMv, "Move") btnCp = wxButton(frame, self.btnCp, "Copy") btnCancel = wxButton(frame, self.btnCancel, "Cancel") for b in (btnMv, btnCp, btnCancel): EVT_BUTTON(b, b.GetId(), self.OnButtonPress) bSizer.Add(btnMv, 1, 0) bSizer.Add(30, 10, 0, wxEXPAND) bSizer.Add(btnCp, 1, 0) bSizer.Add(30, 10, 0, wxEXPAND) bSizer.Add(btnCancel, 1, 0) frame.MakeModal(true) frame.Show(true) self.frame = frame EVT_CLOSE(frame, self.OnCloseWindow)
def OnInit(self): wxInitAllImageHandlers() procMngr = self.procMngr = ProcessManager() paths = sys.argv[1:] or ["~"] width, height = 800, 600 frame = smFrame(None, wxNewId(), "slashManager", wxDefaultPosition, wxSize(width, height), procMngr, paths) frame.Show(true) self.frame = frame self.SetTopWindow(frame) return true
def moveCopy(self, event): print "Moving" destPath = self.path frame = wxFrame(self.ilist, wxNewId(), "Move/Copy Items?") mSizer = wxBoxSizer(wxVERTICAL) frame.SetAutoLayout(true) frame.SetSizer(mSizer) count = self.ilist.GetSelectedItemCount() # number of selected items mSizer.Add(30, 10, 0, wxEXPAND) mSizer.Add(wxStaticText(frame, wxNewId(), "Move/Copy %d item(s)?" % count), 0, 0) mSizer.Add(30, 10, 0, wxEXPAND) bSizer = wxBoxSizer(wxHORIZONTAL) mSizer.Add(bSizer, 0, 0) mSizer.Add(30, 10, 0, wxEXPAND) btnMv = wxButton(frame, self.btnMv, "Move") btnCp = wxButton(frame, self.btnCp, "Copy") btnCancel = wxButton(frame, self.btnCancel, "Cancel") for b in (btnMv, btnCp, btnCancel): EVT_BUTTON(b, b.GetId(), self.OnButtonPress) bSizer.Add(btnMv, 1, 0) bSizer.Add(30, 10, 0, wxEXPAND) bSizer.Add(btnCp, 1, 0) bSizer.Add(30, 10, 0, wxEXPAND) bSizer.Add(btnCancel, 1, 0) frame.MakeModal(true) frame.Show(true) self.frame = frame EVT_CLOSE(frame, self.OnCloseWindow)
def __init__(self, parent, hiddenDirs, dirFunc, path): # initialized the base class style = wxDIRCTRL_EDIT_LABELS | wxDIRCTRL_DIR_ONLY | \ wxDIRCTRL_3D_INTERNAL | wxDIRCTRL_SELECT_FIRST | \ wxNO_BORDER | wxTAB_TRAVERSAL #| wxSUNKEN_BORDER wxGenericDirCtrl.__init__(self, parent, wxNewId(), style=style) self.ShowHidden(hiddenDirs) # this will create a cyclic reference as `dirFunc' is likely to be a bound method with # reference to parent, and parent has a reference to this class. It's not vital since # there is only one instance of this class. self.dirFunc = dirFunc tree = self.GetTreeCtrl() EVT_TREE_SEL_CHANGED(self, tree.GetId(), self.OnDirSelected) self.SetPath(os.path.expanduser(path))
def populate(self): pathList = dircache.listdir(self.path) if self.pathList == pathList: return for m in self.menus: mid = m[0] self.Delete(mid) self.menus = [] self.pathList = pathList for p in pathList: fullPath = os.path.join(self.path, p) if not os.path.isdir(fullPath) or "." == p[0]: continue nid = wxNewId() menu = FSMenu(fullPath, self.ilist) self.AppendMenu(nid, p, menu) self.menus.append([nid, p, fullPath, menu])
def __init__(self, op, fsoList, destPath): self.stopped = false self.InTransfer = false self.op = op if self.COPY == op: txt = "Copy" else: txt = "Move" self.fsoList = fsoList self.destPath = os.path.normpath(destPath) wxDialog.__init__(self, None, wxNewId(), txt + " operation") sizer = wxBoxSizer(wxVERTICAL) self.SetAutoLayout(true) self.SetSizer(sizer) self.sizer = sizer btn = wxButton(self, wxNewId(), "Stop") EVT_BUTTON(self, btn.GetId(), self.OnClick) self.txt1 = wxStaticText(self, wxNewId(), "Destination directory: ") self.txt2 = wxStaticText(self, wxNewId(), destPath) #self.txt = wxStaticText(self, wxNewId(), "Single object progress:") #self.gauge = wxGauge(self, wxNewId(), 100) self.txtAll = wxStaticText(self, wxNewId(), "Overall progress:") self.gaugeAll = wxGauge(self, wxNewId(), len(fsoList)) flags = wxEXPAND | wxALL border = 0 bb = 10 sizer.Add(2 * bb, 2 * bb) # separator sizer.Add(self.txt1, 0, wxLEFT, border) sizer.Add(self.txt2, 0, wxLEFT, border) sizer.Add(bb, bb) # separator #sizer.Add(self.txt, 0, wxLEFT, border) #sizer.Add(bb, bb) # separator #sizer.Add(self.gauge, 0, flags, border) #sizer.Add(bb, bb) # separator sizer.Add(self.txtAll, 0, wxLEFT, border) sizer.Add(bb, bb) # separator sizer.Add(self.gaugeAll, 0, flags, border) sizer.Add(bb, bb) # separator sizer.Add(btn, 0, wxALIGN_CENTRE, border) sizer.Add(2 * bb, 2 * bb) # separator sizer.Layout() self.Refresh() EVT_IDLE(self, self.OnIdle)
import wx from wx import py from wxPython.wx import wxPySimpleApp, wxFrame, wxID_ANY, wxDEFAULT_FRAME_STYLE, wxNO_FULL_REPAINT_ON_RESIZE, wxMenu from wxPython.wx import wxNewId, wxMenuBar, EVT_MENU, EVT_CLOSE, wxMessageDialog, wxOK, wxSplitterWindow from wxPython.wx import WXK_TAB from aksy.device import Devices import sys intro = 'Welcome to the Aksy python shell' ID_ABOUT = wxNewId() ID_EXIT = wxNewId() class Frame(wxFrame): def __init__(self, parent, title): wxFrame.__init__(self, parent, wxID_ANY, title, size=(200, 100), style=wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) filemenu = wxMenu() filemenu.AppendSeparator() filemenu.Append(ID_EXIT, "E&xit\tCtrl+Q", " Terminate the program") helpmenu = wxMenu() helpmenu.Append(ID_ABOUT, "&About", " Information about this program") menuBar = wxMenuBar()
def setupToolbar(self): # A Statusbar in the bottom of the window self.statusBar = self.CreateStatusBar(2, wxST_SIZEGRIP) self.statusBar.SetStatusWidths([300, -1]) # two areas: 300px + the rest self.toolBar = tb = self.CreateToolBar(wxTB_HORIZONTAL | wxTB_DOCKABLE | wxNO_BORDER ) self.pathCombo = wxComboBox(tb, wxNewId(), size=(300, -1), choices=["/"], style=wxCB_DROPDOWN|wxCB_READONLY) self.pathComboAllowed = true tb.AddControl(self.pathCombo) EVT_COMBOBOX(self, self.pathCombo.GetId(), self.OnCombo) #lambda e, self=self: sys.stdout.write(e.GetString()+"\n"))#self.OnDirSelected(e.GetString())) tb.AddSeparator() client = wxART_TOOLBAR size = 16 self.tbNewDirId = wxNewId() self.tbGoUpId = wxNewId() self.tbGoBackId = wxNewId() self.tbGoForwardId = wxNewId() self.tbRefreshId = wxNewId() self.tbGoHomeId = wxNewId() self.tbCopyId = wxNewId() self.tbCutId = wxNewId() self.tbPasteId = wxNewId() self.tbDeleteId = wxNewId() tap = TheArtProvider for t in ((self.tbNewDirId, "New item", " Create new item", tap.NEW_DIR), (), (self.tbGoUpId, "Go up", self.goUpStr, tap.GO_UP), (self.tbGoBackId, "Go back", self.goBackStr, tap.GO_BACK), (self.tbGoForwardId, "Go forward", self.goForwardStr, tap.GO_FORWARD), (self.tbRefreshId, "Refresh", self.refreshStr, tap.REFRESH), (self.tbGoHomeId, "Home", self.goHomeStr, tap.GO_HOME), (), (self.tbCopyId, "Copy", self.copyStr, tap.COPY), (self.tbCutId, "Cut", self.cutStr, tap.CUT), (self.tbPasteId, "Paste", self.pasteStr, tap.PASTE), (), (self.tbDeleteId, "Delete", self.deleteStr, tap.TRASH)): if len(t) < 3: tb.AddSeparator() continue id, txt, toolTip, artid = t bmp = TheArtProvider.GetBitmap(artid, client, (size, size)) tb.AddSimpleTool(id, bmp, txt, toolTip) tb.AddSeparator() self.globCombo = wxComboBox(tb, wxNewId(), "*", choices=["*"], style=wxCB_DROPDOWN) self.globButton = wxButton(tb, wxNewId(), "Filter") tb.AddControl(self.globCombo) tb.AddControl(self.globButton) EVT_TOOL(self, self.tbNewDirId, lambda e, self=self: self.ntbook.NewItem()) EVT_TOOL(self, self.tbGoUpId, lambda e, self=self: self.ntbook.HistoryGo(e, 0)) EVT_TOOL(self, self.tbGoBackId, lambda e, self=self: self.ntbook.HistoryGo(e, -1)) EVT_TOOL(self, self.tbGoForwardId, lambda e, self=self: self.ntbook.HistoryGo(e, +1)) EVT_TOOL(self, self.tbGoHomeId, lambda e, self=self: self.ntbook.GoHome()) EVT_TOOL(self, self.tbRefreshId, lambda e, self=self: self.ntbook.Refresh()) EVT_TOOL(self, self.tbCopyId, lambda e, self=self: self.ntbook.CopyCutPaste(0)) EVT_TOOL(self, self.tbCutId, lambda e, self=self: self.ntbook.CopyCutPaste(1)) EVT_TOOL(self, self.tbPasteId, lambda e, self=self: self.ntbook.CopyCutPaste(2)) EVT_TOOL(self, self.tbDeleteId, lambda e, self=self: self.ntbook.DeleteItems(e))
def __init__(self, parent, hiddenDirs, hiddenFiles, statusBar, itemFunc, showHiddenFunc, sortType=1, sortReverse=0): #style = wxLC_REPORT #style = wxLC_ICON | wxLC_ALIGN_LEFT #style = wxLC_SMALL_ICON | wxLC_ALIGN_LEFT style = wxLC_LIST style = style | wxLC_EDIT_LABELS | wxNO_BORDER | wxSUNKEN_BORDER | wxTAB_TRAVERSAL wxListCtrl.__init__(self, parent, style=style) # this creates cyclic dependency (points to ancestor through bound method) # but the enclosing wxNotebook breaks the cycle when necessary self.itemFunc = itemFunc self.showHiddenFunc = showHiddenFunc self.statusBar = statusBar self.hiddenDirs = hiddenDirs self.hiddenFiles = hiddenFiles self.sortType = sortType self.sortReverse = sortReverse self.currentPath = None self.history = PathHistory() self.beginEditName = "" # popup menu id's self.popNew = wxNewId() self.popView = wxNewId() self.popOpen = wxNewId() self.popEdit = wxNewId() self.popOpenWith = wxNewId() self.popCopy = wxNewId() self.popCut = wxNewId() self.popPaste = wxNewId() self.popEject = wxNewId() self.popMount = wxNewId() self.popUnmount = wxNewId() self.popProps = wxNewId() self.popMoveCopy = wxNewId() client = wxART_TOOLBAR self.imageList = wxImageList(16, 16) self.imageIDs = {} for name in ("FOLDER", "FOLDER_LINK", "NORMAL_FILE", "LINK"): d = TheArtProvider.GetBitmap(getattr(TheArtProvider, name), client, (16, 16)) self.imageIDs[name] = self.imageList.Add(d) self.SetImageList(self.imageList, wxIMAGE_LIST_SMALL) self.fsMenu = FSMenu("", self) self.popMenu = wxMenu() popMenu = self.popMenu for menuItem in ( (self.popNew, "&New item"), (), (self.popView, "&View"), (self.popOpen, "&Open"), (self.popEdit, "&Edit"), (self.popOpenWith, "Open &with"), (), (self.popCopy, "&Copy"), (self.popCut, "C&ut"), (self.popPaste, "&Paste"), (), (self.popEject, "E&ject"), (self.popMount, "&Mount"), (self.popUnmount, "Unmoun&t"), (self.popProps, "P&roperties"), (), ): if len(menuItem) < 1: popMenu.AppendSeparator() continue mid = menuItem[0] txt = menuItem[1] popMenu.Append(mid, txt) popMenu.Enable(mid, false) EVT_MENU(self, mid, self.OnPopup) popMenu.Enable(self.popProps, true) popMenu.AppendMenu(self.popMoveCopy, "Move/Copy To", self.fsMenu) self.selectionTracker = SelectionTracker() # these two methods are called for each entry that changes selection (including user GUI # actions such as Shift+LeftClick) and so they should not do much work EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnItemSelected) EVT_LIST_ITEM_DESELECTED(self, self.GetId(), self.OnItemDeSelected) EVT_LIST_ITEM_ACTIVATED(self, self.GetId(), self.OnActivated) EVT_LIST_ITEM_RIGHT_CLICK(self, self.GetId(), self.OnRightClick) EVT_LIST_BEGIN_LABEL_EDIT(self, self.GetId(), self.OnBeginEdit) EVT_LIST_END_LABEL_EDIT(self, self.GetId(), self.OnEndEdit) #EVT_LIST_KEY_DOWN(self, self.GetId(), self.OnKeyDown) #EVT_LIST_ITEM_FOCUSED(self, self.GetId(), self.OnKeyDown) # not implemented #txtCtrl = self.GetEditControl() # wx's popups occur on UP not DOWN event #EVT_RIGHT_DOWN(self, self.OnRightClick) # this process right click outside of any item #FIXME: learn to interact with normal list event processing EVT_RIGHT_UP(self, self.OnRightClick) self.UpdateStatusBar("", "", 1) EVT_IDLE(self, self.OnIdle)
def setupMenus(self): self.newId = wxNewId() self.openId = wxNewId() self.viewId = wxNewId() self.editId = wxNewId() self.openWithId = wxNewId() self.propertiesId = wxNewId() self.deleteId = wxNewId() self.exitId = wxNewId() self.cutId = wxNewId() self.copyId = wxNewId() self.pasteId = wxNewId() self.pasteLinkId = wxNewId() self.moveToDirId = wxNewId() self.copyToDirId = wxNewId() self.selectAllId = wxNewId() self.deselectAllId = wxNewId() self.invertSelectionId = wxNewId() self.refreshId = wxNewId() self.addBookmarkId = wxNewId() self.manageBookmarkId = wxNewId() self.goUpId = wxNewId() self.goBackId = wxNewId() self.goForwardId = wxNewId() self.goHomeId = wxNewId() self.mountId = wxNewId() self.umountId = wxNewId() self.aboutId = wxNewId() filemenu = wxMenu() filemenu.Append(self.newId, "&New item\tCtrl-N", " New item") filemenu.Append(self.viewId, "&View\tF3", " View selected items") filemenu.Append(self.openId, "&Open\tCtrl-O", " Open selected items") filemenu.Append(self.editId, "&Edit\tF4", " Edit selected items") filemenu.Append(self.openWithId, "Open &with\tCtrl-W", " Open selected items with ...") filemenu.AppendSeparator() filemenu.Append(self.propertiesId, "P&roperties\tCtrl-P", " Show properties of selected items") filemenu.Append(self.deleteId, "&Delete\tDELETE", self.deleteStr) filemenu.AppendSeparator() filemenu.Append(self.exitId, "E&xit\tCtrl-Q", " Terminate the program") editmenu = wxMenu() editmenu.Append(self.copyId, "&Copy\tCtrl-C", self.copyStr) editmenu.Append(self.cutId, "C&ut\tCtrl-X", self.cutStr) editmenu.Append(self.pasteId, "&Paste\tCtrl-V", self.pasteStr) editmenu.Append(self.pasteLinkId, "Paste &link\tCtrl-L", " Paste symbolic link") editmenu.AppendSeparator() editmenu.Append(self.moveToDirId, "&Move to directory\tCtrl-M", " Move to different direcotry") editmenu.Append(self.copyToDirId, "Cop&y to directory\tCtrl-N", " Copy to different direcotry") editmenu.AppendSeparator() editmenu.Append(self.selectAllId, "&Select all\tCtrl-A", " Select all items") editmenu.Append(self.deselectAllId, "&Deselect all\tCtrl-Z", " Deselect all items") editmenu.Append(self.invertSelectionId, "&Invert selection\tCtrl-I", " Invert selection") viewmenu = wxMenu() viewmenu.Append(self.refreshId, "&Refresh\tCtrl-R", self.refreshStr) viewmenu.AppendSeparator() go__menu = wxMenu() go__menu.Append(self.goUpId, "&Up", self.goUpStr) go__menu.Append(self.goBackId, "&Back\tALT-LEFT", self.goBackStr) go__menu.Append(self.goForwardId, "&Forward\tALT-RIGHT", self.goForwardStr) go__menu.Append(self.goHomeId, "&Home\tALT-HOME", self.goHomeStr) bookmenu = wxMenu() bookmenu.Append(self.addBookmarkId, "&Add\tCtrl-D", " Add bookmark") bookmenu.Append(self.manageBookmarkId, "&Manage", " Manage bookmarks") toolmenu = wxMenu() toolmenu.Append(self.mountId, "&Options", " Mount device") helpmenu = wxMenu() helpmenu.Append(self.aboutId, "&About", " Information about this program") # Creating the menubar. menuBar = wxMenuBar(wxMB_DOCKABLE) menuBar.Append(filemenu, "&File") menuBar.Append(editmenu, "&Edit") menuBar.Append(viewmenu, "&View") menuBar.Append(go__menu, "&Go") menuBar.Append(bookmenu, "&Bookmarks") menuBar.Append(toolmenu, "&Tools") menuBar.Append(helpmenu, "&Help") self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content. # attach events to menus EVT_MENU(self, self.deleteId, lambda e, self=self: self.ntbook.DeleteItems(e)) EVT_MENU(self, self.propertiesId, lambda e, self=self: self.ntbook.Properties()) EVT_MENU(self, self.newId, lambda e, self=self: self.ntbook.NewItem()) EVT_MENU(self, self.goUpId, lambda e, self=self: self.ntbook.HistoryGo(e, 0)) EVT_MENU(self, self.goBackId, lambda e, self=self: self.ntbook.HistoryGo(e, -1)) EVT_MENU(self, self.goForwardId, lambda e, self=self: self.ntbook.HistoryGo(e, +1)) EVT_MENU(self, self.goHomeId, lambda e, self=self: self.ntbook.GoHome()) EVT_MENU(self, self.refreshId, lambda e, self=self: self.ntbook.Refresh()) EVT_MENU(self, self.copyId, lambda e, self=self: self.ntbook.CopyCutPaste(0)) EVT_MENU(self, self.cutId, lambda e, self=self: self.ntbook.CopyCutPaste(1)) EVT_MENU(self, self.pasteId, lambda e, self=self: self.ntbook.CopyCutPaste(2)) EVT_MENU(self, self.selectAllId, lambda e, self=self: self.ntbook.SelectItems(1)) EVT_MENU(self, self.deselectAllId, lambda e, self=self: self.ntbook.SelectItems(0)) EVT_MENU(self, self.invertSelectionId, lambda e, self=self: self.ntbook.SelectItems(-1)) EVT_MENU(self, self.aboutId, self.OnAbout) EVT_MENU(self, self.exitId, self.OnExit)
import wx from wx import py from wxPython.wx import wxPySimpleApp, wxFrame,wxID_ANY,wxDEFAULT_FRAME_STYLE,wxNO_FULL_REPAINT_ON_RESIZE,wxMenu from wxPython.wx import wxNewId,wxMenuBar,EVT_MENU, EVT_CLOSE, wxMessageDialog, wxOK, wxSplitterWindow from wxPython.wx import WXK_TAB from aksy.device import Devices import sys intro = 'Welcome to the Aksy python shell' ID_ABOUT=wxNewId() ID_EXIT=wxNewId() class Frame(wxFrame): def __init__(self,parent,title): wxFrame.__init__(self,parent,wxID_ANY, title, size = ( 200,100), style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE) filemenu= wxMenu() filemenu.AppendSeparator() filemenu.Append(ID_EXIT,"E&xit\tCtrl+Q"," Terminate the program") helpmenu = wxMenu() helpmenu.Append(ID_ABOUT, "&About"," Information about this program") menuBar = wxMenuBar() menuBar.Append(filemenu,"&File") menuBar.Append(helpmenu,"&Help") self.SetMenuBar(menuBar) self.SetSize((800, 600)) self.Show(True) EVT_MENU(self, ID_EXIT, self.OnExit)
def __init__(self, parent, id, statusBar, itemFunc, showHiddenFunc, paths): wxNotebook.__init__(self, parent, id) # cyclic dependency: parent <-> child (but there is only one notebook) self.statusBar = statusBar self.itemFunc = itemFunc self.showHiddenFunc = showHiddenFunc self.menuDup = wxNewId() self.menuDel = wxNewId() self.menuHiddenDirs = wxNewId() self.menuHiddenFiles = wxNewId() self.menuSort = wxNewId() self.menuSname = wxNewId() self.menuSdate = wxNewId() self.menuSsize = wxNewId() self.menuStype = wxNewId() self.menuSnone = wxNewId() self.menuSiname = wxNewId() self.menuSreverse = wxNewId() self.menuDirs = wxNewId() self.menuDfirst = wxNewId() self.menuDfirst = wxNewId() self.menuDfirst = wxNewId() for path in paths: path = os.path.abspath(os.path.expanduser(path)) if not os.path.exists(path) or not os.path.isdir(path): continue page = BriefFileList(self, false, false, statusBar, itemFunc, showHiddenFunc) self.AddPage(page, os.path.basename(path) or "/") page.SetPath(path) EVT_RIGHT_UP(self, self.OnRightClick) EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)