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)
def ui_init(self): row = 0 # 创建host部件 build_widget(grid=self.grid, widget_class=QLabel, text="host:", row=row, col=0) hosts = get_host() self.cb_host = build_widget(grid=self.grid, widget_class=QComboBox, text="", row=row, col=1) 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() self.cb_db = build_widget(grid=self.grid, widget_class=QComboBox, text="", row=row, col=1) build_widget_items(self.cb_db, dbs) row += 1 # 创建table部件 build_widget(grid=self.grid, widget_class=QLabel, text="table:", row=row, col=0) self.le_table = build_widget(grid=self.grid, widget_class=QLineEdit, text="", row=row, col=1) 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)
def create_db_ComboBox(self, *args, **kwargs): label = kwargs.get("db_label", "数据库") ld = QLabel(label) self.add_widget(ld, 0) dbs = get_db() cb = QComboBox() build_widget_items(cb, dbs) self.add_widget(cb, 1) self.add_row() return cb
def ui_init(self): row = 0 # 创建host部件 build_widget(grid=self.grid, widget_class=QLabel, text="host:", row=row, col=0) hosts = get_host() self.cb_host = build_widget(grid=self.grid, widget_class=QComboBox, text="", row=row, col=1) 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() self.cb_db = build_widget(grid=self.grid, widget_class=QComboBox, text="", row=row, col=1) build_widget_items(self.cb_db, dbs) self.cb_db.insertItem(0, "*") row += 1 # 创建db_user部件 build_widget(grid=self.grid, widget_class=QLabel, text="db_user:"******"postgres", row=row, col=1) row += 1 # 创建db_password部件 build_widget(grid=self.grid, widget_class=QLabel, text="db_password", row=row, col=0) self.le_dbpasswd = build_widget(grid=self.grid, widget_class=QLineEdit, text="postgres", 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)
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