What works for me is this:

    def close_all_docks(self):
        active_docks = self.dock_area.findAll()[1]        
        for name in active_docks.keys():
            logger.debug('close dock window %s', name)
            active_docks[name].close()
            # fix: without this, last dock is floating and not closed
            QtCore.QCoreApplication.instance().processEvents()



Am Dienstag, 25. August 2015 18:41:30 UTC+2 schrieb Marcos Duarte:
>
> I forgot to mention that I am already using the bleeding edge version of 
> pyqtgraph from its GitHub repo (which includes the changes after the post 
> called Dock feature proposals).
> Mathew, this is the reason why my DockArea class has a method .clear(), 
> which is supposed to *delete* all docks, but it doesn't work for me. 
>
> If as suggested I use the method .close() for the DockArea instance in 
> line 55 of my example, it works apparently. In this case what is being used 
> is a .close() method from PyQt and not from the Dock class, but in fact the 
> docks are not deleted, they are just hidden. You can check that adding 
> these lines after line 55 (with self.area.close()):
>
>     docks = self.area.findAll()[1]
>     print(docks)
>
> But the deletion of all docks will work if I add after the .close() method 
> in line 55:
>
>     for dock in docks.values():
>         dock.setParent(None)
>         dock.label.setParent(None)
>
>
> But this a workaround because it is not using the builtin .close() method 
> from the Dock class and it is going to wash out all the docks, closable or 
> not.
>
>
> What really works with the last version in the repo is to simply delete 
> line 238 in Dock.py (self.label.setParent(None)).
>
> To verify that with my example code, comment lines 66 and 104 where I 
> overrode the .close() method (and you may change the number in line 3 to 
> test different implementations).
>
> I don't know if there are side effects with the removal of that line, but 
> this is working so far for me.
>
> thanks
>
> Marcos
>
> Em terça-feira, 25 de agosto de 2015 06:33:12 UTC-3, Vincent Le Saux 
> escreveu:
>>
>> Hi,
>>
>> Have a look at a previous post called Dock feature proposals.
>>
>> Daniel proposed something on DockArea that may be usefor for you...
>>
>> Vincent
>>
>>
>> Le mardi 25 août 2015 08:21:45 UTC+2, Mathew Schwartz a écrit :
>>>
>>> For me, changing line 55 to self.area.close() instead of clear() makes 
>>> it work.  I get an error that there is no clear() method.
>>>
>>> On Tue, Aug 25, 2015 at 9:00 AM, Marcos Duarte <[email protected]> 
>>> wrote:
>>>
>>>> Hi
>>>>
>>>> First and foremost, thanks for the great package.
>>>>
>>>> I am writing an application with pyqtgraph where the user can create 
>>>> and close many dock widgets and I am having problems when more than one 
>>>> dock is closed programmatically.
>>>>
>>>> For example, when I simply use the DockArea.clear() method to close all 
>>>> docks, some of the docks are torn out from the main window (floated) and 
>>>> not closed.
>>>> When I close programmatically one dock per time (with a dialog asking 
>>>> for confirmation), it works fine most of the times but the behavior is 
>>>> erratic.
>>>> When I close each dock by pressing its close button, it works fine.
>>>>
>>>> I am using pyqtgraph 0.9.10, PyQt 4.11.3, Qt 4.8.6, and Python 3.4.3 in 
>>>> Mac OS X or MS Windows 7.
>>>>
>>>> The code attached reproduces this problem if one tries to close all 
>>>> docks. I tried different ways but none of them works (weirdly, it works a 
>>>> few times!). 
>>>>
>>>> So, my question is how to close more than one dock widget 
>>>> programmatically?
>>>>
>>>> I'd appreciate any help.
>>>>
>>>> Thanks
>>>>
>>>> Marcos
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "pyqtgraph" 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/pyqtgraph/4bb03ced-4faa-4eaf-b10e-496f85558677%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/pyqtgraph/4bb03ced-4faa-4eaf-b10e-496f85558677%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
-- 


fos4X GmbH | www.fos4x.de
Thalkirchner Str. 210, 81371 Munich, DE

Commercial Register: Amtsgericht Muenchen, HRB 189 218
Managing Director: Dr. Lars Hoffmann
Place of Business: Munich, DE

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" 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/pyqtgraph/4ac30b74-84f1-4e07-af25-8d22d4bbf2d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to