Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to open a form (made in QTDesign) in the layer action. It is possible?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Yes you can. Layer actions can call Python so you can do something like this:

from PyQt4 import uic
import os

uifile = r"{path to your UI file}\youruifile.ui"
uiinstance = uic.loadUi(uifile)
uiinstance.exec_()

enter image description here

You could even put that in a python file and call it rather then storing the code in the projet.

In yourcode.py

from PyQt4 import uic
import os

def loadUI():
    uifile = os.path.join(os.path.dirname(__file__) , 'youruifile.ui')
    uiinstance = uic.loadUi(uifile)
    uiinstance.exec_()

enter image description here

share|improve this answer
    
Thank you very much. Is that! –  user1573901 May 17 '13 at 11:45
    
It's possible pass a variable value to the form? –  user1573901 May 17 '13 at 15:16
    
Where I save the yourcode.py ? –  user1573901 May 17 '13 at 15:43
    
Save yourcode.py anywhere Pyton can find it. This is can be in `.qgis2\python` or in the folder with the project. I tend to go with in the folder with the the project. –  Nathan W May 17 '13 at 21:00
    
Thank you Nathan –  user1573901 May 20 '13 at 11:49
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.