Thread 앱
- Qt Designer로 ui 생성
import sys
from PyQt5 import uic
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import time
MAX=1000
class BackgroundWorker(QThread):
procChanged = pyqtSignal(int)
def __init__(self,count=0,parent=None)->None:
super().__init__()
self.main=parent
self.working=False
self.count=count
def run(self):
while self.working:
if self.count<=MAX:
self.procChanged.emit(self.count)
self.count+=1
time.sleep(0.001)
else:
self.working=False
class qtApp(QWidget):
def __init__(self):
super().__init__()
uic.loadUi('./studyThread/threadApp.ui',self)
self.setWindowTitle('Thread 앱')
self.pgbTask.setValue(0)
self.btnStart.clicked.connect(self.btnStartClicked)
self.worker=BackgroundWorker(parent=self, count=0)
self.worker.procChanged.connect(self.procUpdated)
self.pgbTask.setRange(0,MAX)
def procUpdated(self,count):
self.txbLog.append(f'스레드 출력 > {count}')
self.pgbTask.setValue(count)
print(f'스레드 출력 > {count}')
def btnStartClicked(self):
self.worker.start()
self.worker.working = True
self.worker.count=0
if __name__=='__main__':
app=QApplication(sys.argv)
ex=qtApp()
ex.show()
sys.exit(app.exec_())
이메일 보내기 APP
import smtplib
from email.mime.text import MIMEText
send_email='@naver.com'
send_pass='!!'
recv_email='@naver.com'
smtp_name='smtp.naver.com'
smtp_port = 587
text = '''메일 내용
긴급 빨리 연락바람'''
msg=MIMEText(text)
msg['Subject'] = '메일 제목입니다'
msg['From'] = send_email
msg['To'] = recv_email
mail=smtplib.SMTP(smtp_name,smtp_port)
mail.starttls()
mail.login(send_email,send_pass)
mail.sendmail(send_email,recv_email,msg=msg.as_string())
mail.quit()
print('전송완료!')
- send_email / send_pass / recv_email 설정하여
- 송신자 : send_email / 수신자 : recv_email 로 메일 전송 가능
이미지에서 글자 추출(Tesseract-OCR 사용)
from PIL import Image
import pytesseract as tess
img_path='./Python_practice/한글이미지.png'
tess.pytesseract.tesseract_cmd = 'C:/DEV/Tools/Tesseract-OCR/tesseract.exe'
result = tess.image_to_string(Image.open(img_path), lang='kor')
print(result)
- 완벽하진 않지만 다음과 같이 이미지에서 글자가 추출 되는것을 확인