third version

This commit is contained in:
zky2020 2023-06-04 21:49:09 +08:00
parent 48bf45d4fe
commit ada1f226a9
2 changed files with 11 additions and 6 deletions

View file

@ -263,15 +263,14 @@ class AccountTab(TabPage):
# 初始化表格 # 初始化表格
self.accountTable.clear() self.accountTable.clear()
self.accountTable.setRowCount(len(self.transData)) self.accountTable.setRowCount(len(self.accountData))
self.accountTable.setColumnCount(3) # 账户名 账户平衡 备注 self.accountTable.setColumnCount(3) # 账户名 账户平衡 备注
self.accountTable.setHorizontalHeaderLabels(['Account Name', 'Account Balance', 'Description']) self.accountTable.setHorizontalHeaderLabels(['Account Name', 'Account Balance', 'Description'])
# 设置自动调整列宽 # 设置自动调整列宽
self.accountTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch) self.accountTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
# 填充表格 # 填充表格
for i in range(len(self.transData)): for i in range(len(self.accountData)):
#self.accountTable.setItem(i, 0, QTableWidgetItem(self.transData[i][4].strftime("%Y-%m-%d %H:%M:%S")))
self.accountTable.setItem(i, 0, QTableWidgetItem(self.accountData[self.transData[i][1]-1][1])) self.accountTable.setItem(i, 0, QTableWidgetItem(self.accountData[self.transData[i][1]-1][1]))
# if self.transData[i][2] is None: # if self.transData[i][2] is None:
# self.accountTable.setItem(i, 1, QTableWidgetItem("None")) # self.accountTable.setItem(i, 1, QTableWidgetItem("None"))
@ -279,3 +278,4 @@ class AccountTab(TabPage):
# self.accountTable.setItem(i, 1, QTableWidgetItem(self.categoryData[self.transData[i][2]-1][1])) # self.accountTable.setItem(i, 1, QTableWidgetItem(self.categoryData[self.transData[i][2]-1][1]))
self.accountTable.setItem(i, 1, QTableWidgetItem(str(self.transData[i][5]))) self.accountTable.setItem(i, 1, QTableWidgetItem(str(self.transData[i][5])))
self.accountTable.setItem(i, 2, QTableWidgetItem(self.transData[i][6])) self.accountTable.setItem(i, 2, QTableWidgetItem(self.transData[i][6]))

View file

@ -2,6 +2,7 @@ from PyQt6.QtWidgets import *
from ._tab import TabPage from ._tab import TabPage
from ._pg import PostgresTab from ._pg import PostgresTab
from PyQt6.QtGui import QDoubleValidator from PyQt6.QtGui import QDoubleValidator
from PyQt6.QtCore import Qt
import json import json
import datetime import datetime
@ -224,7 +225,7 @@ class CategoryTab(TabPage):
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.categoryData = self.pg.fetchall() self.categoryData = self.pg.fetchall()
print(self.categoryData) print(self.rows)
# 初始化表格 # 初始化表格
self.categoryTable.clear() self.categoryTable.clear()
@ -235,11 +236,15 @@ class CategoryTab(TabPage):
self.categoryTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch) self.categoryTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
# 填充表格 # 填充表格
for i in range(len(self.categoryData)): for i in range(len(self.transData)):
# self.categoryTable.setItem(i, 2, QTableWidgetItem(self.accountData[self.transData[i][1]-1][1])) # self.categoryTable.setItem(i, 2, QTableWidgetItem(self.accountData[self.transData[i][1]-1][1]))
if self.transData[i][2] is None: if self.transData[i][2] is None:
self.categoryTable.setItem(i, 0, QTableWidgetItem("None")) self.categoryTable.setItem(i, 0, QTableWidgetItem("None"))
else: else:
self.categoryTable.setItem(i, 0, QTableWidgetItem(self.categoryData[self.transData[i][2]-1][1])) self.categoryTable.setItem(i, 0, QTableWidgetItem(data))
# self.categoryTable.setItem(i, 0, QTableWidgetItem(self.accountData[self.transData[i][2]-1][1]))
# self.categoryTable.setItem(i, 0, QTableWidgetItem(data[0][0]))
self.categoryTable.setItem(i, 1, QTableWidgetItem(str(self.transData[i][5]))) self.categoryTable.setItem(i, 1, QTableWidgetItem(str(self.transData[i][5])))
self.categoryTable.setItem(i, 2, QTableWidgetItem(self.transData[i][6])) self.categoryTable.setItem(i, 2, QTableWidgetItem(self.transData[i][6]))