示例#1
0
    def ui_init(self):
        row = 0

        # 创建host部件
        build_widget(grid=self.grid, widget_class=QLabel, text="host:", row=row, col=0)
        self.cb_host = build_widget(grid=self.grid, widget_class=QComboBox, text="", row=row, col=1)
        hosts = get_host()
        build_widget_items(self.cb_host, hosts)
        row += 1

        # 创建port部件
        build_widget(grid=self.grid, widget_class=QLabel, text="port:", row=row, col=0)
        self.le_port = build_widget(grid=self.grid, widget_class=QLineEdit, text="5432", row=row, col=1)
        row += 1

        # 创建db部件
        build_widget(grid=self.grid, widget_class=QLabel, text="db:", row=row, col=0)
        dbs = get_db()
        row, ck_db = build_checkbox_widget(grid=self.grid, row=row, col=1, items=dbs)
        [ck.stateChanged.connect(lambda: process_checked(ck_db, self.dbs)) for ck in ck_db]
        row += 1

        # 创建bk_path部件
        build_widget(grid=self.grid, widget_class=QLabel, text="bk_path:", row=row, col=0)
        self.le_bk_path = build_widget(grid=self.grid, widget_class=QLineEdit, text=".", row=row, col=1)
        row += 1

        # 创建提交部件
        bt_commit = build_widget(grid=self.grid, widget_class=QPushButton, text="提交", row=row, col=0)
        bt_commit.clicked.connect(self._commit)
示例#2
0
    def create_db_CheckBox(self, *args, **kwargs):
        col = 0
        label = kwargs.get("db_label", "数据库:")
        lb = QLabel(label)
        self.add_widget(lb, col)
        col += 1

        dbs = get_db()
        ck_list = []
        for db in dbs:
            ck = QCheckBox(db)
            self.add_widget(ck, col)
            ck_list.append(ck)

            # 每行显示4个
            if col > 3:
                self.add_row()
                col = 1
            else:
                col += 1

        [ck.stateChanged.connect(lambda: process_checked(ck_list, self.dbs)) for ck in ck_list]
        self.add_row()
        return ck_list