2 from PyQt4
import QtCore, QtGui
6 QtGui.QWidget.__init__(self, parent)
8 self.default_font_.setForeground(QtGui.QBrush(QtGui.QColor(0,0,0)))
10 self.error_font_.setForeground(QtGui.QBrush(QtGui.QColor(255,0,0)))
12 self.selection_edit_.setFixedHeight(40)
13 self.selection_edit_.updateGeometry()
15 self.status_.setWordWrap(
True)
16 self.status_.setMargin(0)
17 self.status_.setAlignment(QtCore.Qt.AlignRight)
18 self.status_.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
19 QtGui.QSizePolicy.Expanding))
20 vl=QtGui.QVBoxLayout()
25 self.in_bonds_.setChecked(
True)
32 hl=QtGui.QHBoxLayout()
33 l=QtGui.QLabel(
"bonds:")
48 QtCore.QObject.connect(self.
timer_, QtCore.SIGNAL(
'timeout()'),
53 if self.no_bonds_.isChecked():
55 if self.ex_bonds_.isChecked():
56 flags|=mol.EXCLUSIVE_BONDS
57 if self.match_res_.isChecked():
58 flags|=mol.MATCH_RESIDUES
62 return mol.Query(str(self.selection_edit_.toPlainText()))
65 return str(self.selection_edit_.toPlainText())
68 self.no_bonds_.setChecked(flags & mol.NO_BONDS)
69 self.ex_bonds_.setChecked(flags & mol.EXCLUSIVE_BONDS)
70 self.in_bonds_.setChecked(
not (flags & mol.NO_BONDS|mol.EXCLUSIVE_BONDS))
71 self.match_res_.setChecked(flags & mol.MATCH_RESIDUES)
74 self.selection_edit_.setText(query)
76 def _StartTimer(self):
78 self.timer_.start(500)
80 def _UpdateMessage(self):
86 cursor=self.selection_edit_.textCursor()
87 cursor.select(QtGui.QTextCursor.Document)
91 self.status_.setText(
"")
93 d=query.GetErrorDescription()
94 self.status_.setText(
"<font color='red'>%s</font>"%d.msg.strip())
96 cursor.movePosition(QtGui.QTextCursor.Start)
97 if d.range.Loc<len(query.string):
99 cursor.movePosition(QtGui.QTextCursor.NextCharacter,
100 QtGui.QTextCursor.MoveAnchor, d.range.Loc)
101 cursor.movePosition(QtGui.QTextCursor.NextCharacter,
102 QtGui.QTextCursor.KeepAnchor, d.range.Length)
108 QtGui.QDialog.__init__(self, parent)
109 l=QtGui.QVBoxLayout(self)
110 self.setWindowTitle(title)
114 l3=QtGui.QHBoxLayout()
115 ab=QtGui.QPushButton(
'OK')
117 cb=QtGui.QPushButton(
'Cancel')
122 QtCore.QObject.connect(cb, QtCore.SIGNAL(
'clicked()'), self.reject)
123 QtCore.QObject.connect(ab, QtCore.SIGNAL(
'clicked()'), self.accept)
124 self.connect(self.editor.selection_edit_,QtCore.SIGNAL(
"textChanged()"),self.
_CheckNewline)
128 return self.editor.GetQueryFlags()
131 return self.editor.GetQueryText()
134 if e.type() == QtCore.QEvent.KeyPress
and (e.key () == QtCore.Qt.Key_Return
or e.key () == QtCore.Qt.Key_Enter):
138 return QtGui.QDialog.event(self, e)
140 def _CheckNewline(self):
141 if self.editor.GetQueryText().endswith(
"\n"):