main.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # -*- coding: utf-8 -*-
  2. """
  3. /***************************************************************************
  4. MnCheck
  5. A QGIS plugin
  6. Contrôle des données FTTH format MN
  7. Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
  8. -------------------
  9. begin : 2018-12-07
  10. git sha : $Format:%H$
  11. copyright : (C) 2018 by Manche Numérique 2019
  12. email : olivier.massot@manchenumerique.fr
  13. ***************************************************************************/
  14. /***************************************************************************
  15. * *
  16. * This program is free software; you can redistribute it and/or modify *
  17. * it under the terms of the GNU General Public License as published by *
  18. * the Free Software Foundation; either version 2 of the License, or *
  19. * (at your option) any later version. *
  20. * *
  21. ***************************************************************************/
  22. """
  23. import logging
  24. from PyQt5.QtGui import QIcon
  25. from PyQt5.QtWidgets import QAction
  26. from core import logconf
  27. from core.constants import MAIN
  28. from ui.dlg_main import DlgMain
  29. __VERSION__ = "0.1.0"
  30. logger = logging.getLogger("mncheck")
  31. logconf.start("mncheck", logging.DEBUG)
  32. class MnCheck:
  33. def __init__(self, iface):
  34. self.iface = iface
  35. self.plugin_dir = MAIN
  36. self.dlg = DlgMain()
  37. self.actions = []
  38. self.menu = '&MnCheck'
  39. self.toolbar = self.iface.addToolBar('MnCheck')
  40. self.toolbar.setObjectName('MnCheck')
  41. def add_action(self, icon_path, text, callback, enabled_flag=True, add_to_menu=True,
  42. add_to_toolbar=True, status_tip=None, whats_this=None, parent=None):
  43. icon = QIcon(icon_path)
  44. action = QAction(icon, text, parent)
  45. action.triggered.connect(callback)
  46. action.setEnabled(enabled_flag)
  47. if status_tip is not None:
  48. action.setStatusTip(status_tip)
  49. if whats_this is not None:
  50. action.setWhatsThis(whats_this)
  51. if add_to_toolbar:
  52. self.toolbar.addAction(action)
  53. if add_to_menu:
  54. self.iface.addPluginToMenu(self.menu, action)
  55. self.actions.append(action)
  56. return action
  57. def initGui(self):
  58. """Create the menu entries and toolbar icons inside the QGIS GUI."""
  59. icon_path = MAIN / 'icon.png'
  60. self.add_action(icon_path, text='MnCheck', callback=self.run, parent=self.iface.mainWindow())
  61. def unload(self):
  62. """Removes the plugin menu item and icon from QGIS GUI."""
  63. for action in self.actions:
  64. self.iface.removePluginMenu('&MnCheck', action)
  65. self.iface.removeToolBarIcon(action)
  66. del self.toolbar
  67. def run(self):
  68. """Run method that performs all the real work"""
  69. self.dlg.show()
  70. result = self.dlg.exec_()
  71. if result:
  72. pass