Giter Site home page Giter Site logo

Comments (10)

cannibal666 avatar cannibal666 commented on July 19, 2024

Hello, the subject is very interesting. I have a question, how or what would be the best way to program an action in python within a plugin. That is, the end user can use it without having to add code. Thank you

from courses.

spatialthoughts avatar spatialthoughts commented on July 19, 2024

Actions are defined for a layer and embedded within a QGIS Project. It makes it very easy mechanism to distribute your code to other users without having to write a plugin and simply sending them a qgis project. So if you share a qgis project that has actions defined in layers, the users can use it without writing any code.

from courses.

cannibal666 avatar cannibal666 commented on July 19, 2024

Thanks for the immediate response!
I have made a plugin, but I need to add the actions programmatically, that the end user who does not know anything about python can use. I saw that you can use QgsAction but I don't know how.
Passing on a project would be very restrictive, they ask me to be able to download a plugin from a repository and have everything already submitted and not as personalized as sharing a project. Thank you!!!

from courses.

spatialthoughts avatar spatialthoughts commented on July 19, 2024

Actions and Plugins are different mechanisms. You choose one or the other for distributing your code.

Actions MUST be linked to specific project and a specific layer. They are used only when you want to put customizations in a project.

QgsAction does not refer the Actions as described here but a QT Action (which is a menu item or a toolbar item).

If you already have a plugin and want some customisation, just build them as part of your plugin using PyQGIS API. Look at my course on how to do that https://courses.spatialthoughts.com/pyqgis-in-a-day.html

from courses.

cannibal666 avatar cannibal666 commented on July 19, 2024

Ok, conceptually: I need to develop certain functionalities for the end user which I have been developing a plugin with PyQgis (and using several examples from your course for which I greatly appreciate), but in a particular case when a user creates a point I need the form By default, it closes and allows you to select data from other layers and then resume creating the point with that data. For this, implement with QgsAction an action that the user can call and thus complete the functionality. But it doesn't work at all and I don't know if it's because I was missing something or if I'm thinking about it incorrectly.
What do you think, would you do it in a better way?
Thank you so much!

from courses.

spatialthoughts avatar spatialthoughts commented on July 19, 2024

QgsAction is not the Actions described here. So you are looking at the wrong place. You can solve your problem using PyQGIS and using QGIS Attribute Forms. Look at PyQGIS documentation and seek help on specifics at https://gis.stackexchange.com/

from courses.

cannibal666 avatar cannibal666 commented on July 19, 2024

Hello. I have a question. How can I import a python class implemented by me in a plugin from within an action. For example: I have a class A inside My_Plugin and I need to invoke A.my_method() from an action of a layer.
Thank you so much

from courses.

spatialthoughts avatar spatialthoughts commented on July 19, 2024

Try something like below

myPlugin = qgis.utils.plugins["PluginName"]
A = myPlugin.A()
A.my_method()

from courses.

cannibal666 avatar cannibal666 commented on July 19, 2024

Thank you so much. I'm going to try it. If you can walk you would become my idol, like some kind of rock star.

from courses.

cannibal666 avatar cannibal666 commented on July 19, 2024

It went perfect! you are a god

from courses.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.