def inserted(): msg = QMessageBox() 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 aviso(txt): msg = QMessageBox() msg.setText(" Aviso ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Warning) msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def updated(txt): msg = QMessageBox() 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 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 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 open_case(self): """ Gives the user a file dialog to find their existing project and opens that. :return: None """ open_dialog = QFileDialog() user_location = open_dialog.getOpenFileName()[ 0] # Index 0 because user can't pick more than one file. if user_location == '': return # User most likely pressed cancel. case = Case.open_from_disk(user_location) if case is None: # Something bad must have happened. Tell the user that the file is corrupt. Or invalid. alert = QMessageBox() alert.setText("Corrupt case file or invalid file type.") alert.setIcon(QMessageBox.Critical) alert.exec_() return else: # Successfully open a case! case_controller = CaseController(case) self.open_window(case_controller)
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 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 Sucessos(txt): msg = QMessageBox() msg.setWindowTitle("Sucesso") msg.setText(" Sucessos ") msg.setInformativeText(txt) 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 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 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 is2insert(txt="Tem a certaza que gostari de realizar essa operacao?"): msg = QMessageBox() msg.setText(" Confirmacao ") 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 message_box(self, text, informative, icon, buttons=QMessageBox.Ok): """Wraps up the QMessageBox""" msg = QMessageBox(self) msg.setStandardButtons(buttons) msg.setDefaultButton(QMessageBox.Ok) msg.setText(text) msg.setInformativeText(informative) msg.setIcon(icon) return msg.exec_()
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 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 error(txt=None, verbTxt=None): msg = QMessageBox() msg.setText(" Error ") if txt is None and verbTxt is None: msg.setInformativeText("Erro Algo aconteceu tente De novo.") elif txt is not None and verbTxt is None: msg.setInformativeText(txt) else: msg.setInformativeText(txt) msg.setDetailedText(verbTxt) msg.setIcon(QMessageBox.Warning) msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def Sucessos(txt): msg = QMessageBox() msg.setText(" Sucessos ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) msg.exec() #=============================================================================== # if __name__=="__main__": # app = QApplication(sys.argv) # screen = Soft_Warning("Erro nº:1 \nPorfavor tente de novo.") # print(screen) # sys.exit(app.exec_()) #===============================================================================
def _saveFile(self, annotationFilePath): #self.canvas.overrideCursor(WAIT_CURSOR) error_info = self.checkShapes() if error_info is not None: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText("Save File Failed! Error:\n" + error_info) msg.exec_() return False if annotationFilePath and self.saveLabels(annotationFilePath): self.setClean() self.statusBar().showMessage('Saved to %s' % annotationFilePath) self.statusBar().show() return True
def show_success(self): message = QMessageBox(self.gui) message.setIcon(QMessageBox.Information) message.setText("KiPEO has compleletly reshaped your e-book.\r\n\r\nWould you like to see what we have changed?") message.setWindowTitle("KiPEO") message.setStandardButtons(QMessageBox.Yes | QMessageBox.No) message.show() user_choice = message.exec_() if user_choice == QMessageBox.Yes: #Show the user what changes we have made, allowing her to #revert them if necessary self.boss.show_current_diff() #Update the editor UI to take into account all the changes we #have made self.boss.apply_container_update_to_gui()
def save_mpdj_data_to_file(self, p_file_name: str): """Saves the current mpdj data to the file by the path given in p_file_name.""" try: global_properties = GlobalProperties.get_instance() global_properties.save_mpdj_data_to_file(p_file_name) self.statusBar().showMessage('Saved to {}'.format(p_file_name), 5000) except (OSError, IOError) as exception: message_box = QMessageBox() message_box.setText('Error saving the file: {}'.format( str(exception))) message_box.setWindowTitle('Error saving the file.') message_box.setStandardButtons(QMessageBox.Ok) message_box.setIcon(QMessageBox.Warning) message_box.exec_()
def _next_actions(self): try: # Clean Input a Bit # # Change variables to string type wav_files = [str(self._filenames_list.item(i).text()) for i in range(self._filenames_list.count())] output_directory = self._output_directory.text() network_location = self._network_location.text() # Substring network location to give true value needed network_location = network_location[0:network_location.rindex(".")] self._step2 = EvalWizardStep2Window(wav_files, output_directory, network_location) self._step2.show() self.close() except: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setText("There was an error. Double check your input files and try again.") msg.setWindowTitle("Error") msg.exec_()
def timeout(self): time_left = self.get_activation()[3] time_left -= 1 if time_left < 0: time_left = 0 self.set_activation(time_left=time_left) self.activationWindow.set_label_time(time_left) if time_left % 60 == 0 and time_left != 0: msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("У Вас осталось времени: {0} мин. {1} сек.".format(int(time_left/60), time_left % 60)) msg.setWindowTitle("Активация") msg.exec_() if time_left <= 0: self.timer.stop() self.activationWindow.pushFree.setEnabled(False) self.activationWindow.show() self.mainWindow.close()