Advertisement
xunilk

widget_button.py

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