示例#1
0
 def _update_accounts(self, accounts: Iterable[Account]):
     for account in accounts:
         row = self._add_account(account)
         row.setEnabled(True)
         row.info.setText("未开启连接")
     enabled_widget(self.ui.pushButton_createAccount)
     disable_widget(self.ui.pushButton_modifyAccount,
                    self.MODIFY_BUTTON_TOOLTTIP)
     disable_widget(self.ui.pushButton_deleteAccount,
                    self.DELETE_BUTTON_TOOLTIP)
 def setup(self, account: Account):
     self._account = account
     self.ui.label_name.setText(account.name)
     self.ui.label_broker.setText(account.broker.name)
     self.ui.label_account.setText(account.account)
     self.ui.label_assetUnit.setText(account.asset_unit.name)
     disable_widget(self.ui.comboBox_portfolios, "请选择组合")
     self.ui.comboBox_portfolios.clear()
     Future(self,
            lambda: list(account.asset_unit.portfolios.values()),
            callback=self._update_portfolios).run()
示例#3
0
    def setup(self, client: RQAMSClient, username: str, user_id: int):
        self._client = client
        self._user_id = user_id
        self._account_row_map.clear()
        self.ui.tableWidget.setRowCount(0)

        self.ui.menu_currentUser.setTitle(username)

        for btn in (self.ui.pushButton_createAccount,
                    self.ui.pushButton_modifyAccount,
                    self.ui.pushButton_deleteAccount):
            disable_widget(btn, "数据正在加载")
        Future(self, lambda c: list(c.accounts.values()), (client, ),
               self._update_accounts).run()
示例#4
0
    def __init__(self, *args, **kwargs):
        super(_LoginForm, self).__init__(*args, **kwargs)
        self.ui = Ui_LoginForm()
        self.ui.setupUi(self)

        self.ui.lineEdit_username.textChanged[str].connect(
            self._check_username_password)
        self.ui.lineEdit_password.textChanged[str].connect(
            self._check_username_password)
        self.ui.pushButton_login.clicked.connect(self._login)
        disable_widget(self.ui.pushButton_login, self.LOGIN_BUTTON_TOOL_TIP)

        add_enter_press_event(
            (self.ui.lineEdit_username, self.ui.lineEdit_password),
            lambda: self._login()
            if self.ui.pushButton_login.isEnabled() else None)
示例#5
0
    def _check_username_password(self, _):
        login_enabled = True

        username_text = self.ui.lineEdit_username.text()
        if len(username_text) > 0 and not self._check_username(username_text):
            self.ui.label_usernameHint.setText(self.invalid_username_msg)
            login_enabled = False
        else:
            self.ui.label_usernameHint.setText("")

        if 0 < len(self.ui.lineEdit_password.text()) < 6:
            self.ui.label_passwordHint.setText("密码不能少于6位")
            login_enabled = False
        else:
            self.ui.label_passwordHint.setText("")
        enabled_widget(self.ui.pushButton_login)
        if login_enabled:
            enabled_widget(self.ui.pushButton_login)
        else:
            disable_widget(self.ui.pushButton_login,
                           self.LOGIN_BUTTON_TOOL_TIP)
    def setup(self, client: RQAMSClient, account_black_list: Set[str],
              portfolio_black_list: Set[str], asset_unit_black_list: Set[str]):
        self._client = client
        self._brokers = self._asset_units = self._portfolios = self._product = None
        self._account_black_list = account_black_list
        self._portfolio_black_list = portfolio_black_list
        self._asset_unit_black_list = asset_unit_black_list

        for lineEdit in (self.ui.lineEdit_name, self.ui.lineEdit_account,
                         self.ui.lineEdit_products):
            lineEdit.clear()
        self.ui.lineEdit_products.setReadOnly(True)
        for comboBox in (self.ui.comboBox_assetUnits,
                         self.ui.comboBox_portfolios, self.ui.comboBox_broker):
            _disable_combo_box(comboBox)
        disable_widget(self.ui.pushButton_create, "请输入/选择所有字段")

        Future(self, lambda c: list(c.brokers.values()), (client, ),
               self._update_brokers).run()
        Future(self, lambda c: list(c.asset_units.values()), (client, ),
               self._update_asset_units).run()
示例#7
0
    def _row_check_state_changed(self, *_):
        check_count = 0
        disabled_row_checked = False

        for row in self._account_row_map.values():
            if row.isChecked():
                check_count += 1
                if not row.enabled:
                    disabled_row_checked = True

        if check_count > 0:
            enabled_widget(self.ui.pushButton_deleteAccount)
        else:
            disable_widget(self.ui.pushButton_deleteAccount,
                           self.DELETE_BUTTON_TOOLTIP)

        if check_count == 1 and not disabled_row_checked:
            enabled_widget(self.ui.pushButton_modifyAccount)
        else:
            disable_widget(self.ui.pushButton_modifyAccount,
                           self.MODIFY_BUTTON_TOOLTTIP)
 def _check_form(self, *_):
     account_text = self.ui.lineEdit_account.text()
     if not (self.ui.lineEdit_name.text() and account_text
             and self.ui.comboBox_broker.isEnabled()
             and self.ui.comboBox_assetUnits.currentIndex() >= 0
             and self.ui.comboBox_portfolios.currentIndex() >= 0):
         disable_widget(self.ui.pushButton_create, "请输入/选择所有字段")
     elif account_text in self._account_black_list:
         disable_widget(self.ui.pushButton_create, "资金账号重复")
     elif not re.match(r"^[0-9a-zA-Z]+$", account_text):
         disable_widget(self.ui.pushButton_create, "资金账号不合法")
     else:
         enabled_widget(self.ui.pushButton_create)
def _disable_combo_box(box: QComboBox):
    disable_widget(box, "数据正在加载")
    box.clear()
示例#10
0
 def setEnabled(self, enabled: bool, disable_tool_tip: str = ""):
     if enabled:
         enabled_widget(self._widget)
     else:
         disable_widget(self._widget, disable_tool_tip)