Beispiel #1
0
 def show_password_create(self):
     password, confirm_password = '', None
     num_tries = 1
     ok = True
     while ok and password != confirm_password:
         password, ok = QInputDialog().getText(
             self, "Attention", "Password:"******"")
         if ok and password:
             pwd_chk = Crypto.password_check(password)
             if not pwd_chk['password_ok']:
                 # weak password
                 # Password should be longer than 8 characters
                 # and have at least 1 upper case, 1 lower case, 1 number and 1 symbol
                 reply = QMessageBox.question(self, 'Weak Password',
                                              'The password you entered is weak because:\n' + \
                                               pwd_chk['error_msg'] + \
                                              '\n\n\n Do you want to try a stronger password ?',
                                      QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
                 if reply == QMessageBox.Yes:
                     continue
             # strong password
             confirm_password, ok = QInputDialog().getText(
                 self, "Attention", "Re-enter Password to confirm:",
                 QLineEdit.Password if num_tries <= 2 else QLineEdit.Normal,
                 "")
             if password != confirm_password:
                 QMessageBox.critical(self, "Mismatch!",
                                      "Passwords don't match")
                 num_tries = num_tries + 1
             else:
                 return password
     return None
Beispiel #2
0
    def choose_section(self):
        """選擇區間"""
        while True:
            st_N, OK = QInputDialog().getInt(None, '輸入起點', '請輸入起點的N >w<:')

            if OK:
                ed_N, OK = QInputDialog().getInt(None, '輸入起點', '請輸入終點的N >w<:')

                if OK:
                    return [st_N, ed_N]

                else:
                    choice = QMessageBox().information(None,
                                                       '疑問',
                                                       '確定要取消嗎?',
                                                       buttons=QMessageBox.Yes
                                                       | QMessageBox.No)
                    if choice == QMessageBox.Yes:
                        break
                    else:
                        continue

            else:
                choice = QMessageBox().information(None,
                                                   '疑問',
                                                   '確定要取消嗎?',
                                                   buttons=QMessageBox.Yes
                                                   | QMessageBox.No)
                if choice == QMessageBox.Yes:
                    break
                else:
                    continue

        return None
Beispiel #3
0
    def get_custom_ip_settings(self):
        """
        Prompt user for whether they want custom IP and hostnames.

        """
        #TODO validate ip add
        # https://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python
        widget = QWidget()
        base_ip_dialog = QInputDialog()
        robot_ip_dialog = QInputDialog()
        base_hostname_dialog = QInputDialog()
        robot_hostname_dialog = QInputDialog()
        base_ip, ok_1 = base_ip_dialog.getText(
            widget, '', 'Enter the desired IP for the base station.\n\
                        Leave this field blank to use the defaults.',
            QLineEdit.Normal, '')  #TODO does this work??
        if ok_1:
            robot_ip, ok_2 = robot_ip_dialog.getText(
                widget, '', 'Enter the desired IP for the robot station.\n\
                            Leave this field blank to use the defaults.',
                QLineEdit.Normal, '')
            if ok_2:
                self.ip_configs['base_ip'] = base_ip
                self.ip_configs['robot_ip'] = robot_ip
                self.exec_install()
        else:
            self.password = None
            self.first_page()
Beispiel #4
0
 def add_deck(self):
     # TODO: get name and subject from form dialog
     name, ok = QInputDialog().getText(self.mainWidget, "Neues Deck erstellen", "Name: ")
     if ok:
         subject, ok = QInputDialog().getText(self.mainWidget, "Neues Deck erstellen", "Fach: ")
         if ok:
             new_deck = self.controller.add_deck(name, subject)
             self.decksContent.layout().addWidget(new_deck)
             self.decksContent.update()
Beispiel #5
0
def Change_Az_Elev():
    my_Azimut = QInputDialog().getText(None, "Azimut (gradi senso orario)",
                                       "Valore:", QLineEdit.Normal,
                                       str(my_nw_az))
    my_Elevation = QInputDialog().getText(None,
                                          "Elevation (gradi dalla verticale)",
                                          "Valore:", QLineEdit.Normal,
                                          str(my_45_elev))
    my_value = Set_my_Zfactor()
    Change_Az(int(my_Azimut[0]), int(my_Elevation[0]), my_value)
Beispiel #6
0
 def __init__(self, GeometryFinder: SearchGeometry):
     self.dialog = QInputDialog()
     self.dialog.setGeometry(100, 100, 0, 0)
     self.msgbox = QMessageBox()
     self.msgbox.setGeometry(100, 100, 0, 0)
     self.GeometryFinder = GeometryFinder
     self.max_accepted_dist, _ = QInputDialog().getInt(None,
                                                       '想請教一下',
                                                       '請輸入判斷較長路徑的門檻值(km)',
                                                       value=5)
Beispiel #7
0
 def invite(self):
     chat_names = {}
     for i in self.Chats:
         chat_names[self.chat_names[i]] = i
     print(chat_names)
     chat, ok = QInputDialog().getItem(self, "Inviting", "Chat", chat_names,
                                       0, False)
     if ok:
         login, ok = QInputDialog().getText(self, "Inviting", "Login")
         self.sor.sendto(('3' + str(len(self.alias)) + self.alias +
                          chat_names[chat] + login).encode('utf-8'),
                         self.server)
Beispiel #8
0
    def choose_route(self, data_dir, zone2dir):
        """選擇路線"""
        while True:
            routeUID, OK = QInputDialog().getText(None, '輸入UID',
                                                  '請輸入路線UID >w<:')

            if OK:
                #讀取站牌序列的csv
                routeUID = routeUID.upper()
                route_zone = routeUID[
                    0:3]  #讀取公車主管機關代碼(MIA, TXG, CHA, NAN, YUN, THB)
                if route_zone not in zone2dir:  #檢查是不是在目標縣市
                    QMessageBox().information(None, '錯誤', '路線不在目標縣市')
                    continue
                route_dir = os.path.join(data_dir,
                                         zone2dir[route_zone])  #路線檔所在的資料夾路徑
                route_list = pd.read_csv(
                    os.path.join(route_dir, 'route_list.csv'))  #匯入該區域的路徑列表

                candidate_route = route_list[route_list.SubRouteUID ==
                                             routeUID]

                if candidate_route.shape[0] == 2:
                    while True:
                        direction, dir_OK = QInputDialog().getItem(None, '去返程', '請選取路線方向', \
                            list(map(str, candidate_route.Direction.tolist())), editable=False)
                        if dir_OK:
                            break
                elif candidate_route.shape[0] == 1:
                    direction = str(candidate_route.Direction.tolist()[0])
                else:
                    QMessageBox().information(None, '錯誤', '路線不存在')
                    continue

                if candidate_route.if_pass_zone[
                        candidate_route.Direction == int(
                            direction)].tolist()[0] == 0:
                    QMessageBox().information(None, '錯誤',
                                              '這條路線不在目標區域裡\n不用處理啦~')
                else:
                    SubRouteName = candidate_route.SubRouteName[
                        candidate_route.Direction == int(
                            direction)].tolist()[0]
                    route_spec = [routeUID, SubRouteName, direction, route_dir]
                    break
            else:
                route_spec = []
                break

        return route_spec, OK
Beispiel #9
0
 def promptPassword(self):
     alert = QInputDialog()
     alert.setModal(True)
     password, _ = alert.getText(self, 'Please insert database password',
                                 'Your database password')
     alert.show()
     return password
Beispiel #10
0
    def __init__(self):
        super(Ui_MainWindow, self).__init__()

        self.thread = None
        self.fileDialog = QFileDialog()
        self.inputDialog = QInputDialog()
        self.messageBox = QMessageBox()
        self.swindow = Settings()
        self.idialog = ImageDialog()

        self.threadpool = QThreadPool(self)
        self.threads = 4

        self.kappa = 3.0

        self.framearray = []
        self.batch = {}
        self.pname = None
        self.project = None
        self.coords = None

        self.selectedId = None
        self.selectedFtype = None
        self.infotablemodel = None

        self.configurations = {
            "tempdir": "",
            "sexpath": "/usr/bin/sex",
            "processes": 1
        }
Beispiel #11
0
 def on_actionBankEdit_triggered(self):
     tipo = QInputDialog().getText(self, "Xulpymoney",
                                   self.tr("Edit selected bank"),
                                   QLineEdit.Normal,
                                   (self.mqtwBanks.selected.name))
     if tipo[1] == True:
         self.bank_edit(tipo[0])
Beispiel #12
0
    def on_btn_run_clicked(self):
        password = "******"
        if self.export_mode == "scp":
            dlg = QInputDialog(self)
            dlg.setInputMode(QInputDialog.TextInput)
            dlg.setWindowTitle(_("Connecting to %s") % self.paras.exp_scp_server)
            dlg.setLabelText(_("Password for %s@%s:") % (self.paras.exp_scp_user, self.paras.exp_scp_server))
            dlg.setTextEchoMode(QLineEdit.Password)
            #dlg.resize(300, 100)
            if dlg.exec_():
                password = dlg.textValue()
            else:
                return

        super(TransportWidget, self).on_btn_run_clicked()
        self.executor_thread = TransportThread(self.paras,
                                               self.export_mode,
                                               self.all_resources,
                                               password,
                                               self)
        self.executor_thread.signal_exception.connect(self.on_signal_exception)
        self.executor_thread.ask_confirmation.connect(self.on_ask_confirmation)
        self.executor_thread.signal_main_event.connect(self.on_signal_main_event)
        self.executor_thread.signal_minor_event.connect(self.on_signal_minor_event)
        self.executor_thread.signal_next_file.connect(self.on_signal_next_file)
        self.executor_thread.signal_end_processing.connect(self.on_signal_end_processing)
        self.executor_thread.finished.connect(self.on_executor_thread_finished)
        self.executor_thread.start()
        self.update()
Beispiel #13
0
 def __init__(self, name: str, parent=None):
     super().__init__(name=name, parent=parent)
     self.dialog = QInputDialog()
     self.dialog.setWindowTitle('Add patient')
     self.dialog.setLabelText('Enter patient id:')
     self.signal_cancel = self.dialog.rejected
     self.signal_ok = self.dialog.accepted
Beispiel #14
0
    def btn_modes_set_add_click(self):
        input_dialog = QInputDialog()
        text, ok = input_dialog.getText(self, "Добавление настройки", "Наименование", QLineEdit.Normal)

        if ok:
            self.combo_set_micro.addItem(text)
            self.combo_set_micro.setCurrentIndex(self.combo_set_micro.count() - 1)
Beispiel #15
0
    def select_comp(self):
        """
        Prompt user for whether they are on robot or base computer.

        Assigns result to boolean class variable.
        """
        layout = QVBoxLayout()
        dialog = QInputDialog()
        layout.addWidget(dialog)
        item, ok = dialog.getItem(
            QWidget(),
            'Select Computer: Robot or Base',
            "Are you on the robot computer?",
            ['Yes', 'No'],
        )
        if ok:
            if str(item).lower() == "yes":
                self.current_computer_is_robot = True
            elif str(item).lower() == "no":
                self.current_computer_is_robot = False
            else:
                self.input_invalid()
                self.select_comp()
            self.install_directory()
        else:
            self.first_page()
        return layout
Beispiel #16
0
    def __init__(self):
        super().__init__()
        uic.loadUi("CashboxWindow.ui", self)

        cashboxes_names = map(lambda x: x[0],
                              PQLE.select("cashboxes", ["name"]))

        dialog = QInputDialog(self)

        item, OBP = dialog.getItem(self, "Выберите кассу",
                                   "Имя кассы:" + " " * 37, cashboxes_names, 0,
                                   False)

        if OBP:
            self.cashbox_id = PQLE.select("cashboxes", ["id"],
                                          [f"name = '{item}'"])[0][0]
        else:
            self.hide()
            sys.exit()

        self.cashbox_name = PQLE.select("cashboxes", ["name"],
                                        [f"id = {self.cashbox_id}"])[0][0]
        self.setWindowTitle(self.cashbox_name)

        self.parse_n()
        self.update_n()

        self.timer = QTimer(self)
        self.timer.timeout.connect(self.parse_n)
        self.timer.start(10)

        self.plus_button.clicked.connect(self.plus)

        self.show()
Beispiel #17
0
def askPasswordDialog(parent, title, prompt, timeout=None):
    if parent is None:
        app = qttools.createQApplication()
        translator = qttools.translator()
        app.installTranslator(translator)

    import icon
    dialog = QInputDialog()

    timer = QTimer()
    if not timeout is None:
        timer.timeout.connect(dialog.reject)
        timer.setInterval(timeout * 1000)
        timer.start()

    dialog.setWindowIcon(icon.BIT_LOGO)
    dialog.setWindowTitle(title)
    dialog.setLabelText(prompt)
    dialog.setTextEchoMode(QLineEdit.Password)
    QApplication.processEvents()

    ret = dialog.exec_()

    timer.stop()
    if ret:
        password = dialog.textValue()
    else:
        password = ''
    del (dialog)

    return (password)
Beispiel #18
0
def getNewName(names):
    newName, ok = QInputDialog.getText(QInputDialog(), '输入', "输入新的文件名")
    if not ok:
        return "", False
    if not newName:
        box = QMessageBox(QMessageBox.Question, '提醒', '您未输入任何字符')
        yes = box.addButton("重新输入", QMessageBox.YesRole)
        no = box.addButton("取消重命名", QMessageBox.NoRole)
        box.setIcon(1)
        box.exec_()
        if box.clickedButton() == no:
            return "", False
        elif box.clickedButton() == yes:
            getNewName(names)
    if newName in names:
        box = QMessageBox(QMessageBox.Question, '提醒', '已存在同名文件')
        yes = box.addButton("重新输入", QMessageBox.YesRole)
        no = box.addButton("取消重命名", QMessageBox.NoRole)
        box.setIcon(1)
        box.exec_()
        if box.clickedButton() == no:
            return "", False
        elif box.clickedButton() == yes:
            getNewName(names)
    return newName, True
Beispiel #19
0
 def pgn_load_btn_click(self):
     # get file path
     name, _ = QFileDialog.getOpenFileName(self,
                                           caption='Load PGN',
                                           filter='PGN files (*.pgn)')
     if name == '':
         return
     games = []
     with open(name, 'r') as f:
         while True:
             game = chess.pgn.read_game(f)
             if game is None:
                 break
             games.append(game)
     # TODO: assumes unique names
     game_names = [
         g.headers.get('Opening', f'Game {i+1}')
         for i, g in enumerate(games)
     ]
     item, ok = QInputDialog().getItem(self, "Open Game", "Select a game",
                                       game_names)
     if not ok:
         return
     game = games[game_names.index(item)]
     self.board = game.board()
     for move in game.mainline_moves():
         self.board.push(move)
     self.paint_board()
Beispiel #20
0
 def authentication(self):
     while True:
         dlg = QInputDialog()
         login, okPressed = dlg.getText(self, "LOGIN", "Your login:"******"dre")
         if okPressed and login != '':
             self.user = login
         else:
             continue
         password, okPressed = dlg.getText(self, "PASSWORD",
                                           "Your password:"******"12345")
         if okPressed and password != '':
             self.password = password
         else:
             continue
         m = JIMmsg()
         self.msg = m.auth_msg(self.user, self.password)
         self.s.send(self.msg.encode('ascii'))
         data = self.s.recv(1024)
         data = json.loads(data.decode('ascii'))
         if data['response'] == 202:
             break
         else:
             buttonReply = QMessageBox.question(self, data['alert'],
                                                "Try once more",
                                                QMessageBox.Yes,
                                                QMessageBox.Yes)
             if buttonReply == QMessageBox.Yes:
                 continue
Beispiel #21
0
    def join(self):
        print("Attempting to join!")

        host, status = QInputDialog().getText(self.window, "Join", "IP:Port",
                                              QLineEdit.Normal)

        host_ip = host.split(":")
        if host_ip[0] == "":
            host_ip[0] = "127.0.0.1"

        if status and not (1024 <= int(host_ip[1]) <= 65535):
            self.join()

        elif status and host:
            try:
                self.socket.connect((host_ip[0], int(host_ip[1])))
                self.received.insertHtml(
                    """<font color="green"><b><u>You're in!</b></u></font>""")
                self.received.insertPlainText("\n-----------\n")

                self.connected = True

                self.listen = Listener(self.socket)
                self.listen.start()
                self.listen.finished.connect(self.close)
                self.listen.chat_signal.connect(self.m_create)

            except Exception:
                traceback.print_exc(file=sys.stdout)
Beispiel #22
0
    def enterPlaylistName(self):
        inputDialog = QInputDialog()
        inputDialog.setLabelText('Enter a name for the playlist: ')
        inputDialog.exec_()
        name = inputDialog.textValue().replace(" ", "")

        return name
Beispiel #23
0
    def create(self):
        print("Attempting to host!")
        port_no, status = QInputDialog().getText(self.window, "Create",
                                                 "Desired Port Number",
                                                 QLineEdit.Normal)

        if status and (not port_no.isdigit() or
                       not (int(port_no) >= 1024 and int(port_no) <= 65535)):
            self.create()
        elif status and port_no:
            self.connected = True

            try:
                self.socket.bind(("0.0.0.0", int(port_no)))
                self.socket.listen()

                partner, sock_accept = self.socket.accept()
                self.socket.close()
                self.socket = partner

                self.received.insertHtml(
                    """<font color="green"><b><u>You're in!</b></u></font>""")
                self.received.insertPlainText("\n-----------\n")

                self.listen = Listener(partner)
                self.listen.start()

                self.listen.finished.connect(self.close)
                self.listen.chat_signal.connect(self.m_create)

            except:
                self.connected = False
                traceback.print_exc(file=sys.stdout)
Beispiel #24
0
    def select_btn(self):
        self.full_values()
        self.time_start = self.vertical_headers[0]
        self.time_fin = self.vertical_headers[-1]


        time_str = 'от '+ mk_to_str(self.time_start) + ' до ' + mk_to_str(self.time_fin)
        labelT = "Введите интервал для отбора по времени:"
        while True:
            dlg = QInputDialog(self)
            dlg.setInputMode(QInputDialog.TextInput)
            dlg.setWindowTitle("Установка времени отбора")
            dlg.setLabelText(labelT)
            dlg.resize(500,200)
            dlg.setTextValue(time_str)
            ok = dlg.exec_()
            if not(ok):
                break
            time_str2 = dlg.textValue()
            try:
                time_start,time_fin = time_str2.split(' ')[1],time_str2.split(' ')[3]
                time_start,time_fin = str_to_mkt(time_start),str_to_mkt(time_fin)

                self.time_start,self.time_fin = time_start+3600*3,time_fin+3600*3

            except Exception:
                labelT = "Неверный формат ввода, повторите:"
                dlg.setTextValue(time_str)
            else:
                break
        self.select_by_time()
Beispiel #25
0
    def connect(self):
        addr, ok = QInputDialog().getText(
            self.window, "Connect",
            "IP and Port Format (IP:Port). \nPort should be between 1024 and 65535",
            QLineEdit.Normal)
        REGEX = r"((\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})|localhost):\d+"

        addr_l = addr.split(":")

        if ok and (not re.match(REGEX, addr) or
                   not (int(addr_l[1]) >= 1024 and int(addr_l[1]) <= 65535)):
            self.connect()
        elif ok and addr:
            print(addr)
            self.status.setText("Connecting...")
            try:
                self.socket.connect((addr_l[0], int(addr_l[1])))
                self.status.setText("Connected to " + addr)
                self.incoming_text.insertHtml("<b> Connection Formed </b>")
                self.incoming_text.insertPlainText("\n")
                self.connected = True
                self.toggle_buttons()
                self.listen_thread = ListenThread(self.socket)
                self.listen_thread.start()
                self.listen_thread.finished.connect(self.connection_closed)
                self.listen_thread.sig.connect(self.new_mes)
            except ConnectionRefusedError:
                self.status.setText("Connection Failed. Please try again")
            except Exception:
                self.status.setText("Unknown Error has occured.")
                traceback.print_exc(file=sys.stdout)
Beispiel #26
0
 def open_file(self):
     if self.is_filter_on():
         return
     file_name, filter = \
       QFileDialog.getOpenFileName(self, "Open file", ".",
                                   "CSV Files (*.csv *.txt);;All files (*)")
     if not file_name:
         return
     num_tries = 1
     while num_tries <= 5:
         password, ok = QInputDialog().getText(
             self, "Attention", "Password:"******"")
         if ok:
             csv_data = None
             try:
                 csv_data = self.__decrypt_file(file_name, password)
             except:
                 print(sys.exc_info())
                 pass
             if csv_data:
                 self.table_widget.update_model(csv_data)
                 self.reset_needs_save()
                 self.status.showMessage(file_name + " loaded")
                 break
             else:
                 num_tries = num_tries + 1
                 QMessageBox.critical(
                     self, "Wrong Password!",
                     "You entered the wrong password. Please try again.")
         else:
             return
     return
Beispiel #27
0
    def btn_micros_add_click(self):
        input_dialog = QInputDialog()
        text, ok = input_dialog.getText(self, "Добавление камеры", "Наименование", QLineEdit.Normal)

        if ok:
            self.combo_micros.addItem(text)
            self.combo_micros.setCurrentIndex(self.combo_micros.count() - 1)
Beispiel #28
0
    def createobj(self):
        self.objsCount = self.objsCount + 1
        msg = QInputDialog()
        msg.exec_()

        # if path.isfile('data.json') is True:
        #     with open ('data.json','r') as f:
        #         data = json.load(f)
        #         self.checklist = data
        #         print(self.checklist)
        #         print(type(self.checklist))

        txt = msg.textValue()
        if txt != '' and not txt.isspace():
            self.ls.clear()
            for i in self.checklist:
                # self.ls.clear()
                self.ls.append(i)

            if not self.ls:
                self.ls.append(-1)
            print(self.ls,'ls')
            self.s = max(self.ls)
            self.s = int(self.s) + 1

            self.checklist.update({self.s:txt})
            # print(self.checklist,'check')
            # bxx = QCheckBox(txt,self)
            # bxx.show()
            # bxx.move(10, self.s*20)
            # self.lista.append(bxx)
            # print(self.s)
            self.updateS()
            self.initUI()
Beispiel #29
0
 def change_address_clicked(self):
     selected_item = self.view.ui.treeCameras.selectedItems()[0]
     old_address = selected_item.text(0)
     text, ok = QInputDialog().getText(
         self.view,
         _('Checkpoint'),
         _('Enter the address of the checkpoint:'),
         text=old_address)
     if ok:
         if text != '':
             if self.model.checkpoints_service.checkpoint_is_exist(text):
                 QMessageBox.warning(self.view, _('Warning'),
                                     _('Сheckpoint already exists'))
             else:
                 self.model.checkpoints_service.edit_checkpoint(
                     old_address, text)
                 selected_item.setText(0, text)
                 program_logs.change_checkpoint_address_log(
                     old_address, text)
                 QMessageBox.information(
                     self.view, _('Success'),
                     _('Сheckpoint successfully changed'))
         else:
             QMessageBox.warning(self.view, _('Warning'),
                                 _('Enter address'))
Beispiel #30
0
    def set_flux_bound(self):
        rows = self.dataView.get_selected_rows()
        col = self.dataView.get_selected_columns()[0]
        if col == 4:
            max_value = min([self.dataTable.item(r).link.upper_bound for r in rows])
            min_value = -999999.
        elif col == 5:
            min_value = max([self.dataTable.item(r).link.lower_bound for r in rows])
            max_value = 999999
        else:
            raise ValueError("The selected column for set_flux_bound needs to be 4, or 5!")

        value, status = QInputDialog().getDouble(self, "Set Bound", "New bound value:", 0, min_value, max_value)
        if status:
            self.dataTable.blockSignals(True)
            for row in rows:
                item = self.dataTable.item(row)
                if col == 4:
                    item.link.lower_bound = value
                elif col == 5:
                    item.link.upper_bound = value
                self.dataTable.item(row, 2).setText(item.link.reaction)
                self.dataTable.item(row, col).setData(value, 2)
            self.dataTable.blockSignals(False)
            self.dataTable.all_data_changed()