-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcode_Find.py
135 lines (98 loc) · 3.87 KB
/
code_Find.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# import project files
import form_Find
import code_Lists
from PyQt5.QtGui import (
QCursor,
QFont
)
from PyQt5.QtCore import (
Qt,
pyqtSignal
)
from PyQt5.QtWidgets import (
QApplication,
QMdiSubWindow,
)
class Find(QMdiSubWindow, form_Find.Ui_frmFind):
resized = pyqtSignal()
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
self.setAttribute(Qt.WA_DeleteOnClose,True)
self.mdiParent = ""
self.resized.connect(self.resizeMe)
self.btnFind.clicked.connect(self.CreateFindResults)
self.btnCancel.clicked.connect(self.Cancel)
self.txtFind.setFocus()
def CreateFindResults(self):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
#The user has accepted the has clicked OK
searchString = self.txtFind.text()
# get names of which checkboxes are checked
checkedBoxes = []
for c in ([
self.chkCommonName,
self.chkScientificName,
self.chkCountryName,
self.chkStateName,
self.chkCountyName,
self.chkLocationName,
self.chkSpeciesComments,
self.chkChecklistComments
]):
if c.isChecked() is True:
checkedBoxes.append(c.objectName())
# get search results
found = self.mdiParent.db.GetFindResults(searchString, checkedBoxes)
# create child window
sub = code_Lists.Lists()
# save the MDI window as the parent for future use in the child
sub.mdiParent = self.mdiParent
# call the child's fill routine, passing the filter settings list
sub.FillFindChecklists(found)
self.parent().parent().addSubWindow(sub)
self.mdiParent.PositionChildWindow(sub, self)
sub.show()
QApplication.restoreOverrideCursor()
# close the Find child
self.close()
def Cancel(self):
self.close()
def resizeEvent(self, event):
#routine to handle events on objects, like clicks, lost focus, gained forcus, etc.
self.resized.emit()
return super(self.__class__, self).resizeEvent(event)
def resizeMe(self):
windowWidth = self.frameGeometry().width()
windowHeight = self.frameGeometry().height()
self.scrollArea.setGeometry(5, 27, windowWidth - 10, windowHeight - 32)
def scaleMe(self):
metrics = self.txtFind.fontMetrics()
textHeight = metrics.boundingRect("ABCD").height()
self.txtFind.resize(self.txtFind.x(), textHeight)
self.lblFind.resize(self.txtFind.x(), textHeight)
fontSize = self.mdiParent.fontSize
for c in ([
self.chkCommonName,
self.chkScientificName,
self.chkCountryName,
self.chkStateName,
self.chkCountyName,
self.chkLocationName,
self.chkSpeciesComments,
self.chkChecklistComments
]):
c.setFont(QFont("Helvetica", fontSize))
c.resize(c.x(), textHeight * 1.1)
scaleFactor = self.mdiParent.scaleFactor
windowWidth = 400 * scaleFactor
windowHeight = 300 * scaleFactor
self.resize(windowWidth, windowHeight)
baseFont = QFont(QFont("Helvetica", fontSize))
self.lblFind.setFont(baseFont)
self.lblWhatToSearch.setFont(baseFont)
self.txtFind.setFont(baseFont)
metrics = self.txtFind.fontMetrics()
textHeight = metrics.boundingRect("2222-22-22").height()
self.txtFind.resize(self.txtFind.x(), textHeight)
self.lblFind.resize(self.txtFind.x(), textHeight)