def onFrozenRightClick(self, point: QPoint): @Slot(str, str) def onGekuendigt(mv_id: str, datum: str): #Model aktualisieren model.setBis(index.row(), datum) tv = self._view.tableView #model = tv.getTableModel() model = tv.getModel() index = tv.indexAt(point) if not index.column() in (model.nameColumnIdx, model.sollColumnIdx): return mv_id = model.getId(index.row()) menu = QMenu(tv) if index.column() == model.nameColumnIdx: action = QAction("Dieses Mietverhältnis beenden") action.setData("K") menu.addAction(action) menu.addSeparator() action2 = QAction("Mietverhältnisdaten anzeigen") action2.setData("A") menu.addAction(action2) else: action = QAction("Nettomiete und NKV anzeigen") menu.addAction(action) action = menu.exec_(tv.viewport().mapToGlobal(point)) if action and index.column() == model.nameColumnIdx: if action.data() == "K": c = MiniKuendigungsController(self._view) c.mietverhaeltnisGekuendigt.connect(onGekuendigt) c.kuendigeMietverhaeltnisUsingMiniDialog(mv_id) else: self._showMietverhaeltnis(mv_id, point) elif action and index.column() == model.sollColumnIdx: netto, nkv = BusinessLogic.inst().getNettomieteUndNkv( mv_id, self._currentYear, self._currentCheckMonth) box = QMessageBox() box.setWindowTitle("Teile der Bruttomiete") box.setIcon(QMessageBox.Information) box.setText("Nettomiete:\t%.2f €\n\n" "Nebenkosten:\t%.2f €" % (netto, nkv)) box.exec_()
def s_plot(self): """Try to plot the lamination Parameters ---------- self : SWSlot A SWSlot object """ # We have to make sure the slot is right before trying to plot it error = self.check(self.obj) if error: # Error => Display it QMessageBox().critical(self, self.tr("Error"), error) else: # No error => Plot the slot (No winding for LamSquirrelCage) if self.machine.type_machine == 10: # For SRM, this is the last step => Plot the complete machine self.machine.plot() else: self.obj.plot(is_lam_only=not (type(self.obj) is LamSlotWind))
def showAboutDialog(self): text = "<h3>DCS Liberation " + VERSION + "</h3>" + \ "<b>Source code :</b> https://github.com/khopa/dcs_liberation" + \ "<h4>Authors</h4>" + \ "<p>DCS Liberation was originally developed by <b>shdwp</b>, DCS Liberation 2.0 is a partial rewrite based on this work by <b>Khopa</b>." \ "<h4>Contributors</h4>" + \ "shdwp, Khopa, ColonelPanic, Roach, Wrycu, calvinmorrow, JohanAberg, Deus, root0fall, Captain Cody, steveveepee, pedromagueija, parithon, bwRavencl, davidp57, Plob, Hawkmoon" + \ "<h4>Special Thanks :</h4>" \ "<b>rp-</b> <i>for the pydcs framework</i><br/>"\ "<b>Grimes (mrSkortch)</b> & <b>Speed</b> <i>for the MIST framework</i><br/>"\ "<b>Ciribob </b> <i>for the JTACAutoLase.lua script</i><br/>"\ "<b>Walder </b> <i>for the Skynet-IADS script</i><br/>"\ "<b>Anubis Yinepu </b> <i>for the Hercules Cargo script</i><br/>" about = QMessageBox() about.setWindowTitle("About DCS Liberation") about.setIcon(QMessageBox.Icon.Information) about.setText(text) logging.info(about.textFormat()) about.exec_()
def deleteNotOwned(self): """ Deletes items in table that are not owned. Not owned items are items that don't have either the item itself, the box, or the manual. """ currentTab = self.tab.currentIndex() if 0 < currentTab < 4: msgBox = QMessageBox() msgBox.setWindowTitle("Remove not owned items") msgBox.setText("Are you sure?") msgBox.setIcon(QMessageBox.Warning) msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Cancel) ok = msgBox.exec_() if ok == QMessageBox.Ok: self.tableViewList[currentTab-1].deleteNotOwned() self.search()
def update_graph(self): """Plot the skew""" self.w_viewer.axes.clear() # Plot the skew in the viewer fig try: self.machine.rotor.skew.plot(fig=self.w_viewer.fig, ax=self.w_viewer.axes) except Exception as e: QMessageBox().critical( self, self.tr("Error"), self.tr("Error while plotting skew:\n" + str(e)), ) # Update the Graph # self.w_viewer.fig.set_size_inches(8, 4) self.w_viewer.draw()
def open_docker_button(self): required = { 'archr: git clone https://github.com/angr/archr && cd archr && pip install -e .':archr, 'keystone: pip install --no-binary keystone-engine keystone-engine':keystone } is_missing = [ key for key, value in required.items() if value is None ] if len(is_missing) > 0: req_msg = 'You need to install the following:\n\n\t' + '\n\t'.join(is_missing) req_msg += '\n\nInstall them to enable this functionality.' req_msg += '\nRelaunch angr-management after install.' QMessageBox(self).critical(None, 'Dependency error', req_msg) return img_name = self._pick_image_dialog() if img_name is None: return target = archr.targets.DockerImageTarget(img_name, target_path=None) self.workspace.instance.add_job(LoadTargetJob(target)) self.workspace.instance.set_image(img_name)
def setTechID(self, checked): """ If checked, sets the techID if valid and disables text field. Otherwise, re-enable the text field. """ txtField = self.ui.techID if checked: txt = txtField.text() try: self.techID = int(txt) txtField.setReadOnly(True) palette = QPalette() palette.setColor(QPalette.Button, Qt.darkGreen) palette.setColor(QPalette.ButtonText, Qt.white) palette.setColor(QPalette.Base, QColor(100, 143, 100)) txtField.setPalette(palette) self.ui.techIDbutton.setPalette(palette) except: title = "Error" message = "Technician ID must be an integer number." buttons = QMessageBox.Ok message = QMessageBox(QMessageBox.Warning, title, message, buttons=buttons, flags=Qt.Dialog) message.exec_() self.ui.techIDbutton.setChecked(False) self.techID = None return else: self.techID = None txtField.setReadOnly(False) palette = QPalette() if self.theme is 0: palette.setColor(QPalette.Button, QColor(180, 180, 180)) palette.setColor(QPalette.ButtonText, Qt.black) palette.setColor(QPalette.Base, QColor(140, 140, 140)) else: palette.setColor(QPalette.Button, QColor(53, 53, 53)) palette.setColor(QPalette.Base, QColor(25, 25, 25)) txtField.setPalette(palette) self.ui.techIDbutton.setPalette(palette)
def read_config(self): if os.path.exists('config.ini'): # Van config.ini, ki kell értékelni config.read('config.ini') self.station_id = config['DEFAULT'].get('station id') self.secret = config['DEFAULT'].get('secret key') # todo módosítani kell a torna_match táblát, hogy tartalmazza a tabla mellett a hozzá tartozó secret-et is else: # Nincs config.ini, alapértékekkel inicializálni msg = QMessageBox(self) msg.setStyleSheet("fonz-size: 20px") msg.setWindowTitle("Hiányzó beállítás file!") msg.setText( '<html style="font-size: 14px; color: red">Nem tudtam beolvasni a konfigurációt!<br></html>' + '<html style="font-size: 16px">Kérem módosítsa a beállításokat!</html>' ) msg.exec_() sys.exit(1)
def reportCompletion(self, error: int): self.show() # QMessageBox is a modal, meaning that execution of code stops until the window closes # We need our own message box if we want to queue multiple downloads box = QMessageBox(self) box.setWindowTitle("Download Complete") box.setWindowModality(Qt.NonModal) if error == 0: box.setIcon(QMessageBox.Information) box.setText("Download completed successfully.") else: box.setIcon(QMessageBox.Critical) box.setText(f"Download failed. Error code: {'0x%08lx' % error}") box.show() self.isComplete = True self.close()
def cancel_order(self): """撤单""" row = self.activate_order_table.currentRow() symbol = self.activate_order_table.item( row, activate_order_table_column.index('symbol')).text() exchange = self.activate_order_table.item( row, activate_order_table_column.index('exchange')).text() local_symbol = symbol + '.' + exchange order_id = self.activate_order_table.item( row, activate_order_table_column.index('order_id')).text() req = helper.generate_cancel_req_by_str(symbol=local_symbol, exchange=exchange, order_id=order_id) try: bee_current_app.cancel_order(req) TipDialog("撤单请求发送成功") except Exception as e: QMessageBox().warning(self, "提示", "撤单请求发送失败" + str(e), QMessageBox.Ok, QMessageBox.Ok)
def loginCheck(self): user = self.loginW.leuser.text() passwd = self.loginW.lepass.text() sql = f"SELECT * FROM staff WHERE login='******' AND passwd='{passwd}'" result = self.dbConn.queryDB(sql) if result: self.userId = result[0][0] self.fullName = result[0][1] self.user = result[0][2] self.hostName = socket.gethostname() self.userIP = socket.gethostbyname(self.hostName) self.logged = True self.openHome() self.loginW.hide() else: msg = QMessageBox() msg.setWindowTitle('Falha no Login') msg.setText('Dados incorretos, tente novamente.') msg.exec_()
def s_plot(self): """Try to plot the lamination Parameters ---------- self : SMHoleMag a SMHoleMag object """ # Update p for hole in self.obj.hole: hole.Zh = self.machine.stator.winding.p * 2 self.set_hole_pitch(self.obj.hole[0].Zh) # We have to make sure the hole is right before truing to plot it error = self.check(self.obj) if error: # Error => Display it QMessageBox().critical(self, self.tr("Error"), error) else: # No error => Plot the hole (No winding for LamSquirrelCage) self.machine.plot(is_show_fig=True)
def setupUi_(self, MainWindow): # set Icon icon = QIcon() icon.addFile("./icon.ico") MainWindow.setWindowIcon(icon) # Set constant self.LABEL_N = {0: self.label_0, 1: self.label_1, 2: self.label_2, 3: self.label_3, 4: self.label_4, 5: self.label_5, 6: self.label_6, 7: self.label_7, 8: self.label_8, 9: self.label_9} self.QUESTIONS = [i for i in range(1, 11)] self.FILE = "./bank/货运组理论试题.xls" if os.access(self.FILE, os.F_OK) is False: self.FILE = '' self.selectFile() # set QMessageBox self.message = QMessageBox(text="选择题库") self.message.setWindowTitle(" ") # Action self.Select.clicked.connect(self.selectFile) self.Button.clicked.connect(self.cilckButton) for i in self.LABEL_N: _label = self.LABEL_N[i] _label.ANSWER = "" _label.TIME = 0 _label.installEventFilter(self) # 安装事件过滤器 # Filter _regex = QRegExp("^[0-9]*[1-9][0-9]*$") # 正则表达式:正整数 _validator = QRegExpValidator(_regex) self.MinSelect.setValidator(_validator) self.MaxSelect.setValidator(_validator)
def save_report(self): """ Saves the report as a file :return: None """ if self.can_generate_report(): path = QFileDialog(self, "Save Report", "", "*.log") if path.exec_() == QDialog.Accepted: with open(path.selectedFiles()[0], "w") as report: report.write("Bug report\n\n") report.write(f"1. Version: {self.version.text()}\n") report.write( f"2. Environment: {self.environment.text()}\n") report.write( f"3. What's going on?:\n{self.description.toPlainText()}\n" ) report.write( f"4.a Results Expected:\n{self.results[EXPECTED_STR].toPlainText()}\n" ) report.write( f"4.b Results Obtained:\n{self.results[OBTAINED_STR].toPlainText()}\n" ) report.write( f"5. Protocol:\n{self.protocol.toPlainText()}\n") report.write( f"6. Stacktrace:\n{self.stacktrace.toPlainText()}\n") report.write( f"7. Impact:\n\tSeverity: {self.impact[SEVERITY_STR].currentText()}" f"\n\tReproducibility: {self.impact[REPRODUCIBILITY_STR].currentText()}\n" ) report.write( f"8. Priority: {self.priority.currentText()}\n") validation_box = QMessageBox() validation_box.setWindowTitle("Success") validation_box.setText( f"Save successful at {path.selectedFiles()[0]}\nDon't forget the attachment." ) validation_box.setIcon(QMessageBox.Information) validation_box.setStandardButtons(QMessageBox.Ok) validation_box.exec_() else: self.show_missing()
def restore_to_backup(self): msg = QMessageBox() result = QMessageBox.question(msg, "Warning", "Are you sure you wish to roll back the database to a previous backup? " "This may take some time.", QMessageBox.Yes, QMessageBox.No) if result == QMessageBox.No: return else: result = QMessageBox.question(msg, "Warning", "Do you wish to back up the current state of the database? " "This will take longer, but is recommended.", QMessageBox.Yes, QMessageBox.No) if result == QMessageBox.No: pass elif result == QMessageBox.Yes: self.backup_database(force=True) QMessageBox.information(msg, "Important", "Please move the backup you want to use into the 'backup_to_use' " "folder. Restoring will not work if this folder is empty.") backup_file_name = "" for root, dirs, files in os.walk(self.settings["backup_path"] + "/backup_to_use"): if len(files) != 1: QMessageBox.warning(msg, "Error", "No backups present or more than one backup present. Will cancel restoration.") return for file in files: backup_file_name = file try: self.db_conn.connection.close() except: pass command1 = os.path.join(self.settings["postgres_binary_path"], "dropdb") + " -U teleuser telemetry" command2 = os.path.join(self.settings["postgres_binary_path"], "createdb") + " -U teleuser telemetry" command3 = os.path.join(self.settings["postgres_binary_path"], "psql -U teleuser -d telemetry -f ", self.settings["backup_path"], "backup_to_use", backup_file_name) print(command1) subprocess.run(command1, shell=True) subprocess.run(command2, shell=True) subprocess.run(command3, shell=True) self.db_conn.attempt_connection()
def start(self): if self.same_as_zip_name_checkbox.isChecked(): self.video_name = self.zip_name elif self.lineEdit.text() != "": self.video_name = self.lineEdit.text() self.video_location = os.path.join( os.path.join(os.environ['USERPROFILE']), 'Videos', self.video_name) if self.algorithm == 0: dailog = QMessageBox() dailog.setText("Select a Algorithm to Continue") dailog.setWindowTitle("Select a Algorithm") dailog.setStandardButtons(QMessageBox.Ok) dailog.exec_() return self.progressBar.setMaximum(0) self.label_progress.show() self.progressBar.show() if self.algorithm == 1: worker = WorkerThread_merge(self.zip_location, self.video_name, self.video_location) if self.algorithm == 2 or self.algorithm == 3: if self.algorithm == 2: worker = WorkerThread_ffmpeg(self.zip_location, self.video_name, self.video_location, "fast") if self.algorithm == 3: worker = WorkerThread_ffmpeg(self.zip_location, self.video_name, self.video_location, "slow") worker.signals.signal_to_terminal.connect(self.send_to_terminal) worker.signals.signal_to_progress_bar.connect(self.send_to_progress) worker.signals.signal_to_terminal_last_line.connect( self.send_to_terminal_last_line) worker.signals.signal_when_complete.connect(self.on_completes) self.threadpool.start(worker)
def setup_class_variables(self): self.CATALOG = SoftwareLicenseOrganiser("softwares.pi") self.ANALIZER = LicenseWebAnalyzer() self.scanning_in_progress = False self.hide_files_not_containing_paths = False self.hide_files_not_containing_licenses = False self.software_search_text = "" self.license_search_text = "" self.software_list = self.CATALOG.list_installed_software() self.msg_box = QMessageBox(self.ui) drives = win32api.GetLogicalDriveStrings() drives = drives.split('\000')[:-1] action_dictionary = {} from functools import partial for drive in drives: action_dictionary[drive] = self.ui.menuScan_in_drive.addAction( drive) action_dictionary[drive].triggered.connect( partial(self.on_actionScan_in_drive_triggered, drive))
def load_geometry(self): file_names = QFileDialog.getOpenFileNames(caption='Select Geometry', dir='../', filter="Files (*.obj *.stl)", parent=self) loading_dialog = QMessageBox() loading_dialog.setText("Loading Geometry...") loading_dialog.setWindowTitle("AMLab Software") loading_dialog.setStandardButtons(QMessageBox.NoButton) loading_dialog.open() QGuiApplication.processEvents() swapyz = True for file_name in file_names[0]: if self.__slicer_widget.load_geometry(file_name, swapyz): self.geometry_list.addItem( self.__slicer_widget.geometry_name_list[ self.__slicer_widget.geometries_loaded - 1]) self.geometry_list.setCurrentIndex(self.geometry_list.count() - 1) QGuiApplication.processEvents()
def on_select_setting(self, selected): """ Triggered when a new settings item is selected from the list. Updates the stacked widget to the appropriate page for the selected item Args: selected: The selected item """ if self.changes: save = QMessageBox().question( self, "Save", "Changes detected. Save current page?") if save == QMessageBox.Yes: self.save_current_page() self.reset_page() index = selected.indexes()[0].data() self.settings_menu.setCurrentIndex(SETTINGS[index]) self.current_page = SETTINGS[index] self.changes = False self.button_apply.setEnabled(False)
def create_flight(self): aircraft_type = self.select_type_aircraft.currentData() count = self.select_count_of_aircraft.value() if self.available[aircraft_type] < count: msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Not enough aircraft of this type are available. Only " + str(self.available[aircraft_type]) + " available.") msg.setWindowTitle("Not enough aircraft") msg.setStandardButtons(QMessageBox.Ok) msg.setWindowFlags(Qt.WindowStaysOnTopHint) msg.exec_() return else: flight = Flight(aircraft_type, count, self.from_cp, self.select_flight_type.currentData()) self.planner.flights.append(flight) self.planner.custom_flights.append(flight) if self.flight_view is not None: self.flight_view.set_flight_planner(self.planner, len(self.planner.flights)-1) self.close()
def dropEvent(self, drop_event): # QDropEvent url = drop_event.mimeData().urls() image_path = url[0].toLocalFile() extension = os.path.splitext(image_path)[1] if extension.lower() in [".png", ".jpg", ".jpeg", ".gif", ".bmp"]: image_view = ImageView(image_path) self.layout.takeAt(0) # Delete possibly existed widget self.layout.addWidget(image_view) image_view.dropped_relay.connect(self.dropEvent) elif extension == ".svg": web_view = WebView(image_path) self.layout.takeAt(0) self.layout.addWidget(web_view) web_view.dropped_relay.connect(self.dropEvent) else: msgbox = QMessageBox(self) msgbox.setText("Doesn't support this format") msgbox.show() return self.image_dropped.emit(os.path.basename(image_path))
def confirmToSave(self): discard = False if self.ui.textEdit.document().isModified(): msgBox = QMessageBox(self) msgBox.setIcon(QMessageBox.Information) msgBox.setWindowTitle(self.tr('Confirm')) msgBox.setText(self.tr('This file has chages, do you want to save them?')) msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) msgBox.setButtonText(QMessageBox.Yes, self.tr('Yes')) msgBox.setButtonText(QMessageBox.No, self.tr('No')) msgBox.setButtonText(QMessageBox.Cancel, self.tr('Cancel')) msgBox.setDefaultButton(QMessageBox.Yes) msgBox.setEscapeButton(QMessageBox.Cancel) ret = msgBox.exec_() if ret == QMessageBox.Yes: self.onSaveClick() elif ret == QMessageBox.No: discard = True return not self.ui.textEdit.document().isModified() or discard
def askYesNo(message, title=bdstr.question): """Uses `QMessageBox` to ask "Yes" or "No" for a given question. Parameters: message: the question to be displayed title: the window title Output: return True if the "Yes" button has been clicked, False otherwise """ mbox = QMessageBox(QMessageBox.Question, title, message) yesButton = mbox.addButton(QMessageBox.Yes) noButton = mbox.addButton(QMessageBox.No) mbox.setDefaultButton(noButton) mbox.exec_() if mbox.clickedButton() == yesButton: return True else: return False
def initialize(self, img_name): """ This is an initialization for building up a connection between angr-management and archr """ required = { 'archr: git clone https://github.com/angr/archr && cd archr && pip install -e .':archr, 'keystone: pip install --no-binary keystone-engine keystone-engine':keystone } is_missing = [ key for key, value in required.items() if value is None ] if len(is_missing) > 0: req_msg = 'To use this feature you need to install the following:\n\n\t' + '\n\t'.join(is_missing) req_msg += '\n\nInstall them to enable this functionality.' req_msg += '\nRelaunch angr-management after install.' QMessageBox(self).critical(None, 'Dependency error', req_msg) return if img_name is not None: _l.debug('Initializing the connection to archr with Image %s' % img_name) Thread(target=self.the_thread, args=(img_name,), daemon=True).start()
def renderDocs(self): try: if not (self.source_setted and self.source_path): raise Exception('Выберите источник данных!') if not (self.template_setted and self.template_path): raise Exception('Выберите шаблон!') t = TemplateInsert( self.template_path, self.source_obj.get_data(self.comboBox.currentText()), out_path=self.out_path if self.out_path_setted else None, name_field=None if self.comboBox_2.currentText() == 'Нет' else self.comboBox_2.currentText()) t.render() msgBox = QMessageBox() msgBox.setText('Finished!') msgBox.exec_() except Exception as e: errMsgBox = QErrorMessage() errMsgBox.showMessage(repr(e)) errMsgBox.exec_()
def b_ok_clicked(self): getX = self.ui.b_x.text() getY = self.ui.b_y.text() if getX.isdigit() and getY.isdigit(): # todo 这样判定,如果getx个gety是小数,就会被判为否定 send_code = "Relative,{},{}\n".format(getX, getY) elif getX.isdigit() and isVar(getY): print("adfasfd") send_code = "Relative,{},%{}%\n".format(getX, getY) elif isVar(getX) and getY.isdigit(): send_code = "Relative,%{}%,{}\n".format(getX, getY) elif isVar(getX) and isVar(getY): send_code = "Relative,%{}%,%{}%\n".format(getX, getY) else: msgBox = QMessageBox() # todo 报错应该更详细一点,,, msgBox.setText("里面应该放整数或者变量") msgBox.exec() return self.ui.code_text.insertPlainText(send_code)
def reject(self): # Ha valami db művelet kell if self.valtozott or self.uj_station: msg = QMessageBox() msg.setStyleSheet("fonz-size: 20px") msg.setWindowTitle("Regisztrációs eltérés!") msg.setText( '<html style="font-size: 14px; color: red">Kérem módosítás után mentse a beállításokat!<br></html>' ) msg.exec_() else: super().reject() # # if __name__ == '__main__': # app = QApplication([]) # win = NetworkSettingsDialog() # win.show() # app.exec_()
def get_config(self): if os.path.exists("./data/settings.txt"): f = open("./data/settings.txt", "r") read = f.readlines() print(read) self.password = read[0] self.password = self.password[:-1:] self.identity = read[1] self.identity = self.identity[:-1:] self.channel = read[2] self.channel = self.channel[:-1:] f.close() return True else: error_info = QMessageBox() error_info.setWindowTitle("Error!") error_info.setText("No settings directory") error_info.setStandardButtons(QMessageBox.Ok) error_info.exec_() return False
def goLoadExperiment(self): """ Selection of experiment file. """ file = QFileDialog.getOpenFileName(self._widget, self.tr("Load experiment"), "~", self.tr("Any files (*)")) if file[0]: #use selected file try: self._goExperiment(file[0]) except Exception as e: emsg = QMessageBox() emsg.setWindowTitle( self.tr( "There is a problem with loading your experiment :(")) emsg.setText(str(e)) emsg.setIcon(QMessageBox.Critical) emsg.exec()
def save_datapackage(self, checked=False): """Write datapackage to file 'datapackage.json' in data directory.""" if os.path.isfile(os.path.join(self._data_connection.data_dir, "datapackage.json")): msg = ('<b>Replacing file "datapackage.json" in "{}"</b>. ' 'Are you sure?').format( os.path.basename(self._data_connection.data_dir) ) message_box = QMessageBox( QMessageBox.Question, "Replace 'datapackage.json", msg, QMessageBox.Ok | QMessageBox.Cancel, parent=self ) message_box.button(QMessageBox.Ok).setText("Replace File") answer = message_box.exec_() if answer == QMessageBox.Cancel: return False if self.datapackage.save(os.path.join(self._data_connection.data_dir, 'datapackage.json')): msg = '"datapackage.json" saved in {}'.format(self._data_connection.data_dir) self.msg.emit(msg) return True msg = 'Failed to save "datapackage.json" in {}'.format(self._data_connection.data_dir) self.msg_error.emit(msg) return False