Creating first a dummy "hello world" dialog/window, how to display it from taskbar/menu on MacOS. Thanks.
Asked
Active
Viewed 156 times
1 Answers
0
If I understood your question,
you wanted to open a QDialog
from the menu bar of a QMainWindow
, right?
For that this is a simple approach:
import sys
from PySide2.QtCore import Slot
from PySide2.QtWidgets import (QApplication, QMainWindow, QAction,
QDialog, QLabel, QHBoxLayout)
class Dialog(QDialog):
def __init__(self):
QDialog.__init__(self)
layout = QHBoxLayout()
layout.addWidget(QLabel("Hello World"))
self.setLayout(layout)
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.menu = self.menuBar()
self.test_menu = self.menu.addMenu("Test")
self.hello_action = QAction("hello", self)
self.hello_action.triggered.connect(self.hello_dialog)
self.test_menu.addAction(self.hello_action)
@Slot()
def hello_dialog(self, checked):
dialog = Dialog()
dialog.exec_()
if __name__ == "__main__":
app = QApplication()
window = MainWindow()
window.show()
sys.exit(app.exec_())

cmaureir
- 285
- 2
- 8
-
No, what I want is to show a dialog or window, an integrate in the menubar of the MacOS taskbar/menu!! Not to open from a menu which needs to have even an open window. Like this: https://stackoverflow.com/questions/54104947/create-taskbar-menu-application-python-pyside2-for-macos – eddy2k Jan 17 '19 at 03:25