IT/PyQt5(22)
-
[PyQt5] 라벨, 스타일, 색상, 선
라벨이라는 기능을 사용하여 텍스트를 출력할 수 있습니다. 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: #..
2020.02.11 -
[PyQt5] 시간, 날짜,
날짜와 시간을 계산하는 것은 프로그램의 기본이다. 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)}') 출력하는 포멧에 맞추어 날짜가 변경되는 것을 볼 수 있..
2020.02.11 -
[PyQt5] 위치, 정렬, 가운데, 화면
창을 화면 가운데로 옮기는 기능입니다. 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..
2020.02.11 -
[PyQt5] 메뉴, 아이콘, 메뉴바
상단 메뉴바는 무척 많이 사용하는 기능입니다. 단순히 글자만 있는 것보다는 아이콘과 같이 조합하면 멋진 메뉴바를 만들 수 있습니다. 간단히 닫기 메뉴바를 만들어봅니다. 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..
2020.02.11 -
[PyQt5] 메뉴, 아이콘, 메뉴바
상단의 메뉴바를 만드는 기능입니다. 간단히 닫기 버튼을 만들어봅니다. import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QAction, qApp from PyQt5.QtGui import QIcon class mainbar(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): exitAction = QAction(QIcon('files/exit.png'),'닫기', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('창을 닫습니다.') exitAction.triggered.con..
2020.02.11 -
[PyQt5] 상태바, 하단바
모든 윈도우 창은 상태바를 가지고 있습니다. 날짜나 상태, 파일 정보 등 다양한 정보를 표시하는 용도로 사용됩니다. 상태창에 원하는 내용을 표시하는 기능을 알아봅니다. import sys from PyQt5.QtWidgets import QApplication, QMainWindow class stateApp(QMainWindow): def __init__(self): super().__init__() self.initUI() def initUI(self): self.statusBar().showMessage('상태바입니다.') self.setWindowTitle('상태바') self.setGeometry(500,500,200,50) self.show() if __name__ == '__main__': ..
2020.02.11