728x90 QT3 [Python] matplotlib으로 그래프 그리기 QT라이브러리 이용해서 GUI만들고 거기에 그래프 삽입 기타 설명 소스 주석 참고 - 소스코드 class MyWindow(QMainWindow, form_class): def __init__(self): super().__init__() self.setupUi(self) # ... 생략 def create_Graph(self): self.fig1 = plt.Figure() self.canvas1 = FigureCanvasQTAgg(self.fig1) self.y1 = np.arange(-20, 100, 2) # y축 크기 self.x1 = np.arange(0, SIZE, 1) # x축 크기 # x축 크기와 y축 크기는 같아야 함 ex) 60 x 60 self.graphLayout1.addWidget(s.. 2021. 2. 2. [Python] MQTT 통신 - MQTT통신 * QT에서 프로그램 세팅(IP, PORT, TOPIC 등) 후 시작 누르면 QThread사용해서 MQTT 통신 진행 **** QT 안쓰면 QThread 부분을 그냥 파이썬 기본 Thread로 변경하여 사용가능 * main.py # ... 생략 self.Comm = QThread_MQTT.Comm(parent=self, flag=flag2) self.Comm.Comm_ThreadEvent.connect(self.Log_Event) # 쓰레드 이벤트 헨들러 -> 데이터 전송 self.Comm.start() self.Comm.isRunning = True @pyqtSlot(str) def Log_Event(self, n): now= datetime.datetime.now() texts = s.. 2021. 2. 2. [Python] QT Dialog 간 데이터 전달 Parent Dialog 에서 Child Dialog 데이터 읽기 dlg = OptionWindow.OptionWindow() dlg.exec() print("dlg.flag " + str(dlg.flag)) print("dlg.flag2 " + str(dlg.flag2)) Child Dialog - init에서 self.xxxx로 변수 생성 - ok 버튼 클릭 시 변수에 데이터 저장 ==> Parent Dialog에서 위처럼 읽을 수 있음 def __init__(self): super().__init__() # ... 생략 self.flag = 0 self.flag2 = 0 # ... 생략 self.show() def OK_Btn_Clicked(self): # ... 생략 flag1 = self.tab.. 2021. 2. 2. 이전 1 다음 728x90