How to retrieve the data source of the active layer?QGIS 3 - Python : QgsVectorLayerJoinInfo issueJoin CSV...

New order #4: World

Why do we use polarized capacitors?

LWC and complex parameters

Why is my log file so massive? 22gb. I am running log backups

aging parents with no investments

Are objects structures and/or vice versa?

How would photo IDs work for shapeshifters?

Could Giant Ground Sloths have been a good pack animal for the ancient Mayans?

COUNT(*) or MAX(id) - which is faster?

Pristine Bit Checking

Is "plugging out" electronic devices an American expression?

Is it wise to focus on putting odd beats on left when playing double bass drums?

Why is the design of haulage companies so “special”?

Does bootstrapped regression allow for inference?

How to move the player while also allowing forces to affect it

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

Does the average primeness of natural numbers tend to zero?

Are white and non-white police officers equally likely to kill black suspects?

What to wear for invited talk in Canada

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

How to answer pointed "are you quitting" questioning when I don't want them to suspect

Where else does the Shulchan Aruch quote an authority by name?

Piano - What is the notation for a double stop where both notes in the double stop are different lengths?

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?



How to retrieve the data source of the active layer?


QGIS 3 - Python : QgsVectorLayerJoinInfo issueJoin CSV and shapefile in PyQGISError in executing Voronoi polygon algorithmWhy a QgsExpression does not evaluate a feature as expected in PyQGIS 3?QGIS vector layer labels are not showing from python scriptPyQGIS QgsVectorLayer() Loads Invalid Layer in Standalone Python 3 ScriptQGIS Processing Script Stops Working After First RunRename fields of shapefile using PyQGIS 3PYQGIS 3 Using the ouptut from GRASS v.distance algorithmHow to resolve QGIS 3 syntax error from processing.algorithmHelp?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I am trying to get the data source of the layer in the Python action within the layer property. My code in the Python action is:



layer = iface.activeLayer()
QMessageBox.information(None, "parDir: ", layer.source())


When I run the action, the script returned the following error:



An error occurred during execution of following code:
layer = iface.activeLayer()
QMessageBox.information(None, "parDir: ", layer.source())


If I run the same script in the Python console, it has no problem returning the name of the data source.



Does anybody know why the script failed if I run it as Python action?










share|improve this question









New contributor




PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    I am trying to get the data source of the layer in the Python action within the layer property. My code in the Python action is:



    layer = iface.activeLayer()
    QMessageBox.information(None, "parDir: ", layer.source())


    When I run the action, the script returned the following error:



    An error occurred during execution of following code:
    layer = iface.activeLayer()
    QMessageBox.information(None, "parDir: ", layer.source())


    If I run the same script in the Python console, it has no problem returning the name of the data source.



    Does anybody know why the script failed if I run it as Python action?










    share|improve this question









    New contributor




    PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I am trying to get the data source of the layer in the Python action within the layer property. My code in the Python action is:



      layer = iface.activeLayer()
      QMessageBox.information(None, "parDir: ", layer.source())


      When I run the action, the script returned the following error:



      An error occurred during execution of following code:
      layer = iface.activeLayer()
      QMessageBox.information(None, "parDir: ", layer.source())


      If I run the same script in the Python console, it has no problem returning the name of the data source.



      Does anybody know why the script failed if I run it as Python action?










      share|improve this question









      New contributor




      PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I am trying to get the data source of the layer in the Python action within the layer property. My code in the Python action is:



      layer = iface.activeLayer()
      QMessageBox.information(None, "parDir: ", layer.source())


      When I run the action, the script returned the following error:



      An error occurred during execution of following code:
      layer = iface.activeLayer()
      QMessageBox.information(None, "parDir: ", layer.source())


      If I run the same script in the Python console, it has no problem returning the name of the data source.



      Does anybody know why the script failed if I run it as Python action?







      pyqgis-3






      share|improve this question









      New contributor




      PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 40 mins ago









      Vince

      14.8k32849




      14.8k32849






      New contributor




      PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 43 mins ago









      PFTPFT

      1




      1




      New contributor




      PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      PFT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          PFT is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318186%2fhow-to-retrieve-the-data-source-of-the-active-layer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          PFT is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          PFT is a new contributor. Be nice, and check out our Code of Conduct.













          PFT is a new contributor. Be nice, and check out our Code of Conduct.












          PFT is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318186%2fhow-to-retrieve-the-data-source-of-the-active-layer%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

          Meter-Bus Содержание Параметры шины | Стандартизация |...