This commit is contained in:
zky2020 2023-06-04 15:04:13 +08:00
parent b252d1ee2c
commit 5d001cfa16
2 changed files with 22 additions and 9 deletions

View file

@ -249,4 +249,17 @@ class AccountTab(TabPage):
self.accountComboBox.addItem(data)
except Exception as e:
print(e)
QMessageBox.critical(self, 'Error', str(e))
QMessageBox.critical(self, 'Error', str(e))
self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
self.accountData = self.pg.fetchall()
print(self.accountData)
# 初始化表格
self.accountTable.clear()
self.accountTable.setRowCount(len(self.accountData))
self.accountTable.setColumnCount(5) # 时间 账户 类别 金额 描述
self.accountTable.setHorizontalHeaderLabels(['Time', 'Account', 'Category', 'Amount', 'Description'])
# 设置自动调整列宽
self.accountTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)

View file

@ -215,15 +215,15 @@ class CategoryTab(TabPage):
print(e)
QMessageBox.critical(self, 'Error', str(e))
# self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
# self.rows = self.pg.fetchall()
self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
self.categoryData = self.pg.fetchall()
print(self.rows)
print(self.categoryData)
# 初始化表格
self.transTable.clear()
self.transTable.setRowCount(len(self.rows))
self.transTable.setColumnCount(5) # 时间 账户 类别 金额 描述
self.transTable.setHorizontalHeaderLabels(['Time', 'Account', 'Category', 'Amount', 'Description'])
self.categoryTable.clear()
self.categoryTable.setRowCount(len(self.categoryData))
self.categoryTable.setColumnCount(5) # 时间 账户 类别 金额 描述
self.categoryTable.setHorizontalHeaderLabels(['Time', 'Account', 'Category', 'Amount', 'Description'])
# 设置自动调整列宽
self.transTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
self.categoryTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)