style: 调整界面

This commit is contained in:
iridiumR 2023-05-23 20:23:25 +08:00
parent 0bdc637804
commit 1a28aa304c
No known key found for this signature in database
GPG key ID: 49735733EB1A32C8
3 changed files with 29 additions and 23 deletions

View file

@ -35,7 +35,6 @@ class AccountTab(TabPage):
# 新建对话框,询问是否删除 # 新建对话框,询问是否删除
dialog = QDialog(self) dialog = QDialog(self)
dialog.setWindowTitle('Delete Account') dialog.setWindowTitle('Delete Account')
dialog.resize(300, 200)
label1 = QLabel("Are you sure to delete this account?") label1 = QLabel("Are you sure to delete this account?")
label2 = QLabel("This action cannot be undone.") label2 = QLabel("This action cannot be undone.")
@ -48,7 +47,9 @@ class AccountTab(TabPage):
layout.addWidget(label1) layout.addWidget(label1)
layout.addWidget(label2) layout.addWidget(label2)
layout.addWidget(buttonBox) layout.addWidget(buttonBox)
layout.setSpacing(12)
layout.setContentsMargins(15, 15, 15, 15)
dialog.setMinimumWidth(400)
dialog.setLayout(layout) dialog.setLayout(layout)
# 若确认删除,则执行删除操作 # 若确认删除,则执行删除操作
@ -70,7 +71,6 @@ class AccountTab(TabPage):
# 创建添加数据对话框 # 创建添加数据对话框
self.aDialog = QDialog(self) self.aDialog = QDialog(self)
self.aDialog.setWindowTitle('Modify') self.aDialog.setWindowTitle('Modify')
self.aDialog.resize(400, 300)
index = self.accountComboBox.currentIndex() index = self.accountComboBox.currentIndex()
# 若为空,抛出错误 # 若为空,抛出错误
@ -119,7 +119,9 @@ class AccountTab(TabPage):
layout.addRow(label2,line2) layout.addRow(label2,line2)
layout.addRow(label3,line3) layout.addRow(label3,line3)
layout.addRow(buttonLayout) layout.addRow(buttonLayout)
layout.setSpacing(12)
layout.setContentsMargins(15, 15, 15, 15)
self.aDialog.setMinimumWidth(400)
self.aDialog.setLayout(layout) self.aDialog.setLayout(layout)
# 显示添加数据对话框 # 显示添加数据对话框
@ -152,7 +154,6 @@ class AccountTab(TabPage):
# 创建添加数据对话框 # 创建添加数据对话框
self.aDialog = QDialog(self) self.aDialog = QDialog(self)
self.aDialog.setWindowTitle('Add New Account') self.aDialog.setWindowTitle('Add New Account')
self.aDialog.resize(400, 300)
label1 = QLabel("Account Name:") label1 = QLabel("Account Name:")
line1 = QLineEdit() line1 = QLineEdit()
@ -178,7 +179,9 @@ class AccountTab(TabPage):
layout.addRow(label2,line2) layout.addRow(label2,line2)
layout.addRow(label3,line3) layout.addRow(label3,line3)
layout.addRow(buttonLayout) layout.addRow(buttonLayout)
layout.setSpacing(12)
layout.setContentsMargins(15, 15, 15, 15)
self.aDialog.setMinimumWidth(400)
self.aDialog.setLayout(layout) self.aDialog.setLayout(layout)
# 显示添加数据对话框 # 显示添加数据对话框

View file

@ -35,9 +35,8 @@ class CategoryTab(TabPage):
def onCategoryModifyClicked(self): def onCategoryModifyClicked(self):
# 创建添加数据对话框 # 创建添加数据对话框
addDialog = QDialog(self) self.cDialog = QDialog(self)
addDialog.setWindowTitle('Modify Category') self.cDialog.setWindowTitle('Modify Category')
addDialog.resize(400, 300)
index = self.categoryComboBox.currentIndex() index = self.categoryComboBox.currentIndex()
# 若为空,抛出错误 # 若为空,抛出错误
@ -79,20 +78,22 @@ class CategoryTab(TabPage):
buttonLayout.addWidget(button3) buttonLayout.addWidget(button3)
buttonLayout.addWidget(button2) buttonLayout.addWidget(button2)
button1.clicked.connect(addDialog.accept) button1.clicked.connect(self.cDialog.accept)
button3.clicked.connect(self.onCategoryDeleteClicked) button3.clicked.connect(self.onCategoryDeleteClicked)
button2.clicked.connect(addDialog.reject) button2.clicked.connect(self.cDialog.reject)
layout = QFormLayout() layout = QFormLayout()
layout.addRow(label1, line1) layout.addRow(label1, line1)
layout.addRow(label2, line2) layout.addRow(label2, line2)
layout.addRow(label3, line3) layout.addRow(label3, line3)
layout.addRow(buttonLayout) layout.addRow(buttonLayout)
layout.setSpacing(12)
addDialog.setLayout(layout) layout.setContentsMargins(15, 15, 15, 15)
self.cDialog.setLayout(layout)
self.cDialog.setMinimumWidth(400)
# 显示添加数据对话框 # 显示添加数据对话框
if addDialog.exec() == QDialog.DialogCode.Accepted: if self.cDialog.exec() == QDialog.DialogCode.Accepted:
try: try:
# 获取输入数据 # 获取输入数据
name = line1.text() name = line1.text()
@ -124,9 +125,8 @@ class CategoryTab(TabPage):
def onCategoryAddClicked(self): def onCategoryAddClicked(self):
# 创建添加数据对话框 # 创建添加数据对话框
addDialog = QDialog(self) self.cDialog = QDialog(self)
addDialog.setWindowTitle('Add New Category') self.cDialog.setWindowTitle('Add New Category')
addDialog.resize(400, 300)
label1 = QLabel("Category Name:") label1 = QLabel("Category Name:")
line1 = QLineEdit() line1 = QLineEdit()
@ -144,19 +144,21 @@ class CategoryTab(TabPage):
buttonLayout.addWidget(button1) buttonLayout.addWidget(button1)
buttonLayout.addWidget(button2) buttonLayout.addWidget(button2)
button1.clicked.connect(addDialog.accept) button1.clicked.connect(self.cDialog.accept)
button2.clicked.connect(addDialog.reject) button2.clicked.connect(self.cDialog.reject)
layout = QFormLayout() layout = QFormLayout()
layout.addRow(label1, line1) layout.addRow(label1, line1)
layout.addRow(label2, line2) layout.addRow(label2, line2)
layout.addRow(label3, line3) layout.addRow(label3, line3)
layout.addRow(buttonLayout) layout.addRow(buttonLayout)
layout.setSpacing(12)
addDialog.setLayout(layout) layout.setContentsMargins(15, 15, 15, 15)
self.cDialog.setMinimumWidth(400)
self.cDialog.setLayout(layout)
# 显示添加数据对话框 # 显示添加数据对话框
if addDialog.exec() == QDialog.DialogCode.Accepted: if self.cDialog.exec() == QDialog.DialogCode.Accepted:
try: try:
# 获取输入数据 # 获取输入数据
name = line1.text() name = line1.text()

View file

@ -7,7 +7,7 @@ from ._account import AccountTab
def initUI(self): def initUI(self):
self.setWindowTitle('budget') self.setWindowTitle('budget')
self.setGeometry(100, 100, 800, 600) self.setMinimumSize(800, 400)
self.pg = PostgresTab() self.pg = PostgresTab()
self.categoryTab = CategoryTab(self) self.categoryTab = CategoryTab(self)
@ -19,6 +19,7 @@ def initUI(self):
mainWidget.addTab(self.categoryTab, 'Category') mainWidget.addTab(self.categoryTab, 'Category')
mainWidget.addTab(self.accountTab, 'Account') mainWidget.addTab(self.accountTab, 'Account')
# 槽连接
mainWidget.currentChanged.connect(self.onTabChanged) mainWidget.currentChanged.connect(self.onTabChanged)
self.setCentralWidget(mainWidget) self.setCentralWidget(mainWidget)