def wybor(self): poz_lista = [ 'Wykaz narzędzi ', "SELECT * FROM ", 'Baza nie zawiera żadnych pozycji. Plik nie zostanie zapisany.', ] lista_poz = [] lista_poz.append('Brak') from narzedzia_poz import naglowki for i in naglowki(): if "/" in i[0]: lista_poz.append(i[0]) inp = QInputDialog(self) inp.setWhatsThis('Wybierz pozycję aby eksportować do pliku') inp.setLabelText('Wybierz pozycję:') inp.setWindowTitle('Pozycje') inp.setComboBoxItems(lista_poz) inp.setCancelButtonText('Anuluj') if inp.exec_() == QDialog.Accepted: print(inp.textValue()) poz_lista[0] += inp.textValue() poz_lista[1] += "'" + inp.textValue() + "'" if inp.textValue() != 'Brak': self.export(poz_lista) self.statusBar().showMessage( "Wyeksportowano do pliku", 10000) else: QMessageBox.critical(self, 'Wybierz pozycję', 'Nie wybrano żadnej pozycji!', QMessageBox.Ok, QMessageBox.Ok)
async def ask_for_connection(self, connections): connections_titles = [c.title() for c in connections] input_dialog = QInputDialog() input_dialog.setComboBoxItems(connections_titles) input_dialog.setWindowTitle(self.tr("Membership")) input_dialog.setLabelText(self.tr("Select a connection")) await dialog_async_exec(input_dialog) result = input_dialog.textValue() if input_dialog.result() == QDialog.Accepted: for c in connections: if c.title() == result: return c
def chooseterm(self): inputdialog = QInputDialog(self) items = [ '大一上期', '大一下期', '大二上期', '大二下期', '大三上期', '大三下期', '大四上期', '大四下期' ] inputdialog.setComboBoxItems(items) inputdialog.setWindowTitle('学期') inputdialog.setLabelText('选择学期:') inputdialog.setOkButtonText('确定') inputdialog.setCancelButtonText('取消') inputdialog.setWindowOpacity(0.7) ok = inputdialog.exec_() if ok: self.termValueLabel.setText(str(inputdialog.textValue()))
def getText(self,matdata): inputBox=QInputDialog() inputBox.setInputMode(0) inputBox.setWindowTitle('MatFileKeyInputDialog') itemlist=list() for key in matdata.keys(): itemlist.append(key) inputBox.setComboBoxItems(itemlist) inputBox.setComboBoxEditable(False) inputBox.setLabelText('Please Input MatFile Key') inputBox.setOkButtonText(u'Ok') inputBox.setCancelButtonText(u'Cancel') if inputBox.exec_() and inputBox.textValue()!='': return inputBox.textValue()
def addImageFlowFunc(self, ind:int): myDebug(self.__class__.__name__, get_current_function_name()) input_flow_list = self.controller.getInputFlowList() items = [item.getName() for item in input_flow_list] # print(input_flow_list) dialog = QInputDialog(self) dialog.setModal(True) dialog.setStyleSheet(""" background-color: rgba(0, 0, 0, 200); border:1px solid rgba(0, 200, 200, 150); """) dialog.setFixedSize(350,250) dialog.setWindowTitle('Set Input Flow for Improcessor') dialog.setComboBoxItems(items) dialog.textValueSelected.connect(lambda x: self._addImageFlow(input_flow_list[dialog.findChild(QComboBox).currentIndex()]) if dialog.findChild(QComboBox).currentIndex() >= 0 else None) dialog.show()
def addImageProcFunc(self, ind:int): myDebug(self.__class__.__name__, get_current_function_name()) register = getImageProcRegister() items = register.getNames() dialog = QInputDialog(self) dialog.setModal(True) dialog.setStyleSheet(""" background-color: rgba(0, 0, 0, 200); border:1px solid rgba(0, 200, 200, 150); """) dialog.setFixedSize(350,250) dialog.setWindowTitle('Set Input Flow for Improcessor') dialog.setComboBoxItems(items) dialog.textValueSelected.connect(lambda: self._addImageProc(ind, register[dialog.findChild(QComboBox).currentIndex()]) if dialog.findChild(QComboBox).currentIndex() >= 0 else None) # dialog.textValueSelected.connect(partial(self._addImageProc, ind, register[dialog.findChild(QComboBox).currentIndex()])) dialog.show()
def askForChapter(self): chapters = [] selected_ch = 0 chapter_index_curr = 0 for ch in self.model.getChapters(): ch_num = self.getChapterNumber(ch) if ch_num in self.model.allowed_chapters: chapters.append(ch) if ch_num == self.model.engine.currentDungeon: selected_ch = chapter_index_curr chapter_index_curr += 1 dialog = QInputDialog() dialog.setStyleSheet("") dialog.setComboBoxItems(chapters) dialog.setWindowTitle("Select chapter") dialog.setLabelText("Chapter:") ret = dialog.exec() if ret: new_ch = self.getChapterNumber(dialog.textValue()) self.controller.requestchangeCurrentChapter(new_ch)
def contextMenuEvent(self, event): # create menu pos = self.mapToScene(event.pos()) menu = QMenu(self) # remove from memory after usage menu.setAttribute(Qt.WA_DeleteOnClose) # remove from memory spawn_point_menu = menu.addMenu('Spawn Point') spawn_point_create = spawn_point_menu.addAction('Create on Cursor') spawn_point_delete = spawn_point_menu.addAction('Delete on Cursor') spawn_point_delete_all = spawn_point_menu.addAction('Delete All') way_point_menu = menu.addMenu('Way Point') way_point_create = way_point_menu.addAction('Create on Cursor') way_point_delete = way_point_menu.addAction('Clear') load_map = menu.addAction('Load Map') # execute action = menu.exec_(self.mapToGlobal(event.pos())) # parse response if action == spawn_point_create: spawn_time = text_time_to_seconds('6:40') dialog = QInputDialog(self) dialog.setWindowTitle('Create Spawn Point') dialog.setLabelText('Respawn Time (hh:mm:ss):') dialog.setTextValue('6:40') if dialog.exec_(): spawn_time = text_time_to_seconds(dialog.textValue()) dialog.deleteLater() spawn = SpawnPoint(location=MapPoint( x=pos.x(), y=pos.y(), z=self._data.geometry.z_groups[self._z_index]), length=spawn_time) self._scene.addItem(spawn) self._data.spawns.append(spawn) spawn.start() if action == spawn_point_delete: pixmap = self._scene.itemAt(pos.x(), pos.y(), QTransform()) if pixmap: group = pixmap.parentItem() if group: self._data.spawns.remove(group) self._scene.removeItem(group) if action == spawn_point_delete_all: for spawn in self._data.spawns: self._scene.removeItem(spawn) self._data.spawns = [] if action == way_point_create: if self._data.way_point: self._scene.removeItem(self._data.way_point.pixmap) self._scene.removeItem(self._data.way_point.line) self._data.way_point = None self._data.way_point = WayPoint(location=MapPoint( x=pos.x(), y=pos.y(), z=self._data.geometry.z_groups[self._z_index])) self._scene.addItem(self._data.way_point.pixmap) self._scene.addItem(self._data.way_point.line) if action == way_point_delete: if self._data.way_point: self._scene.removeItem(self._data.way_point.pixmap) self._scene.removeItem(self._data.way_point.line) self._data.way_point = None if action == load_map: dialog = QInputDialog(self) dialog.setWindowTitle('Load Map') dialog.setLabelText('Select map to load:') dialog.setComboBoxItems( sorted([map.title() for map in MapData.get_zone_dict().keys()])) if dialog.exec_(): self.load_map(dialog.textValue().lower()) dialog.deleteLater() self.update_()
def nueva_sol(self, restricciones, mensaje, respuesta, iteraciones, holgura, artificial, data): vars_sol = [] vars_entrada = [] ultima_iteracion = iteraciones[len(iteraciones) - 1] for var in respuesta: tmp = str(var).split(" = ") if float(tmp[1]) > 0 and tmp[0] != 'Z': vars_sol.append(tmp[0]) print("VARIABLES DE LA SOLUCION: ", vars_sol) for var in range(len(ultima_iteracion[0])): if ultima_iteracion[0][var] != "V.B" and ultima_iteracion[0][ var] != 'bi' and not ultima_iteracion[0][var] in vars_sol: if ultima_iteracion[len(ultima_iteracion) - 1][var] == 0: vars_entrada.append(ultima_iteracion[0][var]) print("VARIABLES DE ENTRADA: ", vars_entrada) input_ = QInputDialog(self) input_.setLabelText("Seleccione la nueva Variable de Entrada") input_.setWindowTitle("Seleccione la Nueva Variable de entrada") input_.setComboBoxItems(vars_entrada) input_.setOkButtonText("Encontrar la nueva Solución") input_.setCancelButtonText("Cancelar") button = input_.exec() print("RESULT: ", input_.textValue()) print("BUTTON: ", button) pivote = sp.special_solution( ultima_iteracion[0].index(input_.textValue()), ultima_iteracion) sol_ = copy.deepcopy(ultima_iteracion) sol_ = sp.var_salida(sol_, pivote) sol_ = sp.reducir_fila_pivote(sol_, pivote) sol_ = sp.nueva_solucion_v2(sol_, pivote, holgura, artificial) sol_ = sp.depurar_nueva_solucion(sol_) iteraciones.append(sol_) respuesta = sp.generar_solucion(sol_, 2) message = QMessageBox() message.setWindowTitle("Simplex") message.setText("Nueva Solución") sol = "" for var in respuesta: sol = sol + var + "\n" message.setInformativeText("Solución: \n\n" + sol + "\n" + "¿Desea obtener una nueva solución?") yes = message.addButton("Sí", QMessageBox.YesRole) no = message.addButton("No", QMessageBox.NoRole) message.setIcon(QMessageBox.Information) message.setStyleSheet("font-weight: bold;") message.exec() if message.clickedButton() == yes: self.nueva_sol(restricciones, mensaje, respuesta, iteraciones, holgura, artificial, data) elif message.clickedButton() == no: reporte = saveReport(restricciones, respuesta, iteraciones, mensaje, data) reporte.crear_pdf() reporte.mostrar_pdf()