Thanks Justin. I didn't realize that I could use that same method!
I have a couple of questions:
- Do you know if there is a way to get the results of
*self.findChildren(QtGui.QDockWidget)
*in order of visual appearance? I'm not sure what's defining the order
in which they appear but they seem to be different every tme that I select
one of the Docks. Ideally, I'd like to get *the current Dock* and know
which docks I have *to each side* to determine if I can/should use
*self.tabifyDocWidget()*.
- When I right click on the title of a *Dock*, it triggers a menu. This
menu is also shared with toolbars to define what's visible and whatnot.
Ideally I want to have different menus depending on which is the item in
which I right click. I've been able to get rid of the menu by using the
following in my *QMainWindow*:
def createPopupMenu(self):
pass
Does that mean that I will need to overload this method, check what's under
the cursor and depending on that, create the menu? Or is there another way
to do this?
Thanks in advance
--
David Martinez - Technical Animator
Email: [email protected]
Website: http://www.elusiveideas.com
On Fri, Aug 22, 2014 at 10:11 PM, Justin Israel <[email protected]>
wrote:
> You can keep using the tabify method to switch the order of the tabs.
> tabifyDockWidget(under, over)
>
> import random
> class MainWin(QtGui.QMainWindow):
>
> def __init__(self):
> super(MainWin, self).__init__()
>
> prev = None
> for i in xrange(5):
> d = QtGui.QDockWidget("Dock %d" % i, self)
> self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, d)
> if prev:
> self.tabifyDockWidget(prev, d)
> prev = d
>
> t = QtCore.QTimer(self)
> t.timeout.connect(self.randomTab)
> t.start(2000)
>
> def randomTab(self):
> a, b = random.sample(self.findChildren(QtGui.QDockWidget), 2)
> print "Setting %s over %s" % (b.windowTitle(), a.windowTitle())
> self.tabifyDockWidget(a, b)
>
>
>
>
>
> On Sat, Aug 23, 2014 at 5:28 AM, David Martinez <
> [email protected]> wrote:
>
>> It occurs to me that one way of doing it would be to get all the 'Docks'
>> that a given 'QMainWindow' has and then before adding a new one, I could do
>> the following:
>>
>> # Creates second bottom Dock
>> self.bottom_dock_02 = QDockWidget("Second Bottom Dock", self)
>> self.bottom_dock_02.setObjectName('bottom_dock_02')
>> self.bottom_dock_02.setAllowedAreas(Qt.BottomDockWidgetArea)
>> self.widget_second_dock = QWidget(self.bottom_dock_02)
>> self.widget_second_dock.setFixedHeight(150)
>> self.bottom_dock_02.setWidget(self.widget_second_dock)
>> self.addDockWidget(Qt.BottomDockWidgetArea, self.bottom_dock_02)
>>
>> existing_widget = None
>>
>> for current_dock in self.findChildren(QDockWidget):
>> if self.dockWidgetArea(current_dock) ==
>> Qt.BottomDockWidgetArea:
>> existing_widget = current_dock
>> break
>>
>> if existing_widget:
>> self.tabifyDockWidget(self.bottom_dock_02,current_dock)
>>
>>
>> Does that sound like a good way of doing it? If so, I have a couple of
>> questions more:
>>
>>
>> - Is it possible to change the order in which the items have been
>> stacked? I'd like the user to be able to re-arrange them if they want to
>> do
>> so.
>>
>>
>>
>> Many thanks
>>
>>
>>
>> --
>> David Martinez - Technical Animator
>>
>> Email: [email protected]
>> Website: http://www.elusiveideas.com
>>
>>
>>
>>
>> On Fri, Aug 22, 2014 at 5:58 PM, David Martinez <
>> [email protected]> wrote:
>>
>>> Ah!
>>>
>>> I've got it working by adding the following line:
>>>
>>> self.tabifyDockWidget(self.bottom_dock_01,self.bottom_dock_02)
>>>
>>> Which brings me to my next question... How do I know if there are
>>> 'QDockWidgets' already in one of the four zones? I'm asking because I'm
>>> creating those dynamically and I will need to do the check before I try to
>>> stack them.
>>>
>>> Cheers
>>>
>>>
>>>
>>> On Friday, August 22, 2014 1:43:33 PM UTC+1, David Martinez wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a question in regards on how the 'QDockWidget' works in
>>>> 'PyQt/PySide'. I have an application that creates an instance of
>>>> 'QMainWindow' and this one creates two 'QDockWidgets' in the bottom area.
>>>>
>>>> I'd like them to be stacked upon creation but instead they appear next
>>>> to each other. Once the application is running, I can drop one on top of
>>>> the other but I'd like to stack them when they get created. Is that
>>>> possible?
>>>>
>>>> Here is some mock up code:
>>>>
>>>> https://gist.github.com/davidmartinezanim/6c69ca5cca39f390f89a
>>>>
>>>> (I know this way of importing is bad practice but it just for the sake
>>>> of the example)
>>>>
>>>> Do you have any ideas about how to get this working the way I want?
>>>>
>>>>
>>>> --
>>>> David Martinez - Technical Animator
>>>> Email: [email protected]
>>>> Website: http://www.elusiveideas.com
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/e0d9289e-4208-44f4-8e6d-15a74125c401%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/e0d9289e-4208-44f4-8e6d-15a74125c401%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpymBonZFOtmvmGNjsf%3Dpc4FYt_WihLZh3SvrE6hjKSLaw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpymBonZFOtmvmGNjsf%3Dpc4FYt_WihLZh3SvrE6hjKSLaw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2iz%3DbPvY8x38iQ5zCyUkSg7UTk4htkbSfYcLjWALSAeA%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2iz%3DbPvY8x38iQ5zCyUkSg7UTk4htkbSfYcLjWALSAeA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpwqh8Y5D2n-ZxrdZdEF3tmm1ZjmjXiz4O6BDRr%3DGh%2BPgw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.