class config_fmask(object): def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QtCore.QSettings().value("locale/userLocale")[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'config_fmask_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QtCore.QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QtCore.QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = FmaskDialog(self.iface) def initGui(self): """ Create toolbar item for plugin """ # Dialog button self.show_dialog = QtGui.QAction(QtGui.QIcon( ':/plugins/config_fmask/icon.png'), 'Test Fmask Parameters', self.iface.mainWindow()) self.show_dialog.triggered.connect(self.show_fmask_dialog) self.iface.addToolBarIcon(self.show_dialog) def show_fmask_dialog(self): """ Show dialog window """ self.dlg.show() def unload(self): """ Shutdown by removing icons and disconnecting signals """ # Remove toolbar icons self.iface.removeToolBarIcon(self.show_dialog) # Disconnect signals self.show_dialog.triggered.disconnect() # Tell dialog to unload resources self.dlg.unload() self.dlg.close() self.dlg = None # run method that performs all the real work def run(self): # show the dialog self.dlg.show() # Run the dialog event loop result = self.dlg.exec_() # See if OK was pressed if result == 1: # do something useful (delete the line containing pass and # substitute with your code) pass
class config_fmask(object): def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QtCore.QSettings().value("locale/userLocale")[0:2] localePath = os.path.join(self.plugin_dir, 'i18n', 'config_fmask_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QtCore.QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QtCore.QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = FmaskDialog(self.iface) def initGui(self): """ Create toolbar item for plugin """ # Dialog button self.show_dialog = QtGui.QAction( QtGui.QIcon(':/plugins/config_fmask/icon.png'), 'Test Fmask Parameters', self.iface.mainWindow()) self.show_dialog.triggered.connect(self.show_fmask_dialog) self.iface.addToolBarIcon(self.show_dialog) def show_fmask_dialog(self): """ Show dialog window """ self.dlg.show() def unload(self): """ Shutdown by removing icons and disconnecting signals """ # Remove toolbar icons self.iface.removeToolBarIcon(self.show_dialog) # Disconnect signals self.show_dialog.triggered.disconnect() # Tell dialog to unload resources self.dlg.unload() self.dlg.close() self.dlg = None # run method that performs all the real work def run(self): # show the dialog self.dlg.show() # Run the dialog event loop result = self.dlg.exec_() # See if OK was pressed if result == 1: # do something useful (delete the line containing pass and # substitute with your code) pass