Tabbed menubar
-
Do you mean the ribbon? Yes, but there's no ready made componenent like that in Qt. You'd have to build it yourself with QTabBar, QStackedWidget, QFrame etc.
Of course people already did it, so if you don't want to write that yourself you can buy a ready solution like QtitanRibbon or find an open source implementation like qt-ribbon. -
@Chris-Kawa yeah, ribbon. I need it in Python unfortunately.
-
QtitanRibbon at least seems to have python bindings. I'm sure if you google for it you'll find more options. It's not exactly new or unusual concept.
-
@burrito22 said in Tabbed menubar:
I was searching for definition of QTabWidget class but found nothing
Really? The first link in a Google search gives you the C++ QTabWidget docs, and the second link gives you a Pythonic version.
Is there any docs/tutorials to help defining such a thing on my own?
You could model you own Python version on the GPLv3 qt-ribbon already referenced.
-
class QMenuBar(QWidget): def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... def setNativeMenuBar(self, nativeMenuBar: bool) -> None: ... def isNativeMenuBar(self) -> bool: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... def event(self, a0: QtCore.QEvent) -> bool: ... def eventFilter(self, a0: QtCore.QObject, a1: QtCore.QEvent) -> bool: ... def focusInEvent(self, a0: QtGui.QFocusEvent) -> None: ... def focusOutEvent(self, a0: QtGui.QFocusEvent) -> None: ... def actionEvent(self, a0: QtGui.QActionEvent) -> None: ... def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... def paintEvent(self, a0: QtGui.QPaintEvent) -> None: ... def leaveEvent(self, a0: QtCore.QEvent) -> None: ... def mouseMoveEvent(self, a0: QtGui.QMouseEvent) -> None: ... def mousePressEvent(self, a0: QtGui.QMouseEvent) -> None: ... def mouseReleaseEvent(self, a0: QtGui.QMouseEvent) -> None: ... def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: ... def changeEvent(self, a0: QtCore.QEvent) -> None: ... def initStyleOption(self, option: 'QStyleOptionMenuItem', action: QAction) -> None: ... def hovered(self, action: QAction) -> None: ... def triggered(self, action: QAction) -> None: ... def setVisible(self, visible: bool) -> None: ... def cornerWidget(self, corner: QtCore.Qt.Corner = ...) -> QWidget: ... def setCornerWidget(self, widget: QWidget, corner: QtCore.Qt.Corner = ...) -> None: ... def actionAt(self, a0: QtCore.QPoint) -> QAction: ... def actionGeometry(self, a0: QAction) -> QtCore.QRect: ... def heightForWidth(self, a0: int) -> int: ... def minimumSizeHint(self) -> QtCore.QSize: ... def sizeHint(self) -> QtCore.QSize: ... def isDefaultUp(self) -> bool: ... def setDefaultUp(self, a0: bool) -> None: ... def setActiveAction(self, action: QAction) -> None: ... def activeAction(self) -> QAction: ... def clear(self) -> None: ... def insertSeparator(self, before: QAction) -> QAction: ... def insertMenu(self, before: QAction, menu: QMenu) -> QAction: ... def addSeparator(self) -> QAction: ... @typing.overload def addMenu(self, menu: QMenu) -> QAction: ... @typing.overload def addMenu(self, title: str) -> QMenu: ... @typing.overload def addMenu(self, icon: QtGui.QIcon, title: str) -> QMenu: ... @typing.overload def addAction(self, action: QAction) -> None: ... @typing.overload def addAction(self, text: str) -> QAction: ... @typing.overload def addAction(self, text: str, slot: PYQT_SLOT) -> QAction: ...
that's in QWidgets.pyi only. In brackets are arguments, but the body is empty.....
-
@burrito22
The file you have there is an interface definition (mostly of use to Python IDEs I expect). If you want to see how QMenuBar is implemented you need to look at the C++ sources. There is no Python implementation of QMenuBar, there is only binary glue that loads and uses the compiled Qt library when the Python is executed. The same is true for all the Qt classes exposed in Python:Python interface <-> minimal glue code <-> Qt library.
If you want to know how to compose standard widgets into a ribbon-like structure with a degree of flexibility then you could try a Python reimplementation of the C++ open-source example (or a usable subset).
Alternatively, you could build the glue that provides Python interfaces to a binary qt-ribbon. Tools like SWIG help but you need to understand both Python and C++ internals. I think this is the harder row to hoe.