def _show_widget_toplevel(self, node): # creates/shows the widget of the given toplevel node and all its children if not wx.IsBusy(): wx.BeginBusyCursor() if not node.widget.widget: node.widget.create_widget() node.widget.finish_widget_creation() node.widget.drop_target = clipboard.DropTarget(node.widget) node.widget.widget.SetDropTarget(node.widget.drop_target) with node.widget.frozen(): if node.children: for c in node.children: self.create_widgets(c) node.widget.post_load( ) # only edit_sizers.SizerBase has this method implemented and calls it for toplevel node.widget.create() if node.widget.widget.TopLevel: node.widget.widget.Show() else: node.widget.widget.GetParent().Show() misc.set_focused_widget(node.widget) node.widget.widget.Raise() # set the best size for the widget (if no one is given) props = node.widget.properties if 'size' in props and not props['size'].is_active(): if node.widget.sizer: node.widget.sizer.fit_parent() elif getattr(node.widget, "top_sizer", None): wx.Yield( ) # by now, there are probably many EVT_SIZE in the queue node.widget.top_sizer.fit_parent() if wx.IsBusy(): wx.EndBusyCursor()
def on_expanding(self, event): if not wx.IsBusy(): wx.BeginBusyCursor() item = event.GetItem() if item.Ok(): iteminfo = self.GetPyData(event.GetItem()) # aggiungiamo il contenuto della cartella all'albero # lo facciamo tutte le volte in modo che se i contenuti cambiano # si puo' fare refresh collassando e espandendo il nodo... if iteminfo.pidl not in self._added: try: ## contents = [(c[2].lower(), _DirItemInfo(c)) for c in ## _dc.get_subfolders_of(iteminfo.pidl)] contents = [(c[8], c[1].lower(), c[2], _DirItemInfo(c)) for c in _dc.get_subfolders_of(iteminfo.pidl)] contents.sort() #contents = [c[1] for c in contents] for s, n1, n2, i in contents: #print s, n, i.pidl self._add_item(item, i) if not contents: self.SetItemHasChildren(item, False) except Exception as xxx_todo_changeme: #print "PYTHON, EXCEPTION:", errno, strerr (errno, strerr) = xxx_todo_changeme.args #print "PYTHON, EXCEPTION:", errno, strerr if errno: wx.MessageBox(strerr, "Errore", style=wx.OK | wx.ICON_ERROR) self.SetItemHasChildren(item, False) self._added[iteminfo.pidl] = 1 if wx.IsBusy(): wx.EndBusyCursor() event.Skip()
def _apply(self, event=None): """Apply the operation. @keyword event: The wx event. @type event: wx event """ # A bit of user feedback. wx.BeginBusyCursor() # Execute. self.exec_status = self.on_execute() # Execution failure. if not self.exec_status: if wx.IsBusy(): wx.EndBusyCursor() return # Finished. self.on_completion() # Execute the on_apply() method. self.on_apply() # Turn off the busy cursor if needed. if wx.IsBusy(): wx.EndBusyCursor()
def on_expanding(self, event): if not wx.IsBusy(): wx.BeginBusyCursor() item = event.GetItem() if item.Ok(): iteminfo = self.GetPyData(event.GetItem()) # aggiungiamo il contenuto della cartella all'albero # lo facciamo tutte le volte in modo che se i contenuti cambiano # si puo' fare refresh collassando e espandendo il nodo... if id(iteminfo) not in self._added: try: contents = iteminfo.get_subdirs(self._show_hidden) for i in contents: self._add_item(item, i) if not contents: self.SetItemHasChildren(item, False) except OSError as e: #print "PYTHON, EXCEPTION:", errno, strerr wx.MessageBox(str(e), "Errore", style=wx.OK | wx.ICON_ERROR) self.SetItemHasChildren(item, False) except Exception: import traceback traceback.print_exc() self.SetItemHasChildren(item, False) self._added[id(iteminfo)] = 1 if wx.IsBusy(): wx.EndBusyCursor() event.Skip()
def OnRenderDone(self): """Rendering process done Make image composiotion, emits updateMap event. """ stopTime = time.time() maps = list() masks = list() opacities = list() for layer in self.layers: if layer.GetType() == 'overlay': continue if os.path.isfile(layer.mapfile): maps.append(layer.mapfile) masks.append(layer.maskfile) opacities.append(str(layer.opacity)) # run g.pngcomp to get composite image bgcolor = ':'.join( map( str, UserSettings.Get(group='display', key='bgcolor', subkey='color'))) startCompTime = time.time() if maps: ret, msg = RunCommand('g.pnmcomp', getErrorMsg=True, overwrite=True, input='%s' % ",".join(maps), mask='%s' % ",".join(masks), opacity='%s' % ",".join(opacities), bgcolor=bgcolor, width=self.Map.width, height=self.Map.height, output=self.Map.mapfile, env=self._env) if ret != 0: self._rendering = False if wx.IsBusy(): wx.EndBusyCursor() raise GException(_("Rendering failed: %s" % msg)) stop = time.time() Debug.msg (1, "RenderMapMgr.OnRenderDone() time=%f sec (comp: %f)" % \ (stop - self._startTime, stop - startCompTime)) self._rendering = False if wx.IsBusy(): wx.EndBusyCursor() self.updateMap.emit()
def clipboard_paste(self): if vfs.is_virtual(self.path): wx.MessageBox(_('Error'), _("Can't paste on this path: %s") % self.path, style=wx.OK | wx.ICON_ERROR) return if not wx.IsBusy(): wx.BeginBusyCursor() files, cutting = clipboard.paste() dialog = None go_on = False action = None needs_refresh = False for f in files: dst = os.path.join(self.path, os.path.basename(f)) if f == dst: continue if os.path.exists(dst): if not go_on: if dialog is None: dialog = resources.ImageCopyDialog() action = dialog.show(dst, f, len(files) > 1) if action == dialog.CANCEL: break if action == dialog.SKIP_ALL: action = dialog.SKIP go_on = True elif action == dialog.OVERWRITE_ALL: action = dialog.OVERWRITE go_on = True # process actions... if action == dialog.RENAME: dst = os.path.join(os.path.dirname(dst), dialog.get_new_name()) elif action == dialog.SKIP: continue try: src = fileops.open(f) out = open(dst, 'wb') for line in src: out.write(line) src.close() out.close() needs_refresh = True if cutting: fileops.unlink(f) except (IOError, OSError) as e: wx.LogError(str(e)) if dialog is not None: dialog.destroy() if wx.IsBusy(): wx.EndBusyCursor() if files and needs_refresh: self.set_path(self.path, True) # refresh the list
def SubmitLog(self, myDataMainFrame, settings, url="https://cvl.massive.org.au/cgi-bin/mydata_log_drop.py"): """ Open the SubmitDebugReportDialog and submit a debug report if the user clicks OK """ # pylint: disable=too-many-branches self.contactName = settings.general.contactName self.contactEmail = settings.general.contactEmail dlg = SubmitDebugReportDialog( myDataMainFrame, "MyData - Submit Debug Log", self.loggerOutput.getvalue(), settings) try: if wx.PyApp.IsMainLoopRunning(): if wx.IsBusy(): wx.EndBusyCursor() stoppedBusyCursor = True else: stoppedBusyCursor = False result = dlg.ShowModal() submitDebugLogOK = (result == wx.ID_OK) if stoppedBusyCursor: if not wx.IsBusy(): wx.BeginBusyCursor() else: dlg.Show() dlg.Hide() submitDebugLogOK = True if submitDebugLogOK: self.contactName = dlg.GetContactName() self.contactEmail = dlg.GetContactEmail() self.comments = dlg.GetComments() self.pleaseContactMe = dlg.GetPleaseContactMe() finally: dlg.Destroy() if submitDebugLogOK: self.debug("About to send debug log") fileInfo = {"logfile": self.GenerateDebugLogContent(settings)} try: response = requests.post( url, files=fileInfo, timeout=settings.miscellaneous.connectionTimeout) response.raise_for_status() logger.info("Debug log was submitted successfully!") except RequestException: logger.error("An error occurred while attempting to submit " "the debug log.") logger.error(traceback.format_exc())
def sync(self, mw, silent, profile="Default Autosync"): self.silent = silent # start the autosync process # import the calender, find the entry point for the import function self.mw = mw if mw.config.ReadInt("SafeMode", False): self.log("Auto Sync: Disabled, BitPim in safe mode") return 0 if wx.IsBusy(): self.log("Auto Sync: Failed, BitPim busy") return 0 self.log("Auto Sync: Starting (silent mode=%d)..." % (silent)) self.mw.OnBusyStart() self.mw.GetStatusBar().progressminor( 0, 100, 'Auto Calendar Import in progress ...') # retrieve the configuration self.settings = _getsettings(mw, profile) # update BitPims calender res = self.importcalenderdata() if res == 1: # send updated calender to the phone res = self.sendcalendertophone() else: self.mw.OnBusyEnd() if silent == 0: wx.MessageBox('Unable to Auto-Import Calendar Data', 'Auto Calendar Import failed', wx.OK) self.log("Auto Sync: Failed, Unable to synchronize phone schedule") return res
def gui_raise(relax_error, raise_flag=False): """Handle errors in the GUI to be reported to the user. @param relax_error: The error object. @type relax_error: RelaxError instance @keyword raise_flag: A flag which if True will cause the error to be raised, terminating execution. @type raise_flag: bool @raises RelaxError: This raises all RelaxErrors, if the raise flag is given. """ # Turn off the busy cursor if needed. if wx.IsBusy(): wx.EndBusyCursor() # Non-fatal - the error is not raised so just send the text to STDERR. if not raise_flag: sys.stderr.write(relax_error.__str__()) sys.stderr.write("\n") # Show the relax controller (so that the window doesn't hide the dialog). app = wx.GetApp() app.gui.show_controller(None) app.Yield(True) # Show a dialog explaining the error. dlg = wx.MessageDialog(None, relax_error.text, caption="RelaxError", style=wx.OK | wx.ICON_ERROR) if status.show_gui: dlg.ShowModal() # Throw the error to terminate execution. if raise_flag: raise relax_error
def __init__(self, parent): windows.ErrorDialogBase.__init__(self, parent) self.SetEscapeId(windows.ERROR_CLOSE) if wx.IsBusy(): wx.EndBusyCursor()
def showSubmitDebugLogDialog(): dlg = SubmitDebugReportDialog( None, wx.ID_ANY, "", self.loggerOutput.getvalue(), self.globalLauncherConfig, self.globalLauncherPreferencesFilePath, showFailedToOpenRemoteDesktopMessage= showFailedToOpenRemoteDesktopMessage) try: if wx.IsBusy(): wx.EndBusyCursor() stoppedBusyCursor = True else: stoppedBusyCursor = False result = dlg.ShowModal() if stoppedBusyCursor: wx.BeginBusyCursor() launcherMainFrame.submit_log = result == wx.ID_OK if launcherMainFrame.submit_log: self.name = dlg.getName() self.email = dlg.getEmail() self.comments = dlg.getComments() self.pleaseContactMe = dlg.getPleaseContactMe() finally: dlg.Destroy() launcherMainFrame.submitDebugLogDialogCompleted = True
def setup_dipole_pair(self, event=None): """Create the wizard for the dipole-dipole interaction. @keyword event: The wx event. @type event: wx event """ # Change the cursor to busy. wx.BeginBusyCursor() # Destroy the dipole-dipole interaction wizard, if it exists. if hasattr(self, 'dipole_wizard'): self.dipole_wizard.Destroy() # Create the wizard. self.dipole_wizard = Wiz_window( parent=self.gui, size_x=1000, size_y=750, title="Dipole-dipole interaction setup") # Structural data. if not hasattr(cdp, 'structure'): # Create the PDB reading page. page = uf_store['structure.read_pdb'].create_page( self.dipole_wizard, sync=True) self.dipole_wizard.add_page(page, skip_button=True) # Create the position reading page. page = uf_store['structure.get_pos'].create_page( self.dipole_wizard, sync=True) self.dipole_wizard.add_page(page, skip_button=True) # Create the interatom.define page. page = uf_store['interatom.define'].create_page(self.dipole_wizard, sync=True) page.SetValue('spin_id1', '@N') page.SetValue('spin_id2', '@H') self.dipole_wizard.add_page(page) # Create the interatom.set_dist page. page = uf_store['interatom.set_dist'].create_page(self.dipole_wizard, sync=True) page.SetValue('spin_id1', '@N*') page.SetValue('spin_id2', '@H*') page.SetValue('ave_dist', NH_BOND_LENGTH) self.dipole_wizard.add_page(page) # Create the interatom.unit_vectors page. page = uf_store['interatom.unit_vectors'].create_page( self.dipole_wizard, sync=True) self.dipole_wizard.add_page(page) # Reset the cursor. if wx.IsBusy(): wx.EndBusyCursor() # Execute the wizard. self.dipole_wizard.run()
def OnBrowse(self, event): parent = self.text.GetParent() filename = gui_util.directory_dialog(self.text) if filename: self.text.SetValue(filename) parent.Raise() while wx.IsBusy(): wx.EndBusyCursor()
def OnBrowse(self, event): parent = self.text.GetParent() filename = gui_util.save_file_dialog(parent, self.extension) if filename: self.text.SetValue(filename) parent.Raise() while wx.IsBusy(): wx.EndBusyCursor()
def __GotoNextAnno(self, el): if not el.HasProperty('LocationString'): return location_str = el.GetProperty('LocationString') results = self.__context.dbhandle.database.location_manager.getLocationInfo( location_str, {}) if results == self.__context.dbhandle.database.location_manager.LOC_NOT_FOUND: return # # @todo Prevent this command from being called without a valid location location_id, _, clock = results # # @todo Current tick should be based on this element's t_offset. cur_tick = self.__context.GetHC() results = self.__context.GetTransactionFields(cur_tick, location_str, ['annotation']) cur_annotation = results.get('annotation') if cur_annotation is None: cur_annotation = '' def progress_cb(percent, num_results, info): cont = True skip = False if num_results > 0: cont = False # Found some results. No need to keep searching return (cont, skip) wx.BeginBusyCursor() try: # # @todo Include location ID in searches results = self.__context.searchhandle.Search( 'string', cur_annotation, cur_tick + 1, # start tick -1, # end tick [location_id], progress_cb, invert=True) except Exception as ex: error('Error searching: ', ex, file=sys.stderr) return # Failed to search finally: wx.EndBusyCursor() closest = None for start, end, loc, annotation in results: if loc == location_id: if annotation != cur_annotation: diff = start - cur_tick if closest is None or (start > cur_tick and start < closest): closest = start if closest is not None: self.__context.GoToHC(closest) if wx.IsBusy(): wx.EndBusyCursor()
def __GotoPrevAnno(self, el): if not el.HasProperty('LocationString'): return location_str = el.GetProperty('LocationString') results = self.__context.dbhandle.database.location_manager.getLocationInfo( location_str, {}) if results == self.__context.dbhandle.database.location_manager.LOC_NOT_FOUND: return # # \todo Prevent this command from being called without a valid location location_id, _, clock = results # # @todo Current tick should be based on this element's t_offset. cur_tick = self.__context.GetHC() results = self.__context.GetTransactionFields(cur_tick, location_str, ['annotation']) cur_annotation = results.get('annotation') if cur_annotation is None: cur_annotation = '' def progress_cb(self, percent, *args): cont = True skip = False return (cont, skip) wx.BeginBusyCursor() try: results = self.__context.searchhandle.Search( 'string', cur_annotation, 0, # start tick cur_tick - 1, # end tick [location_id], progress_cb, invert=True) # TODO Support some kind of reverse search that doesn't require starting from the beginning except Exception as ex: error(f'Error searching: {ex}') return # Failed to search finally: wx.EndBusyCursor() closest = None for start, end, loc, annotation in results: if loc == location_id: if annotation != cur_annotation: if closest is None or ( end <= cur_tick and end > closest ): # <= cur_tick because end is exclusive closest = end if closest is not None: self.__context.GoToHC(max(0, closest - 1)) if wx.IsBusy(): wx.EndBusyCursor()
def Abort(self): """Abort all rendering processes""" Debug.msg(1, "RenderMapMgr.Abort()") for layer in self.layers: layer.GetRenderMgr().Abort() self._init() if wx.IsBusy(): wx.EndBusyCursor() self.updateProgress.emit(range=0, value=0, text=_("Rendering aborted"))
def on_item_selected(self, event): self._selected_index = event.GetIndex() if self.picture_list is not None: if not wx.IsBusy(): wx.BeginBusyCursor() if not self.set_path_timer.Start(100, True): pass # wx.Timer.Start seems to return always False... #print 'impossible to start the timer! (bmarks)' #self.on_timer() event.Skip()
def _onIdle(self, event): if len(self.onIdleCmdQueue_) > 0: # print len(self.onIdleCmdQueue_) gauge = xrc.XRCCTRL(self.idleProzessPanel, 'IdleGauge') if not self.idleProzessPanel.IsShown(): gauge.SetRange(len(self.onIdleCmdQueue_) - 1) gauge.SetValue(0) self.idleProzessPanel.Layout() self.idleProzessPanel.Show() wx.BeginBusyCursor(wx.StockCursor(wx.CURSOR_WAIT)) else: try: gauge.SetValue(gauge.GetValue() + 1) except: pass [cmd, args, name] = self.onIdleCmdQueue_[0] label = xrc.XRCCTRL(self.idleProzessPanel, 'IdleLabel') print(gauge.GetValue(), ": ", name) label.SetLabel("Prozessing: " + str(gauge.GetValue()) + "/" + str(gauge.GetRange()) + " ... " + name) try: if len(args) == 0: print(name, cmd) cmd() elif len(args) == 1: cmd(args[0]) elif len(args) == 2: cmd(args[0], args[1]) except Exception as e: import traceback traceback.print_exc(file=sys.stdout) print(e) self.onIdleCmdQueue_.pop(0) else: if self.idleProzessPanel.IsShown(): wx.EndBusyCursor() self.idleProzessPanel.Hide() elif wx.IsBusy() and not self.busyCursorWarning: self.busyCursorWarning = True self.idleProzessPanel.Hide() wx.EndBusyCursor() err = wx.MessageDialog( self, 'Hanging busy cursor found, probably something goes wrong. Please refer to the error log.', 'Something goes wrong.', wx.OK | wx.ICON_WARNING) # err.ShowModal() if err.ShowModal() == wx.ID_OK: self.busyCursorWarning = False
def _show_widget_toplevel(self, node): # creates/shows the widget of the given toplevel node and all its children if not wx.IsBusy(): wx.BeginBusyCursor() if not node.widget.widget: node.widget.create_widget() node.widget.finish_widget_creation() if node.children: for c in node.children: self.create_widgets(c) node.widget.post_load() node.widget.create() node.widget.widget.Show() misc.set_focused_widget(node.widget) node.widget.widget.Raise() # set the best size for the widget (if no one is given) props = node.widget.properties if 'size' in props and not props['size'].is_active( ) and node.widget.sizer: node.widget.sizer.fit_parent() if wx.IsBusy(): wx.EndBusyCursor()
def set_progress(self, progress, message, noTime=False): self._main_frame.set_progress(int(round(progress)), message) # we also output an informative message to standard out # in cases where DeVIDE is very busy, this is quite # handy. print "%s: %.2f" % (message, progress) # activate the busy cursor (we're a bit more lenient # on its epsilon) if abs(progress - 100.0) > 1: if not wx.IsBusy(): wx.BeginBusyCursor() # or switch it off else: if wx.IsBusy(): wx.EndBusyCursor() # let's also show the completion message in the # message log... self.log_info(message) # bring this window to the top if the user wants it #if self._main_frame.progressRaiseCheckBox.GetValue(): # self._main_frame.Raise() # we want wx to update its UI, but it shouldn't accept any # user input, else things can get really crazy. - # we do keep interaction for the main window enabled, # but we disable all menus. menuCount = self._main_frame.GetMenuBar().GetMenuCount() for menuPos in range(menuCount): self._main_frame.GetMenuBar().EnableTop(menuPos, False) wx.SafeYield(win=self._main_frame) for menuPos in range(menuCount): self._main_frame.GetMenuBar().EnableTop(menuPos, True)
def on_tree_sel_changed(self, event): if getattr(self.dir_ctrl, 'dont_trigger_change_dir', False): # ugly hack (see PictureList.set_path), to avoid path changes # when the user visits a hidden dir, but the tree isn't showing # them return if not wx.IsBusy(): wx.BeginBusyCursor() self.which_case = 0 if not self.set_path_timer.Start(100, True): pass # wx.Timer.Start seems to return always False... #print 'impossible to start the timer!' #self.on_timer() event.Skip()
def show_widget(self, node, toplevel=False): """\ Shows the widget of the given node and all its children """ if toplevel: if not wx.IsBusy(): wx.BeginBusyCursor() if not node.widget.widget: node.widget.create_widget() node.widget.finish_widget_creation() if node.children: for c in node.children: self.show_widget(c) node.widget.post_load() node.widget.show_widget(True) node.widget.show_properties() node.widget.widget.Raise() # set the best size for the widget (if no one is given) props = node.widget.properties if 'size' in props and not props['size'].is_active() and \ node.widget.sizer: node.widget.sizer.fit_parent() if wx.IsBusy(): wx.EndBusyCursor() else: import edit_sizers def show_rec(node): node.widget.show_widget(True) self.expand(node, True) if node.children: for c in node.children: show_rec(c) node.widget.post_load() ## w = node.widget ## if isinstance(w, edit_sizers.SizerBase): return ## elif not w.properties['size'].is_active() and \ ## w.sizer and w.sizer.toplevel: ## w.sizer.fit_parent() show_rec(node)
def ShowSubmitDebugLogDialog(): dlg = SubmitDebugReportDialog(myDataMainFrame, "MyData - Submit Debug Log", self.loggerOutput.getvalue(), settingsModel) try: if wx.IsBusy(): wx.EndBusyCursor() stoppedBusyCursor = True else: stoppedBusyCursor = False result = dlg.ShowModal() if stoppedBusyCursor: if not wx.IsBusy(): wx.BeginBusyCursor() myDataMainFrame.submitDebugLog = (result == wx.ID_OK) if myDataMainFrame.submitDebugLog: self.contactName = dlg.GetName() self.contactEmail = dlg.GetEmail() self.comments = dlg.GetComments() self.pleaseContactMe = dlg.GetPleaseContactMe() finally: dlg.Destroy() myDataMainFrame.submitDebugLogDialogCompleted = True
def BeginBusyCursorIfRequired(event=None): """ Begin busy cursor if it's not already being displayed. """ try: if not wx.IsBusy(): wx.BeginBusyCursor() if event and hasattr(event, 'settingsDialog') and event.settingsDialog: if 'phoenix' in wx.PlatformInfo: busyCursor = wx.Cursor(wx.CURSOR_WAIT) else: busyCursor = wx.StockCursor(wx.CURSOR_WAIT) event.settingsDialog.dialogPanel.SetCursor(busyCursor) except wx.PyAssertionError as err: logger.warning(err)
def __init__(self, name, parent=None, height_desc=220, sync=False, execute=True): """Set up the window. @param name: The name of the user function. @type name: str @keyword parent: The parent class containing the GUI. @type parent: class instance @keyword height_desc: The height in pixels of the description part of the wizard. @type height_desc: int or None @keyword sync: A flag which if True will call user functions via interpreter.apply and if False via interpreter.queue. @type sync: bool @keyword execute: A flag which if True will prevent the user function from being executed when clicking on 'Next', 'Ok', or 'Apply'. This can be useful for delaying the execution of the user function. @type execute: bool """ # Store the args. self.name = name self.sync = sync self.execute_flag = execute # Storage of the user function argument elements. self.uf_args = {} # Yield to allow the cursor to be changed. wx.Yield() # Change the cursor to waiting. wx.BeginBusyCursor() # Get the user function data object. self.uf_data = uf_info.get_uf(name) # Set the wizard image. self.image_path = self.uf_data.wizard_image # Set the user function title. if self.uf_data.title_short != None: self.title = self.uf_data.title_short else: self.title = self.uf_data.title # Execute the base class method. super(Uf_page, self).__init__(parent, height_desc=height_desc) # Reset the cursor. if wx.IsBusy(): wx.EndBusyCursor()
def update_pipes(self, event=None): """Update the spin view data pipe selector. @keyword event: The wx event. @type event: wx event """ # Change the cursor to busy. wx.BeginBusyCursor() # Init. pipe_switch = False # The selected pipe. if event: # The name of the selected pipe. pipe = gui_to_str(self.pipe_name.GetString(event.GetSelection())) # A pipe change. if pipe != cdp_name(): pipe_switch = True else: pipe = cdp_name() if not pipe: pipe = '' # Clear the previous data. self.pipe_name.Clear() # The list of pipe names. for name in pipe_names(): self.pipe_name.Append(str_to_gui(name)) # Switch. if pipe_switch: # Switch data pipes. self.gui.interpreter.apply('pipe.switch', pipe) # Update the tree view. self.tree_panel.update() # Set the pipe name to the cdp. self.pipe_name.SetValue(str_to_gui(pipe)) # Reset the cursor. if wx.IsBusy(): wx.EndBusyCursor()
def refresh_safe(self): """Refresh the spin viewer window.""" # Change the cursor to busy. wx.BeginBusyCursor() # Update the data pipe selector. self.update_pipes() # Update the tree. self.tree_panel.update() # Redisplay the container. self.container.display(self.tree_panel.get_info()) # Reset the cursor. if wx.IsBusy(): wx.EndBusyCursor()
def EndBusyCursorIfRequired(event=None): """ The built in wx.EndBusyCursor raises an ugly exception if the busy cursor has already been stopped. """ try: if wx.IsBusy(): wx.EndBusyCursor() if event and hasattr(event, 'settingsDialog') and event.settingsDialog: if 'phoenix' in wx.PlatformInfo: arrowCursor = wx.Cursor(wx.CURSOR_ARROW) else: arrowCursor = wx.StockCursor(wx.CURSOR_ARROW) event.settingsDialog.dialogPanel.SetCursor(arrowCursor) except wx.PyAssertionError as err: if "no matching wxBeginBusyCursor()" \ not in str(err): logger.warning(str(err)) raise
def save_file(self, contents, extension): """ Export the LogWindow/USBTreeWindow content to a file Called by LogWindow and USB Tree View Window Args: self:The self parameter is a reference to the current instance of the class,and is used to access variables that belongs to the class. Returns: return- success for file save in directiry """ # Save a file self.dirname = "" dlg = wx.FileDialog(self, "Save as", self.dirname, "", extension, wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: wx.BeginBusyCursor() dirname = dlg.GetDirectory() filename = os.path.join(dirname, dlg.GetFilename()) if (os.path.isdir(dirname) and os.access(dirname, os.X_OK | os.W_OK)): self.dirname = dirname try: f = open(filename, 'w') f.write(contents) f.close() except IOError: options = wx.OK | wx.ICON_ERROR dlg_error = wx.MessageDialog( self, "Error saving file\n\n" + strerror, "Error", options) dlg_error.ShowModal() dlg_error.Destroy() dlg.Destroy() if (wx.IsBusy()): wx.EndBusyCursor() return