Re: [QGIS-Developer] Set text of QgsLayoutItemLabel
Hi, This thread might help you to find a workaround : https://gis.stackexchange.com/questions/241213/how-to-get-a-composer-label-by-id-with-python-in-qgis -- Christophe Le 16/03/2018 à 16:56, KOHLMANN Hannes a écrit : Hello! I am facing difficulties trying to set the text of a QgsLayoutItemLabel. I do something like the following to load a .qpt composer template and print this to a .png file (which works) path = "C:\\QGIS3\\apps\\qgis\\composer_templates" template_file = open(path+"\\ANSR_print_composer2.qpt") template_content = template_file.read() template_file.close() document = QDomDocument() document.setContent(template_content) composition = QgsLayout(QgsProject.instance()) composition.loadFromTemplate(document, QgsReadWriteContext()) map_item = composition.itemById('map') legend_item = composition.itemById('legend') text_item = composition.itemById('textbox') QgsLayoutExporter(composition).exportToImage( path+"\\report.png", QgsLayoutExporter.ImageExportSettings()) And now I’d like to modify only the text of the QgsLayoutItemLabel, which is the “textbox”: 1)I can move it around with setX(), setY(), but I don’t know how to edit the text of the label. I thought of something like text_item.setText() or text_item.setLabelText(), but I think that text_item is just an instance of QgsLayoutItem, not QgsLayoutItemLabel. And there I get stuck. 2)How would you manually add another text label, set the main property etc, such that, at the end of the day, my above code would export a .png containing this QgsLayoutItem? I would have begun this way: new = QgsLayoutItemLabel(composition) new.setText(“New label”) But it does not quite work that way! Would be of great help, if you could give me some hints on that. Thank you in advance! J Hannes ___ 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] Processing algorithm plugin help
Hi all, I developed a processing algorithm plugin using the Plugin Builder but I'm having trouble setting up the Help panel which usually shows on the right side of the windows, or at least the a help button pointing to a static file. I've tried creating the .py.help file with the same name as my algorithm and provider files and placing them in both the "~/.qgis2/processing/scripts" and "~/.qgis2/python/plugins/my_plugin" folders, but without success. Implementing the helpString() and helpUrl() methods in my GeoAlgorithm class didn't work either. Am I missing something? Sorry if it's a noob question. André ___ 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] Processing algorithm plugin help
I was already doing something quite similar but unfortunately it still doesn't work. No help panel and no help button, just the parameters. Is there anything else I should do on the defineCharacteristics() method maybe? As for the QGIS version, I'm still using 2.18. Could this be the problem? Thanks for the input! André class TestlAlgorithm(GeoAlgorithm): > INPUT_LAYER = ' INPUT _LAYER' > OUTPUT_LAYER = 'OUTPUT_LAYER' > > def helpString(self): > return "Test 321" > > def shortHelpString(self): > return "Test 123" > > def helpUrl(self): > return QUrl.fromLocalFile("file:file.txt").toString() > 2018-03-18 2:07 GMT-03:00 Luke Pinner : > In QGIS 3.0 I use something like the following. I don't know if it will be > of any use for QGIS 2x though. > > > from qgis.PyQt.QtCore import QUrl > > class MyAlg(etc...) > etc... > > def shortHelpString(self) > return "My short help string for the right side of the dialog" > #or > return open("/path/to/myshorthelp.txt").read() > > And > > def helpUrl(self): > return QUrl.fromLocalFile("/path/to/my_long_help.html").toString() > > > On 18 Mar. 2018 15:31, "André William" wrote: > >> Hi all, >> >> I developed a processing algorithm plugin using the Plugin Builder but >> I'm having trouble setting up the Help panel which usually shows on the >> right side of the windows, or at least the a help button pointing to a >> static file. >> >> I've tried creating the .py.help file with the same name as my algorithm >> and provider files and placing them in both the >> "~/.qgis2/processing/scripts" and "~/.qgis2/python/plugins/my_plugin" >> folders, but without success. >> >> Implementing the helpString() and helpUrl() methods in my GeoAlgorithm >> class didn't work either. >> >> Am I missing something? Sorry if it's a noob question. >> >> André >> >> ___ >> 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