-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainMenu.py
98 lines (82 loc) · 3.33 KB
/
MainMenu.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- coding: utf-8 -*-
"""
/***************************************************************************
NMTAnalysis
A QGIS plugin
Wtyczka QGIS umożliwiająca zautomatyzowane analizy numerycznych modeli terenu.
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2020-12-12
git sha : $Format:%H$
copyright : (C) 2020 by Eryk Chełchowski
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
"""
import os.path
from qgis.PyQt import QtGui
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QAction
from .MainMenu_UI.MainMenu_UI import NMTMainMenu
class NMTAnalysis:
def __init__(self, iface):
self.iface = iface
self.plugin_dir = os.path.dirname(__file__)
self.actions = []
self.menu = self.tr(u'&Analizy NMT')
self.first_start = None
def tr(self, message):
return QCoreApplication.translate('NMTAnalysis', message)
def add_action(
self,
icon_path,
text,
callback,
enabled_flag=True,
status_tip=None,
whats_this=None,
parent=None):
icon = QIcon(icon_path)
action = QAction(icon, text, parent)
action.triggered.connect(callback)
action.setEnabled(enabled_flag)
if status_tip is not None:
action.setStatusTip(status_tip)
if whats_this is not None:
action.setWhatsThis(whats_this)
self.iface.addToolBarIcon(action)
self.iface.addPluginToMenu(self.menu, action)
self.actions.append(action)
return action
def initGui(self):
icon_path = os.path.join(self.plugin_dir, 'images/icon_s.png')
self.add_action(
icon_path,
text=self.tr('Analizy NMT'),
callback=self.run,
parent=self.iface.mainWindow())
self.first_start = True
def unload(self):
for action in self.actions:
self.iface.removePluginMenu(
self.tr('Analizy NMT'),
action)
self.iface.removeToolBarIcon(action)
def run(self):
if self.first_start:
self.first_start = False
self.dlg = NMTMainMenu(plugin_path=self.plugin_dir)
self.dlg.setWindowIcon(
QtGui.QIcon(os.path.join(self.plugin_dir, 'images/icon.png')))
else:
self.dlg.btn_gen_model3d.setEnabled(True)
self.dlg.show()
result = self.dlg.exec_()