修改metadata优化按钮

This commit is contained in:
wangweiye7840 2024-04-26 20:25:17 +08:00
parent eaa944e7eb
commit 90b61d8b34
3 changed files with 39 additions and 5 deletions

View File

@ -24,10 +24,16 @@ class Ui_Form(object):
Form.resize(760, 490)
self.pushButton_exec = QPushButton(Form)
self.pushButton_exec.setObjectName(u"pushButton_exec")
self.pushButton_exec.setGeometry(QRect(220, 190, 321, 101))
self.pushButton_exec.setGeometry(QRect(210, 220, 321, 101))
font = QFont()
font.setBold(True)
self.pushButton_exec.setFont(font)
self.pushButton_open = QPushButton(Form)
self.pushButton_open.setObjectName(u"pushButton_open")
self.pushButton_open.setGeometry(QRect(210, 100, 321, 101))
font1 = QFont()
font1.setBold(False)
self.pushButton_open.setFont(font1)
self.retranslateUi(Form)
@ -36,6 +42,7 @@ class Ui_Form(object):
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u4fee\u6539metadata", None))
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u4fee\u6539metadata", None))
self.pushButton_exec.setText(QCoreApplication.translate("Form", u"\u5728\u6570\u636e\u5e93\u4e2d\u4fee\u6539metadata", None))
self.pushButton_open.setText(QCoreApplication.translate("Form", u"\u6253\u5f00metadata\u6587\u4ef6", None))
# retranslateUi

View File

@ -19,6 +19,14 @@ class MyWindow_tjzd(QWidget,Ui_Form):
def bind(self):
self.metadatafilepath = "文本文件/metadata.txt"
self.pushButton_exec.clicked.connect(self.exec)
self.pushButton_open.clicked.connect(self.openmeta)
self.pushButton_exec.setEnabled(False)
def openmeta(self):
os.system(f"code -w {self.metadatafilepath}")
self.pushButton_exec.setEnabled(True)
def exec(self):
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
@ -53,6 +61,7 @@ class MyWindow_tjzd(QWidget,Ui_Form):
mydb.rollback()
else:
print("未作修改.")
self.pushButton_exec.setEnabled(False)

View File

@ -16,8 +16,8 @@
<widget class="QPushButton" name="pushButton_exec">
<property name="geometry">
<rect>
<x>220</x>
<y>190</y>
<x>210</x>
<y>220</y>
<width>321</width>
<height>101</height>
</rect>
@ -28,7 +28,25 @@
</font>
</property>
<property name="text">
<string>修改metadata</string>
<string>在数据库中修改metadata</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_open">
<property name="geometry">
<rect>
<x>210</x>
<y>100</y>
<width>321</width>
<height>101</height>
</rect>
</property>
<property name="font">
<font>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>打开metadata文件</string>
</property>
</widget>
</widget>