def Quit(self): """Tell the editor to exit @postcondition: Editor begins exit, confirming file saves """ wx.PostEvent(self.GetTopLevelParent(), wx.CloseEvent(wx.wxEVT_CLOSE_WINDOW))
def OnClose(self, event): """Close properly the client then exit.""" closeEvent = wx.CloseEvent(wx.wxEVT_CLOSE_WINDOW, self.GetId()) closeEvent.SetEventObject(self) wx.PostEvent(self._clientpanel, closeEvent) self.Close()
def test_EventVeto(): if False: # see note about GetVeto being disabled e = wx.CloseEvent() e.Veto(True) assert e.GetVeto() e.Veto(False) assert not e.GetVeto() assert callable(e.Veto)
def perform_update(self): try: tmpdir = tempfile.gettempdir() tmpdir = os.path.join(tmpdir, os.path.basename(self._latest)) filename, _ = urllib.urlretrieve(self._latest, tmpdir) subprocess.Popen([filename], creationflags=0x00000008) wx.PostEvent(self.parent, wx.CloseEvent(wxEVT_CLOSE_WINDOW)) except urllib2.URLError, e: self._log.error("Failed to get URL [%s]", e)
def perform_update(self): tmpdir = tempfile.gettempdir() tmpdir = os.path.join(tmpdir, os.path.basename(self._latest)) filename, _ = urllib.urlretrieve(self._latest, tmpdir) mnt_path = tempfile.mkdtemp("edproxy_update") # Mount the .dmg filesystem update_mount = [ "/usr/bin/hdiutil", "attach", "-autoopen", "-mountpoint", mnt_path, filename ] subprocess.Popen(update_mount) wx.PostEvent(self.parent, wx.CloseEvent(wxEVT_CLOSE_WINDOW))
def OnOpenDB(self, e): """ Open a file""" dirname = os.getenv('GIVEDB') dlg = wx.FileDialog(self, "Choose a database", dirname, "", "*.db", wx.OPEN) if dlg.ShowModal() == wx.ID_OK: self.DBfilename = dlg.GetFilename() dirname = dlg.GetDirectory() DBname = os.path.join(dirname, self.DBfilename) self.DBconn = sqlite3.connect(DBname) statusBar = self.GetStatusBar() statusBar.SetStatusText(DBname, 0) #self.PListPanel.OnOpenDB(self.DBconn) else: print "CANCEL THE WHOLE THING!" e = wx.CloseEvent() self.OnExit(e)
def run(self): dobreak = False while self._cam.running: self._abort_lock.acquire() sa = self._should_abort self._abort_lock.release() if sa: break # Wait for a new camera picture self._cam.new_image.acquire() self._cam.new_image.wait(.25) if not self._cam.running: dobreak = True else: i = self._cam.current_image self._cam.new_image.release() if dobreak: wx.PostEvent(self._ld, wx.CloseEvent() ) # we continue as normal, the ld will abort us elif self._ld: wx.PostEvent(self._ld, NewImageEvent(i)) wx.Yield()
def OnKey(self, event): if event.GetEventType() == wx.wxEVT_KEY_UP: if event.GetKeyCode() == self.GetModifierKey(): topLevel = wx.GetTopLevelParent(self) closeEvent = wx.CloseEvent(wx.wxEVT_CLOSE_WINDOW, topLevel.GetId()) closeEvent.SetEventObject(topLevel) closeEvent.SetCanVeto(False) topLevel.GetEventHandler().ProcessEvent(closeEvent) return event.Skip() return keyCode = event.GetKeyCode() if keyCode in [wx.WXK_ESCAPE, wx.WXK_RETURN]: if keyCode == wx.WXK_ESCAPE: self._items.SetSelection(-1) topLevel = wx.GetTopLevelParent(self) closeEvent = wx.CloseEvent(wx.wxEVT_CLOSE_WINDOW, topLevel.GetId()) closeEvent.SetEventObject(topLevel) closeEvent.SetCanVeto(False) topLevel.GetEventHandler().ProcessEvent(closeEvent) return elif keyCode in [wx.WXK_TAB, self.GetExtraNavigationKey()]: if event.ShiftDown(): self._items.SetSelection(self._items.GetSelection() - 1) if self._items.GetSelection() < 0: self._items.SetSelection(self._items.GetItemCount() - 1) self.AdvanceToNextSelectableItem(-1) else: self._items.SetSelection(self._items.GetSelection() + 1) if self._items.GetSelection() >= self._items.GetItemCount(): self._items.SetSelection(0) self.AdvanceToNextSelectableItem(1) self.GenerateSelectionEvent() self.Refresh() elif keyCode in [wx.WXK_DOWN, wx.WXK_NUMPAD_DOWN]: self._items.SetSelection(self._items.GetSelection() + 1) if self._items.GetSelection() >= self._items.GetItemCount(): self._items.SetSelection(0) self.AdvanceToNextSelectableItem(1) self.GenerateSelectionEvent() self.Refresh() elif keyCode in [wx.WXK_UP, wx.WXK_NUMPAD_UP]: self._items.SetSelection(self._items.GetSelection() - 1) if self._items.GetSelection() < 0: self._items.SetSelection(self._items.GetItemCount() - 1) self.AdvanceToNextSelectableItem(-1) self.GenerateSelectionEvent() self.Refresh() elif keyCode in [wx.WXK_HOME, wx.WXK_NUMPAD_HOME]: self._items.SetSelection(0) self.AdvanceToNextSelectableItem(1) self.GenerateSelectionEvent() self.Refresh() elif keyCode in [wx.WXK_END, wx.WXK_NUMPAD_END]: self._items.SetSelection(self._items.GetItemCount() - 1) self.AdvanceToNextSelectableItem(-1) self.GenerateSelectionEvent() self.Refresh() elif keyCode in [wx.WXK_LEFT, wx.WXK_NUMPAD_LEFT]: item = self._items.GetItem(self._items.GetSelection()) row = item.GetRowPos() newCol = item.GetColPos() - 1 if newCol < 0: newCol = self._items.GetColumnCount() - 1 # Find the first item from the end whose row matches and whose column is equal or lower for i in range(self._items.GetItemCount()-1, -1, -1): item2 = self._items.GetItem(i) if item2.GetColPos() == newCol and item2.GetRowPos() <= row: self._items.SetSelection(i) break self.AdvanceToNextSelectableItem(-1) self.GenerateSelectionEvent() self.Refresh() elif keyCode in [wx.WXK_RIGHT, wx.WXK_NUMPAD_RIGHT]: item = self._items.GetItem(self._items.GetSelection()) row = item.GetRowPos() newCol = item.GetColPos() + 1 if newCol >= self._items.GetColumnCount(): newCol = 0 # Find the first item from the end whose row matches and whose column is equal or lower for i in range(self._items.GetItemCount()-1, -1, -1): item2 = self._items.GetItem(i) if item2.GetColPos() == newCol and item2.GetRowPos() <= row: self._items.SetSelection(i) break self.AdvanceToNextSelectableItem(1) self.GenerateSelectionEvent() self.Refresh() else: event.Skip()
def test_CloseEvent_ctor(self): evt = wx.CloseEvent()
def exit(self, evt: wx.CommandEvent): """ called by the exit button, fowards to the root.OnClose() method :param evt: placeholder """ self.OnClose( wx.CloseEvent() ) # there's already an handler, so use that