Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 애플
- Home Assistant
- 월패드
- 배당
- 힐스테이트 광교산
- 홈네트워크
- Bestin
- 파이썬
- raspberry pi
- RS-485
- Python
- 라즈베리파이
- 현대통신
- 오블완
- 공모주
- matter
- 국내주식
- 매터
- MQTT
- 해외주식
- Espressif
- ConnectedHomeIP
- 나스닥
- 티스토리챌린지
- esp32
- 미국주식
- 취미생활
- Apple
- 마이크로소프트
- homebridge
Archives
- Today
- Total
YOGYUI
PyQt5 - QMenuBar location in macOS 본문
반응형

Mac OS에서 PyQt5로 윈도우를 만들어서 메뉴바를 추가하면 default로 상단 작업표시줄에 메뉴바가 표시된다
(테스트 당시 OSX 버전은 11.5.2, PyQt5 버전은 5.15.4)
[테스트 코드]
if __name__ == '__main__':
import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
app = QCoreApplication.instance()
if app is None:
app = QApplication(sys.argv)
window = QMainWindow()
menubar = QMenuBar(window)
window.setMenuBar(menubar)
menu1 = QMenu('Menu1', menubar)
menubar.addAction(menu1.menuAction())
mb1 = QAction('menu 1-1')
menu1.addAction(mb1)
menu2 = QMenu('Menu2', menubar)
menubar.addAction(menu2.menuAction())
mb2 = QAction('menu 2-1')
menu2.addAction(mb2)
window.show()
app.exec_()

메뉴바가 작업표시줄로 옮겨가기 때문에, 평소 Windows OS와 UI가 달라진다
개인적인 느낌인 (워낙에 앱등이인지라) Mac OS의 UX가 훨씬 보기 좋다 ㅎㅎ
(굳이) OS 환경에 상관없이 메뉴바를 동일하게 QMainWindow의 타이틀바 아래에 위치하게 하고 싶다면 QMenuBar의 'nativeMenuBar' 속성을 False로 설정해주면 된다

if __name__ == '__main__':
# ...
window = QMainWindow()
menubar = QMenuBar(window)
window.setMenuBar(menubar)
menubar.setNativeMenuBar(False) # 추가
# ...

반응형
'Software > Python' 카테고리의 다른 글
pandas - 중복된 요소 넘버링하기 (0) | 2021.12.15 |
---|---|
pandas - 데이터프레임 데이터형(dtype) 확인 (0) | 2021.09.21 |
PyQt5 - QtWebEngine Chromium Version 확인하기 (0) | 2021.09.10 |
PyQt5 - QtWebEngine::웹브라우저 만들기 (3) (0) | 2021.09.06 |
PyQt5 - QtWebEngine::웹브라우저 만들기 (2) (0) | 2021.09.05 |