ndw.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:DarkWallet 作者: DissentDifference 项目源码 文件源码
def _new_account(self):
        index = 0
        account_name = ""
        password = ""
        is_testnet = False
        while True:
            self.screen.clear()
            self.screen.addstr(1, 2, "Account name:")
            if index == 0:
                color = self._active_account_color()
            else:
                color = self._inactive_account_color()
            row_len = 26
            acc_row = account_name + "_" * (row_len - len(account_name))
            self.screen.addstr(2, 2, acc_row, color)
            self.screen.addstr(3, 2, "Password:")
            if index == 1:
                color = self._active_account_color()
            else:
                color = self._inactive_account_color()
            pass_row = "*" * len(password) + "_" * (row_len - len(password))
            self.screen.addstr(4, 2, pass_row, color)
            if index == 2:
                color = self._active_account_color()
            else:
                color = self._inactive_account_color()
            mark = "X" if is_testnet else " "
            self.screen.addstr(6, 2, "[%s] Testnet" % mark, color)
            c = self.screen.getch()
            if c == curses.KEY_BACKSPACE:
                if index == 0:
                    account_name = account_name[:-1]
                elif index == 1:
                    password = password[:-1]
            elif c == curses.KEY_ENTER or c == 10 or c == 13:
                ec = await api.Account.create(self._ws, account_name,
                                              password, is_testnet)
                if ec:
                    self._status = ec.name
                break
            elif c == curses.KEY_UP:
                index -= 1
                if index < 0:
                    index = 2
            elif c == curses.KEY_DOWN:
                index += 1
                if index >= 3:
                    index = 0
            elif c == ord(" ") and index == 2:
                is_testnet = not is_testnet
            else:
                if index == 0:
                    account_name += chr(c)
                elif index == 1:
                    password += chr(c)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号