summaryrefslogtreecommitdiff
path: root/src/main/python/utils/dialogs.py
diff options
context:
space:
mode:
authorBlaine2020-05-07 13:08:08 +0530
committerBlaine2020-05-07 13:08:08 +0530
commit47ab33d71bec2e099b0bd6a432b3cbae067f4bba (patch)
tree5a55218787a65ae1482233d99b58b2127a3e1fbb /src/main/python/utils/dialogs.py
parent6c5a39579c737d0054e29403ec0a045cc6a6d52a (diff)
downloadChemical-PFD-47ab33d71bec2e099b0bd6a432b3cbae067f4bba.tar.gz
Chemical-PFD-47ab33d71bec2e099b0bd6a432b3cbae067f4bba.tar.bz2
Chemical-PFD-47ab33d71bec2e099b0bd6a432b3cbae067f4bba.zip
added context menu plus dialog to side view tab
Diffstat (limited to 'src/main/python/utils/dialogs.py')
-rw-r--r--src/main/python/utils/dialogs.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/python/utils/dialogs.py b/src/main/python/utils/dialogs.py
index 4970468..8ab8f6f 100644
--- a/src/main/python/utils/dialogs.py
+++ b/src/main/python/utils/dialogs.py
@@ -59,7 +59,41 @@ class paperDims(QDialog):
self.deleteLater() #remove from memory
#if ok was pressed return value else return None
return (self._canvasSize, self._ppi) if self.result() else None
+
+class sideViewSwitchDialog(QDialog):
+
+ def __init__(self, parent=None, tabList = None, initial = None):
+ super(sideViewSwitchDialog, self).__init__(parent=parent)
+ self.tabList = tabList
+ self.returnVal = initial
+ self.initial = initial
+
+ dialogBoxLayout = QFormLayout(self)
+ tabListComboBox = QComboBox()
+ tabListComboBox.addItems(self.tabList)
+ tabListComboBox.activated[str].connect(lambda x: setattr(self, 'returnVal', self.tabList.index(x)))
+ tabLabel = QLabel("Change Side View")
+ tabLabel.setBuddy(tabListComboBox) # label for the above combo box
+ tabListComboBox.setCurrentIndex(self.returnVal)
+ dialogBoxLayout.setWidget(1, QFormLayout.LabelRole, tabLabel)
+ dialogBoxLayout.setWidget(1, QFormLayout.FieldRole, tabListComboBox)
+
+ # add ok and cancel buttons
+ buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
+ buttonBox.accepted.connect(self.accept)
+ buttonBox.rejected.connect(self.reject)
+ dialogBoxLayout.addWidget(buttonBox)
+ self.setLayout(dialogBoxLayout)
+ self.resize(300,100) #resize to a certain size
+
+ def exec_(self):
+ #overload exec_ to add return values and delete itself(currently being tested)
+ super(sideViewSwitchDialog, self).exec_()
+ self.deleteLater() #remove from memory
+ #if ok was pressed return value else return None
+ return self.returnVal if self.result() else self.initial
+
def saveEvent(parent = None):
#utility function to generate a Qt alert window requesting the user to save the file, returns user intention on window close
alert = QMessageBox.question(parent, parent.objectName(), "All unsaved progress will be LOST!",