def remove_last_empty_paragraph(self): done = False try: # The book being edited as a container object container = self.current_container for name, media_type in container.mime_map.iteritems(): if media_type in OEB_DOCS: # A HTML file. Parsed HTML files are lxml elements for body in XPath('//h:body')( container.parsed(name)): # read xml nodes children = body.getchildren() if children is not None: count = len(children) if count > 0: # Crow all child lastPara = children[count - 1] # remove tag if it's empty or whitespace! if lastPara.tag.lower().endswith("p"): lastP_children = lastPara.getchildren() if (lastPara.text is None or lastPara.text.decode('utf-8').isspace()) and \ (lastP_children is None or len(lastP_children) == 0): done |= True # remove this node lastPara.getparent().remove(lastPara) container.dirty(name) # Tell the container that we have changed if done: self.cleanasawhistle = False except Exception as e: QMessageBox.information(self.gui, "Remove Extra Tags Err", "error({0}): {1}".format(type(e), e.args)) return False else: return done
def get_label_info(self, dir_path): labels_path = os.path.join(dir_path, 'labels') labels_exist_path = labels_path if os.path.exists( labels_path) else dir_path self.label_to_num = {} for file_name in tqdm(os.listdir(labels_exist_path), "check label"): if os.path.splitext(file_name)[1] != XML_EXT: continue xml_path = os.path.join(labels_exist_path, file_name) reader = PascalVocReader(xml_path) for shape in reader.shapes: if shape[0] not in self.label_to_num: self.label_to_num.setdefault(shape[0], 1) else: self.label_to_num[shape[0]] += 1 list_of_dataset = os.listdir(dir_path) self.label_to_num['origin_image_num'] = 0 self.label_to_num['labeled_image_num'] = 0 for each_item in list_of_dataset: if os.path.splitext(each_item)[1] == '.jpg': self.label_to_num['origin_image_num'] += 1 else: self.check_label_exist(os.path.join(dir_path, each_item)) QMessageBox.information(None, 'info', str(self.label_to_num))
def remove_tag(self, this_node, tag): found = False if this_node is None or tag is None: return found try: if this_node.tag.lower().endswith(tag): # remove this node this_node.getparent().remove(this_node) found = True else: children = this_node.getchildren() if children is not None: count = len(children) if count > 0: # Crow all child # 1 <-- last for index in range(count - 1, -1, -1): found |= self.remove_tag(children[index], tag) except Exception as e: QMessageBox.information(self.gui, "Remove Tag Err", "error({0}): {1}".format(type(e), e.args)) return False else: return found
def add_persian_and_page_direction(self): self.boss.commit_all_editors_to_container() self.boss.add_savepoint('Before: AddPersianAndDirection') container = self.current_container # The book being edited as a container object persianResult = 'false' directionResult = 'false' for name, media_type in container.mime_map.iteritems(): if media_type in OPF_MIME: # The prefix // means search at any level of the document. # for item in XPath('//h:spine')(container.parsed(name)): for item in container.parsed(name): if item.tag == '{http://www.idpf.org/2007/opf}spine': item.attrib['page-progression-direction'] = 'rtl' directionResult = 'true' for i in item: if i.tag == '{http://purl.org/dc/elements/1.1/}language': i.text = 'fa' persianResult = 'true' if directionResult == 'true' and persianResult == 'true': QMessageBox.information(self.gui, "salam", "کتاب فارسی شد" + "\n" + "جهت ورق خوردن راست به چپ شد") container.dirty(name) # Update the editor UI to take into account all the changes we # have made self.boss.apply_container_update_to_gui() else: QMessageBox.information(self.gui, "salam", "خطا در انجام عملیات" + "\n" + "لطفا به صورت دستی انجام دهید")
def DMCurrent_set(self): global DMInterval, DMChannelName, DMCurrentAmplitude if not self.DMChannelRight: if None == caget(DMChannelName, timeout=0.5): # 尝试是否可以连接到通道并读取数据 QMessageBox.information(self, "提示", "无法连接到通道,请检查是否有误!") else: self.DMChannelRight = True if self.DMChannelRight: if DMInterval == 0: caput(DMChannelName, DMCurrentAmplitude) else: if self.DMCurrentRun: self.ui.DMPutBtn.setText("Put") self.DMCurrentRun = not self.DMCurrentRun # 线程停止并销毁 self.DMCurrent.stop() self.ui.DM_I.setReadOnly(False) else: self.ui.DMPutBtn.setText("Stop") self.DMCurrentRun = not self.DMCurrentRun #创建线程并开启 self.DMCurrent = DMCurrent.DMCurrentThread( DMChannelName, DMInterval, DMCurrentAmplitude) self.DMCurrent.CurrentSignal.connect(self.receiveDMCurrent) self.QMCurrent.sendData.connect( self.DMCurrent.receiveError) self.DMCurrent.start() self.ui.DM_I.setReadOnly(True)
def saveXML(self): if len(self.tools.framemenu.getAllFrames()) > 1: result = QFileDialog.getSaveFileName(self, 'Choose the destination for the animation file!', '.', 'Animation File (*.armo)') if result[0] != "": XML().toXML(self.tools.framemenu.getAllFrames(), result[0]) else: QMessageBox.information(self, "Stickman Message", "You need at least 2 frames to save the animation!")
def image_create_model(self, show_message=True): self.image_block.b_img_create_pair_models() self.image_block.b_img_create_block_model() message_box_widget = QWidget() # create QWidget if show_message: QMessageBox.information(message_box_widget, "Create Model", "Process finished successfully!") # message information
def on_pushButton_next_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet self.test_result=test_results() addr_sa=str(self.maddress) addr_sa = "TCPIP0::" + addr_sa + "::inst0::INSTR" if not self.demo: try: self.sa=SpectrumAnalyzer.SpectrumAnalyzer(addr_sa) except: QMessageBox.warning(self,ModuleConstants.QMESSAGEBOX_WARN, ModuleConstants.QMESSAGEBOX_WARN_INSTR_NOT_VALID) return self.test_result.test_item = ModuleConstants.TESTITEM_TR_LO self.test_result.test_condition = '--' self.test_result.test_results=str(self.testProcess()) if self.test_result.test_results ==self.threshold: QMessageBox.information(self,ModuleConstants.QMESSAGEBOX_INFO,ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_NORMAL,QMessageBox.Ok) self.test_result.test_conclusion=ModuleConstants.TESTRESULT_PASS else: QMessageBox.information(self,ModuleConstants.QMESSAGEBOX_INFO,ModuleConstants.TESTITEM_TR_LO+ ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_ABNORMAL,QMessageBox.Ok) self.test_result.test_conclusion=ModuleConstants.TESTRESULT_FAIL self._signalTest.emit("test_lo") self.accept() self.close()
def image_find_feature_points(self, flag=IMG_AKAZE, show_message=True): """ Use the appropriate flag and find the feature points for each image in the list. It takes a while to calculate for big images. :param show_message: True/False :param flag: IMG_SIFT, IMG_SURF, IMG_ORB, IMG_AKAZE :return: Nothing """ success = False # Set success to False for image in self.image_list: # For each image in image list success = True # Set success to True (this means there are images in list) image.img_find_feature_points(flag=flag) # find feature points using the specified flag if success: # if success = True self.image_default_find_feature_points_checked() # reset the find feature checked # reset the default create block (do this because this function doesnt recreate the block). The block needs # to be recreated after find feature points action for updated results. self.image_default_create_block_checked() if flag == self.F_AKAZE: # if flag AKAZE self.ui_main_win.actionAKAZE.setChecked(self.UP) # find feature points using akaze method elif flag == self.F_ORB: # if flag ORB self.ui_main_win.actionORB.setChecked(self.UP) # find feature points using orb method self.ui_simple_img_viewer.check_box_draw_keypoints.setEnabled(self.UP) # enable draw keypoints to simgv self.ui_simple_img_viewer.check_box_draw_keypoints.setChecked(self.DOWN) # uncheck it self.draw_kp = self.DOWN # set the draw kp boolean to uncheck (use this for code readability) self.ui_main_win.actionCreate_Block.setEnabled(self.UP) # enable action Create Block if show_message: message_box_widget = QWidget() # Create QWidget QMessageBox.information(message_box_widget, flag, "Process finished successfully!") # message information
def on_pushButton_next_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet self.test_result = test_results() self.test_result.test_item = ModuleConstants.TESTITEM_SWITCH self.test_result.test_condition = '--' self.test_result.test_results = str(self.testProcess()) if self.test_result.test_results == self.threshold: QMessageBox.information( self, ModuleConstants.QMESSAGEBOX_INFO, ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_NORMAL, QMessageBox.Ok) self.test_result.test_conclusion = ModuleConstants.TESTRESULT_PASS else: QMessageBox.information( self, ModuleConstants.QMESSAGEBOX_INFO, ModuleConstants.TESTITEM_SWITCH + ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_ABNORMAL, QMessageBox.Ok) self.test_result.test_conclusion = ModuleConstants.TESTRESULT_FAIL self._signalTest.emit("test_switch") self.accept() self.close()
def initial_changes(self): self.boss.commit_all_editors_to_container() self.boss.add_savepoint('Before: DeleteKeshDahandeh') container = self.current_container # The book being edited as a container object for name, media_type in container.mime_map.iteritems(): if media_type in OEB_DOCS: for item in container.parsed(name).getroottree().iter(): if item.text is not None: item.text = re.sub( ur"([^ \w><:+=\.1234567890۱۲۳۴۵۶۷۸۹۰])([\u0640]{1,})([^ \w><:+=\.1234567890۱۲۳۴۵۶۷۸۹۰])", ur"\1\3", item.text) item.text = re.sub( ur"([^ \w><:+=\.1234567890۱۲۳۴۵۶۷۸۹۰])([\u0640]{1,})([^ \w><:+=\.1234567890۱۲۳۴۵۶۷۸۹۰])", ur"\1\3", item.text) container.dirty(name) if "span" in str( item.tag ) and item.text == " " and "nim_fasele" in str( item.get("class")): # QMessageBox.information(self.gui, ":)","Tag name is: "+ str(item.tag)+"\nAnd attrs are: " + str(item.get('class'))) item.text = "\u200C" container.dirty(name) # Show the user what changes we have made, allowing her to # revert them if necessary # self.boss.show_current_diff() QMessageBox.information(self.gui, ":)", "Process successfuly completed.") # Update the editor UI to take into account all the changes we # have made self.boss.apply_container_update_to_gui()
def image_create_block(self, show_message=True): """ Create a block of images for all checked images in image list. :return: Nothing """ image_list_tmp = [] # create a temporary image list image_list_size = len(self.image_list) # take the size of the actual list # for image in self.image_list: # print(image.info.name) success = False # set success boolean to False counter = 0 # set image in image_list_tmp counter to 0 for index_id in range(0, image_list_size): # for index id in range(0, list_size) if self.ui_main_win.listImage.item(index_id).checkState(): # check the image item state (if true) counter += 1 # increase the counter if counter > 1: # a block needs at least 2 images (if counter > 1) success = True # set success to True image_list_tmp.append(self.image_list[index_id]) # append the image from image list to tmp image list # print(image_list_tmp) # print image list for debugging if success: # if success = True self.ui_main_win.actionCreate_Block.setChecked(self.UP) # check Create Block self.image_block.b_img_create_image_list(image_list_tmp) # set the image block self.ui_main_win.menuImage_Matching.setEnabled(self.UP) # enable menu Image Matching if show_message: message_box_widget = QWidget() # create QWidget QMessageBox.information(message_box_widget, "Create Block", "Process finished successfully!") # message information
def saveActivity(self): self.updateCurrentActivity() if len(self.activities) > 0: direc = self.cache.get('LASTSUCCESSFULWORKSPACE',default='.') filename = QFileDialog.getSaveFileName(None, 'Save file',direc,"JSON (*.json)") if not filename is None and len(filename[0].strip()) > 0: #Update filenames to be relative to this file bdir = os.path.dirname(filename[0]) for aid in self.activities: activity = self.activities[aid] if isinstance(activity,dict): cf = activity['clothingFile'] cp = os.path.abspath(cf) activity['clothingFile'] = str(os.path.relpath(cp, bdir)) rf = activity['radiationFluxFile'] if len(rf.strip())>0: rp = os.path.abspath(rf) activity['radiationFluxFile'] = str(os.path.relpath(rp, bdir)) with open(filename[0],'w') as ser: self.activities['activityname']=self.activityName.text() if self.activities['activityname']=='Unnamed': self.activities['activityname']=os.path.splitext(os.path.basename(filename[0]))[0] self.activityName.setText(self.activities['activityname']) json.dump(self.activities,ser) self.cache.set('LASTSUCCESSFULWORKSPACE',os.path.dirname(filename[0])) self.dataSaved.emit(filename[0]) else: QMessageBox.information(self, tr("In correct usage"), tr("No activities defined. Did you forget to click add!"))
def image_matching(self, fast=False, show_message=True): """ If fast=True run fast matching method. Else run block matching method (match all images). :param show_message: True/False :param fast: True/False :return: Nothing """ if fast: self.image_default_matching() self.image_block.b_img_fast_matching() message_box_widget = QWidget() # create QWidget self.ui_main_win.actionFast_Matching.setChecked(self.UP) if show_message: QMessageBox.information(message_box_widget, "Fast Matching", "Process finished successfully!") # message information self.ui_main_win.actionCreate_Model.setEnabled(self.UP) else: self.image_default_matching() self.image_block.b_img_match_all_images() self.ui_main_win.actionAll_Images_Matching.setChecked(self.UP) if show_message: message_box_widget = QWidget() # create QWidget QMessageBox.information(message_box_widget, "Matching All Images", "Process finished successfully!") # message information self.ui_main_win.actionCreate_Model.setEnabled(self.UP)
def fusion_video(self, picpath, output, savename, fps): self.ui.progressBar.setValue(0) fourcc = cv2.VideoWriter_fourcc( *'MPEG') # e.g. XVID, DIVX, MJPG, X264, mp4v, I420 path = picpath fps = int(fps) list = sorted(os.listdir(path)) frame = cv2.imread(path + "/" + list[0]) size = np.shape(frame)[:2] size0 = size[0] size1 = size[1] size = (size1, size0) videowriter = cv2.VideoWriter(output + '/' + savename, fourcc, fps, size) for i in range(len(list)): frame = cv2.imread(path + '/' + list[i]) videowriter.write(frame) cv2.imshow("frame", frame) cv2.waitKey(20) progressValue = int((i + 1) / len(list) * 100) self.ui.progressBar.setValue(progressValue) pass videowriter.release() QMessageBox.information(self, 'information', 'already fusion video', QMessageBox.Ok, QMessageBox.Ok)
def QMCurrent_set(self): global QMInterval, QMCycle, QMChannelName, QMCurrentAmplitude if not self.QMChannelRight: if None == caget(QMChannelName, timeout=0.5): # 尝试是否可以连接到通道并读取数据 QMessageBox.information(self, "提示", "无法连接到通道,请检查是否有误!") else: self.QMChannelRight = True if self.QMChannelRight: if QMInterval == 0: caput(QMChannelName, QMCurrentAmplitude) else: # 为四极铁添加周期性电流(创建子线程文件) if self.sinCurrentRun: self.ui.QMPutBtn.setText("Put") self.sinCurrentRun = not self.sinCurrentRun # 线程停止并销毁 self.QMCurrent.stop() self.ui.QM_I.setReadOnly(False) else: self.ui.QMPutBtn.setText("Stop") self.sinCurrentRun = not self.sinCurrentRun #创建线程并开启 self.QMCurrent.start() self.QMSetParameters.emit(QMChannelName, QMCycle, QMInterval, QMCurrentAmplitude) self.ui.QM_I.setReadOnly(True)
def ChannelTest_slot(self, channelName): ''' 检测通道名是否有效 目前作废函数 :return: ''' if None == caget(channelName, timeout=1): # 尝试是否可以连接到通道并读取数据 QMessageBox.information(self, "提示", "无法连接到通道,请检查是否有误")
def show_font_face_rule_for_font_file(file_data, added_name, parent=None): rule = rule_for_font(BytesIO(file_data), added_name) QApplication.clipboard().setText(rule) QMessageBox.information( parent, _('Font file added'), _('The font file <b>{}</b> has been added. The text for the CSS @font-face rule for this file has been copied' ' to the clipboard. You should paste it into whichever CSS file you want to add this font to.' ).format(added_name))
def doGoogleDownload(self): try: path=prefs['librarypath'] path=path+"/" self.downloadFolderToFolder(path,"Calibre") self.downloadDelete(path) QMessageBox.information(self, "Info", _("Download complete.")) except: QMessageBox.information(self, "Info", _("Calibre file does not exist on your Drive!"))
def save_huidu_click(self): savefilename, _ = QFileDialog.getSaveFileName(self, "保存图片", 'Image', '*.png *.jpg *.bmp') if savefilename and (hasattr(self, "temp")): cv2.imwrite(savefilename, self.temp) QMessageBox.information(self, "保存灰度图", "保存成功") else: QMessageBox.information(self, "保存灰度图失败", "请选择有效路径或生成灰度图先") return
def get_response(self): try: from dmsic import Integration i = Integration(self) res = i.get_response()[0] if res: QMessageBox.information(self.w, tr("Получен ответ"), str(res)) except: self.report_error()
def update_progressBar(self,n): self.ui.progressBar.setValue(n * 100) if n == 0: self.ui.progressBar.show() elif n == 1: self.ui.progressBar.hide() self.dataProcessing.quit() self.ui.comboBox.setEnabled(True) self.ui.calUsingBunchBtn.setEnabled(True) QMessageBox.information(self,"Tip","Calculate done!")
def save_config(self, dir_path=None): if dir_path is None: target_dir = self.target_dir else: target_dir = dir_path if not verify_file_path(target_dir): return self._save_generation_param(target_dir) QMessageBox.information(self, "Info", "Saved config to: " + target_dir)
def on_mergeDir_clicked(self): if self.dirList.count() < 1: QMessageBox.information(self, "Info", "dir list is empty") return dest_dir = self._open_dir() if len(dest_dir) == 0: return self._mergeDirs(dest_dir) QMessageBox.information( self, "info", "merge dir for " + str(self.dirList.count()) + " finished")
def on_randomGenerate_train_clicked(self): if self._check_generate_config_saved(): dest_path = os.path.abspath(os.path.expanduser(self.target_dir)) train_test_ratio = self.ui.train_test_ratio.value() / 100 train_val_ratio = self.ui.train_val_ratio.value() / 100 pos_neg_ratio = self.ui.pos_neg_ratio.value() / 100 else: QMessageBox.information(self, "Info", "The current config has not been saved", QMessageBox.Ok)
def show_font_face_rule_for_font_files(container, added_names, parent=None): rules = [] for name in sorted(added_names): rule = rule_for_font(container.open(name), name) if rule: rules.append(rule) if rules: QApplication.clipboard().setText('\n\n'.join(rules)) QMessageBox.information(parent, _('Font files added'), _( 'The specified font files have been added. The text for the CSS @font-face rules for these files has been copied' ' to the clipboard. You should paste it into whichever CSS file you want to add these fonts to.'))
def fromXML(self): file = QFileDialog.getOpenFileName(self, "Load Animation", ".", "Animation Files (*.armo)") if file[0] != "": try: frames = XML().fromXML(file[0]) self.tools.framemenu.removeAllFrames() for frame in frames: self.tools.framemenu.addNewFrame(frame) if len(frames) > 0: getWorld().setWorldFrom(frames[0]) except: QMessageBox.information(self, "Stickman Message", "The animation file is not valid!")
def video2images_compute(self): """ Executed when the user press compute and export the video frames to the given folder. :return: Nothing """ video_name = self.ui_video2images.combo_box_select_video.currentText() export_folder_name = self.ui_video2images.line_edit_export_images_at.text() fps = self.ui_video2images.spin_box_fps.value() export_folder_name += "/" self.video2images_compute_yes(video_name, export_folder_name, fps) message_box_widget = QWidget() QMessageBox.information(message_box_widget, "img2video", "Process finished successfully!")
def on_pushButton_next_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet try: self.freq_sg = float(self.lineEdit_freq_sg.text()) * 1e6 self.power_sg = float(self.lineEdit_power_sg.text()) self.freq_sa = float(self.lineEdit_freq_sa.text()) * 1e6 self.bw_sa = float(self.lineEdit_bw_sa.text()) * 1e6 addr_sg = str(self.addr_sg) addr_sa = str(self.addr_sa) except: QMessageBox.warning( self, ModuleConstants.QMESSAGEBOX_WARN, ModuleConstants.QMESSAGEBOX_WARN_INPUT_PARAMETER_NOT_ENOUGH) return addr_sg = "TCPIP0::" + addr_sg + "::inst0::INSTR" addr_sa = "TCPIP0::" + addr_sa + "::inst0::INSTR" self.test_result = test_results() if not self.demo: try: self.sa = SpectrumAnalyzer.SpectrumAnalyzer(addr_sa) self.sg = SignalGenerator.SignalGenerator(addr_sg) except: QMessageBox.warning( self, ModuleConstants.QMESSAGEBOX_WARN, ModuleConstants.QMESSAGEBOX_WARN_INSTR_NOT_VALID) return self.test_result.test_item = ModuleConstants.TESTITEM_TR_R self.test_result.test_condition = ModuleConstants.TESTCONDITION_FREQ+self.lineEdit_freq_sg.text()+\ ModuleConstants.TESTCONDITION_FREQ_UNIT+','+ModuleConstants.TESTCONDITION_POWER+\ self.lineEdit_power_sg.text()+ModuleConstants.TESTCONDITION_POWER_UNIT self.test_result.test_results = self.testProcess() if self.thresholdL < self.test_result.test_results < self.thresholdH: QMessageBox.information( self, ModuleConstants.QMESSAGEBOX_INFO, ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_NORMAL, QMessageBox.Ok) self.test_result.test_conclusion = ModuleConstants.TESTRESULT_PASS else: QMessageBox.information( self, ModuleConstants.QMESSAGEBOX_INFO, ModuleConstants.TESTITEM_TR_R + ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_ABNORMAL, QMessageBox.Ok) self.test_result.test_conclusion = ModuleConstants.TESTRESULT_FAIL if not self.demo: self.sa.Preset() self.sg.Preset() self._signalTest.emit("test") self.accept() self.close()
def buttonExportClicked(self): (filePaths, filter) = QFileDialog.getOpenFileNames( parent=self, caption="转换数据库文件为文本格式", directory=QApplication.applicationDirPath() + "/../data", filter="Database file (*.db * mdb)", ) if not filePaths: return # if DatabaseMgr().convertToText(filePaths): QMessageBox.information(self, "格式转换", "转换成功!") else: QMessageBox.warning(self, "格式转换", "转换失败!")
def on_pushButton_next_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet try: self.freq_na = float(self.lineEdit_freq_na.text()) * 1e6 self.bw_na = float(self.lineEdit_bw_na.text()) * 1e6 addr_na = str(self.addr_na) except: QMessageBox.warning( self, ModuleConstants.QMESSAGEBOX_WARN, ModuleConstants.QMESSAGEBOX_WARN_INPUT_PARAMETER_NOT_ENOUGH) return addr_na = "TCPIP0::" + addr_na + "::inst0::INSTR" self.test_result = test_results() if not self.demo: try: self.na = AgilentN5242.VNA_AgilentN5242(addr_na) except: QMessageBox.warning( self, ModuleConstants.QMESSAGEBOX_WARN, ModuleConstants.QMESSAGEBOX_WARN_INSTR_NOT_VALID) return self.test_result.test_item = ModuleConstants.TESTITEM_FILTER self.test_result.test_condition = ModuleConstants.TESTCONDITION_FREQ+self.lineEdit_freq_na.text()+\ ModuleConstants.TESTCONDITION_FREQ_UNIT+','+ModuleConstants.TESTCONDITION_BAND+\ self.lineEdit_bw_na.text()+ModuleConstants.TESTCONDITION_BAND_UNIT mTemp = self.testProcess() self.test_result.test_results = 'S11: ' + str( mTemp[0]) + ' S21: ' + str(mTemp[1]) if self.thresholdL_1 < mTemp[ 0] < self.thresholdH_1 and self.thresholdL_2 < mTemp[ 1] < self.thresholdH_2: QMessageBox.information( self, ModuleConstants.QMESSAGEBOX_INFO, ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_NORMAL, QMessageBox.Ok) self.test_result.test_conclusion = ModuleConstants.TESTRESULT_PASS else: QMessageBox.information( self, ModuleConstants.QMESSAGEBOX_INFO, ModuleConstants.TESTITEM_FILTER + ModuleConstants.QMESSAGEBOX_CONTENTS_TEST_ABNORMAL, QMessageBox.Ok) self.test_result.test_conclusion = ModuleConstants.TESTRESULT_FAIL self._signalTest.emit("test") self.accept() self.close()
def impotVrc(self): try: success, data = self.openFile() if success: data = json.loads(data) self.textEdit.setText(data["origin"]["text"]) if (data["translated"] == True): self.textEdit_2.setText(data["translate"]["text"]) else: self.textEdit_2.setText("") except (json.decoder.JSONDecodeError): QMessageBox.information(self, '提示', '打开的不是标准的VRC格式文件', QMessageBox.Cancel) pass
def gray(self): #hasattr判断这个对象是否有这个变量或属性 if not hasattr(self, "src"): QMessageBox.information(self, "灰度失败", "请先打开图片") return self.temp = cv2.cvtColor(self.src, cv2.COLOR_BGR2GRAY) rows, columns = self.temp.shape bytePerLine = columns # 灰度图是单通道,所以需要用Format_Indexed8 QImg = QImage(self.temp.data, columns, rows, bytePerLine, QImage.Format_Indexed8) self.label_3.setPixmap( QPixmap.fromImage(QImg).scaled(self.label_3.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation))
def _monkey_clicked(self, row, col): employee = self.tbl.item(row, 0).text() monkey = self.monkeys[col - 2] hdr = '%s\n%s' % (employee, Monkey.prettify(monkey)) lines = [] total = 0 for asn in self.efforts[employee].assignments: interval = TimeInterval( first_month=asn.first_month, last_month=asn.last_month ) asn_monkeys = Monkey.monkey_list(interval) if monkey in asn_monkeys: lines.append('%s: %d' % (asn.project_name, asn.effort)) total += asn.effort msg = hdr + '\n\n' + '\n'.join(lines) + ('\n\nTotal: %d' % total) QMessageBox.information(QMessageBox(), 'Effort Breakdown', msg)
def show_font_face_rule_for_font_file(file_data, added_name, parent=None): try: fm = FontMetadata(BytesIO(file_data)).to_dict() except UnsupportedFont: return pp = _('Change this to the relative path to: %s') % added_name rule = '''@font-face {{ src: url({pp}); font-family: "{ff}"; font-weight: {w}; font-style: {sy}; font-stretch: {st}; }}'''.format(pp=pp, ff=fm['font-family'], w=fm['font-weight'], sy=fm['font-style'], st=fm['font-stretch']) QApplication.clipboard().setText(rule) QMessageBox.information(parent, _('Font file added'), _( 'The font file <b>{}</b> has been added. The text for the CSS @font-face rule for this file has been copied' ' to the clipboard. You should paste it into whichever CSS file you want to add this font to.').format(added_name))
def javaScriptAlert(self, frame, msg): QMessageBox.information(self.view().parentWidget(), None, msg)
def show_dialog(self): QMessageBox.information(self, 'A test dialog', 'While this dialog is shown, the global menu should be hidden')