Advertisement
xunilk

Untitled

Oct 4th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from PyQt5 import QtCore, QtGui, QtWidgets
  3. from qgis.gui import QgsMessageBar
  4. import importlib
  5. import widget_button_dialog
  6.  
  7. class WidgetButton(QtWidgets.QDialog):
  8.     def __init__(self):
  9.         QtWidgets.QDialog.__init__(self)
  10.         # Set up the user interface from Designer.
  11.         # After setupUI you can access any designer object by doing:
  12.         # self.<objectname>
  13.         self.ui = widget_button_dialog.Ui_Dialog()
  14.         self.ui.setupUi(self)
  15.  
  16.     def openForm(self):
  17.         self.show()
  18.  
  19.     def testSignal(self):
  20.         iface.messageBar().pushMessage("Aviso: ",
  21.                                        u"El boton ha sido clickado",
  22.                                        Qgis.Info, 5)
  23.        
  24.         self.close()
  25.  
  26. # Create the dialog and keep reference
  27. importlib.reload(widget_button_dialog)
  28. dlg = WidgetButton()
  29.  
  30. dlg.openForm()
  31.  
  32. btn = dlg.ui.pushButton
  33.  
  34. print (btn.objectName())
  35.  
  36. btn.clicked.connect(dlg.testSignal)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement