Re: [QGIS-Developer] open atlas layout, using python
Hi Nyall, The setAtlasPreviewEnabled(True) still does not work correctly. It works exactly like the python workaround you mentioned: It toggles the atlas button but does not activate the atlas. I mean, the prev and next buttons stay disabled and the map does not display page number 1. If I then, turn off and on the atlas preview, it works as expected. Does it need to get some kind of gui redraw/update call? Regards, Raymond On 12-10-18 01:39, Nyall Dawson wrote: On Fri, 12 Oct 2018 at 02:22, Raymond Nijssen wrote: By the way, the fragile code solution does not work for me. It does toggle the button but it does not activate the atlas preview. Ok - I've done the proper approach in https://github.com/qgis/QGIS/pull/8170/files (I've also exposed an API call to show the item properties for a particular item) Let me know if there's anything else you think should be exposed from the designer to the designer API. Nyall # open layout designer = iface.openLayoutDesigner(layout) # turn on atlas preview mode lo_view = designer.view() lo_window = lo_view.window() action = lo_window.findChild(QAction, 'mActionAtlasPreview') action.toggle() On 11-10-18 16:51, Raymond Nijssen wrote: Hi Nyall, It sounded great and I spent some hours on that better approach, but I didn't succeed. So maybe 3.6 will have it... Tnx! Raymond On 25-09-18 23:57, Nyall Dawson wrote: On Tue, 25 Sep 2018 at 22:36, Raymond Nijssen wrote: 1. Can I open a layout window with a python command? designer = iface.openLayoutDesigner( layout ) 2. Can I turn on "atlas preview" with a python command? You'd have to do some fragile code to do this. Basically: - get designer window from designer.view()'s parent window - find the mActionAtlasPreview child action in the window - manually toggle it on This should work, but isn't stable API - so is likely to break ;) A better approach is to (quickly, before 3.4 final!) file a PR exposing the toggle atlas preview behavior to QgsLayoutDesignerInterface. Then you'll be able to just do: designer = iface.openLayoutDesigner( layout ) designer.toggleAtlasPreview( True ) Nyall Hope anyone knows! Kind regards, Raymond ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] open atlas layout, using python
Thank you Nyall, compiling now. Yesterday I was asked to create a plugin that works on layouts, so it will need a button in the layout composer. I think I could do this the same fragile/hacky way, but is there a proper way? I also find it hard to create reports from python, but maybe that is still too young and not all finished? Regards, Raymond On 12-10-18 01:39, Nyall Dawson wrote: On Fri, 12 Oct 2018 at 02:22, Raymond Nijssen wrote: By the way, the fragile code solution does not work for me. It does toggle the button but it does not activate the atlas preview. Ok - I've done the proper approach in https://github.com/qgis/QGIS/pull/8170/files (I've also exposed an API call to show the item properties for a particular item) Let me know if there's anything else you think should be exposed from the designer to the designer API. Nyall # open layout designer = iface.openLayoutDesigner(layout) # turn on atlas preview mode lo_view = designer.view() lo_window = lo_view.window() action = lo_window.findChild(QAction, 'mActionAtlasPreview') action.toggle() On 11-10-18 16:51, Raymond Nijssen wrote: Hi Nyall, It sounded great and I spent some hours on that better approach, but I didn't succeed. So maybe 3.6 will have it... Tnx! Raymond On 25-09-18 23:57, Nyall Dawson wrote: On Tue, 25 Sep 2018 at 22:36, Raymond Nijssen wrote: 1. Can I open a layout window with a python command? designer = iface.openLayoutDesigner( layout ) 2. Can I turn on "atlas preview" with a python command? You'd have to do some fragile code to do this. Basically: - get designer window from designer.view()'s parent window - find the mActionAtlasPreview child action in the window - manually toggle it on This should work, but isn't stable API - so is likely to break ;) A better approach is to (quickly, before 3.4 final!) file a PR exposing the toggle atlas preview behavior to QgsLayoutDesignerInterface. Then you'll be able to just do: designer = iface.openLayoutDesigner( layout ) designer.toggleAtlasPreview( True ) Nyall Hope anyone knows! Kind regards, Raymond ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] open atlas layout, using python
On Fri, 12 Oct 2018 at 02:22, Raymond Nijssen wrote: > > By the way, the fragile code solution does not work for me. It does > toggle the button but it does not activate the atlas preview. Ok - I've done the proper approach in https://github.com/qgis/QGIS/pull/8170/files (I've also exposed an API call to show the item properties for a particular item) Let me know if there's anything else you think should be exposed from the designer to the designer API. Nyall > > # open layout > designer = iface.openLayoutDesigner(layout) > > # turn on atlas preview mode > lo_view = designer.view() > lo_window = lo_view.window() > action = lo_window.findChild(QAction, 'mActionAtlasPreview') > action.toggle() > > > On 11-10-18 16:51, Raymond Nijssen wrote: > > Hi Nyall, > > > > It sounded great and I spent some hours on that better approach, but I > > didn't succeed. So maybe 3.6 will have it... > > > > Tnx! > > Raymond > > > > > > On 25-09-18 23:57, Nyall Dawson wrote: > >> On Tue, 25 Sep 2018 at 22:36, Raymond Nijssen > >> wrote: > >>> > >>> 1. Can I open a layout window with a python command? > >> > >> designer = iface.openLayoutDesigner( layout ) > >> > >>> 2. Can I turn on "atlas preview" with a python command? > >> > >> You'd have to do some fragile code to do this. Basically: > >> > >> - get designer window from designer.view()'s parent window > >> - find the mActionAtlasPreview child action in the window > >> - manually toggle it on > >> > >> This should work, but isn't stable API - so is likely to break ;) > >> > >> A better approach is to (quickly, before 3.4 final!) file a PR > >> exposing the toggle atlas preview behavior to > >> QgsLayoutDesignerInterface. Then you'll be able to just do: > >> > >> designer = iface.openLayoutDesigner( layout ) > >> designer.toggleAtlasPreview( True ) > >> > >> Nyall > >> > >> > >> Hope anyone knows! > >>> > >>> Kind regards, > >>> Raymond > >>> > >>> ___ > >>> QGIS-Developer mailing list > >>> QGIS-Developer@lists.osgeo.org > >>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > >>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > >> > > > > ___ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] open atlas layout, using python
By the way, the fragile code solution does not work for me. It does toggle the button but it does not activate the atlas preview. # open layout designer = iface.openLayoutDesigner(layout) # turn on atlas preview mode lo_view = designer.view() lo_window = lo_view.window() action = lo_window.findChild(QAction, 'mActionAtlasPreview') action.toggle() On 11-10-18 16:51, Raymond Nijssen wrote: Hi Nyall, It sounded great and I spent some hours on that better approach, but I didn't succeed. So maybe 3.6 will have it... Tnx! Raymond On 25-09-18 23:57, Nyall Dawson wrote: On Tue, 25 Sep 2018 at 22:36, Raymond Nijssen wrote: 1. Can I open a layout window with a python command? designer = iface.openLayoutDesigner( layout ) 2. Can I turn on "atlas preview" with a python command? You'd have to do some fragile code to do this. Basically: - get designer window from designer.view()'s parent window - find the mActionAtlasPreview child action in the window - manually toggle it on This should work, but isn't stable API - so is likely to break ;) A better approach is to (quickly, before 3.4 final!) file a PR exposing the toggle atlas preview behavior to QgsLayoutDesignerInterface. Then you'll be able to just do: designer = iface.openLayoutDesigner( layout ) designer.toggleAtlasPreview( True ) Nyall Hope anyone knows! Kind regards, Raymond ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] open atlas layout, using python
Hi Nyall, It sounded great and I spent some hours on that better approach, but I didn't succeed. So maybe 3.6 will have it... Tnx! Raymond On 25-09-18 23:57, Nyall Dawson wrote: On Tue, 25 Sep 2018 at 22:36, Raymond Nijssen wrote: 1. Can I open a layout window with a python command? designer = iface.openLayoutDesigner( layout ) 2. Can I turn on "atlas preview" with a python command? You'd have to do some fragile code to do this. Basically: - get designer window from designer.view()'s parent window - find the mActionAtlasPreview child action in the window - manually toggle it on This should work, but isn't stable API - so is likely to break ;) A better approach is to (quickly, before 3.4 final!) file a PR exposing the toggle atlas preview behavior to QgsLayoutDesignerInterface. Then you'll be able to just do: designer = iface.openLayoutDesigner( layout ) designer.toggleAtlasPreview( True ) Nyall Hope anyone knows! Kind regards, Raymond ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer -- Terglobo Fahrenheitstraat 1 5223 BJ 's-Hertogenbosch The Netherlands +31 (0) 6 25 31 49 83 ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] open atlas layout, using python
On Tue, 25 Sep 2018 at 22:36, Raymond Nijssen wrote: > > 1. Can I open a layout window with a python command? designer = iface.openLayoutDesigner( layout ) > 2. Can I turn on "atlas preview" with a python command? You'd have to do some fragile code to do this. Basically: - get designer window from designer.view()'s parent window - find the mActionAtlasPreview child action in the window - manually toggle it on This should work, but isn't stable API - so is likely to break ;) A better approach is to (quickly, before 3.4 final!) file a PR exposing the toggle atlas preview behavior to QgsLayoutDesignerInterface. Then you'll be able to just do: designer = iface.openLayoutDesigner( layout ) designer.toggleAtlasPreview( True ) Nyall Hope anyone knows! > > Kind regards, > Raymond > > ___ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
[QGIS-Developer] open atlas layout, using python
1. Can I open a layout window with a python command? 2. Can I turn on "atlas preview" with a python command? Hope anyone knows! Kind regards, Raymond ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer