본문 바로가기

공부/Python

(24)
6. [Python] QThread , Thread 의 이해 import sys from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QBoxLayout from PyQt5 import QtCore from PyQt5.QtCore import QObject class Test(QObject): def __init__(self): super().__init__() self.cnt = 0 self.stop_flag = False def start_test(self): while True: self.cnt += 1 print('test1 = ', self.cnt) loop = QtCore.QEventLoop() QtCore.QTimer.singleShot(1000, loop.quit) #1000 ms loop..
4. [Python] QWaitCondition import sys from PyQt5.QtCore import QThread, pyqtSignal, QMutex, pyqtSlot, QWaitCondition from PyQt5.QtWidgets import QWidget, QTextEdit, QApplication, QPushButton, QBoxLayout, QProgressBar from PyQt5.QtCore import Qt from PyQt5 import QtCore class test_thread(QThread): change_value = pyqtSignal(str) def __init__(self): super().__init__() self.cond = QWaitCondition() self.mutex = QMutex() self.c..
[Python] ** 의 쓰임 class Test_arg(): def _Test(self, Ts_v1=1, Ts_v2=2, Ts_v3=3): print(Ts_v1) print(Ts_v2) print(Ts_v3) test = Test_arg() T_argv = { "Ts_v1": 11, "Ts_v2": 12, } test._Test(**T_argv) 참고 사이트 https://jhproject.tistory.com/109
[Python] Empty suite 에러 해결 Empty suite 라는 에러 코드가 발생하는 경우가 있는데 이럴 때는 test_widget.py 를 복사하여 이름을 다시 지정할 때 _test_widget.py 이렇게 언더바를 넣어주면 해결이 된다.
3. [Python] Qt Designer 기본 소스 Designer 설치 위치 1. .UI 파일로 구성하기 import sys from PyQt5.QtWidgets import * from PyQt5 import uic from PyQt5.QtGui import * form_class = uic.loadUiType("MainWindows.ui")[0] class MyWindow(QMainWindow, form_class): def __init__(self): super().__init__() self.setUI() self.textEdit.setText('하이') print(self.textEdit.toPlainText()) def setUI(self): self.setupUi(self) self.pushButton.clicked.connect(self...
2. [Python] pyqtSignal signal 순서 1. 선언 2. emit 3. connect import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * class signal_test(QObject): signal1 = pyqtSignal() def run(self): self.signal1.emit() class MainWindow(QMainWindow): def __init__(self): super().__init__() mainsignal = signal_test() mainsignal.signal1.connect(self.signal1_emit) mainsignal.run() @pyqtSlot() def signal1_emit(self): print("signal..
1.[Python] 기본 문법 num = 5 _dir = {1: 'a', 2: 'b', 3: 'c'} a = 0 # if의 활용 if num == 5: print("hello1") if not 0: print("hello2") if not 1: print("hello3") else: print("hello4") if _dir is not None: print(_dir) # for 의 활용 for i in range(10): print("i = %d" % i) # while 의 활용 while True: a += 1 if a == 10: break else: print("a = %d" % a) print("end") 결과 화면 hello1 hello2 hello4 {1: 'a', 2: 'b', 3: 'c'} i = 0 i = 1 i =..
1. 사용환경 설치 1. 아나콘다 설치 (Python + 기타 등등 합쳐진 형태) https://www.anaconda.com/distribution/ Anaconda Python/R Distribution - Free Download Anaconda Distribution is the world's most popular Python data science platform. Download the free version to access over 1500 data science packages and manage libraries and dependencies with Conda. www.anaconda.com 2. QT designer 실행 아나콘다를 설치하면 설치 경로에서 -> Anaconda3\Library\bin ..