PyQt5
-
PyQt QTableWidget ์์ ํญ๋ชฉ ๊ฒ์ ๋ฐ ๋ณต์ ๊ธฐ๋ฅ ๊ตฌํ ๋ฐฉ๋ฒ
QTableWidget ์์ ํญ๋ชฉ ๊ฒ์ ๋ฐ ๋ณต์ ๊ธฐ๋ฅ ๊ตฌํ ๋ฐฉ๋ฒ๋ค์ด๊ฐ๋ฉฐPyQt์ QTableWidget ์์ ํญ๋ชฉ์ ๊ฒ์ํ๊ณ , ์๋์ ๋ด์ฉ์ ๋ณต์ ์ํค๋ ๋ฐฉ๋ฒ์ ์ ๋ฆฌํด๋ณธ๋ค. ๋ฐฉ๋ฒ๊ฒ์ํ๊ณ ์ ํ๋ ๋ด์ฉ์ด ํด๋น ํ์ ์์ ๊ฒฝ์ฐ ํ์ํ๊ณ , ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ ์จ๊ธฐ๋ ๋ฐฉ๋ฒ์ ์ด์ฉํ๋ค.from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QTableWidget, QTableWidgetItem, QPushButton, QLineEditclass SearchResetTableApp(QWidget): def __init__(self): super(SearchResetTableApp, self).__init__() self.ini..
0 2024.01.29 -
PyQt QTableWidget๊ณผ SQLite3๋ฅผ ์ฐ๋ํ์ฌ ๊ตฌํํ CRUD ํ๋ก๊ทธ๋จ
QTableWidget๊ณผ SQLite3๋ฅผ ์ฐ๋ํ์ฌ ๊ตฌํํ CRUD ํ๋ก๊ทธ๋จ ๋ค์ด๊ฐ๋ฉฐ QTableWidget๊ณผ SQLite3๋ฅผ ์ฐ๋ํ์ฌ ๊ฐ๋จํ๊ฒ ๊ตฌํํ CRUD ํ๋ก๊ทธ๋จ ์์ค ์ฝ๋๋ฅผ ์ ๋ฆฌํด๋ณธ๋ค. ์์ค ์ฝ๋ import sys import sqlite3 from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLineEdit, QTableWidget, QTableWidgetItem, QLabel, QMessageBox class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("C..
0 2023.11.27 -
PyQt ๊ฐ๋จํ CRUD(Create, Read, Update, Delete) ํ๋ก๊ทธ๋จ
๊ฐ๋จํ CRUD(Create, Read, Update, Delete) ํ๋ก๊ทธ๋จ ๋ค์ด๊ฐ๋ฉฐ PyQt5๋ก ๊ฐ๋จํ CRUD(Create, Read, Update, Delete) ๊ธฐ๋ฅ์ ์ํํ ์ ์๋ ํ๋ก๊ทธ๋จ์ ๋ง๋ค์ด๋ณด์. ์ฝ๋ QTextEdit ์์ ฏ์ ์ด์ฉํ์ฌ CRUD ๊ธฐ๋ฅ์ ์ํํ ์ ์๋ ๋ฉ๋ชจ์ฅ๊ณผ ๋น์ทํ ํ๋ก๊ทธ๋จ์ด๋ค. import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QAction, QFileDialog class TextEditor(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): self.textEdit = QT..
0 2023.07.18 -
PyQt QTimer.singleShot ํจ์๋ฅผ ํน์ ์๊ฐ ๊ฐ๊ฒฉ์ผ๋ก ์ฌ๋ฌ๋ฒ ์คํํ๋ ๋ฐฉ๋ฒ
QTimer.singleShot ํจ์๋ฅผ ํน์ ์๊ฐ ๊ฐ๊ฒฉ์ผ๋ก ์ฌ๋ฌ๋ฒ ์คํํ๋ ๋ฐฉ๋ฒ๋ค์ด๊ฐ๋ฉฐPyQt5์์ QTimer.singleShot ํจ์๋ฅผ ํน์ ์๊ฐ ๊ฐ๊ฒฉ์ผ๋ก ์ฌ๋ฌ๋ฒ ์คํํ ์ ์๋ค.QTimer.singleShot ํจ์๋ ๋ฐ๋ฆฌ์ด ๋จ์์ ์๊ฐ ์ง์ฐ์ ์ค ํ, ํน์ ํจ์๋ฅผ ์คํํด์ฃผ๋ ํจ์์ด๋ค. ์์ ๋ค์์ QTimer.singleShot ํจ์๋ฅผ 3์ด ๊ฐ๊ฒฉ์ผ๋ก ์ฌ๋ฌ ๋ฒ ์คํํ๋ ์์ ์ด๋ค.๋ฐ๋ณต๋ฌธ๊ณผ ์ฌ๊ท ํธ์ถ์ ์ด์ฉํ์ฌ ๊ตฌํํ์๋ค.from PyQt5.QtCore import QTimerclass MyClass: def __init__(self): self.count = 0 def start_timer(self): self.count = 0 self.r..
0 2023.07.16 -
PyQt QAction์์ triggered ์๊ทธ๋์ ์ฌ์ฉํ ๋, ์ธ์๋ฅผ triggered ๋ฉ์๋์ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ
QAction์์ triggered ์๊ทธ๋์ ์ฌ์ฉํ ๋, ์ธ์๋ฅผ triggered ๋ฉ์๋์ ์ ๋ฌํ๋ ๋ฐฉ๋ฒPyQt์ QAction์์ triggered ์๊ทธ๋์ ์ฌ์ฉํ ๋, ์ธ์๋ฅผ triggered ๋ฉ์๋์ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์. ๋๋ค ํจ์ ์ฌ์ฉํ๊ธฐaction = QAction("My Action", parent)action.triggered.connect(lambda: my_function(arg1, arg2))my_function์ arg1๊ณผ arg2๋ฅผ ์ธ์๋ก ๋ฐ๋ ํจ์์ด๋ค.triggered ์๊ทธ๋์ด ๋ฐ์ํ๋ฉด, ๋๋ค ํจ์๊ฐ ํธ์ถ๋๊ณ my_function์ด ํธ์ถ๋๋ค.arg1๊ณผ arg2๋ ๋๋ค ํจ์์์ ์ง์ ์ ๋ฌ๋๋ค. functools.partial ์ฌ์ฉํ๊ธฐimport functoolsa..
0 2023.07.08 -
PyQt QClipboard.Clipboard์ QClipboard.Selection์ ์ฐจ์ด์
PyQt5์์ QClipboard.Clipboard์ QClipboard.Selection์ ์ฐจ์ด์ ๋ค์ด๊ฐ๋ฉฐQClipboard.Clipboard์ QClipboard.Selection์ PyQt์์ ํด๋ฆฝ๋ณด๋์ ๋ฐ์ดํฐ๋ฅผ ์ค์ ๋ฐ ๊ฐ์ ธ์ค๋ ๋ฐฉ๋ฒ์ ์ง์ ํ๋ ์์์ด๋ค. ์ฌ์ฉ๋ฒ๋ค์ ๋ชจ๋์ importํ์ฌ ํด๋ฆฝ๋ณด๋ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์๋ค.from PyQt5.QtGui import QClipboard ์ฌ์ฉ ์def copyElementNameToClipboard(self): name = self.sender().text() app = QApplication.instance() clipboard = app.clipboard() clipboard.setText(name, QClipb..
0 2023.07.07 -
PyQt ์ปค์คํ ์์ด์ฝ ํจํค์ง(fugueicons) ์ค์น ๋ฐ ์ฌ์ฉํด๋ณด๊ธฐ
PyQt ์ปค์คํ ์์ด์ฝ ํจํค์ง(fugueicons) ์ค์น ๋ฐ ์ฌ์ฉํด๋ณด๊ธฐ ๋ค์ด๊ฐ๋ฉฐ PyQt์๋ ๊ธฐ๋ณธ ์์ด์ฝ ํฉ์ด ์์ง๋ง(์ฐธ๊ณ ), ์์ด์ฝ์ ์ข ๋ฅ๊ฐ ์ ๋ค. ๊ทธ๋์ ์ปค์คํ ์์ด์ฝ ํจํค์ง(fugueicons)๋ฅผ ์ค์นํ์ฌ ์ฌ์ฉํ ์ ์๋ค. ๋ฐฉ๋ฒ pyqt5-fugeicons ํจํค์ง ์ค์นํ๊ธฐ ํฐ๋ฏธ๋์์ ๋ค์ ๋ช ๋ น์ ์คํํ์ฌ pyqt5-fugeicons ํจํค์ง๋ฅผ ์ค์นํ๋ค. > pip install pyqt5-fugueicons ์์ด์ฝ ์ฌ์ฉํด๋ณด๊ธฐ ๋ค์๊ณผ ๊ฐ์ด ๋ชจ๋์ ๋ถ๋ฌ์fugeicons์ ์์ด์ฝ์ ์ฌ์ฉํด๋ณผ ์ ์๋ค. import pyqt5_fugueicons as fugue icon() ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ์์ด์ฝ์ ๋ถ๋ฌ์ฌ ์ ์๋ค. PyQt ๊ธฐ๋ณธ ์์ด์ฝํฉ์ ์์ด์ฝ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ๊ณผ ์ ์ฌํ๋ค. QActi..
0 2023.07.05 -
PyQt style().standardIcon() ๋ฉ์๋์์ ์ฌ์ฉํ ์ ์๋ ์์ด์ฝ ์ข ๋ฅ ๋ฐ ์ซ์
PyQt style().standardIcon() ๋ฉ์๋์์ ์ฌ์ฉํ ์ ์๋ ์์ด์ฝ ์ข ๋ฅ ๋ฐ ์ซ์ ๋ค์ด๊ฐ๋ฉฐ PyQt์๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ด์ฅ๋์ด ์๋ ํ์ค ์์ด์ฝ(Standard Icon)๋ค์ด ์๋ค. ์์ด์ฝ ํ์ผ์ ์ง์ ๊ตฌํ์ง ์๊ณ ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก, ํ๋ก๊ทธ๋จ์ ๋ง๋ค ๋ ํ์ฉํ๋ฉด ์ ์ฉํ๋ค. ์์ด์ฝ ํ์ธํด๋ณด๊ธฐ import sys from PyQt5.QtWidgets import QApplication, QGridLayout, QPushButton, QStyle, QWidget class Window(QWidget): def __init__(self): super(Window, self).__init__() icons = sorted([attr for attr in dir(QStyle) if attr.start..
1 2023.05.17 -
PyQt PyQt5์์ QWebView ์ฌ์ฉํ๊ธฐ
PyQt5์์ QWebView ์ฌ์ฉํ๊ธฐ๋ค์ด๊ฐ๋ฉฐ์๋ PyQt์์ QWebView ์์ ฏ์ ์ฌ์ฉํ ์ ์์์ผ๋, PyQt5์์๋ถํฐ๋ ๋ ์ด์ ๊ธฐ๋ณธ์ผ๋ก ์ ๊ณต๋์ง ์๊ฒ ๋์๋ค.๋ฐ๋ผ์ QWebView ์์ ฏ์ ์ฌ์ฉํ๋ ค๋ฉด QWebEngineView ๋ชจ๋์ ์ฌ์ฉํด์ผ ํ๋ค. ๊ทธ๋ฆฌ๊ณ QWebView ๊ฐ์ฒด๊ฐ ์๋, QWebEngineView ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ค. ๋ฐฉ๋ฒ๋ค์์ ๋ช ๋ น์ ํฐ๋ฏธ๋์์ ์คํํ์ฌ QWebEngineView๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด ํ์ํ ํจํค์ง๋ฅผ ์ค์นํ๋ค.> pip install PyQtWebEngine ๋ค์๊ณผ ๊ฐ์ด import ํ์ฌ ์ฌ์ฉํ๋ค.from PyQt5.QtCore import QUrlfrom PyQt5.QtWidgets import QApplication, QWidgetfrom Py..
0 2023.05.16 -
PyQt ๊ตฌ๊ธ ๋ฒ์ญ๊ธฐ ํ๋ก๊ทธ๋จ ๋ง๋ค๊ธฐ & "'NoneType' object has no attribute 'group'" ์ด์ ํด๊ฒฐํ๊ธฐ
PyQt๋ก ๊ตฌ๊ธ ๋ฒ์ญ๊ธฐ ํ๋ก๊ทธ๋จ ๋ง๋ค๊ธฐ๋ค์ด๊ฐ๋ฉฐPyQt๋ฅผ ์ด์ฉํ์ฌ ๊ฐ๋จํ๊ฒ ํ๊ธ์ ๋ฌธ์ฅ์ ์์ด ๋ฌธ์ฅ์ผ๋ก ๋ฒ์ญํ๋ ํ๋ก๊ทธ๋จ์ ๋ง๋ค์ด๋ณด์.์ด๋, ๋ฌด๋ฃ๋ก ์ฌ์ฉํ ์ ์๋ ๊ตฌ๊ธ ๋ฒ์ญ๊ธฐ ํจํค์ง(googletrans)๋ฅผ ์ฌ์ฉํ๋๋ก ํ๋ค. ์ฝ๋import sysfrom PyQt5.QtWidgets import *from googletrans import Translatorclass MyApp(QWidget): def __init__(self): super().__init__() self.lbl1 = QLabel('ํ๊ตญ์ด:', self) self.lbl2 = QLabel('์์ด:', self) self.le = QLineEdit(self) self..
0 2023.05.15 -
PyQt self.width()์ self.height()๋ฅผ ์ฌ์ฉํ ๋, ์คํ์ฐฝ์ด ํ๊ธฐ๋ ๊ฒฝ์ฐ ํด๊ฒฐ ๋ฐฉ๋ฒ
PyQt์์ self.width()์ self.height()๋ฅผ ์ฌ์ฉํ ๋, ์คํ์ฐฝ์ด ํ๊ธฐ๋ ๊ฒฝ์ฐ ํด๊ฒฐ ๋ฐฉ๋ฒ๋ค์ด๊ฐ๋ฉฐPyQt์์ self.width()์ self.height()๋ฅผ ์ฌ์ฉํ ๋, ์คํ์ฐฝ์ด ํ๊ธฐ๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.์๋ฅผ ๋ค์ด, self.width() ๊ฐ๊ณผ self.height() ๊ฐ์ ์ง์ ์ ์๋ก ๋๋์ด ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์คํ์ฐฝ์ด ํ๊ธฐ๊ฒ ๋๋ค.qp.drawPoint(self.width() / 2, self.height() / 2) ํด๊ฒฐ ๋ฐฉ๋ฒself.width() / 2์ self.height() / 2์ ๊ฒฐ๊ณผ๊ฐ์ด ์ค์ํ(Float)์ด๊ธฐ ๋๋ฌธ์ ์คํ์ฐฝ์ด ํ๊ธฐ๊ฒ ๋๋ ๊ฒ์ด๋ค.๋ฐ๋ผ์ ๋ค์๊ณผ ๊ฐ์ด ์ ์ํ ํ์ ๋ณํ ํจ์ int()๋ฅผ ์ฌ์ฉํด์ค์ผ ํ๋ค.qp.drawPoint(int(se..
0 2023.05.14