라벨이라는 기능을 사용하여 텍스트를 출력할 수 있습니다. import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout class stylesheetApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): red_label = QLabel('빨간 라벨') blue_label = QLabel('파란 라벨') green_label = QLabel('초록 라벨') red_label.setStyleSheet("color: #FF5733; border-style: solid; border-width: 2px; border-color: #..
날짜와 시간을 계산하는 것은 프로그램의 기본이다. from PyQt5.QtCore import QDate, Qt now = QDate.currentDate() print(f'-> now : {now.toString()}') print(f'-> now yy-M-d : {now.toString("yy-M-d")}') print(f'-> now yyyy-MMMM-ddd : {now.toString("yyyy-MMMM-ddd")}') print(f'-> now ISODate : {now.toString(Qt.ISODate)}') print(f'-> now DefaultLocal : {now.toString(Qt.DefaultLocaleLongDate)}') 출력하는 포멧에 맞추어 날짜가 변경되는 것을 볼 수 있..
창을 화면 가운데로 옮기는 기능입니다. import sys from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget class centerApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.setWindowTitle('가운데로') self.resize(200,200) self.center() self.show() def center(self): frame_info = self.frameGeometry() print(f'-> frame_info : {frame_info}') display_center = QDesktopWidget().av..
상단 메뉴바는 무척 많이 사용하는 기능입니다. 단순히 글자만 있는 것보다는 아이콘과 같이 조합하면 멋진 메뉴바를 만들 수 있습니다. 간단히 닫기 메뉴바를 만들어봅니다. import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QAction, qApp from PyQt5.QtGui import QIcon class toolbar(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): exitAction = QAction(QIcon('./files/exit2.png'), '닫기', self) exitAction.setShortcut('Ctrl+Q') e..