From ada1f226a99dd05b59de0da91be26c3fb9920d62 Mon Sep 17 00:00:00 2001 From: zky2020 <3439415903@qq.comm> Date: Sun, 4 Jun 2023 21:49:09 +0800 Subject: [PATCH] third version --- src/budget/_account.py | 6 +++--- src/budget/_category.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/budget/_account.py b/src/budget/_account.py index 581fcc2..ae8f411 100644 --- a/src/budget/_account.py +++ b/src/budget/_account.py @@ -263,15 +263,14 @@ class AccountTab(TabPage): # 初始化表格 self.accountTable.clear() - self.accountTable.setRowCount(len(self.transData)) + self.accountTable.setRowCount(len(self.accountData)) self.accountTable.setColumnCount(3) # 账户名 账户平衡 备注 self.accountTable.setHorizontalHeaderLabels(['Account Name', 'Account Balance', 'Description']) # 设置自动调整列宽 self.accountTable.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch) # 填充表格 - for i in range(len(self.transData)): - #self.accountTable.setItem(i, 0, QTableWidgetItem(self.transData[i][4].strftime("%Y-%m-%d %H:%M:%S"))) + for i in range(len(self.accountData)): self.accountTable.setItem(i, 0, QTableWidgetItem(self.accountData[self.transData[i][1]-1][1])) # if self.transData[i][2] is 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(str(self.transData[i][5]))) self.accountTable.setItem(i, 2, QTableWidgetItem(self.transData[i][6])) + diff --git a/src/budget/_category.py b/src/budget/_category.py index 6c093cd..b076319 100644 --- a/src/budget/_category.py +++ b/src/budget/_category.py @@ -2,6 +2,7 @@ from PyQt6.QtWidgets import * from ._tab import TabPage from ._pg import PostgresTab from PyQt6.QtGui import QDoubleValidator +from PyQt6.QtCore import Qt import json import datetime @@ -224,7 +225,7 @@ class CategoryTab(TabPage): self.pg.execute("SELECT c_id, meta ->> 'name' FROM category ORDER BY c_id") self.categoryData = self.pg.fetchall() - print(self.categoryData) + print(self.rows) # 初始化表格 self.categoryTable.clear() @@ -235,11 +236,15 @@ class CategoryTab(TabPage): 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])) if self.transData[i][2] is None: self.categoryTable.setItem(i, 0, QTableWidgetItem("None")) 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, 2, QTableWidgetItem(self.transData[i][6])) + +