-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkwg_plugin_dialog.py
97 lines (82 loc) · 4.21 KB
/
kwg_plugin_dialog.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
# -*- coding: utf-8 -*-
"""
/***************************************************************************
kwg_pluginDialog
A QGIS plugin
KWG plugin
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2021-06-04
git sha : $Format:%H$
copyright : (C) 2021 by Rushiraj Nenuji, University of California Santa Barbara
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 logging
import os
from qgis.PyQt import QtWidgets, Qt
from qgis.PyQt import uic
# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QSplitter, QTextEdit, QFrame, QDockWidget, QListWidget, QMessageBox
from PyQt5.uic.properties import QtCore
from .resources import *
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'kwg_plugin_dialog_base.ui'))
class kwg_pluginDialog(QtWidgets.QDialog, FORM_CLASS):
def __init__(self, parent=None):
"""Constructor."""
super(kwg_pluginDialog, self).__init__(parent)
# Set up the user interface from Designer through FORM_CLASS.
# After self.setupUi() you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
# displaying help
self.displayingHelp = False
self.setFixedWidth(650)
self.plainTextEdit.setHidden(True)
self.plainTextEdit.setReadOnly(True)
# logging
self.logger = logging.getLogger()
self.logger.setLevel(logging.DEBUG)
self.path = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
if not os.path.exists(os.path.join(self.path, 'logs')):
os.makedirs(os.path.join(self.path, 'logs'))
handler = logging.FileHandler(os.path.join(self.path, 'logs', 'kwg_geoenrichment.log'), 'w+', 'utf-8')
formatter = logging.Formatter(
'%(asctime)s - %(levelname)s - %(filename)s:%(funcName)s - %(message)s')
handler.setFormatter(formatter) # Pass handler as a parameter, not assign
self.logger.addHandler(handler)
self.toolButton.setIcon(QIcon(":/plugins/kwg_geoenrichment/resources/help-circle.png"))
self.toolButton.setIconSize(QtCore.QSize(32, 32))
self.pushButton_gdb.setIcon(QIcon(":/plugins/kwg_geoenrichment/resources/file.svg"))
self.pushButton_polygon.setIcon(QIcon(":/plugins/kwg_geoenrichment/resources/plus.svg"))
self.pushButton_refresh.setIcon(QIcon(":/plugins/kwg_geoenrichment/resources/refresh.svg"))
self.pushButton_gdb.setIconSize(QtCore.QSize(24, 24))
self.pushButton_polygon.setIconSize(QtCore.QSize(24, 24))
self.pushButton_refresh.setIconSize(QtCore.QSize(24, 24))
self.toolButton.clicked.connect(self.displayHelp)
stylesheet = os.path.join(self.path, 'style.qss')
fo = open(stylesheet, "r")
self.setStyleSheet(fo.read())
fo.close()
def displayHelp(self):
if self.displayingHelp:
self.displayingHelp = False
self.plainTextEdit.setHidden(True)
self.setFixedWidth(650)
else:
self.displayingHelp = True
self.plainTextEdit.setVisible(True)
self.setFixedWidth(850)