def msgBox(self): msgBox = QMessageBox() msgBox.setWindowTitle("경고창") # 메세지창의 상단 제목 msgBox.setText("돌이 이미 있습니다") # 메세지 내용 msgBox.setStandardButtons(QMessageBox.Yes) msgBox.exec_() msgBox.show()
def doStartSubProcess(self, strObjName): print('Button {} clicked'.format(strObjName)) args0 = strObjName.split('_') iIndex = int(args0[1]) strAddress = self.lstTextEditAddress[iIndex].text() strPort = self.lstTextEditPort[iIndex].text() #todo fix here if strAddress != "" and strAddress != 'localhost': msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("尝试启动远程服务进程!😹 ") msg.setInformativeText("不是本地localhost本地进程😹 ") msg.setWindowTitle("操作提示:") msg.setDetailedText("请在远程机器上启动本程序启动服务进程") retval = msg.exec() return if strAddress == "": strAddress = 'localhost' if strPort == "": strPort = str(portNumberStart + iIndex) mediator = self.getMediator() bRetOk = mediator.startUpEastMoneyZjlxProcess(self, iIndex, strAddress, strPort)
def doStopSubProcess(self, strObjName): print('Button {} clicked'.format(strObjName)) args0 = strObjName.split('_') iIndex = int(args0[1]) strAddress = self.lstTextEditAddress[iIndex].text() strPort = self.lstTextEditPort[iIndex].text() #todo fix here if strAddress != "" and strAddress != 'localhost': msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("远程程服务进程!😹 ") msg.setInformativeText("不是本地localhost本地进程😹 ") msg.setWindowTitle("操作提示:") msg.setDetailedText("请在远程机器上关闭服务进程") retval = msg.exec() return if strAddress == "": strAddress = 'localhost' if strPort == "": strPort = portNumberStart + iIndex mediator = self.getMediator() mediator.shutdownEastMoneyZjlxProcess(self, iIndex, strAddress, strPort) # self.lstBntStartSubProcessSocketServer[iIndex].setEnabled(True) # self.lstBntStopSubProcessSocketServer[iIndex].setEnabled(False) # # self.lstTextEditPort[iIndex].setEnabled(True) # self.lstTextEditAddress[iIndex].setEnabled(True) pass
def send_key_to_server(self, key: str): check = False msg = QMessageBox() msg.setIcon(QMessageBox.Information) try: sock = socket.socket() sock.settimeout(2) sock.connect((self.HOST, self.PORT)) data = json.dumps([self.current_machine_id, key]).encode("utf-8") sock.send(data) data = sock.recv(1024) sock.close() password = str(data, encoding="utf-8") if self.xor(self.current_machine_id, key) == password: self.set_activation(password=password, key=key) msg.setText("Активация успешно пройдена") check = True else: msg.setText("Ключ не верен или не действителен!") except Exception as E: print(E.args) # соединение разорвано msg.setText("Не удалось подключиться к серверу") msg.setWindowTitle("Активация") msg.exec_() if check is True: self.activationWindow.close() self.mainWindow.closed.disconnect(self.mainWindow_closed) self.mainWindow.show()
def __ask_for_continue_if_unsaved_changes(self): if not self.__command_handler.can_undo.get(): # Continue if there are no unsaved changes return True else: # Ask if there are unsaved changes box = QMessageBox() box.addButton(QCoreApplication.translate("main_window", "Yes"), box.YesRole) no_button = box.addButton(QCoreApplication.translate("main_window", "No"), box.NoRole) box.setDefaultButton(no_button) box.setWindowTitle(QCoreApplication.translate("main_window", "Unsaved changes")) box.setText(QCoreApplication.translate( "main_window", "Do you really want to continue " "without saving changes?")) box.setIcon(box.Icon.Question) response = box.exec() if (response == 1): # Do not continue because user wants to stop return False else: return True
def ok_button_clicked(self): """Is executed when the OK button is clicked. Merges the two nodes.""" node_name1 = self.combo_node1.currentText() node_name2 = self.combo_node2.currentText() if node_name1 == node_name2: msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Please select two different nodes") msg.setInformativeText( "It makes to sense to merge a node with itself") msg.setWindowTitle("Cannot merge") msg.exec_() return new_name = self.tf_new_name.text() if new_name == '': msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Please provide the name for the resulting node.") msg.setInformativeText("The resulting node should have a name.") msg.setWindowTitle("No new name given") msg.exec_() return connection_mode = ConnectionMergeMode[ self.combo_connection_transfer_mode.currentText().upper()] global_properties = GlobalProperties.get_instance() global_properties.mpdj_data.merge_two_nodes_into_one( node_name1, node_name2, new_name, connection_mode) self.close()
def copy_selection(p_selection,p_with_connections=True): """Copy p_selection into a new collection and adds this to the selection of """ global_properties = GlobalProperties.get_instance() new_selection = deepcopy(p_selection) copy_selection_name = new_selection.name copy_selection_name = copy_selection_name + " ( copy )" if global_properties.mpdj_data.selection_with_name_exists(copy_selection_name): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Unable to create selection_copy, name exists.") msg.setInformativeText( "{} can't be created, a selection with this name exists.".format(copy_selection_name)) msg.setWindowTitle("MessageBox ") msg.setDetailedText("The details are as follows:") new_selection.set_name(copy_selection_name) global_properties.mpdj_data.add_song_selection(new_selection) if p_with_connections: neighbours = global_properties.mpdj_data.get_neighbours_for_node_name( p_selection.get_name()) for neighbour in neighbours: global_properties.mpdj_data.set_connected(copy_selection_name,neighbour,1,False) all_selections = global_properties.mpdj_data.get_song_selection_names() for selection in all_selections: if global_properties.mpdj_data.is_connected(selection, p_selection.get_name()): global_properties.mpdj_data.set_connected(selection,copy_selection_name,1,False) global_properties.inform_update_listener()
def new_map(self): # метод класса Edit_Map, новая карта if (not self.input_col.text().isdigit() or not self.input_row.text().isdigit()) or \ (int(self.input_col.text()) < 14 or int(self.input_row.text()) < 14): # проверяем значения x, y. Если не числа, то выводим окно ошибки msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setText("Error") # текст окна msg msg.setWindowTitle("Error") # название окна msg msg.exec_() return self._col = int(self.input_col.text()) # запоминаем новое значение x self._row = int(self.input_row.text()) # запоминаем новое значение y self._sp_map = [[0 for i in range(self._col)] for j in range(self._row) ] # создаем список 0 по размерам x, y self.input_col.setVisible(False) # прячем строку для ввода x self.input_row.setVisible(False) # прячем строку для ввода y self.button_new_map.setVisible(False) # прячем кнопку "СОЗДАТЬ КАРТУ" edit_map.move_button( ) # Расширяем окно и меняем положение кнопок "ОТКРЫТЬ", "НАЗАД", "СОЗДАТЬ", "СОХРАНИТЬ" self.button_back.setVisible(True) # показываем кнопку "НАЗАД" self.button_save.setVisible(True) # показываем кнопку "СОХРАНИТЬ" self.button_open.setVisible(True) # показываем кнопку "ОТКРЫТЬ" self.button_create.setVisible(True) # показываем кнопку "СОЗДАТЬ" self.center() # отцентровываем окно относительно экрана for i in range( PIC ): # записываем в elem_map изображения из которых будет состоять карта self._elem_map.append(QPixmap()) self._elem_map[i].load(resource_path("PIC/" + str(i) + "_0.png")) self._flag_1 = True
def aviso(txt): msg = QMessageBox() msg.setWindowTitle("Aviso") msg.setText(" Aviso ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Warning) msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def updated(txt): msg = QMessageBox() msg.setWindowTitle("Sucesso") msg.setText(" Sucessos ") msg.setInformativeText("Os Dados Foram Atualizados onde: "+txt+" na base de dados") msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def display_error(self, text: str): message_box = QMessageBox() message_box.setIcon(QMessageBox.Critical) message_box.setWindowTitle("Error") message_box.setText(text) message_box.setStandardButtons(QMessageBox.Ok) message_box.exec_()
def inserted(): msg = QMessageBox() msg.setWindowTitle("Sucesso") msg.setText(" Sucessos ") msg.setInformativeText("Os Dados Foram inseridos com sucesso na base de dados") msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def display_info(self, text: str): message_box = QMessageBox() message_box.setIcon(QMessageBox.Information) message_box.setWindowTitle("Information") message_box.setText(text) message_box.setStandardButtons(QMessageBox.Ok) message_box.exec_()
def show_messagebox(message, title, icon=QMessageBox.Information): msg_box = QMessageBox() msg_box.setIcon(icon) msg_box.setText(message) # msg_box.setInformativeText(message) msg_box.setWindowTitle(title) # msg_box.setDetailedText("The details are as follows:") msg_box.setStandardButtons(QMessageBox.Ok) retval = msg_box.exec_()
def display_error(text: str): """Displays an error message to the user.""" message = QMessageBox() message.setIcon(QMessageBox.Critical) message.setWindowTitle("Error") message.setText(text) message.setStandardButtons(QMessageBox.Ok) message.exec_()
def is2insert(txt="Tem a certaza que gostari de realizar essa operacao?"): msg = QMessageBox() msg.setWindowTitle("Confirmação") msg.setText(" Confirmação ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Question) msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) clicked = msg.exec() resp = True if clicked == QMessageBox.Yes else False return resp
def stopAllThread(self): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("🤑还未实现,请一个个点击 按钮关闭进程!😹 ") msg.setInformativeText("🙄一次关闭,电脑会变得很慢,后期实现😹 ") msg.setWindowTitle("操作提示:") msg.setDetailedText("🤮笔记本电脑严重发烫") retval = msg.exec() pass
def startAllThread(self): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("😯还未实现,请一个个点击 按钮启动进程!😹 ") msg.setInformativeText("🤐一次启动,电脑会变得很慢,后期实现😹 ") msg.setWindowTitle("😬操作提示:") msg.setDetailedText("🤔笔记本电脑严重发烫") retval = msg.exec() pass
def documentIsNotSave(parent): msgBox = QMessageBox(parent) msgBox.setWindowTitle('The document has been modified') msgBox.setText('The document has been modified') msgBox.setInformativeText('Do you want to save your change?') msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Save) msgBox.setIcon(QMessageBox.Warning) return msgBox.exec_()
def __about(self): # Create and set about text box = QMessageBox() box.setWindowTitle("About") box.setText("<h1>About</h1>Developed at the University" " of Applied Sciences and Arts Northwestern" " Switzerland (FHNW) by Nicolai Wassermann" " and Simon Näf." "<br><br>Client: Prof. Dr. Hanspeter Schmid" "<br>Supervision: Prof. Dr. Dominik Gruntz") box.exec()
def tallenna_rakenne(self): '''Hoitaa rakenteen tallentamisen''' tallennus = Tallennin.tallenin(self) if tallennus == True: '''Kerrotaan käyttäjälle, että tallennus onnistui''' msgBox = QMessageBox() msgBox.setText("Tallennus onnistui!") msgBox.setWindowTitle("Onnistunut Tallennus") msgBox.setMinimumWidth(50) msgBox.addButton(QPushButton('OK'), QMessageBox.NoRole) msgBox.exec_()
def message_yes_no_cancel(self, question: str, yes: str, no: str) -> int: box = QMessageBox() box.setIcon(QMessageBox.Question) box.setWindowTitle("Photocopieuse") box.setText(question) box.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) btYes = box.button(QMessageBox.Yes) btYes.setText(yes) btNo = box.button(QMessageBox.No) btNo.setText(no) return box.exec_()
def show_discard_data_ok_cancel_message(): """Shows a QMessageBox to ask if the current mpdj data should be discarded. Contains an OK and an Cancel Button.""" msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("You have unsaved changes in your current Data. Discard\ unsaved changes and proceed?") msg.setInformativeText("Unsaved changes will be lost.") msg.setWindowTitle("Unsaved changes") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) retval = msg.exec_() return retval
def close_application(self, event): """ Opens a message box to handle program exit properly asking the user if the project should be saved first. Args: event(`QCloseEvent`): A QCloseEvent Returns: status_code (`int`): 0 when process finished correctly, otherwise >0 """ self.settings.setValue('display_on_startup', self.qi.display_on_startup) msg_box = QMessageBox() msg_box.setWindowIcon( QtGui.QIcon( resource_path( os.path.join("ui", "icons", "pyIMD_logo_icon.ico")))) msg_box.setWindowTitle('pyIMD :: Quit Program') msg_box.setText( 'Do you want to save changes before quitting the program?') save_btn = QPushButton('Save') save_btn.setIcon(QApplication.style().standardIcon( QStyle.SP_DialogSaveButton)) msg_box.addButton(save_btn, QMessageBox.YesRole) no_save_btn = QPushButton('Don\'t save') no_save_btn.setIcon(QApplication.style().standardIcon( QStyle.SP_DialogNoButton)) msg_box.addButton(no_save_btn, QMessageBox.NoRole) abort_btn = QPushButton('Cancel') abort_btn.setIcon(QApplication.style().standardIcon( QStyle.SP_DialogCancelButton)) msg_box.addButton(abort_btn, QMessageBox.RejectRole) ret = msg_box.exec_() if ret == 0: self.save_project() if not event: self.close() else: event.accept() elif ret == 1: if not event: self.close() else: event.accept() else: self.print_to_console("Program quit aborted") if not event: return else: event.ignore()
def _save_dialog(self, parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) return d.exec_()
def step_dialog(parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) return d.exec_() & QMessageBox.Cancel