pyqt 首先需要安装
pyqt安装包我这边是pyqt5的安装包
然后通过Qcheckbox创建关联窗口的checkbox,通过按钮绑定事件触发事件。
btn.clicked.connect(self.push)
btn1.clicked.connect(self.select_all)
btn2.clicked.connect(self.select_none)
btn = QPushButton(name, self)
import sys
from PyQt5.QtWidgets import (QWidget, QApplication)
from PyQt5.QtWidgets import QCheckBox, QPushButton
from PyQt5.Qt import QTextEdit
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUi()
def create_btn(self, name, x, y):
btn = QPushButton(name, self)
btn.move(x, y)
btn.setFixedSize(200, 40)
btn.setText(name)
return btn
def initUi(self):
all_check_box = []
self.textbox = QTextEdit(self)
self.textbox.move(800, 800)
self.textbox.resize(400, 300)
btn = self.create_btn("push pipeline", 200, 1000) # QPushButton("push", self)
btn1 = self.create_btn("select all", 200, 1050)
btn2 = self.create_btn("select None", 200, 1100)
ar = ['integration-idoc', 'Consumer Writeservice', 'Consumer IDOC', 'Consumer Event', 'Service Manager',
'Write Service',
'integration-vp', 'Core-Metering', 'Core-Log-Retention', 'Service Broker', 'CDS Compiler', 'Read Service',
'Overdue',
'Metadata Service', 'Consumer event process pair', 'Consumer VP', 'MPE Service', 'MPE UI',
'Check Processes Service',
'Check Processes Service UI', 'Data Protect Privacy Service Pipeline', 'Manage Models', 'FLP2',
'Overview Page Pipeline']
arr_check_id = []
count = 0
ar1 = ["int", "acc", "performance", "pre-live","partner","live"]
count1 = 0
for space in ar1:
checkbox = QCheckBox(self)
checkbox.move(200 + count1 * 180, 50)
count1 = count1 + 1
checkbox.setText(space)
checkbox.setChecked(True)
all_check_box.append(checkbox)
for parameter in ar:
count = count + 2
checkbox = QCheckBox(self)
checkbox.check_id = count
checkbox.setText(parameter)
checkbox.move(200, 200 + 15 * count)
checkbox.setChecked(True)
arr_check_id.append(count)
all_check_box.append(checkbox)
self.all_check_box = all_check_box
self.setGeometry(300, 300, 350, 250)
self.setWindowTitle('pushpipeline')
# btn.setGeometry(170, 180, 50, 50)
btn.clicked.connect(self.push)
btn1.clicked.connect(self.select_all)
btn2.clicked.connect(self.select_none)
self.check_id = arr_check_id
self.show()
def push(self):
self.textbox.resize(200, 300)
self.textbox.setGeometry(600, 600, 350, 250)
choose_item = []
spce_item = []
for i in list(self.all_check_box):
if i.isChecked():
choose_item.append(i.text())
str1 = ""
file = open("ttmaster.csv", "w")
dic1 = {
"integration-idoc": "Y,GTT V2 integration-idoc Service Pipeline,gtt-integration-idoc,PipelineMasterTemplate,tt\n",
"Consumer Writeservice": "Y,GTT V2 Consumer Writeservice Pipeline,gtt-consumer-writeservice,PipelineMasterTemplate,tt\n",
"Consumer IDOC": "Y,GTT V2 Consumer IDOC Pipeline,gtt-consumer-event,PipelineMasterTemplate,tt\n",
"Consumer Event": "Y,GTT V2 Consumer event Pipeline,gtt-consumer-event,PipelineMasterTemplate,tt\n",
"Service Manager": "Y,GTT V2 Service Manager Pipeline,gtt-core-service-manager,PipelineMasterTemplate,tt\n",
"Write Service": "Y,GTT V2 Write Service Pipeline,gtt-core-inbound-writeservice,PipelineMasterTemplate,tt\n",
"integration-vp": "Y,GTT V2 integration-vp Service Pipeline,gtt-integration-vp,PipelineMasterTemplate,tt\n",
"Core-Metering": "Y,GTT V2 Core-Metering Pipeline,gtt-core-metering,PipelineMasterTemplate,tt\n",
"Core-Log-Retention": "Y,GTT V2 Core-Log-Retention Pipeline,gtt-core-log-retention,PipelineMasterTemplate,tt\n",
"Service Broker": "Y,GTT V2 Service Broker Pipeline,gtt-core-service-broker,PipelineMasterTemplate,tt\n",
"CDS Compiler": "Y,GTT V2 CDS Compiler Pipeline,gtt-core-cds-compiler,PipelineMasterTemplate,tt\n",
"Read Service": "Y,GTT V2 Read Service Pipeline,gtt-core-outbound-readservice,PipelineMasterTemplate,tt\n",
"Overdue": "Y,GTT V2 Overdue Pipeline,gtt-core-overdue-detection,PipelineMasterTemplate,tt\n",
"Metadata Service": "Y,GTT V2 Metadata Service Pipeline,gtt-core-metadata-service,PipelineMasterTemplate,tt\n",
"Consumer event process pair": "Y,GTT V2 Consumer event process pair Pipeline,gtt-consumer-event-process-pair,PipelineMasterTemplate,tt\n",
"Consumer VP": "Y,GTT V2 Consumer VP Pipeline,gtt-consumer-VP,PipelineMasterTemplate,tt\n",
"MPE Service": "Y,GTT V2 Apps MPE Service Pipeline,gtt-v2-mpe-service,PipelineMasterTemplate,tt\n",
"MPE UI": "Y,GTT V2 Apps UI MPE UI Pipeline,gtt-v2-ui-mpe,PipelineMasterTemplate,tt\n",
"Check Processes Service": "Y,GTT V2 Apps Check Processes Service Pipeline,gtt-v2-check-processes-service,PipelineMasterTemplate,tt\n",
"Check Processes Service UI": "Y,GTT V2 Apps UI Check Processes Service UI Pipeline,gtt-v2-ui-check-processes,PipelineMasterTemplate,tt\n",
"Data Protect Privacy Service Pipeline": "Y,GTT V2 Apps Data Protect Privacy Service Pipeline,gtt-v2-data-protect-privacy-service,PipelineMasterTemplate,tt\n",
"Manage Models": "Y,GTT V2 Apps UI Manage Models UI Pipeline,gtt-v2-ui-manage-models,PipelineMasterTemplate,tt\n",
"FLP2": "Y,GTT V2 FLP2 Pipeline,lbn-gtt-flp2,PipelineMasterTemplate,tt\n",
"Overview Page Pipeline": "Y,GTT V2 Apps UI GTT V2 Overview Page Pipeline,gtt-v2-ui-ovp,PipelineMasterTemplate,tt\n",
}
ar_spaces = ["int", "acc", "performance", "pre-live"]
file.write("isReleased, pipelineName, artifectName, templateClass, jenkinsName\n")
if not len(choose_item):
print("please input something")
self.textbox.setText("He")
for i in choose_item:
if i in dic1.keys():
str1 = str1 + i + "\n"
# print(str1)
file.write(dic1[i])
if i in ar_spaces:
str1 = str1 + i + "\t"
spce_item.append(i)
str1 = str1 +"\n"
file.close()
self.textbox.setText(str(str1))
print(ar_spaces)
if "acc" in spce_item and "performance" in spce_item:
print("push acc and performance")
self.push_acc()
self.push_preference()
elif "acc" in spce_item and "performance" not in spce_item and len(spce_item) == 2:
print("push int and acc")
self.push_acc()
elif "performance" in spce_item and len(spce_item) == 1:
print("push int and perf")
self.push_preference()
elif "int" in spce_item and len(spce_item) == 1:
print("push int")
self.push_int()
elif "pre-live" in spce_item and len(spce_item) == 1:
print("push pre-live")
self.push_pre_live()
def select_all(self):
for i in list(self.all_check_box):
i.setChecked(True)
def select_none(self):
for i in list(self.all_check_box):
i.setChecked(False)
def push_int(self):
print("push_int")
def push_acc(self):
print("push_acc")
def push_preference(self):
print("push_preference")
def push_pre_live(self):
print("push_pre_live")
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())