<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EstiloCorreioElectrnico18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=PT link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Germán.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Your tips are exactly what I was looking for!<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>So I can now open a dialog:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>iface=qgis.utils.iface<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>menu=iface.layerMenu()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>myActions=menu.actions()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>myAction=[ac for ac in myActions if ac.objectName()==&quot;mActionEmbedLayers&quot;][0]<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>myAction.trigger()<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>So now for the final 1 million dollar question: can I change the first textbox in the dialog?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Duarte<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Germán Carrillo [mailto:carrillo.german@gmail.com] <br><b>Enviada:</b> quinta-feira, 15 de Dezembro de 2011 13:26<br><b>Para:</b> Duarte Carreira; qgis-developer@lists.osgeo.org<br><b>Assunto:</b> Re: [Qgis-developer] quick noob python question<o:p></o:p></span></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>Hi Duarte, <br><br>if I understood well, you would like to simulate a click in QGIS buttons. For this you can use the slot trigger() of the available QAction's in the class QgisInteface [1]. For example, if you want to open the &quot;Open Project...&quot; dialog you can type this in the Python Console (inside QGIS):<o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>iface=qgis.utils.iface<o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>iface.actionOpenProject().trigger()<o:p></o:p></p><p class=MsoNormal><br>Regarding Toolbars, you can also access them from the QgisInterface class. For example, to access the Layer menu do this: <br><br>iface=qgis.utils.iface<o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>m=iface.layerMenu()<o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'><o:p>&nbsp;</o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>Since a menu consists of a set of actions you could trigger any action of the menu: <o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'><o:p>&nbsp;</o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>iface=qgis.utils.iface<o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>for a in m.actions():<o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>print a.text()<o:p></o:p></p><p style='margin:0cm;margin-bottom:.0001pt'>m.actions()[2].trigger()<o:p></o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'><br>Hope this helps.<br><br>Regards, <br><br>Germán<br><br>-------------------------<br>[1] <a href="http://www.qgis.org/api/classQgisInterface.html">http://www.qgis.org/api/classQgisInterface.html</a> <o:p></o:p></p><div><p class=MsoNormal>2011/12/15 Duarte Carreira &lt;<a href="mailto:DCarreira@edia.pt">DCarreira@edia.pt</a>&gt;<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Just an additional question: generally speaking the gui is not accessible from python? We cannot simulate a toolbar button click, or menu item?</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Duarte</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><div><div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0cm 0cm 0cm;border-color:-moz-use-text-color -moz-use-text-color'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Duarte Carreira [mailto:<a href="mailto:DCarreira@edia.pt" target="_blank">DCarreira@edia.pt</a>] <br><b>Enviada:</b> quarta-feira, 14 de Dezembro de 2011 17:05<br><b>Para:</b> Germán Carrillo; <a href="mailto:qgis-developer@lists.osgeo.org" target="_blank">qgis-developer@lists.osgeo.org</a><br><b>Assunto:</b> RE: [Qgis-developer] quick noob python question</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Germán, thanks.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Maybe that&#8217;s what I&#8217;ll do, but it pains me to duplicate code&#8230;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Duarte</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0cm 0cm 0cm;border-color:-moz-use-text-color -moz-use-text-color'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Germán Carrillo [mailto:<a href="mailto:carrillo.german@gmail.com" target="_blank">carrillo.german@gmail.com</a>] <br><b>Enviada:</b> quarta-feira, 14 de Dezembro de 2011 12:30<br><b>Para:</b> <a href="mailto:qgis-developer@lists.osgeo.org" target="_blank">qgis-developer@lists.osgeo.org</a>; Duarte Carreira<br><b>Assunto:</b> Re: [Qgis-developer] quick noob python question</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>Hi Duarte, <br><br>from my experience it is not possible. You can of course re-use the ui file and implement the whole functionality on your own based on the cpp file, basically a translation from C++ to Python. I've done this before and it is not a complex process, but it requires time. <br><br>By the way, the folder app of QGIS source code contains QGIS-application-specific code, so I would say you won't find there functionality available in PyQGIS, for that you would have to have a look to the gui and core folders. <br><br>Perhaps there are other ways to set the project file programmatically from Python, but I don't know them, sorry.<br><br>Regards, <br><br>Germán<o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>2011/12/14 Duarte Carreira &lt;<a href="mailto:DCarreira@edia.pt" target="_blank">DCarreira@edia.pt</a>&gt;<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>Using python is it possible to call QgsEmbedLayerDialog and set the project file programmatically (</span><span lang=EN-US style='font-size:9.0pt;font-family:"Courier New";color:black;background:white'>mProjectFileLineEdit</span><span lang=EN-US>)?</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=EN-US>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><a href="https://github.com/qgis/Quantum-GIS/blob/release-1_8/src/app/qgsembedlayerdialog.cpp" target="_blank">https://github.com/qgis/Quantum-GIS/blob/release-1_8/src/app/qgsembedlayerdialog.cpp</a><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><a href="https://github.com/qgis/Quantum-GIS/blob/release-1_8/src/ui/qgsembedlayerdialogbase.ui" target="_blank">https://github.com/qgis/Quantum-GIS/blob/release-1_8/src/ui/qgsembedlayerdialogbase.ui</a><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Thanks,<br><span style='color:#888888'>Duarte Carreira</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p></o:p></p></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><br>_______________________________________________<br>Qgis-developer mailing list<br><a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>-- <br>-----------<br>&nbsp; |\__&nbsp; <br>(:&gt;__)(<br>&nbsp; |/&nbsp; &nbsp; <br><br>Soluciones Geoinformáticas Libres&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br><a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><o:p></o:p></p></div></div></div></div></div><p class=MsoNormal><br><br clear=all><br>-- <br>-----------<br>&nbsp; |\__&nbsp; <br>(:&gt;__)(<br>&nbsp; |/&nbsp; &nbsp; <br><br>Soluciones Geoinformáticas Libres&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br><a href="http://geotux.tuxfamily.org/">http://geotux.tuxfamily.org/</a><o:p></o:p></p></div></body></html>