Python wx.BeginBusyCursor() Examples
The following are 17
code examples of wx.BeginBusyCursor().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: clipboard.py From wxGlade with MIT License | 6 votes |
def _paste(parent, index, clipboard_data): "parse XML and insert widget" option, span, flag, border, xml_unicode = clipboard2widget( clipboard_data ) if not xml_unicode: return False import xml_parse try: wx.BeginBusyCursor() # widget representation is still unicode, but parser need UTF8 xml_utf8 = xml_unicode.encode('utf8') parser = xml_parse.ClipboardXmlWidgetBuilder(parent, index, option, span, flag, border) with parent and parent.frozen() or misc.dummy_contextmanager(): parser.parse_string(xml_utf8) if parent and hasattr(parent, "on_child_pasted"): parent.on_child_pasted() # trigger e.g. re-sizing of the children freeze = parser._object_counter>80 # for more objects, we freeze the Tree during re-build misc.rebuild_tree( parser.top_obj, freeze=freeze ) return True # Widget hierarchy pasted. except xml_parse.XmlParsingError: if config.debugging: raise return False finally: wx.EndBusyCursor()
Example #2
Source File: edit_windows.py From wxGlade with MIT License | 6 votes |
def create(self): # creates/shows the widget of the given toplevel node and all its children wx.BeginBusyCursor() try: WindowBase.create(self) finally: wx.EndBusyCursor() # from old code: # below, probably check_prop should be False ## set the best size for the widget (if no one is given) #if not self.check_prop('size'): #if self.sizer: # self.sizer is the containing sizer, i.e. the parent #self.sizer.fit_parent() #elif self.WX_CLASS=="wxPanel" and self.children: #wx.Yield() # by now, there are probably many EVT_SIZE in the queue #self.children[0].fit_parent() self.widget.GetTopLevelParent().Show() # SafeYield and SetFocus are required for e.g. Ubuntu w. Python 3.8 and wxPython 4.0.7 # see file SIMPLIFICATIONS\Tests_full.wxg where the first frame will not be layouted wx.SafeYield() self.widget.Raise() self.widget.SetFocus()
Example #3
Source File: xrced.py From admin4 with Apache License 2.0 | 6 votes |
def OnOpen(self, evt): if not self.AskSave(): return dlg = wx.FileDialog(self, 'Open', os.path.dirname(self.dataFile), '', '*.xrc', wx.OPEN | wx.CHANGE_DIR) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() self.SetStatusText('Loading...') wx.BeginBusyCursor() try: if self.Open(path): self.SetStatusText('Data loaded') else: self.SetStatusText('Failed') self.SaveRecent(path) finally: wx.EndBusyCursor() dlg.Destroy()
Example #4
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 6 votes |
def HighlightEvents(self, entries): date = self.GetDate() year = date.GetYear() month = date.GetMonth() + 1 has_events = 0 days = [] years = entries.get_years() if year in years: months = entries.get_months(year) if month in months: has_events = 1 days = entries.get_days(year, month) wx.BeginBusyCursor() try: for day in range(1, 32): if day in days and has_events: self.SetDayAttr(day, True) else: self.SetDayAttr(day, False) self.Refresh(True) finally: wx.EndBusyCursor()
Example #5
Source File: adm.py From admin4 with Apache License 2.0 | 6 votes |
def StartWaiting(txt=None, mayAbort=False): frame=GetCurrentFrame() if frame: if hasattr(frame, 'tree') and frame.tree: node=frame.tree.GetNode() if node: node.waitingFrame=frame if not txt: txt=xlt("working...") frame.PushStatus(txt) if not mayAbort: wx.BeginBusyCursor() frame.MakeModal(True) try: wx.SafeYield() except: pass return frame
Example #6
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 6 votes |
def _CalendarDisplayChanged(self, event): date = event.GetDate() year = date.GetYear() month = date.GetMonth() + 1 has_events = 0 days = [] years = self.entries.get_years() if year in years: months = self.entries.get_months(year) if month in months: has_events = 1 days = self.entries.get_days(year, month) wx.BeginBusyCursor() try: for day in range(1, 32): if day in days and has_events: self.cal.SetDayAttr(day, True) else: self.cal.SetDayAttr(day, False) self.cal.Refresh(True) finally: wx.EndBusyCursor()
Example #7
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
def _FileArchiveMenu(self, event): date = self._QueryChooseDate('Archive files before which date?') if date is None: return path = None new_basename = '' if self.conf.data_file is not None: new_base, new_ext = os.path.splitext(os.path.basename( self.conf.data_file)) if not new_ext: new_ext = '.tkj' new_basename = new_base + '.archive' + new_ext dialog = self._GetFileDialog('Archive to a new data file', wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT, new_basename) if dialog.ShowModal() == wx.ID_OK: path = dialog.GetPath() dialog.Destroy() if path is None: return if len(path) < 5 or not path.endswith('.tkj'): path = path + '.tkj' wx.Yield() wx.BeginBusyCursor() try: self._ArchiveEntriesBeforeDate(path, date.GetYear(), date.GetMonth() + 1, date.GetDay()) finally: wx.EndBusyCursor()
Example #8
Source File: xrced.py From admin4 with Apache License 2.0 | 5 votes |
def OnRecentFile(self,evt): # open recently used file if not self.AskSave(): return wx.BeginBusyCursor() try: path=conf.recentfiles[evt.GetId()] if self.Open(path): self.SetStatusText('Data loaded') else: self.SetStatusText('Failed') except KeyError: self.SetStatusText('No such file') wx.EndBusyCursor()
Example #9
Source File: activities.py From grass-tangible-landscape with GNU General Public License v2.0 | 5 votes |
def PostProcessing(self, onDone=None): wx.BeginBusyCursor() wx.SafeYield() env = get_environment(rast=self.settings['output']['scan']) try: postprocess = imp.load_source('postprocess', os.path.join(self._getTaskDir(), self.tasks[self.current]['analyses'])) except Exception as e: print(e) return functions = [func for func in dir(postprocess) if func.startswith('post_')] for func in functions: exec('del postprocess.' + func) try: postprocess = imp.load_source('postprocess', os.path.join(self._getTaskDir(), self.tasks[self.current]['analyses'])) except Exception as e: print(e) return functions = [func for func in dir(postprocess) if func.startswith('post_')] for func in functions: try: exec('postprocess.' + func + "(real_elev=self.settings['scan']['elevation']," " scanned_elev=self.settings['output']['scan']," " filterResults=self.scaniface.filter['counter']," " timeToFinish=self.endTime," " subTask=self.currentSubtask," " logDir=self.configuration['logDir']," " env=env)") except (CalledModuleError, Exception, ScriptError) as e: traceback.print_exc() wx.EndBusyCursor() if self.handsoff: ll = self.giface.GetLayerList() ll.DeleteLayer(self.handsoff) self.handsoff = None if onDone: onDone()
Example #10
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
def _SetFont(self, font): """Set the font used by the entry text field.""" wx.BeginBusyCursor() self.ignore_text_event = True try: self.frame.FindWindowById(self.text_id).SetFont(font) self.conf.font_face = font.GetFaceName() self.conf.font_size = font.GetPointSize() self.options_dialog.FindWindowById(self.font_id).SetLabel( "%s, %dpt" % (self.conf.font_face, self.conf.font_size)) finally: self.ignore_text_event = False wx.EndBusyCursor()
Example #11
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
def EntryChangedListener(self, entry, year, month, day, id): """Callback for TKEntries.store_entry().""" date = self.GetDate() if date.GetYear() != year: return if (date.GetMonth() + 1) != month: return wx.BeginBusyCursor() try: if entry: self.SetDayAttr(day, True) else: self.SetDayAttr(day, False) finally: wx.EndBusyCursor()
Example #12
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
def EntryChangedListener(self, tag, entry, add=True): """Callback for TKEntries.store_entry().""" year, month, day = entry.get_date() id = entry.get_id() wx.BeginBusyCursor() try: stack = self.GetTagStack(tag, year, month, day, id) tag_path = list(map(str, tag.split('/'))) expected_stack_len = len(tag_path) + 2 # root + tag pieces + entry if not add: if len(stack) == expected_stack_len: self.Prune(stack[-1]) else: newtag = None for i in range(len(tag_path)): if i == 0: newtag = tag_path[i] else: newtag = newtag + '/' + tag_path[i] if len(stack) == i + 1: data = TKEntryKey(None, None, None, None, newtag) stack.append(self.AppendItem(stack[i], tag_path[i], -1, -1, data)) self.SortChildren(stack[i]) subject = entry.get_subject() if len(stack) == i + 2: data = TKEntryKey(year, month, day, id, newtag) stack.append(self.AppendItem(stack[i + 1], self._ItemLabel(day, month, year, subject), -1, -1, data)) self.SortChildren(stack[i + 1]) else: self.SetItemText(stack[i + 2], self._ItemLabel(day, month, year, subject)) finally: wx.EndBusyCursor()
Example #13
Source File: app.py From thotkeeper with BSD 2-Clause "Simplified" License | 5 votes |
def EntryChangedListener(self, entry, year, month, day, id, expand=True): """Callback for TKEntries.store_entry().""" wx.BeginBusyCursor() try: stack = self.GetDateStack(year, month, day, id) if not entry: if stack[3]: self.Prune(stack[3]) else: subject = entry.get_subject() if not stack[1]: data = TKEntryKey(year, None, None, None) stack[1] = self.AppendItem(stack[0], str(year), -1, -1, data) self.SortChildren(stack[0]) if not stack[2]: data = TKEntryKey(year, month, None, None) stack[2] = self.AppendItem(stack[1], month_names[month - 1], -1, -1, data) self.SortChildren(stack[1]) if not stack[3]: data = TKEntryKey(year, month, day, id) stack[3] = self.AppendItem(stack[2], self._ItemLabel(day, subject), -1, -1, data) self.SortChildren(stack[2]) else: self.SetItemText(stack[3], self._ItemLabel(day, subject)) if expand: self.Expand(stack[0]) self.Expand(stack[1]) self.Expand(stack[2]) self.Expand(stack[3]) self.SelectItem(stack[3]) finally: wx.EndBusyCursor()
Example #14
Source File: trelby.py From trelby with GNU General Public License v2.0 | 5 votes |
def OnSpellCheckerDlg(self): self.sp.clearMark() self.clearAutoComp() wasAtStart = self.sp.line == 0 wx.BeginBusyCursor() if not spellcheck.loadDict(mainFrame): wx.EndBusyCursor() return sc = spellcheck.SpellChecker(self.sp, gd.scDict) found = sc.findNext() wx.EndBusyCursor() if not found: s = "" if not wasAtStart: s = "\n\n(Starting position was not at\n"\ "the beginning of the script.)" wx.MessageBox("Spell checker found no errors." + s, "Results", wx.OK, mainFrame) return dlg = spellcheckdlg.SpellCheckDlg(mainFrame, self, sc, gd.scDict) dlg.ShowModal() if dlg.changedGlobalDict: gd.saveScDict() dlg.Destroy() self.sp.clearMark() self.makeLineVisible(self.sp.line) self.updateScreen()
Example #15
Source File: namesdlg.py From trelby with GNU General Public License v2.0 | 4 votes |
def OnSearch(self, event = None): l = [] wx.BeginBusyCursor() s = util.lower(misc.fromGUI(self.searchEntry.GetValue())) sex = self.sexRb.GetSelection() nt = self.nameRb.GetSelection() selTypes = {} item = -1 while 1: item = self.typeList.GetNextItem(item, wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED) if item == -1: break selTypes[self.typeList.GetItemData(item)] = True if len(selTypes) == len(nameArr.typeNamesCnt): doTypes = False else: doTypes = True for i in xrange(nameArr.count): if (sex != 2) and (sex == nameArr.sex[i]): continue if doTypes and nameArr.type[i] not in selTypes: continue if s: name = util.lower(nameArr.name[i]) if nt == 0: if not name.startswith(s): continue elif nt == 1: if name.find(s) == -1: continue elif nt == 2: if not name.endswith(s): continue l.append(i) self.list.items = l self.list.SetItemCount(len(l)) self.list.EnsureVisible(0) wx.EndBusyCursor() self.foundLabel.SetLabel("%d names found." % len(l))
Example #16
Source File: xrced.py From admin4 with Apache License 2.0 | 4 votes |
def OnSaveOrSaveAs(self, evt): if evt.GetId() == wx.ID_SAVEAS or not self.dataFile: if self.dataFile: name = '' else: name = defaultName dirname = os.path.abspath(os.path.dirname(self.dataFile)) dlg = wx.FileDialog(self, 'Save As', dirname, name, '*.xrc', wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() if isinstance(path, unicode): path = path.encode(sys.getfilesystemencoding()) dlg.Destroy() else: dlg.Destroy() return if conf.localconf: # if we already have a localconf then it needs to be # copied to a new config with the new name lc = conf.localconf nc = self.CreateLocalConf(path) flag, key, idx = lc.GetFirstEntry() while flag: nc.Write(key, lc.Read(key)) flag, key, idx = lc.GetNextEntry(idx) conf.localconf = nc else: # otherwise create a new one conf.localconf = self.CreateLocalConf(path) else: path = self.dataFile self.SetStatusText('Saving...') wx.BeginBusyCursor() try: try: tmpFile,tmpName = tempfile.mkstemp(prefix='xrced-') os.close(tmpFile) self.Save(tmpName) # save temporary file first shutil.move(tmpName, path) self.dataFile = path if conf.localconf.ReadBool("autogenerate", False): pypath = conf.localconf.Read("filename") embed = conf.localconf.ReadBool("embedResource", False) genGettext = conf.localconf.ReadBool("genGettext", False) self.GeneratePython(self.dataFile, pypath, embed, genGettext) self.SetStatusText('Data saved') self.SaveRecent(path) except IOError: self.SetStatusText('Failed') finally: wx.EndBusyCursor()
Example #17
Source File: spellcheckdlg.py From trelby with GNU General Public License v2.0 | 4 votes |
def OnSuggest(self, event): if not self.sc.word: return isAllCaps = self.sc.word == util.upper(self.sc.word) isCapitalized = self.sc.word[:1] == util.upper(self.sc.word[:1]) word = util.lower(self.sc.word) wl = len(word) wstart = word[:2] d = 500 fifo = util.FIFO(5) wx.BeginBusyCursor() for w in spellcheck.prefixDict[util.getWordPrefix(word)]: if w.startswith(wstart): d = self.tryWord(word, wl, w, d, fifo) for w in self.gScDict.words.iterkeys(): if w.startswith(wstart): d = self.tryWord(word, wl, w, d, fifo) for w in self.ctrl.sp.scDict.words.iterkeys(): if w.startswith(wstart): d = self.tryWord(word, wl, w, d, fifo) items = fifo.get() wx.EndBusyCursor() if len(items) == 0: wx.MessageBox("No similar words found.", "Results", wx.OK, self) return dlg = wx.SingleChoiceDialog( self, "Most similar words:", "Suggestions", items) if dlg.ShowModal() == wx.ID_OK: sel = dlg.GetSelection() newWord = items[sel] if isAllCaps: newWord = util.upper(newWord) elif isCapitalized: newWord = util.capitalize(newWord) self.replaceEntry.SetValue(newWord) dlg.Destroy() # if w2 is closer to w1 in Levenshtein distance than d, add it to # fifo. return min(d, new_distance).