def queue_program(username, password, label): queue = ProgramQueue(username, password) try: rc = queue.login() except: rc = False if not rc: QMessageBox.critical( main_window, main_window.tr('Login failed'), main_window.tr('Could not log in to the program queue.')) return output = StringIO() storage = SimpleFormat(output) serialize(storage) program_data = output.getvalue() output.close() try: id = queue.upload_program(program_data, label) except: id = False if not id: QMessageBox.critical( main_window, main_window.tr('Upload failed'), main_window.tr('Could not upload program to queue.')) return try: queue.logout() except: pass QMessageBox.information( main_window, main_window.tr('Uploaded program'), main_window.tr('Uploaded program (%d) successfully.') % id)
def queue_program(username, password, label): queue = ProgramQueue(username, password) try: rc = queue.login() except: rc = False if not rc: QMessageBox.critical(main_window, main_window.tr('Login failed'), main_window.tr('Could not log in to the program queue.')) return output = StringIO() storage = SimpleFormat(output) serialize(storage) program_data = output.getvalue() output.close() try: id = queue.upload_program(program_data, label) except: id = False if not id: QMessageBox.critical(main_window, main_window.tr('Upload failed'), main_window.tr('Could not upload program to queue.')) return try: queue.logout() except: pass QMessageBox.information(main_window, main_window.tr('Uploaded program'), main_window.tr('Uploaded program (%d) successfully.') % id)
def doAddWordButton(self, newWord, rank): additionResult = self.wordCollection.addToUserDict(newWord, rankInt=rank); if additionResult: QMessageBox.information(self, # dialog parent "Dictionary addition", "Word '%s' has been saved in user dictionary." % newWord, QMessageBox.Ok, QMessageBox.NoButton); else: QMessageBox.information(self, # dialog parent "Dictionary addition", "Word '%s' was already in the dictionary. No action taken" % newWord, QMessageBox.Ok, QMessageBox.NoButton);
def handleSaveWordButton(self): # Get content of output panel: currOutput = self.outputPanel.toPlainText(); # If noth'n there, done: if len(currOutput) == 0: QMessageBox.information(self, "Dictionary addition", "Output panel has no content; so there is no word to save.", QMessageBox.Ok, QMessageBox.NoButton); return; # Get the last word in the output panel: newWord = re.split("[.;:?! @()]", currOutput)[-1]; # Ask user about capitalization, and expected word frequency. # This call will raise a modal dialog box. Signal handlers # handleAddDictWordCapitalizeStateChanged(), and handleAddDictWordOK_Cancel() # take it from there: self.getAddWordUserInfo(newWord);
def save_screenshot(): path = os.path.expanduser('~') filename_template = 'robot-%d.png' serial = 1 while True: filename = os.path.join(path, filename_template % serial) if not os.path.exists(filename): break serial += 1 widget = robot_view.children()[0] pixmap = QPixmap.grabWindow(widget.winId()) rc = pixmap.save(filename) if rc: QMessageBox.information(main_window, main_window.tr('Saved screenshot'), main_window.tr('Screenshot saved in file: %s') % filename) else: QMessageBox.critical(main_window, main_window.tr('Saving screenshot failed'), main_window.tr('Could not save screenshot.'))
def save_screenshot(): path = os.path.expanduser('~') filename_template = 'robot-%d.png' serial = 1 while True: filename = os.path.join(path, filename_template % serial) if not os.path.exists(filename): break serial += 1 widget = robot_view.children()[0] pixmap = QPixmap.grabWindow(widget.winId()) rc = pixmap.save(filename) if rc: QMessageBox.information( main_window, main_window.tr('Saved screenshot'), main_window.tr('Screenshot saved in file: %s') % filename) else: QMessageBox.critical(main_window, main_window.tr('Saving screenshot failed'), main_window.tr('Could not save screenshot.'))