多个窗口QTDesigner
实现代码如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| import PyQt5.QtCore from PyQt5.Qt import * from main_gui import Ui_MainWindow import sys
class Thread(QThread): move_point = pyqtSignal(int, int) def __init__(self): super(Thread, self).__init__() self.x = 0 self.y = 0
def run(self) -> None: self.x = (self.x + 1) % 10 self.y = (self.y + 1) % 10 self.move_point.emit(self.x, self.y)
class Window(QMainWindow, Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) self.drawWidget.installEventFilter(self)
self.thread = Thread() self.thread.move_point.connect(self.mypainterEvent) self.thread.start()
def eventFilter(self, watched, event): if event.type() == QEvent.Paint and watched == self.drawWidget: self.mypainterEvent() return super().eventFilter(watched, event)
def mypainterEvent(self, x=10, y=10): painter = QPainter() painter.begin(self.drawWidget) painter.setPen(QPen(QColor(0, 0, 255), 7)) painter.drawPoint(x, y) painter.end()
if __name__ == "__main__": app = QApplication(sys.argv) window = Window()
window.show() sys.exit(app.exec_())
|
但是由于不知道如何向事件里面传递线程里面的参数,最后用label来实现按算了。
最后实现代码如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| from PyQt5.Qt import * from main_gui import Ui_MainWindow import sys
class Thread(QThread): move_point = pyqtSignal(int, int) def __init__(self): super(Thread, self).__init__() self.x = 0 self.y = 0
def run(self) -> None: while True: self.x = (self.x + 10) % 100 self.y = (self.y + 10) % 100 self.move_point.emit(self.x, self.y) 】、
class Window(QMainWindow, Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) self.drawWidget.installEventFilter(self)
self.thread = Thread() self.thread.move_point.connect(self.mypointEvent) self.thread.start()
def mypointEvent(self, x=10, y=10): self.pointLabel.setGeometry(QRect(x, y, 31, 31))
if __name__ == "__main__": app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
|
原点坐标:(100,112)
半径:100
Intel杯相关论文
【经典简读】知识蒸馏(Knowledge Distillation) 经典之作 - 知乎 (zhihu.com)
知识蒸馏(Knowledge Distillation)_Law-Yao的博客-CSDN博客_知识蒸馏