-
Notifications
You must be signed in to change notification settings - Fork 0
/
puplugin.py
83 lines (59 loc) · 2.75 KB
/
puplugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
"""
/***************************************************************************
puPlugin
A QGIS plugin
Plugin pro pozemkové úpravy
-------------------
begin : 2016-09-01
git sha : $Format:%H$
copyright : (C) 2016 by Ondřej Svoboda
email : svoboond@gmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
from PyQt4.QtGui import QAction, QIcon, QToolButton, QPixmap
from PyQt4.QtCore import QDir, Qt
import os
from pubin import dockwidget
class puPlugin(object):
"""The main class of the PU Plugin."""
def __init__(self, iface):
"""Constructor.
Args:
iface (QgisInterface): A reference to the QgisInterface.
"""
self.iface = iface
self.name = u'PU Plugin'
self.pluginDir = QDir(os.path.dirname(__file__))
def initGui(self):
"""Initializes GUI."""
self.puAction = QAction(self.iface.mainWindow())
self.puAction.setText(self.name)
puIcon = QIcon(self.pluginDir.filePath(u'puplugin.svg'))
self.puAction.setIcon(puIcon)
self.puAction.triggered.connect(self.run)
self.iface.addToolBarIcon(self.puAction)
self.iface.addPluginToMenu(self.name, self.puAction)
self.dockWidget = dockwidget.DockWidget(
self.iface, self.pluginDir, self.name)
self.iface.addDockWidget(Qt.TopDockWidgetArea, self.dockWidget)
def unload(self):
"""Removes the plugin menu and icon."""
self.dockWidget.disconnect_from_iface()
self.iface.removePluginMenu(self.name, self.puAction)
self.iface.removeToolBarIcon(self.puAction)
self.iface.removeDockWidget(self.dockWidget)
def run(self):
"""Shows the dockWidget if not visible, otherwise hides it."""
if not self.dockWidget.isVisible():
self.dockWidget.show()
else:
self.dockWidget.hide()