建表
This commit is contained in:
parent
b252d1ee2c
commit
5d001cfa16
2 changed files with 22 additions and 9 deletions
|
@ -250,3 +250,16 @@ class AccountTab(TabPage):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(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)
|
|
@ -215,15 +215,15 @@ class CategoryTab(TabPage):
|
||||||
print(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.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id")
|
||||||
# self.rows = self.pg.fetchall()
|
self.categoryData = self.pg.fetchall()
|
||||||
|
|
||||||
print(self.rows)
|
print(self.categoryData)
|
||||||
|
|
||||||
# 初始化表格
|
# 初始化表格
|
||||||
self.transTable.clear()
|
self.categoryTable.clear()
|
||||||
self.transTable.setRowCount(len(self.rows))
|
self.categoryTable.setRowCount(len(self.categoryData))
|
||||||
self.transTable.setColumnCount(5) # 时间 账户 类别 金额 描述
|
self.categoryTable.setColumnCount(5) # 时间 账户 类别 金额 描述
|
||||||
self.transTable.setHorizontalHeaderLabels(['Time', 'Account', 'Category', 'Amount', 'Description'])
|
self.categoryTable.setHorizontalHeaderLabels(['Time', 'Account', 'Category', 'Amount', 'Description'])
|
||||||
# 设置自动调整列宽
|
# 设置自动调整列宽
|
||||||
self.transTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
self.categoryTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
Loading…
Reference in a new issue