mborgerson / pyside6_qtads

Python bindings to Qt Advanced Docking System for PySide6
Other
22 stars 9 forks source link

error using addAutoHideDockWidget / SideBarLocation #23

Closed RubendeBruin closed 8 months ago

RubendeBruin commented 1 year ago

First of all thanks for making ADS this available in PySide6.

I'm trying to use the addAutoHideDockWidget function but can not get it to work. From the examples it seems that it expects a first argument of type SideBarLocation, for example SideBarRight However I can not find that enum in PySide6QtAds.

It is defined in ads_globals.sip. The other enum values from that file do seems to be present in PySide6QtAds.

Reproduce:

from PySide6.QtWidgets import (
        QApplication,
        QMainWindow,
        QLabel,
    )
import PySide6QtAds

app = QApplication()
mw = QMainWindow()

PySide6QtAds.CDockManager.setAutoHideConfigFlag(PySide6QtAds.CDockManager.DefaultAutoHideConfig)

contents = QLabel("Main Widget")
contents.setStyleSheet("background-color: lightblue;")

central_dock = PySide6QtAds.CDockWidget("Central Dock", mw)
central_dock.setWidget(contents)

dock_manager = PySide6QtAds.CDockManager(mw)

central_dock_area = dock_manager.setCentralWidget(central_dock)
central_dock_area.setAllowedAreas(PySide6QtAds.DockWidgetArea.OuterDockAreas)

side_contents = QLabel("Side dock (auto-hide)")
side_contents.setStyleSheet("background-color: lightyellow;")

dock = PySide6QtAds.CDockWidget("Demo", mw)
dock.setWidget(side_contents)

# Would expect to work
"""
    enum SideBarLocation
    {
        SideBarTop,
        SideBarLeft,
        SideBarRight,
        SideBarBottom,
        SideBarNone
    };
"""

dock_manager.addAutoHideDockWidget(PySide6QtAds.SideBarRight, dock)  # <-- AttributeError: module 'PySide6QtAds' has no attribute 'SideBarRight'

# Works (work-around)
dock_manager.addDockWidget(PySide6QtAds.DockWidgetArea.RightDockWidgetArea, dock)
mw.show()
dock.setAutoHide(True)

app.exec()

Running Python 3.11 on Windows

RubendeBruin commented 1 year ago

It seems that SideBarLocation is not imported from _ads. The following does work:

dock_manager.addAutoHideDockWidget(PySide6QtAds._ads.SideBarLocation.SideBarRight, dock) 

it can be solved by adding

SideBarLocation = _ads.SideBarLocation

to __init__.py

are PRs accepted?