def msg(self): #后面四个数字的作用依次是 初始值 最小值 最大值 小数点后位数 doubleNum,ok1 = QInputDialog.getDouble(self, "标题","计数:", 37.56, -10000, 10000, 2) #后面四个数字的作用依次是 初始值 最小值 最大值 步幅 intNum,ok2 = QInputDialog.getInt(self, "标题","计数:", 37, -10000, 10000, 2) #第三个参数可选 有一般显示 (QLineEdit.Normal)、密碼显示( QLineEdit. Password)与不回应文字输入( QLineEdit. NoEcho) stringNum,ok3 = QInputDialog.getText(self, "标题","姓名:",QLineEdit.Normal, "王尼玛") #1为默认选中选项目,True/False 列表框是否可编辑。 items = ["Spring", "Summer", "Fall", "Winter"] item, ok4 = QInputDialog.getItem(self, "标题","Season:", items, 1, True) text, ok5 = QInputDialog.getMultiLineText(self, "标题", "Address:", "John Doe\nFreedom Street")
def insertLengthsByEmbeddings(self): text, ok = QInputDialog.getMultiLineText( self, 'Insert embedding', 'Insert list of coordinates of v1,..., v7:') if ok: try: evaluated_expr = ast.literal_eval(str(text)) v1, v2, v3, v4, v5, v6, v7 = evaluated_expr lengths = { '12': self.graph.dist(v1, v2), '13': self.graph.dist(v1, v3), '14': self.graph.dist(v1, v4), '15': self.graph.dist(v1, v5), '16': self.graph.dist(v1, v6), '27': self.graph.dist(v2, v7), '37': self.graph.dist(v3, v7), '47': self.graph.dist(v4, v7), '57': self.graph.dist(v5, v7), '67': self.graph.dist(v6, v7), '23': self.graph.dist(v2, v3), '34': self.graph.dist(v3, v4), '45': self.graph.dist(v4, v5), '56': self.graph.dist(v5, v6), '26': self.graph.dist(v2, v6) } self.printLog('Inserted lengths: ') self.graph.setLengthsAndUpdateFixedTriangle(lengths) self.update_graph2R26() self.update_graph2tabLengths() self.update_graph2phi() self.computeCouplerCurves() except Exception as e: self.showError('Problem with input: \n' + str(e))
def showDialog(self): ''' 这是一个我们点击不同按钮会有不同对话框出现的函数 ''' sender = self.sender() sex = ['男', '女'] if sender == self.bt1: text, ok = QInputDialog.getText(self, '修改姓名', '请输入姓名:') if ok: self.lb6.setText(text) #文字输入对话框 elif sender == self.bt2: text, ok = QInputDialog.getInt(self, '修改年龄', '请输入年龄:', min=1) if ok: self.lb7.setText(str(text)) #整数输入对话框 elif sender == self.bt3: text, ok = QInputDialog.getItem(self, '修改性别', '请选择性别:', sex) if ok: self.lb8.setText(text) #下拉列表对话框 elif sender == self.bt4: text, ok = QInputDialog.getDouble(self, '修改身高', '请输入身高:', min=1.0) if ok: self.lb9.setText(str(text)) #浮点数输入对话框 elif sender == self.bt5: text, ok = QInputDialog.getMultiLineText(self, '修改信息', '请输入个人信息:') if ok: self.tb.setText(text) #富文本输入对话框
def my_insert(self): mul_text, ok = QInputDialog.getMultiLineText(self, "添加商品", "输入商品信息", "请按行输入id,price,number") if (ok): print(mul_text) # 把我们从对话框接收到的文本设置到单行编辑框组件上显示。 data = mul_text.splitlines() # 获取游标 db = pymysql.connect(host='127.0.0.1', user='******', password='******', port=3306, db='wanjin') db.select_db('wanjin') # 获取游标 cur = db.cursor() sql = "INSERT INTO wanjin.myshop(\ id, price, number) \ VALUES ('%s', %s, '%s')" % \ (data[0], data[1], data[2]) try: # 执行sql语句 cur.execute(sql) # 执行sql语句 db.commit() except: # 发生错误时回滚 db.rollback() cur.execute("SELECT*FROM myshop") rows = cur.fetchall() for row in rows: print(row) # 关闭数据库连接 db.close()
def showDialog(self): sender = self.sender() sex = ['男', '女'] if sender == self.btn_name: text, ok = QInputDialog.getText(self, "修改姓名", "请输入姓名:") if ok: self.ld_name.setText(text) elif sender == self.btn_age: text, ok = QInputDialog.getInt(self, "修改年龄", "请输入年龄:", min=1, max=130) if ok: self.ld_age.setText(str(text)) elif sender == self.btn_sex: # 注意这里添加了一个参数 editable=False 表示用户不能修改输入框,只能从提供的列表中选取一个值 text, ok = QInputDialog.getItem(self, "修改性别", "请选择性别:", sex, editable=False) if ok: self.ld_sex.setText(text) elif sender == self.btn_height: text, ok = QInputDialog.getDouble(self, "修改身高", "请输入身高:", min=1.0) if ok: self.ld_height.setText(str(text)) elif sender == self.btn_basicInfo: text, ok = QInputDialog.getMultiLineText(self, "修改信息", "请输入个人信息:") if ok: self.text_browser.setText(text)
def problem(self): tekst, ok = QInputDialog.getMultiLineText( self, 'Zgłoś problem', 'Wpisz poniżej rodzaj problemu') if ok and tekst: wysylanie(tekst, self.id_user[0])
def fasong(self, Dialog): model = self.tableView.selectionModel() selected = model.selectedIndexes() listint = [] for index in selected: listint.append(int(index.row())) listint = list(set(listint)) if len(listint) == 0: QMessageBox.information(self.msgbox, "警告", "你没选择任何好友\群,请重新选择!", QMessageBox.Yes) return if self.comboBox.currentText() == "发送文本": mul_text, ok = QInputDialog.getMultiLineText( self.msgbox, "发送文本", "输入要发送的文本", "") if ok: str3 = "已向:" for object in listint: if object == 0: self.bot.file_helper.send_msg(mul_text) else: self.listobject[object].send_msg(mul_text) str3 += self.list[object][1] + "," str3 += "发送消息!" str1 = self.textEdit.toHtml() nowTime = datetime.datetime.now().strftime('%H:%M:%S') str2 = str1 + "<br/>" + "<span style='font-size:10pt;'>" + str( nowTime) + "::" + str3 + "</span>" self.textEdit.setHtml(str2) print("我:" + mul_text) if self.comboBox.currentText() == "发送图片": multext, ok = QFileDialog.getOpenFileName(self.msgbox, "选择要发送的图片", "", "图片(*.png *.jpg *.bmp)") if ok: im = Image.open(multext) x, y = im.size xy = 400, int(400 * (y / x)) im.thumbnail(xy, Image.ANTIALIAS) shijianchuo = str(int(time.time())) pathh = "image/" + shijianchuo + ".jpg" if len(im.split()) == 4: r, g, b, a = im.split() im = Image.merge("RGB", (r, g, b)) im.save(pathh) else: im.save(pathh) str3 = "已向:" for object in listint: if object == 0: self.bot.file_helper.send_image(pathh) else: self.listobject[object].send_image(pathh) str3 += self.list[object][1] + "," str3 += "发送消息!" str1 = self.textEdit.toHtml() nowTime = datetime.datetime.now().strftime('%H:%M:%S') str2 = str1 + "<br/>" + "<span style='font-size:10pt;'>" + str( nowTime) + "::" + str3 + "</span>" self.textEdit.setHtml(str2) print("我:发送图片")
def on_multicast_message_clicked(self): msg, ok = QInputDialog.getMultiLineText(None, "Message", "Type your Message:") if ok: data = {"msg": msg, "code": MESSSAGE_CODE} jdata = json.dumps(data) self.signal_has_multicast_to_send.emit(jdata)
def addJs(self, lp_2020_path, url, path_2020): value, ok = QInputDialog.getMultiLineText(self, "输入下载地址", "安卓\nios:", "android\nios") android = '' ios = '' href_data = [] if value and ok: os.makedirs(path_2020) data = value.split('\n') android = data[0] ios = data[1] if android == 'android': android = '' if ios == 'ios': ios = '' GEN_HTML = "%s%s%s%s%s" % (lp_2020_path, '\\', url, '\\', 'down.js') # 打开文件,准备写入 f = open(GEN_HTML, 'w') # 写入HTML界面中 message = """var down_href={ios:%s%s%s,android:%s%s%s};""" % ( "\"", ios, "\"", "\"", android, "\"") # 写入文件 f.write(message) get_add_down_js.getstr(self) QtWidgets.QMessageBox.about(self, '提示', "已在path_2020文件夹添加成功")
def commit_double_click(self, event): message, accepted = QInputDialog.getMultiLineText( self, "Renaming commit message", "", self.history[self.current_git_diff_index].message) if accepted: self.history[self.current_git_diff_index].message = message self.refresh(self.current_git_diff_index)
def publish(self): if self.app.prepare_publish(): text, status = QInputDialog.getMultiLineText( self, 'Publish Blog', 'Describe your changes', '') if status: self.app.commit_changes(text) self.app.publish()
def people1(self): mul_text, ok = QInputDialog.getMultiLineText( self, "经理管理", "经理管理", "按行输入经理id,开除(1)|其他(0),经理rank") if (ok): print(mul_text) # 把我们从对话框接收到的文本设置到单行编辑框组件上显示。 mydata = mul_text.splitlines() # 获取游标 db = pymysql.connect(host='127.0.0.1', user='******', password='******', port=3306, db='wanjin') db.select_db('wanjin') # 获取游标 cur = db.cursor() print("flag1") try: # 执行sql语句 if mydata[2] == '1': cur.execute( '''DELETE FROM `wanjin`.`manager` WHERE id = (%s);''', mydata[0]) db.commit() else: cur.execute( '''select * from `wanjin`.`manager` where id = (%s);''', mydata[0]) print("flag2") result = cur.fetchall() if len(result) != 0: print("flag3") tmp_data0 = (mydata[2], mydata[0]) # cur.execute("UPDATE `wanjin`.`employee` SET `salary` = %s WHERE `id `= '%s'"%tmp_data0) tmp_data0_up = "UPDATE `wanjin`.`manager` SET `rank` = '%s' WHERE `id`= '%s'" % tmp_data0 cur.execute(tmp_data0_up) # cur.execute("UPDATE `wanjin`.`man_emp` SET manager_id = '%s' where id = '%s';"% tmp_data1) # cur.execute(s) db.commit() if len(result) == 0: insert_data0 = (mydata[0], mydata[2]) data1 = "INSERT INTO `wanjin`.`manager`(`id`, `rank`)VALUES(%s, %s)" print("flag4") cur.execute(data1 % insert_data0) print("flag5") # 执行sql语句 db.commit() except: # 发生错误时回滚 db.rollback() cur.execute("SELECT*FROM manager") rows = cur.fetchall() for row in rows: print(row) # 关闭数据库连接 cur.close() db.close()
def open_dialog_func(self, btn): if btn == self.name_btn: # 1 name, ok = QInputDialog.getText(self, 'Name Input', 'Please enter the name:') if ok: self.name_line.setText(name) elif btn == self.gender_btn: # 2 gender_list = ['Female', 'Male'] gender, ok = QInputDialog.getItem(self, 'Gender Input', 'Please choose the gender:', gender_list, 0, False) if ok: self.gender_line.setText(gender) elif btn == self.age_btn: age, ok = QInputDialog.getInt(self, 'Age Input', 'Please select the age:') if ok: self.age_line.setText(str(age)) elif btn == self.score_btn: score, ok = QInputDialog.getDouble(self, 'Score Input', 'Please select the score:') if ok: self.score_line.setText(str(score)) else: info, ok = QInputDialog.getMultiLineText(self, 'Info Input', 'Please enter the info:') if ok: self.info_textedit.setText(info)
def showDialog(self): sender = self.sender() sex = ['男', '女'] # sex = [1, 2] if sender == self.bt1: text, ok = QInputDialog.getText(self, '修改姓名', '请输入姓名') if ok: # print(text) self.lb6.setText(text) elif sender == self.bt2: text, ok = QInputDialog.getInt(self, '修改年龄', '请输入年龄',step=3, value=0, min=1) if ok: self.lb7.setText(str(text)) elif sender == self.bt3: text, ok = QInputDialog.getItem(self, '修改性别', '请输入性别', sex,current=1, editable=False) if ok: self.lb8.setText(text) elif sender == self.bt4: text, ok = QInputDialog.getDouble(self, '修改身高', '请输入身高',min=1.0) if ok: self.lb9.setText(str(text)) elif sender == self.bt5: text, ok = QInputDialog.getMultiLineText(self, '修改信息', '请输入个人信息:') if ok: self.tb.setText(text)
def readlines(self): text, ok = QInputDialog.getMultiLineText( self.parentWidget, self.title, self.label ) if ok: return str(text) else: return ""
def showFileList(self): s, ok = QInputDialog.getMultiLineText(self, 'Input files', 'Editable list of input files', '\n'.join(self.data.filenames)) if ok: fn = s.splitlines() if fn: self.updateFileList(fn, True)
def mouseDoubleClickEvent(self, event): index = self.selectedIndexes()[0] line = self.model.item(index.row(), 0) hookCode = self.hookCodeMap[line.address] code, ok = QInputDialog.getMultiLineText(self, 'Insert Hook', '', hookCode) if ok: self.hookCodeMap[line.address] = code super(ListInstructions, self).mouseDoubleClickEvent(event)
def proxyIp(self): ip, ok = QInputDialog.getMultiLineText( self, "代理", "请输入地址:", "http://*****:*****@t.16yun.cn:31111") proxies = { "http": ip, "https": ip, } if ok: self._proxyIp = proxies
def _edit_comment(self): # self._edit_comment_item(('COMMENT', 'Input comment'), 'comment') # _edit_comment_item(self, to_update, item_no): checked = self._check_existence() data_, ok_pressed = QInputDialog.getMultiLineText( self.ui.extList, "Input comment", "", getattr(checked, "comment")) if ok_pressed: ut.update_other("COMMENT", (data_, checked.comment_id)) self._populate_comment_field(checked, edit=True)
def set_pwd(self): pwd_str = "" for x in MySettings.settings_pwd: pwd_str = pwd_str + x + "\n" pwd_save, ok = QInputDialog.getMultiLineText(self, "输入URL,每行一个", "URL", pwd_str) if ok: MySettings.settings_pwd = str(pwd_save).split("\n")[:-1] MySettings.write_pwd() logging.debug("写入密码成功")
def addData(self): text, ok_press = QInputDialog.getMultiLineText( self, 'Добавить данные', 'Введите данные статистики') user = md5(self.login.encode()).hexdigest() if text and ok_press: with open('data/statistic/' + user + '.txt', encoding='utf8', mode='w') as file: file.write(text + ';') self.verticalLayout_2.addWidget(QLabel(text))
def on_pb_commit_update_clicked(self): comment, ok = QInputDialog.getMultiLineText(self, "备注更新", "请输入备注本次更新(可为空):", "") if ok: # ~ self.show_result("正在提交更新") self.path = self.le_path.text() os.chdir(self.path) self.exec_cmd("cd {};git add -A;git commit -m '{}'".format( self.path, comment)) self.show_result("$ 提交更新成功")
def set_url(self): url_str = "" for x in MySettings.settings_url: url_str = url_str + x + "\n" url_save, ok = QInputDialog.getMultiLineText(self, "输入URL,每行一个", "URL", url_str) if ok: MySettings.settings_url = str(url_save).split("\n")[:-1] MySettings.write_url() logging.debug("写入URL成功")
def addHook(self): indexes = self.selectedIndexes() if len(indexes) > 0: item = self.getItemFormIndex(indexes[0]) if isinstance(item, AsmLineWithOpcode): code = '' if item.address in self.hookCode: code = self.hookCode[item.address] code, ok = QInputDialog.getMultiLineText(self, 'Insert Hook', '', code) if ok: self.hookCode[item.address] = code
def msg(self): # 后面四个数字的作用依次是 初始值 最小值 最大值 小数点后位数 doubleNum, ok1 = QInputDialog.getDouble(self, "标题", "计数:", 37.56, -10000, 10000, 2) # 后面四个数字的作用依次是 初始值 最小值 最大值 步幅 intNum, ok2 = QInputDialog.getInt(self, "标题", "计数:", 37, -10000, 10000, 2) # 第三个参数可选 有一般显示 (QLineEdit.Normal)、密碼显示( QLineEdit. Password)与不回应文字输入( QLineEdit. NoEcho) stringNum, ok3 = QInputDialog.getText(self, "标题", "姓名:", QLineEdit.Normal, "王尼玛") # 1为默认选中选项目,True/False 列表框是否可编辑。 items = ["Spring", "Summer", "Fall", "Winter"] item, ok4 = QInputDialog.getItem(self, "标题", "Season:", items, 1, True) text, ok5 = QInputDialog.getMultiLineText(self, "标题", "Address:", "John Doe\nFreedom Street")
def setClashCodeActionTriggered(self): clashCodeStr = self.clashCode newClashCode, ok = QInputDialog.getMultiLineText(self.widget, 'CLaSH code for ' + self.nodeName, 'CLaSH code:', text=clashCodeStr) if ok: try: # TODO add validation of code self.clashCode = newClashCode self.widget.editClashCode(self.nodeName, newClashCode) except: Log.addLogMessage(Log.ERROR, 'Invalid CLaSH code') QMessageBox.critical(self.widget, 'Error', 'Invalid CLaSH code')
def look(self, Dialog): init = "" model = self.tableView.selectionModel() selected = model.selectedIndexes() listint = [] for index in selected: listint.append(int(index.row())) listint = list(set(listint)) if len(listint) == 0: QMessageBox.information(self.msgbox, "警告", "你没选择任何好友\群,请重新选择!", QMessageBox.Yes) return for object in listint: if self.list[object][0] == "Friend": init += "好友:" + self.list[object][1] + "\n" else: for member in self.listobject[object]: mingzi = str(member).strip("<>").split(":")[1] qunhao = self.list[object][1] init += "群:" + qunhao + "昵称:" + mingzi + "\n" QInputDialog.getMultiLineText(self.msgbox, "信息", "可以修改/复制", init)
def getChoice(self, cols): # Get item/choice """ 选择合并文件的共有字段名 :param cols: ALL字段名 :return: 选中的字段名 """ cols = [str(x) for x in cols] # item, okPressed = QInputDialog.getItem(self, "选择连接轴", "字段", cols, 4, True)#单选复选框,后面功能需要用到 item, okPressed = QInputDialog.getMultiLineText( self, "删除不需要的字段", "字段名", "\n".join(cols)) if okPressed and item: item = item.split() return item
def add(self): description, ok = QInputDialog.getMultiLineText( self, 'Task description', 'What should be done?') if not ok or not description.strip(): QMessageBox.critical(self, 'Error', 'Description is required', QMessageBox.Ok) return task = db.addTask(self.user, description) model.content.append(task) model.layoutChanged.emit() if len(model.content) == 1: self.refresh()
def show_dict(self): """ Shows word, defenition and translation of it from string that we got before """ s = "" for i in self.word_gd: s += str(i[0]) + ': ' + str(i[1]) + ': ' + str(i[2]) + '\n' txt, okBtnPressed = QInputDialog.getMultiLineText( self, "Output", 'Output', s)
def add_rule_f(self): """ Добавление правило """ cur = self.db.cursor() res = cur.execute("SELECT Name FROM Lessons").fetchall() res = list(map(lambda x: str(x[0]), res)) lesson, ok_pressed = QInputDialog.getItem( self, "Добавить правило", "Название предмета:", res, res.index(self.choose_lesson.currentText()), False, ) # Выбрать предмет if ok_pressed: answer1, ok_pressed = QInputDialog.getText( self, "Добавить правило", "Название правила:", text=self.find_label.text(), ) # Ввести название if ok_pressed: answer2, ok_pressed = QInputDialog.getMultiLineText( self, "Добавить правило", "Полное правило:") # Ввести полное правило if ok_pressed: file_dialog = QFileDialog() file_dialog.setFileMode(QFileDialog.ExistingFiles) filt = "JPEG (*.jpg);;PNG (*.png);;Все файлы (*)" fnames = file_dialog.getOpenFileNames( self, "Выбрать файлы", "C://Desktop", filt)[0] # Выбрать картинки if not fnames: fnames = None else: fnames = "|".join(fnames) cur.execute( f"""INSERT INTO main(Lesson_id, Short_rule, Full_rule, Picture_path) VALUES((SELECT id FROM Lessons WHERE Name = ?), ?, ?, ?)""", (lesson, answer1, answer2, fnames), ) # Сохранить в БД self.db.commit() self.update_lesson_list()
def dodaj(self): """ Dodawanie nowego zadania """ zadanie, ok = QInputDialog.getMultiLineText(self, 'Zadanie', 'Co jest do zrobienia?') if not ok or not zadanie.strip(): QMessageBox.critical(self, 'Błąd', 'Zadanie nie może być puste.', QMessageBox.Ok) return zadanie = baza.dodajZadanie(self.osoba, zadanie) model.tabela.append(zadanie) model.layoutChanged.emit() # wyemituj sygnał: zaszła zmiana! if len(model.tabela) == 1: # jeżeli to pierwsze zadanie self.odswiezWidok() # trzeba przekazać model do widoku
def editTableItemRuleSlot(self): """编辑列表项规则""" rowIndex = self.tableWidget.currentRow() if rowIndex != -1: try: # 父控件, 标题, 标签提示, 默认值, window flags rules, ok = QInputDialog.getMultiLineText(self, self.tr("Edit rule"), self.tr("XPath rule(format: \"[(time, commit), (time, commit)]\"):"), re.sub("\),|],|',", lambda x: "%s\n" % x.group(), str(self.tableContents[rowIndex].get_rules(ui=True)) )) if ok: self.tableContents[rowIndex].set_rules(rules) except (IndexError, UnboundLocalError): QMessageBox.warning(self, self.tr("Warning"), self.tr("The row is empty.")) else: QMessageBox.warning(self, self.tr("Warning"), self.tr("Please select a row."))
def encryptPhoto(self, toEmbMessage): if not runtime['seed']: password, isOK = getPasswordInput(self) if not isOK: # 取消输入密码 return else: self.passwordEntered.emit(password) runtime['seed'] = password2seed(password) cipher = JPEGImageCipher(runtime['seed']) if toEmbMessage: msg, isOK = QInputDialog.getMultiLineText( self, 'Enter the message you want to emb', 'Message:' ) bdata = msg.encode('utf-8') # str -> bytes Log.i('get `{}`<=>`{}` from input dialog'.format(msg, bdata)) img = cipher.encrtptAndEmbData(runtime['ori']['image'], bdata) self.__loadDstPhoto(img=img, msg=msg, clear=True) else: img = cipher.encrypt(runtime['ori']['image']) self.__loadDstPhoto(img=img, clear=True)
def get_or_set_config(): """Get config if exist else Set config if not exist.""" global config log.debug("Vacap Config File: {}.".format(CONFIG_FILENAME)) days = ["Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado", "Domingo"] # if config does not exist or cant be read then try to create it, ask user. if not os.path.isfile(CONFIG_FILENAME): log.warning("Vacap Config File does not exist; Will try to create it.") QMessageBox.information(None, __doc__, "<b>Vamos a Configurar Vacap!.") msg = "<b>Hacer un Backup Copia de Seguridad al Iniciar la compu ?." _st = QMessageBox.question( None, __doc__, msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes msg = "<b>Hacer Backup Copia de Seguridad si la compu esta a Bateria ?" _bt = QMessageBox.question( None, __doc__, msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) == QMessageBox.Yes msg = "<b>Que Dia de la Semana Hacer Backup Copia de Seguridad ?." _day = str(QInputDialog.getItem( None, __doc__, msg, days, 4, False)[0]).lower() msg = "<b>A que Hora del Dia hacer Hacer Backup Copia de Seguridad ?." _hour = int(QInputDialog.getInt(None, __doc__, msg, 12, 1, 23)[0]) msg = "<b>Donde Guardar el Backup Copia de Seguridad ?." QMessageBox.information(None, __doc__, msg) _trg = QFileDialog.getExistingDirectory(None, __doc__, gettempdir()) msg = "<b>Agregar 1 Carpeta para hacer Backup Copia de Seguridad ?." _backup_from = [] while QMessageBox.question( None, __doc__, msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) == QMessageBox.Yes: _backup_from.append(str(QFileDialog.getExistingDirectory( None, __doc__, os.path.expanduser("~")))) configura = { "MAKE_BACKUP_FROM": _backup_from, "SAVE_BACKUP_TO": _trg, "MAKE_BACKUP_ON_STARTUP": _st, "MAKE_BACKUP_WHEN_RUNNING_ON_BATTERY": _bt, "MAKE_BACKUP_ON_WEEK_DAY": _day, "MAKE_BACKUP_AT_THIS_HOUR": _hour, } config = dumps(configura, ensure_ascii=False, indent=4, sort_keys=True) log.debug("Configuration: {}.".format(config)) confirm = QInputDialog.getMultiLineText( None, __doc__, "<b>Resumen Final de la Configuracion:", config)[1] if confirm: with open(CONFIG_FILENAME, "w", encoding="utf-8") as _config: _config.write(config) try: log.info("Making Config {} Hidden".format(CONFIG_FILENAME)) ctypes.windll.kernel32.SetFileAttributesW(CONFIG_FILENAME, 0x02) # hidden file log.info("Making Config {} ReadOnly.".format(CONFIG_FILENAME)) os.chmod(CONFIG_FILENAME, S_IREAD) # make read-only except Exception as reason: log.critical(reason) else: return get_or_set_config() else: log.debug("Reading/Parsing Config File: {}.".format(CONFIG_FILENAME)) with open(CONFIG_FILENAME, "r", encoding="utf-8") as _config: config = loads(_config.read()) return config