引用来自“mr_chip”的评论贴个button的slot代码
self.pushButton = QtWidgets.QPushButton(self.tab)
self.pushButton.setGeometry(QtCore.QRect(10, 120, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.run)
def starting(self):
# pass
read = HBTiaoShi.readCSV()
read.implementor()
read.getInfo()
# time1 = HBTiaoShi.time.time()
HBTiaoShi.log.initLogConf()
HBTiaoShi.log = HBTiaoShi.logging.getLogger('')
read.openfile("..")
HBTiaoShi.time.sleep(10)
def startingflow(self):
observer = HBTiaoShi.Observer()
event_handler = HBTiaoShi.FileEventHandler()
observer.schedule(event_handler, "..", True)
observer.start()
try:
while True:
HBTiaoShi.time.sleep(600)
except KeyboardInterrupt:
observer.stop()
observer.join()
def run(self):
p=Process(target=self.starting)
p.start()
self.startingflow()
因为我的功能之前都是封装到类中,实例化调用运行的。然后我给它添加GUI后我就不知道要怎么调用。因为我是尽量的一键自动运行,又因为我是一个大整体将每个环节做成了一个function。