[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Upgrading from static to dock widgets?
From:       Matic Kukovec <kukovecmatic () hotmail ! com>
Date:       2019-06-27 10:36:36
Message-ID: VI1PR01MB5344F6E50AFFA1DE92BEB3E4D7FD0 () VI1PR01MB5344 ! eurprd01 ! prod ! exchangelabs ! com
[Download RAW message or body]

Hey Kyle,

If it was ported, it would be exactly what I need.
Unfortunately, I don't have any experience with SIP to be able to do it. But I will \
look into it, thanks.

If anyone else has other suggestions/solutions, please let me know.

Regards,
Matic
From: Kyle Altendorf <sda@fstab.net>
Sent: Wednesday, June 26, 2019 1:23 PM
To: Matic Kukovec
Cc: pyqt@riverbankcomputing.com
Subject: Re: [PyQt] Upgrading from static to dock widgets?


Side note, perhaps something like below would be of interest to you.  It would \
require wrapping it for Python but hopefully SIP would make that 'easy'.  I've been \
meaning to do that myself for awhile but haven't gotten to it yet.

https://github.com/richardjdare/Qt-Advanced-Docking-System

Cheers,

-kyle

On 2019-06-26 05:33, Matic Kukovec wrote:

Hi guys,

I have an application that uses three QTabWidgets in a QGroupBox as the central \
widget. This works great and I have implemented dragging of tabs between these three \
widgets.

To upgrade to docking, I would wrap each QTabWidget in a QDockWidget and remove it's \
titlebar with 'setTitleBarWidget', as I don't want a titlebar. I would also remove \
the central widget and just have three QDockWidget's docked somewhere. My questions \
are:

  *   I would upgrade the QTabWidget to wrap a dragged tab by putting it inside a new \
QTabWidget and putting it into a QDockWidget automatically on the fly. How can I then \
manually initiate a 'dock move' when I drag one of the tabs from a QTabWidget after \
                the dragged tab widget was wrapped as described in the previous \
                sentence?
  *   I tried playing around with QDockWidgets to figure out how to make them movable \
to any space (above, below, left, right) of any other QDockWidget, but the way in \
which they can be moved is limited to what area they were initialized in. For example \
if I add 4 dockwidgets to the QMainWindow with the \
'self.addDockWidget(Qt.TopDockWidgetArea, dockwidget)', I can only move them \
side-by-side, I cannot move one above or below another. What am I missing? My test \
Example: from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys

class Window(QMainWindow):
    def __init__(self):
        super().__init__()

        title = "DockAble Application"
        top = 400
        left = 400
        width = 600
        height = 500

        self.setWindowTitle(title)
        self.setGeometry(top,left, width, height)

        self.dockAble()

    def dockAble(self):
        for i in range(3):
            dock = QDockWidget("Test widget", self)
            dock.setAllowedAreas(Qt.AllDockWidgetAreas)
            self.addDockWidget(Qt.TopDockWidgetArea, dock)

app = QApplication(sys.argv)
window = Window()
window.show()
app.exec()


Thanks,
Matic


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com<mailto:PyQt@riverbankcomputing.com>
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Hey guys,

I've got the docking anywhere working correctly, didn't know that at least one widget \
inside a dockwidget is needed for the docking to work correctly.

Now I am trying to emulate the behavior of click&dragging the dockwidget's titlebar, \
by having it work exactly the same when click&dragging the dockwidget's child's tab \
bar. I'm working with this example: from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys

class Window(QMainWindow):
    def __init__(self):
        super().__init__()

        title = "DockAble Application"
        top = 400
        left = 400
        width = 600
        height = 500

        self.setWindowTitle(title)
        self.setGeometry(top,left, width, height)

        self.dockAble()
        self.setDockOptions(self.dockOptions() & ~QMainWindow.AnimatedDocks)
        self.setDockNestingEnabled(True)

    def dockAble(self):
        for i in range(4):
            dock = QDockWidget("Employee", self)
            dock.setFloating(False)
            dock.setAllowedAreas(Qt.AllDockWidgetAreas)
            self.employee = ["John", "Doe", "Parwiz", "Bob"]
            tabw = QTabWidget(dock)
            listw = QListWidget(tabw)
            listw.addItems(self.employee)
            tabw.addTab(listw, "MyTab")
            dock.setWidget(tabw)
            self.addDockWidget(Qt.TopDockWidgetArea, dock)

app = QApplication(sys.argv)
window = Window()
window.show()
app.exec()

Can anyone give me a hint of where to start?

Thanks,
Matic


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div>
<div>
<div>
<div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; \
color:rgb(0,0,0)"> <blockquote style="border-color:rgb(200,200,200); border-left:3px \
solid rgb(200,200,200); padding-left:1ex; margin-left:0.8ex; color:rgb(102,102,102)"> \
<div> <div>
<div>
<div dir="ltr">
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
Hey Kyle,</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
<br>
</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
If it was ported, it would be exactly what I need.<br>
Unfortunately, I don't have any experience with SIP to be able to do it. But I will \
look into it, thanks.</div> <div style="color:black; font-size:12pt; \
font-family:Calibri,Helvetica,sans-serif"> <br>
</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
If anyone else has other suggestions/solutions, please let me know.<br>
</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
<br>
</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
Regards,<br>
</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
Matic<br>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div dir="ltr">
<div dir="ltr"><font style="font-size:11pt" face="Calibri,sans-serif" \
color="black"><b>From:</b> Kyle Altendorf &lt;sda@fstab.net&gt;<br> <b>Sent:</b> \
Wednesday, June 26, 2019 1:23 PM<br> <b>To:</b> Matic Kukovec<br>
<b>Cc:</b> pyqt@riverbankcomputing.com<br>
<b>Subject:</b> Re: [PyQt] Upgrading from static to dock widgets?</font>
<div>&nbsp;</div>
</div>
<div style="font-size:10pt">
<p style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; \
margin-top:0; margin-bottom:0"> Side note, perhaps something like below would be of \
interest to you.&nbsp; It would require&nbsp;wrapping it for Python but hopefully SIP \
would make that 'easy'.&nbsp; I've been meaning to do that myself for awhile but \
haven't gotten to it yet.</p> <p style="margin-top: 0px; margin-bottom: \
0px;margin-top:0px; margin-bottom:0px; margin-top:0; margin-bottom:0"> <a \
href="https://github.com/richardjdare/Qt-Advanced-Docking-System" target="_blank" \
rel="noopener noreferrer">https://github.com/richardjdare/Qt-Advanced-Docking-System</a></p>
 <p style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; \
margin-top:0; margin-bottom:0"> Cheers,</p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; \
                margin-top:0; margin-bottom:0">
-kyle</p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<div>
<div dir="ltr">
<div style="font-size:10pt">
<p style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px; \
margin-top:0; margin-bottom:0"> On 2019-06-26 05:33, Matic Kukovec wrote:</p>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
Hi guys,</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
&nbsp;</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
I have an application that uses three QTabWidgets in a QGroupBox as the central \
widget.<br> This works great and I have implemented dragging of tabs between these \
three widgets.</div> <div style="color:black; font-size:12pt; \
font-family:Calibri,Helvetica,sans-serif"> &nbsp;</div>
<div style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif">
To upgrade to docking, I would wrap each QTabWidget in a QDockWidget and remove it's \
titlebar with 'setTitleBarWidget', as I don't want a titlebar. I would also remove \
the central widget and just have three QDockWidget's docked somewhere.</div> <div \
style="color:black; font-size:12pt; font-family:Calibri,Helvetica,sans-serif"> My \
questions are:</div> <ul>
<li><span style="font-family:Calibri,Helvetica,sans-serif">I would upgrade the \
QTabWidget to wrap a dragged tab by putting it inside a new QTabWidget and putting it \
into a QDockWidget automatically on the fly.<br> How can I then manually initiate a \
'dock move' when I drag one of the tabs from a QTabWidget after the dragged tab \
widget was wrapped as described in the previous sentence?</span></li><li><span \
style="font-family:Calibri,Helvetica,sans-serif">I tried playing around with \
QDockWidgets to figure out how to make them movable to any space (above, below, left, \
right) of any other QDockWidget, but the way in which they can be moved is limited to \
what area they were initialized in. For example if I add 4 dockwidgets to the \
QMainWindow with the '</span><span \
style="font-family:Calibri,Helvetica,sans-serif">self.addDockWidget(Qt.TopDockWidgetArea, \
dockwidget)</span><span style="font-family:Calibri,Helvetica,sans-serif">',  I can \
only move them side-by-side, I cannot move one above or below another. What am I \
missing? My test Example:</span><br> <span \
style="font-family:Calibri,Helvetica,sans-serif"></span><span \
style="font-family:Calibri,Helvetica,sans-serif"><span><span \
style="line-height:normal">from PyQt5.QtWidgets import *</span><span><br> \
</span></span></span> <div><span style="line-height:normal">from PyQt5.QtGui import \
*</span></div> <div><span style="line-height:normal">from PyQt5.QtCore import \
*</span></div> <div><span style="line-height:normal">import sys</span></div>
<div>&nbsp;</div>
<div><span style="line-height:normal">class Window(QMainWindow):</span></div>
<div><span style="line-height:normal">&nbsp; &nbsp; def __init__(self):</span></div>
<div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; \
super().__init__()</span></div> <div>&nbsp;</div>
<div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; title = \
&quot;DockAble Application&quot;</span></div> <div><span \
style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; top = 400</span></div> \
<div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; left = \
400</span></div> <div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; \
width = 600</span></div> <div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; \
&nbsp; height = 500</span></div> <div>&nbsp;</div>
<div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; \
self.setWindowTitle(title)</span></div> <div><span style="line-height:normal">&nbsp; \
&nbsp; &nbsp; &nbsp; self.setGeometry(top,left, width, height)</span></div> \
<div>&nbsp;</div> <div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; \
self.dockAble()</span></div> <div>&nbsp;</div>
<div><span style="line-height:normal">&nbsp; &nbsp; def dockAble(self):</span></div>
<div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; for i in \
range(3):</span></div> <div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; dock = QDockWidget(&quot;Test widget&quot;, self)</span></div> \
<div><span style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
dock.setAllowedAreas(Qt.AllDockWidgetAreas)</span></div> <div><span \
style="line-height:normal">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
self.addDockWidget(Qt.TopDockWidgetArea, dock)</span></div> <div>&nbsp;</div>
<div><span style="line-height:normal">app = QApplication(sys.argv)</span></div>
<div><span style="line-height:normal">window = Window()</span></div>
<div><span style="line-height:normal">window.show()</span></div>
<span style="font-family:Calibri,Helvetica,sans-serif"><span \
style="line-height:normal">app.exec()</span></span></li></ul> <div><span \
style="font-family:Calibri,Helvetica,sans-serif"><span style="font-size:12pt; \
line-height:normal">&nbsp;</span></span></div> <div><span \
style="font-family:Calibri,Helvetica,sans-serif"><span style="font-size:12pt; \
line-height:normal">Thanks</span><span \
style="line-height:normal">,</span></span></div> <div><span \
style="font-family:Calibri,Helvetica,sans-serif"><span style="font-size:12pt; \
line-height:normal">Matic</span><span style="line-height:normal"><br> \
</span></span></div> <div>&nbsp;</div>
<br>
<div style="font-family:monospace; margin:0; \
padding:0">_______________________________________________<br> PyQt mailing list \
&nbsp;&nbsp;&nbsp;<a href="mailto:PyQt@riverbankcomputing.com" target="_blank" \
rel="noopener noreferrer">PyQt@riverbankcomputing.com</a><br> <a \
href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank" \
rel="noopener noreferrer">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></div>
 </div>
</div>
</div>
</div>
</div>
</blockquote>
<div>Hey guys,</div>
<div><br>
</div>
<div>I've got the docking anywhere working correctly, didn't know that at least one \
widget inside a dockwidget is needed for the docking to work correctly.</div> \
<div><br> </div>
<div>Now I am trying to emulate the behavior of click&amp;dragging the dockwidget's \
titlebar, by having it work exactly the same when click&amp;dragging the dockwidget's \
child's tab bar. I'm working with this example:</div> <blockquote style="margin-top: \
0px; margin-bottom: 0px;"> <div><span style="font-size: 10pt; line-height: \
normal;">from PyQt5.QtWidgets import *</span><span><br> </span>
<div><span style="font-size: 10pt; line-height: normal;">from PyQt5.QtGui import \
*</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">from PyQt5.QtCore import \
*</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">import sys</span><br>
</div>
</div>
<div>
<div><br>
</div>
<div><span style="font-size: 10pt; line-height: normal;">class \
Window(QMainWindow):</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; def \
__init__(self):</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
super().__init__()</span><br> </div>
<div><br>
</div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
title = &quot;DockAble Application&quot;</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
top = 400</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
left = 400</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
width = 600</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
height = 500</span><br> </div>
<div><br>
</div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
self.setWindowTitle(title)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
self.setGeometry(top,left, width, height)</span><br> </div>
<div><br>
</div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
self.dockAble()</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
self.setDockOptions(self.dockOptions() &amp; ~QMainWindow.AnimatedDocks)</span><br> \
</div> <div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; \
&nbsp; self.setDockNestingEnabled(True)</span><br> </div>
<div><br>
</div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; def \
dockAble(self):</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
for i in range(4):</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; dock = QDockWidget(&quot;Employee&quot;, self)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; dock.setFloating(False)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; dock.setAllowedAreas(Qt.AllDockWidgetAreas)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; self.employee = [&quot;John&quot;, &quot;Doe&quot;, &quot;Parwiz&quot;, \
&quot;Bob&quot;]</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; tabw = QTabWidget(dock)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; listw = QListWidget(tabw)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; listw.addItems(self.employee)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; tabw.addTab(listw, &quot;MyTab&quot;)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; dock.setWidget(tabw)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; self.addDockWidget(Qt.TopDockWidgetArea, dock)</span><br> </div>
<div><br>
</div>
<div><span style="font-size: 10pt; line-height: normal;">app = \
QApplication(sys.argv)</span><br> </div>
<div><span style="font-size: 10pt; line-height: normal;">window = Window()</span><br>
</div>
<div><span style="font-size: 10pt; line-height: normal;">window.show()</span><br>
</div>
<span style="font-size: 10pt; line-height: normal;">app.exec()</span><br>
</div>
</blockquote>
<div><br>
</div>
<div>Can anyone give me a hint of where to start?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Matic<br>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>


[Attachment #4 (unknown)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic