def toggle_groupbox(self, button, *things): """This is intended to be part of the slot method for clicking on an open/close icon of a dialog GroupBox. The arguments should be the button (whose icon will be altered here) and the child widgets in the groupbox whose visibility should be toggled. """ if things: if things[0].isVisible(): styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand = False) button.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() button.setPalette(palette) button.setIcon(geticon("ui/actions/Properties Manager/GHOST_ICON")) for thing in things: thing.hide() else: styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand = True) button.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() button.setPalette(palette) button.setIcon(geticon("ui/actions/Properties Manager/GHOST_ICON")) for thing in things: thing.show() else: print "Groupbox has no widgets. Clicking on groupbox button has no effect." return
def _createActions(self, parentWidget): self.exitProteinAction = NE1_QWidgetAction(parentWidget, win=self.win) self.exitProteinAction.setText("Exit Protein") self.exitProteinAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) self.exitProteinAction.setCheckable(True) self.buildPeptideAction = NE1_QWidgetAction(parentWidget, win=self.win) self.buildPeptideAction.setText("Peptide") self.buildPeptideAction.setCheckable(True) self.buildPeptideAction.setIcon( geticon("ui/actions/Tools/Build Structures/Peptide.png")) self.editRotamersAction = NE1_QWidgetAction(parentWidget, win=self.win) self.editRotamersAction.setText("Rotamers") self.editRotamersAction.setCheckable(True) self.editRotamersAction.setIcon( geticon("ui/actions/Tools/Build Structures/Rotamer.png")) self.editResiduesAction = NE1_QWidgetAction(parentWidget, win=self.win) self.editResiduesAction.setText("Residues") self.editResiduesAction.setCheckable(True) self.editResiduesAction.setIcon( geticon("ui/actions/Tools/Build Structures/Rotamer.png")) self.displayProteinStyleAction = NE1_QWidgetAction(parentWidget, win=self.win) self.displayProteinStyleAction.setText("Edit Style") self.displayProteinStyleAction.setCheckable(True) self.displayProteinStyleAction.setIcon( geticon("ui/actions/Edit/EditProteinDisplayStyle.png"))
def toggleExpandCollapse(self): """Slot method for the title button to expand/collapse the groupbox. """ if self.expanded: # Collapse groupbox by hiding ahe yellow TextEdit. # The styleSheet contains the expand/collapse icon. styleSheet = self.getTitleButtonStyleSheet(showExpanded = False) self.titleButton.setStyleSheet(styleSheet) # Why do we have to keep resetting the palette? # Does assigning a new styleSheet reset the button's palette? # If yes, we should add the button's color to the styleSheet. # Mark 2007-05-20 self.titleButton.setPalette(self.getTitleButtonPalette()) self.titleButton.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON")) self.MessageTextEdit.hide() self.expanded = False else: # Expand groupbox by showing the yellow TextEdit. # The styleSheet contains the expand/collapse icon. styleSheet = self.getTitleButtonStyleSheet(showExpanded = True) self.titleButton.setStyleSheet(styleSheet) # Why do we have to keep resetting the palette? # Does assigning a new styleSheet reset the button's palette? # If yes, we should add the button's color to the styleSheet. # Mark 2007-05-20 self.titleButton.setPalette(self.getTitleButtonPalette()) self.titleButton.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON")) self.MessageTextEdit.show() self.expanded = True
def toggle_groupbox(self, button, *things): """This is intended to be part of the slot method for clicking on an open/close icon of a dialog GroupBox. The arguments should be the button (whose icon will be altered here) and the child widgets in the groupbox whose visibility should be toggled. """ if things: if things[0].isVisible(): styleSheet = self.getGroupBoxButtonStyleSheet( bool_expand=False) button.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() button.setPalette(palette) button.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON")) for thing in things: thing.hide() else: styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand=True) button.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() button.setPalette(palette) button.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON")) for thing in things: thing.show() else: print "Groupbox has no widgets. Clicking on groupbox button has no effect." return
def toggleExpandCollapse(self): """Slot method for the title button to expand/collapse the groupbox. """ if self.expanded: # Collapse groupbox by hiding ahe yellow TextEdit. # The styleSheet contains the expand/collapse icon. styleSheet = self.getTitleButtonStyleSheet(showExpanded=False) self.titleButton.setStyleSheet(styleSheet) # Why do we have to keep resetting the palette? # Does assigning a new styleSheet reset the button's palette? # If yes, we should add the button's color to the styleSheet. # Mark 2007-05-20 self.titleButton.setPalette(self.getTitleButtonPalette()) self.titleButton.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON")) self.MessageTextEdit.hide() self.expanded = False else: # Expand groupbox by showing the yellow TextEdit. # The styleSheet contains the expand/collapse icon. styleSheet = self.getTitleButtonStyleSheet(showExpanded=True) self.titleButton.setStyleSheet(styleSheet) # Why do we have to keep resetting the palette? # Does assigning a new styleSheet reset the button's palette? # If yes, we should add the button's color to the styleSheet. # Mark 2007-05-20 self.titleButton.setPalette(self.getTitleButtonPalette()) self.titleButton.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON")) self.MessageTextEdit.show() self.expanded = True
def _createActions(self, parentWidget): self.exitDnaAction = NE1_QWidgetAction(parentWidget, win=self.win) self.exitDnaAction.setText("Exit DNA") self.exitDnaAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) self.exitDnaAction.setCheckable(True) self.dnaDuplexAction = NE1_QWidgetAction(parentWidget, win=self.win) self.dnaDuplexAction.setText("Insert DNA") self.dnaDuplexAction.setCheckable(True) self.dnaDuplexAction.setIcon( geticon("ui/actions/Tools/Build Structures/InsertDsDna.png")) self.breakStrandAction = NE1_QWidgetAction(parentWidget, win=self.win) self.breakStrandAction.setText("Break Strand") self.breakStrandAction.setCheckable(True) self.breakStrandAction.setIcon( geticon("ui/actions/Command Toolbar/Break_Strand.png")) self.joinStrandsAction = NE1_QWidgetAction(parentWidget, win=self.win) self.joinStrandsAction.setText("Join Strands") self.joinStrandsAction.setCheckable(True) self.joinStrandsAction.setIcon( geticon("ui/actions/Command Toolbar/Join_Strands.png")) self.makeCrossoversAction = NE1_QWidgetAction(parentWidget, win=self.win) self.makeCrossoversAction.setText("Crossovers") self.makeCrossoversAction.setCheckable(True) self.makeCrossoversAction.setIcon( geticon("ui/actions/Command Toolbar/Crossover.png")) self.dnaOrigamiAction = NE1_QWidgetAction(parentWidget, win=self.win) self.dnaOrigamiAction.setText("Origami") self.dnaOrigamiAction.setIcon( geticon("ui/actions/Tools/Build Structures/DNA_Origami.png")) self.convertPAM3to5Action = NE1_QWidgetAction(parentWidget, win=self.win) self.convertPAM3to5Action.setText("PAM3 to PAM5") self.convertPAM3to5Action.setIcon( geticon("ui/actions/Command Toolbar/Convert3to5.png")) self.convertPAM5to3Action = NE1_QWidgetAction(parentWidget, win=self.win) self.convertPAM5to3Action.setText("PAM5 to PAM3") self.convertPAM5to3Action.setIcon( geticon("ui/actions/Command Toolbar/Convert5to3.png")) self.orderDnaAction = NE1_QWidgetAction(parentWidget, win=self.win) self.orderDnaAction.setText("Order DNA") self.orderDnaAction.setIcon( geticon("ui/actions/Command Toolbar/Order_DNA.png")) self.editDnaDisplayStyleAction = NE1_QWidgetAction(parentWidget, win=self.win) self.editDnaDisplayStyleAction.setText("Edit Style") self.editDnaDisplayStyleAction.setCheckable(True) self.editDnaDisplayStyleAction.setIcon( geticon("ui/actions/Edit/EditDnaDisplayStyle.png"))
def setupUi(self, orientationWidget): win = self.win MainWindow = self.win # Set the default width and height. _width = 150 _height = 280 _maxWidth = 400 # 400 should be more than enough. --mark # "View > Orientation" Dock Widget orientationWidget.setEnabled(True) orientationWidget.setFloating(True) orientationWidget.setVisible(False) orientationWidget.setWindowTitle("Orientation" ) orientationWidget.setWindowIcon( geticon("ui/actions/View/Modify/Orientation.png")) orientationWidget.setGeometry(QRect(0, 0, _width, _height)) orientationWidget.setMaximumWidth(400) x = max(0, win.geometry().x()) y = max(0, win.geometry().y()) orientationWidget.move(x, y) self.orientationWindowContents = QtGui.QWidget(orientationWidget) gridlayout = QtGui.QGridLayout(self.orientationWindowContents) gridlayout.setMargin(4) gridlayout.setSpacing(4) hboxlayout = QtGui.QHBoxLayout() hboxlayout.setMargin(0) hboxlayout.setSpacing(6) self.pinOrientationWindowToolButton = QtGui.QToolButton(self.orientationWindowContents) self.pinOrientationWindowToolButton.setCheckable(True) self.pinOrientationWindowToolButton.setIcon( geticon("ui/dialogs/unpinned.png")) hboxlayout.addWidget(self.pinOrientationWindowToolButton) self.saveNamedViewToolButton = QtGui.QToolButton(self.orientationWindowContents) self.saveNamedViewToolButton.setIcon( geticon("ui/actions/View/Modify/Save_Named_View.png")) #@@ ninad 061115 dir path will be modified hboxlayout.addWidget(self.saveNamedViewToolButton) gridlayout.addLayout(hboxlayout, 0, 0, 1, 1) self.orientationViewList = QtGui.QListWidget(orientationWidget) self.orientationViewList.setFlow(QtGui.QListWidget.TopToBottom) self.orientationViewList.setWindowIcon( geticon("ui/actions/View/Modify/Orientation.png")) gridlayout.addWidget(self.orientationViewList, 1, 0, 1, 1) orientationWidget.setWidget(self.orientationWindowContents) MainWindow.addDockWidget(Qt.BottomDockWidgetArea, orientationWidget)
def changePinIcon(self): """ Change the icon of the Pinned button """ if self.pinOrientationWindowToolButton.isChecked(): self.pinOrientationWindowToolButton.setIcon( geticon("ui/dialogs/pinned.png")) else: self.pinOrientationWindowToolButton.setIcon( geticon("ui/dialogs/unpinned.png"))
def changePinIcon(self): """ Change the icon of the Pinned button """ if self.pinOrientationWindowToolButton.isChecked(): self.pinOrientationWindowToolButton.setIcon( geticon("ui/dialogs/pinned.png")) else: self.pinOrientationWindowToolButton.setIcon( geticon("ui/dialogs/unpinned.png"))
def _createActions(self, parentWidget): """ Define flyout toolbar actions for this mode. """ #@NOTE: In Build mode, some of the actions defined in this method are also #used in Build Atoms PM. (e.g. bond actions) So probably better to rename #it as _init_modeActions. Not doing that change in mmkit code cleanup #commit(other modes still implement a method by same name)-ninad20070717 _superclass._createActions(self, parentWidget) # The subControlActionGroup is the parent of all flyout QActions. self.subControlActionGroup = QActionGroup(parentWidget) # Shouldn't the parent be self.win? # Isn't parentWidget = BuildAtomsPropertyManager. # Ask Bruce about this. --Mark 2008-12-07. self.subControlActionGroup.setExclusive(True) #Following Actions are added in the Flyout toolbar. #Defining them outside that method as those are being used #by the subclasses of deposit mode (testmode.py as of 070410) -- ninad self.atomsToolAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.atomsToolAction.setText("Atoms Tool") self.atomsToolAction.setIcon(geticon( "ui/actions/Command Toolbar/BuildAtoms/AtomsTool.png")) self.atomsToolAction.setCheckable(True) self.atomsToolAction.setChecked(True) self.atomsToolAction.setObjectName('ACTION_ATOMS_TOOL') self.bondsToolAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.bondsToolAction.setText("Bonds Tool") self.bondsToolAction.setIcon(geticon( "ui/actions/Command Toolbar/BuildAtoms/BondsTool.png")) self.bondsToolAction.setCheckable(True) self.bondsToolAction.setObjectName('ACTION_BOND_TOOL') self.subControlActionGroup.addAction(self.atomsToolAction) self.subControlActionGroup.addAction(self.bondsToolAction) self.transmuteAtomsAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.transmuteAtomsAction.setText("Transmute Atoms") self.transmuteAtomsAction.setIcon(geticon( "ui/actions/Command Toolbar/BuildAtoms/TransmuteAtoms.png")) self.transmuteAtomsAction.setCheckable(False) self._createBondToolActions(parentWidget)
def _createActions(self, parentWidget): """ Define flyout toolbar actions for this mode. """ #@NOTE: In Build mode, some of the actions defined in this method are also #used in Build Atoms PM. (e.g. bond actions) So probably better to rename #it as _init_modeActions. Not doing that change in mmkit code cleanup #commit(other modes still implement a method by same name)-ninad20070717 _superclass._createActions(self, parentWidget) # The subControlActionGroup is the parent of all flyout QActions. self.subControlActionGroup = QActionGroup(parentWidget) # Shouldn't the parent be self.win? # Isn't parentWidget = BuildAtomsPropertyManager. # Ask Bruce about this. --Mark 2008-12-07. self.subControlActionGroup.setExclusive(True) #Following Actions are added in the Flyout toolbar. #Defining them outside that method as those are being used #by the subclasses of deposit mode (testmode.py as of 070410) -- ninad self.atomsToolAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.atomsToolAction.setText("Atoms Tool") self.atomsToolAction.setIcon( geticon("ui/actions/Command Toolbar/BuildAtoms/AtomsTool.png")) self.atomsToolAction.setCheckable(True) self.atomsToolAction.setChecked(True) self.atomsToolAction.setObjectName('ACTION_ATOMS_TOOL') self.bondsToolAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.bondsToolAction.setText("Bonds Tool") self.bondsToolAction.setIcon( geticon("ui/actions/Command Toolbar/BuildAtoms/BondsTool.png")) self.bondsToolAction.setCheckable(True) self.bondsToolAction.setObjectName('ACTION_BOND_TOOL') self.subControlActionGroup.addAction(self.atomsToolAction) self.subControlActionGroup.addAction(self.bondsToolAction) self.transmuteAtomsAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.transmuteAtomsAction.setText("Transmute Atoms") self.transmuteAtomsAction.setIcon( geticon( "ui/actions/Command Toolbar/BuildAtoms/TransmuteAtoms.png")) self.transmuteAtomsAction.setCheckable(False) self._createBondToolActions(parentWidget)
def _createSimulateProteinsActions(self, parentWidget): """ Create the actions to be included in flyout toolbar, when the 'Simulate Proteins' is active. @see: self._createActions() where this is called. """ self.subControlActionGroupForSimulateProtein = QActionGroup( parentWidget) # Shouldn't the parent be self.win? # Isn't parentWidget = BuildProteinPropertyManager? # Ask Bruce about this. --Mark 2008-12-07. self.subControlActionGroupForSimulateProtein.setExclusive(True) self.rosetta_fixedbb_design_Action = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.rosetta_fixedbb_design_Action.setText("Fixed BB") self.rosetta_fixedbb_design_Action.setCheckable(True) self.rosetta_fixedbb_design_Action.setIcon( geticon( "ui/actions/Command Toolbar/BuildProtein/FixedBackbone.png")) self.rosetta_backrub_Action = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.rosetta_backrub_Action.setText("Backrub") self.rosetta_backrub_Action.setCheckable(True) self.rosetta_backrub_Action.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Backrub.png")) self.editResiduesAction = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.editResiduesAction.setText("Residues") self.editResiduesAction.setCheckable(True) self.editResiduesAction.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Residues.png")) self.rosetta_score_Action = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.rosetta_score_Action.setText("Score") self.rosetta_score_Action.setCheckable(True) self.rosetta_score_Action.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Score.png")) self.subControlActionGroupForSimulateProtein.addAction( self.rosetta_fixedbb_design_Action) self.subControlActionGroupForSimulateProtein.addAction( self.rosetta_backrub_Action) self.subControlActionGroupForSimulateProtein.addAction( self.editResiduesAction) self.subControlActionGroupForSimulateProtein.addAction( self.rosetta_score_Action) return
def _createActions(self, parentWidget): self.exitNanotubeAction = NE1_QWidgetAction(parentWidget, win=self.win) self.exitNanotubeAction.setText("Exit NT") self.exitNanotubeAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) self.exitNanotubeAction.setCheckable(True) self.insertNanotubeAction = NE1_QWidgetAction(parentWidget, win=self.win) self.insertNanotubeAction.setText("Insert NT") self.insertNanotubeAction.setCheckable(True) self.insertNanotubeAction.setIcon( geticon("ui/actions/Tools/Build Structures/InsertNanotube.png"))
def _createActions(self, parentWidget): """ Define flyout toolbar actions for this mode. """ _superclass._createActions(self, parentWidget) #Urmi 20080814: show this flyout toolbar only when rosetta plugin path # is there #Probably only rosetta_enabled_prefs_key check would have sufficed plugin_name = "ROSETTA" plugin_prefs_keys = (rosetta_enabled_prefs_key, rosetta_path_prefs_key) errorcode, errortext_or_path = \ checkPluginPreferences(plugin_name, plugin_prefs_keys, ask_for_help = False) #print "Error code =", errorcode, errortext_or_path if errorcode == 0: self.rosetta_enabled = True else: self.rosetta_enabled = False # The subControlActionGroup is the parent of all flyout QActions. self.subControlActionGroup = QActionGroup(parentWidget) # Shouldn't the parent be self.win? # Isn't parentWidget = BuildProteinPropertyManager? # Ask Bruce about this. --Mark 2008-12-07. self.subControlActionGroup.setExclusive(True) self.modelProteinAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.modelProteinAction.setText("Model") self.modelProteinAction.setIcon(geticon( 'ui/actions/Command Toolbar/BuildProtein/ModelProtein.png')) self.modelProteinAction.setCheckable(True) self.modelProteinAction.setChecked(True) self.modelProteinAction.setObjectName('ACTION_MODEL_PROTEINS') self.simulateProteinAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.simulateProteinAction.setText("Simulate") self.simulateProteinAction.setIcon(geticon( "ui/actions/Command Toolbar/BuildProtein/Simulate.png")) self.simulateProteinAction.setCheckable(True) self.simulateProteinAction.setObjectName('ACTION_SIMULATE_PROTEINS') self.subControlActionGroup.addAction(self.modelProteinAction) self.subControlActionGroup.addAction(self.simulateProteinAction) self._createModelProteinsActions(parentWidget) self._createSimulateProteinsActions(parentWidget)
def _createActions(self, parentWidget): self.exitNanotubeAction = NE1_QWidgetAction(parentWidget, win = self.win) self.exitNanotubeAction.setText("Exit NT") self.exitNanotubeAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) self.exitNanotubeAction.setCheckable(True) self.insertNanotubeAction = NE1_QWidgetAction(parentWidget, win = self.win) self.insertNanotubeAction.setText("Insert NT") self.insertNanotubeAction.setCheckable(True) self.insertNanotubeAction.setIcon( geticon("ui/actions/Tools/Build Structures/InsertNanotube.png"))
def _loadBackgroundColorItems(self): """ Load the background color combobox with all the color options and sets the current background color """ backgroundIndexes = [bg_BLUE_SKY, bg_EVENING_SKY, bg_SEAGREEN, bg_BLACK, bg_WHITE, bg_GRAY, bg_CUSTOM] backgroundNames = ["Blue Sky (default)", "Evening Sky", "Sea Green", "Black", "White", "Gray", "Custom..."] backgroundIcons = ["Background_BlueSky", "Background_EveningSky", "Background_SeaGreen", "Background_Black", "Background_White", "Background_Gray", "Background_Custom"] backgroundIconsDict = dict(zip(backgroundNames, backgroundIcons)) backgroundNamesDict = dict(zip(backgroundIndexes, backgroundNames)) for backgroundName in backgroundNames: basename = backgroundIconsDict[backgroundName] + ".png" iconPath = os.path.join("ui/dialogs/Preferences/", basename) self.backgroundColorComboBox.addItem(geticon(iconPath), backgroundName) self._updateBackgroundColorComboBoxIndex() # Not needed, but OK. return
def grab_text_using_dialog(default="", title="title", label="label", iconPath="ui/border/MainWindow.png"): """ Get some text from the user by putting up a dialog with the supplied title, label, and default text. Return (ok, text) as described below. Replace @@@ with \n in the returned text (and convert it to a Python string). If it contains unicode characters, raise UnicodeEncodeError. @return: the 2-tuple (ok, text), which is (True, text) if we succeed, or (False, None) if the user cancels. """ # TODO: add an option to allow this to accept unicode, # and do something better if that's not provided and unicode is entered # (right now it just raises a UnicodeEncodeError). # modified from _set_test_from_dialog( ), # which was modified from debug_runpycode_from_a_dialog, # which does the "run py code" debug menu command # Qt4 version [070329; similar code in an exprs-module file] inputDialog = QDialog() # No parent inputDialog.setWindowIcon(geticon(iconPath)) text, ok = QInputDialog.getText(inputDialog, title, label, QLineEdit.Normal, default) # note: parent arg is needed in Qt4, not in Qt3 if ok: # fyi: type(text) == <class '__main__.qt.QString'> text = str(text) text = text.replace("@@@", "\n") else: pass # print "grab_text_using_dialog: cancelled" return ok, text
def __init__(self, jig, glpane): """ Constructor for the class JigProp. @param jig: the jig whose property dialog will be shown @type jig: L{Jig} @param glpane: GLPane object @type glpane: L{GLPane} """ QDialog.__init__(self) self.setupUi(self) self.connect(self.cancel_btn, SIGNAL("clicked()"), self.reject) self.connect(self.ok_btn, SIGNAL("clicked()"), self.accept) self.connect(self.choose_color_btn, SIGNAL("clicked()"), self.change_jig_color) # Set the dialog's border icon and caption based on the jig type. jigtype_name = jig.__class__.__name__ # Fixes bug 1208. mark 060112. self.setWindowIcon(geticon("ui/border/"+ jigtype_name)) self.setWindowTitle(jigtype_name + " Properties") self.jig = jig self.glpane = glpane
def showProgress(self, modal=True): """ Open the progress dialog to show the current job progress. """ #Replace "self.edit_cntl.win" with "None" #---Huaicai 7/7/05: To fix bug 751, the "win" may be none. #Feel awkward for the design of our code. simProgressDialog = QProgressDialog() simProgressDialog.setModal(True) simProgressDialog.setObjectName("progressDialog") simProgressDialog.setWindowIcon(geticon('ui/border/MainWindow')) if self.Calculation == 'Energy': simProgressDialog.setWindowTitle( "Calculating Energy ...Please Wait") else: simProgressDialog.setWindowTitle("Optimizing ...Please Wait") progBar = QProgressBar(simProgressDialog) progBar.setMaximum(0) progBar.setMinimum(0) progBar.setValue(0) progBar.setTextVisible(False) simProgressDialog.setBar(progBar) simProgressDialog.setAutoReset(False) simProgressDialog.setAutoClose(False) return simProgressDialog
def insertItems(self, row, items, setAsDefault = True): """ Insert the <items> specified items in this list widget. The list widget shows item name string , as a QListwidgetItem. This QListWidgetItem object defines a 'key' of a dictionary (self._itemDictionary) and the 'value' of this key is the object specified by the 'item' itself. Example: self._itemDictionary['C6'] = instance of class Atom. @param row: The row number for the item. @type row: int @param items: A list of objects. These objects are treated as values in the self._itemDictionary @type items: list @param setAsDefault: Not used here. See PM_ListWidget.insertItems where it is used. @see: self.renameItemValue() for a comment about self._suppress_itemChanged_signal """ #delete unused argument. Should this be provided as an argument in this #class method ? del setAsDefault #self.__init__ for a comment about this flag self._suppress_itemChanged_signal = True #Clear the previous contents of the self._itemDictionary self._itemDictionary.clear() #Clear the contents of this list widget, using QListWidget.clear() #See U{<http://doc.trolltech.com/4.2/qlistwidget.html>} for details self.clear() for item in items: if hasattr(item.__class__, 'name'): itemName = item.name else: itemName = str(item) listWidgetItem = QListWidgetItem(itemName, self) #When we support editing list widget items , uncomment out the #following line . See also self.editItems -- Ninad 2008-01-16 listWidgetItem.setFlags( listWidgetItem.flags()| Qt.ItemIsEditable) if hasattr(item.__class__, 'iconPath'): try: listWidgetItem.setIcon(geticon(item.iconPath)) except: print_compact_traceback() self._itemDictionary[listWidgetItem] = item #Reset the flag that temporarily suppresses itemChange signal. self._suppress_itemChanged_signal = False
def _createToolButton(self, widgetParams): """ Returns a tool button created using the custom parameters. @param widgetParams: A list containing tool button parameters. @type widgetParams: list @see: L{self._createWidgetUsingParameters} where this method is called. """ buttonSize = QSize(32, 32) #@ FOR TEST ONLY buttonParams = list(widgetParams) buttonId = buttonParams[1] buttonText = buttonParams[2] buttonIconPath = buttonParams[3] buttonToolTip = buttonParams[4] buttonShortcut = buttonParams[5] button = QToolButton(self) button.setText(buttonText) if buttonIconPath: buttonIcon = geticon(buttonIconPath) if not buttonIcon.isNull(): button.setIcon(buttonIcon) button.setIconSize(QSize(22, 22)) button.setToolTip(buttonToolTip) if buttonShortcut: button.setShortcut(buttonShortcut) button.setFixedSize(buttonSize) #@ Currently fixed to 32 x 32. button.setCheckable(True) return button
def _createToolButton(self, widgetParams): """ Returns a tool button created using the custom parameters. @param widgetParams: A list containing tool button parameters. @type widgetParams: list @see: L{self._createWidgetUsingParameters} where this method is called. """ buttonSize = QSize(32, 32) #@ FOR TEST ONLY buttonParams = list(widgetParams) buttonId = buttonParams[1] buttonText = buttonParams[2] buttonIconPath = buttonParams[3] buttonToolTip = buttonParams[4] buttonShortcut = buttonParams[5] button = QToolButton(self) button.setText(buttonText) if buttonIconPath: buttonIcon = geticon(buttonIconPath) if not buttonIcon.isNull(): button.setIcon(buttonIcon) button.setIconSize(QSize(22, 22)) button.setToolTip(buttonToolTip) if buttonShortcut: button.setShortcut(buttonShortcut) button.setFixedSize(buttonSize) #@ Currently fixed to 32 x 32. button.setCheckable(True) return button
def showProgress(self, modal = True): """ Open the progress dialog to show the current job progress. """ #Replace "self.edit_cntl.win" with "None" #---Huaicai 7/7/05: To fix bug 751, the "win" may be none. #Feel awkward for the design of our code. simProgressDialog = QProgressDialog() simProgressDialog.setModal(True) simProgressDialog.setObjectName("progressDialog") simProgressDialog.setWindowIcon(geticon('ui/border/MainWindow')) if self.Calculation == 'Energy': simProgressDialog.setWindowTitle("Calculating Energy ...Please Wait") else: simProgressDialog.setWindowTitle("Optimizing ...Please Wait") progBar = QProgressBar(simProgressDialog) progBar.setMaximum(0) progBar.setMinimum(0) progBar.setValue(0) progBar.setTextVisible(False) simProgressDialog.setBar(progBar) simProgressDialog.setAutoReset(False) simProgressDialog.setAutoClose(False) return simProgressDialog
def getGroupBoxTitleButton(self, name, parent=None, bool_expand=True): #Ninad 070206 """ Return the groupbox title pushbutton. The pushbutton is customized such that it appears as a title bar to the user. If the user clicks on this 'titlebar' it sends appropriate signals to open or close the groupboxes 'name = string -- title of the groupbox 'bool_expand' = boolean .. NE1 uses a different background image in the button's Style Sheet depending on the bool. (i.e. if bool_expand = True it uses a opened group image '^') See also: getGroupBoxTitleCheckBox , getGroupBoxButtonStyleSheet methods """ button = QtGui.QPushButton(name, parent) button.setFlat(False) button.setAutoFillBackground(True) palette = self.getGroupBoxButtonPalette() button.setPalette(palette) styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand) button.setStyleSheet(styleSheet) #ninad 070221 set a non existant 'Ghost Icon' for this button #By setting such an icon, the button text left aligns! #(which what we want :-) ) #So this might be a bug in Qt4.2. If we don't use the following kludge, #there is no way to left align the push button text but to subclass it. #(could mean a lot of work for such a minor thing) So OK for now button.setIcon(geticon("ui/actions/Properties Manager/GHOST_ICON")) return button
def insertItems(self, row, items, setAsDefault = True): """ Insert the <items> specified items in this list widget. The list widget shows item name string , as a QListwidgetItem. This QListWidgetItem object defines a 'key' of a dictionary (self._itemDictionary) and the 'value' of this key is the object specified by the 'item' itself. Example: self._itemDictionary['C6'] = instance of class Atom. @param row: The row number for the item. @type row: int @param items: A list of objects. These objects are treated as values in the self._itemDictionary @type items: list @param setAsDefault: Not used here. See PM_ListWidget.insertItems where it is used. @see: self.renameItemValue() for a comment about self._suppress_itemChanged_signal """ #delete unused argument. Should this be provided as an argument in this #class method ? del setAsDefault #self.__init__ for a comment about this flag self._suppress_itemChanged_signal = True #Clear the previous contents of the self._itemDictionary self._itemDictionary.clear() #Clear the contents of this list widget, using QListWidget.clear() #See U{<http://doc.trolltech.com/4.2/qlistwidget.html>} for details self.clear() for item in items: if hasattr(item.__class__, 'name'): itemName = item.name else: itemName = str(item) listWidgetItem = QListWidgetItem(itemName, self) #When we support editing list widget items , uncomment out the #following line . See also self.editItems -- Ninad 2008-01-16 listWidgetItem.setFlags( listWidgetItem.flags()| Qt.ItemIsEditable) if hasattr(item.__class__, 'iconPath'): try: listWidgetItem.setIcon(geticon(item.iconPath)) except: print_compact_traceback() self._itemDictionary[listWidgetItem] = item #Reset the flag that temporarily suppresses itemChange signal. self._suppress_itemChanged_signal = False
def getGroupBoxTitleButton(self, name, parent = None, bool_expand = True): #Ninad 070206 """ Return the groupbox title pushbutton. The pushbutton is customized such that it appears as a title bar to the user. If the user clicks on this 'titlebar' it sends appropriate signals to open or close the groupboxes 'name = string -- title of the groupbox 'bool_expand' = boolean .. NE1 uses a different background image in the button's Style Sheet depending on the bool. (i.e. if bool_expand = True it uses a opened group image '^') See also: getGroupBoxTitleCheckBox , getGroupBoxButtonStyleSheet methods """ button = QtGui.QPushButton(name, parent) button.setFlat(False) button.setAutoFillBackground(True) palette = self.getGroupBoxButtonPalette() button.setPalette(palette) styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand) button.setStyleSheet(styleSheet) #ninad 070221 set a non existant 'Ghost Icon' for this button #By setting such an icon, the button text left aligns! #(which what we want :-) ) #So this might be a bug in Qt4.2. If we don't use the following kludge, #there is no way to left align the push button text but to subclass it. #(could mean a lot of work for such a minor thing) So OK for now button.setIcon(geticon("ui/actions/Properties Manager/GHOST_ICON")) return button
def _createSimulateProteinsActions(self, parentWidget): """ Create the actions to be included in flyout toolbar, when the 'Simulate Proteins' is active. @see: self._createActions() where this is called. """ self.subControlActionGroupForSimulateProtein = QActionGroup(parentWidget) # Shouldn't the parent be self.win? # Isn't parentWidget = BuildProteinPropertyManager? # Ask Bruce about this. --Mark 2008-12-07. self.subControlActionGroupForSimulateProtein.setExclusive(True) self.rosetta_fixedbb_design_Action = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.rosetta_fixedbb_design_Action.setText("Fixed BB") self.rosetta_fixedbb_design_Action.setCheckable(True) self.rosetta_fixedbb_design_Action.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/FixedBackbone.png")) self.rosetta_backrub_Action = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.rosetta_backrub_Action.setText("Backrub") self.rosetta_backrub_Action.setCheckable(True) self.rosetta_backrub_Action.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Backrub.png")) self.editResiduesAction = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.editResiduesAction.setText("Residues") self.editResiduesAction.setCheckable(True) self.editResiduesAction.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Residues.png")) self.rosetta_score_Action = \ NE1_QWidgetAction(self.subControlActionGroupForSimulateProtein, win = self.win) self.rosetta_score_Action.setText("Score") self.rosetta_score_Action.setCheckable(True) self.rosetta_score_Action.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Score.png")) self.subControlActionGroupForSimulateProtein.addAction(self.rosetta_fixedbb_design_Action) self.subControlActionGroupForSimulateProtein.addAction(self.rosetta_backrub_Action) self.subControlActionGroupForSimulateProtein.addAction(self.editResiduesAction) self.subControlActionGroupForSimulateProtein.addAction(self.rosetta_score_Action) return
def _setExtensionButtonIcon(self): """ Sets the icon for the Flyout Toolbar extension button. The PNG image can be 24 (or less) pixels high by 10 pixels wide. """ extension_button = self.getExtensionButton() extension_button.setIcon(geticon( "ui/actions/Command Toolbar/ExtensionButtonImage.png"))
def _setExtensionButtonIcon(self): """ Sets the icon for the Flyout Toolbar extension button. The PNG image can be 24 (or less) pixels high by 10 pixels wide. """ extension_button = self.getExtensionButton() extension_button.setIcon( geticon("ui/actions/Command Toolbar/ExtensionButtonImage.png"))
def _createModelProteinsActions(self, parentWidget): """ Create the actions to be included in flyout toolbar, when the 'Model Proteins' is active. @see: self._createActions() where this is called. """ self.subControlActionGroupForModelProtein = QActionGroup(parentWidget) # Shouldn't the parent be self.win? # Isn't parentWidget = BuildProteinPropertyManager? # Ask Bruce about this. --Mark 2008-12-07. self.subControlActionGroupForModelProtein.setExclusive(True) self.buildPeptideAction = \ NE1_QWidgetAction(self.subControlActionGroupForModelProtein, win = self.win) self.buildPeptideAction.setText("Insert Peptide") self.buildPeptideAction.setCheckable(True) self.buildPeptideAction.setIcon( geticon( "ui/actions/Command Toolbar/BuildProtein/InsertPeptide.png")) self.compareProteinsAction = \ NE1_QWidgetAction(self.subControlActionGroupForModelProtein, win = self.win) self.compareProteinsAction.setText("Compare") self.compareProteinsAction.setCheckable(True) self.compareProteinsAction.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Compare.png")) self.displayProteinStyleAction = \ NE1_QWidgetAction(self.subControlActionGroupForModelProtein, win = self.win) self.displayProteinStyleAction.setText("Edit Style") self.displayProteinStyleAction.setCheckable(True) self.displayProteinStyleAction.setIcon( geticon( "ui/actions/Command Toolbar/BuildProtein/EditProteinDisplayStyle.png" )) self.subControlActionGroupForModelProtein.addAction( self.buildPeptideAction) self.subControlActionGroupForModelProtein.addAction( self.displayProteinStyleAction) self.subControlActionGroupForModelProtein.addAction( self.compareProteinsAction) return
def __init__(self, win): self.xmlfile = os.path.join(_sponsordir, 'sponsors.xml') self.win = win self.needToAsk = False self.downloadSponsors = False threading.Thread.__init__(self) if not self.refreshWanted(): return if env.prefs[sponsor_permanent_permission_prefs_key]: # We have a permanent answer so no need for a dialog if env.prefs[sponsor_download_permission_prefs_key]: self.downloadSponsors = True return self.needToAsk = True QDialog.__init__(self, None) self.setObjectName("Permission") self.setModal(True) #This fixes bug 2296. Mitigates bug 2297 layout = QGridLayout() self.setLayout(layout) layout.setMargin(0) layout.setSpacing(0) layout.setObjectName("PermissionLayout") self.text_browser = QTextBrowser(self) self.text_browser.setObjectName("text_browser") layout.addWidget(self.text_browser, 0, 0, 1, 4) self.text_browser.setMinimumSize(400, 80) self.setWindowTitle('May we use your network connection?') self.setWindowIcon(geticon('ui/border/MainWindow.png')) self.text_browser.setPlainText(self.text) self.accept_button = QPushButton(self) self.accept_button.setObjectName("accept_button") self.accept_button.setText("Always OK") self.accept_once_button = QPushButton(self) self.accept_once_button.setObjectName("accept_once_button") self.accept_once_button.setText("OK now") self.decline_once_button = QPushButton(self) self.decline_once_button.setObjectName("decline_once_button") self.decline_once_button.setText("Not now") self.decline_always_button = QPushButton(self) self.decline_always_button.setObjectName("decline_always_button") self.decline_always_button.setText("Never") layout.addWidget(self.accept_button, 1, 0) layout.addWidget(self.accept_once_button, 1, 1) layout.addWidget(self.decline_once_button, 1, 2) layout.addWidget(self.decline_always_button, 1, 3) self.connect(self.accept_button, SIGNAL("clicked()"), self.acceptAlways) self.connect(self.accept_once_button, SIGNAL("clicked()"), self.acceptJustOnce) self.connect(self.decline_once_button, SIGNAL("clicked()"), self.declineJustOnce) self.connect(self.decline_always_button, SIGNAL("clicked()"), self.declineAlways)
def _createFlyoutActions(self): self.exitEditCommandAction = NE1_QWidgetAction(self.win, win = self.win) if self.editCommand: text = "Exit " + self.editCommand.cmdname else: text = "Exit" self.exitEditCommandAction.setText(text) self.exitEditCommandAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) self.exitEditCommandAction.setCheckable(True)
def hideGroupBox(self, groupBoxButton, groupBoxWidget): """Hide a groupbox (this is not the same as 'toggle' groupbox)""" groupBoxWidget.hide() styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand = False) groupBoxButton.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() groupBoxButton.setPalette(palette) groupBoxButton.setIcon(geticon("ui/actions/Properties Manager/GHOST_ICON"))
def _loadLayerPropertiesGroupBox(self, inPmGroupBox): """ Load widgets in the Layer Properties group box. @param inPmGroupBox: The Layer Properties groupbox in the PM @type inPmGroupBox: L{PM_GroupBox} """ self.currentLayerComboBox = \ PM_ComboBox( inPmGroupBox, index = 0, spanWidth = True ) self.addLayerButton = PM_PushButton(inPmGroupBox) self.addLayerButton.setIcon( geticon('ui/actions/Properties Manager/addlayer.png')) self.addLayerButton.setFixedSize(QSize(26, 26)) self.addLayerButton.setIconSize(QSize(22, 22)) # A widget list to create a widget row. # Format: # - Widget type, # - widget object, # - column firstRowWidgetList = [('PM_ComboBox', self.currentLayerComboBox, 1), ('PM_PushButton', self.addLayerButton, 2)] widgetRow = PM_WidgetRow( inPmGroupBox, title='', widgetList=firstRowWidgetList, label="Layer:", labelColumn=0, ) self.layerCellsSpinBox = \ PM_SpinBox( inPmGroupBox, label = "Lattice cells:", labelColumn = 0, value = 2, minimum = 1, maximum = 25 ) self.layerThicknessLineEdit = PM_LineEdit(inPmGroupBox, label="Thickness:", text="", setAsDefault=False, spanWidth=False) #self.layerThicknessLineEdit.setReadOnly(True) self.layerThicknessLineEdit.setDisabled(True) tooltip = "Thickness of layer in Angstroms" self.layerThicknessLineEdit.setToolTip(tooltip)
def _loadLayerPropertiesGroupBox(self, inPmGroupBox): """ Load widgets in the Layer Properties group box. @param inPmGroupBox: The Layer Properties groupbox in the PM @type inPmGroupBox: L{PM_GroupBox} """ self.currentLayerComboBox = \ PM_ComboBox( inPmGroupBox, index = 0, spanWidth = True ) self.addLayerButton = PM_PushButton(inPmGroupBox) self.addLayerButton.setIcon( geticon('ui/actions/Properties Manager/addlayer.png')) self.addLayerButton.setFixedSize(QSize(26, 26)) self.addLayerButton.setIconSize(QSize(22, 22)) # A widget list to create a widget row. # Format: # - Widget type, # - widget object, # - column firstRowWidgetList = [('PM_ComboBox', self.currentLayerComboBox, 1), ('PM_PushButton', self.addLayerButton, 2) ] widgetRow = PM_WidgetRow(inPmGroupBox, title = '', widgetList = firstRowWidgetList, label = "Layer:", labelColumn = 0, ) self.layerCellsSpinBox = \ PM_SpinBox( inPmGroupBox, label = "Lattice cells:", labelColumn = 0, value = 2, minimum = 1, maximum = 25 ) self.layerThicknessLineEdit = PM_LineEdit(inPmGroupBox, label = "Thickness:", text = "", setAsDefault = False, spanWidth = False ) #self.layerThicknessLineEdit.setReadOnly(True) self.layerThicknessLineEdit.setDisabled(True) tooltip = "Thickness of layer in Angstroms" self.layerThicknessLineEdit.setToolTip(tooltip)
def showGroupBox(self, groupBoxButton, groupBoxWidget): """Show a groupbox (this is not the same as 'toggle' groupbox)""" if not groupBoxWidget.isVisible(): groupBoxWidget.show() styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand = True) groupBoxButton.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() groupBoxButton.setPalette(palette) groupBoxButton.setIcon(geticon("ui/actions/Properties Manager/GHOST_ICON"))
def hideGroupBox(self, groupBoxButton, groupBoxWidget): """Hide a groupbox (this is not the same as 'toggle' groupbox)""" groupBoxWidget.hide() styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand=False) groupBoxButton.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() groupBoxButton.setPalette(palette) groupBoxButton.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON"))
def __init__(self, parent=None): """ Constructor for Rosetta simulation parameters dialog """ self.parentWidget = parent super(RosettaSimulationPopUpDialog, self).__init__(parent) self.setWindowIcon(geticon('ui/border/Rosetta.png')) self.setWindowTitle("Rosetta Simulation Parameters") self._loadWidgets() self.connectSignals() self.show() return
def __init__(self, parent = None): """ Constructor for Rosetta simulation parameters dialog """ self.parentWidget = parent super(RosettaSimulationPopUpDialog, self).__init__(parent) self.setWindowIcon(geticon('ui/border/Rosetta.png')) self.setWindowTitle("Rosetta Simulation Parameters") self._loadWidgets() self.connectSignals() self.show() return
def __init__(self): QWidget.__init__(self) self.setupUi(self) self.connect(self.help_tab, SIGNAL("currentChanged(int)"), self.setup_current_page) self.connect(self.close_btn, SIGNAL("clicked()"), self.close) self.setWindowIcon(geticon("ui/border/MainWindow.png")) self._setup_mouse_controls_page() self.help_tab.setCurrentIndex(0) return
def showGroupBox(self, groupBoxButton, groupBoxWidget): """Show a groupbox (this is not the same as 'toggle' groupbox)""" if not groupBoxWidget.isVisible(): groupBoxWidget.show() styleSheet = self.getGroupBoxButtonStyleSheet(bool_expand=True) groupBoxButton.setStyleSheet(styleSheet) palette = self.getGroupBoxButtonPalette() groupBoxButton.setPalette(palette) groupBoxButton.setIcon( geticon("ui/actions/Properties Manager/GHOST_ICON"))
def getFlyoutActionList(self): #Ninad 20070618 """ Returns a tuple that contains mode spcific actionlists in the added in the flyout toolbar of the mode. CommandToolbar._createFlyoutToolBar method calls this @return: params: A tuple that contains 3 lists: (subControlAreaActionList, commandActionLists, allActionsList)""" #'allActionsList' returns all actions in the flyout toolbar #including the subcontrolArea actions allActionsList = [] #Action List for subcontrol Area buttons. #In this mode, there is really no subcontrol area. #We will treat subcontrol area same as 'command area' #(subcontrol area buttons will have an empty list as their command area #list). We will set the Comamnd Area palette background color to the #subcontrol area. subControlAreaActionList =[] self.exitMoveAction = NE1_QWidgetAction(self.w, win = self.w) self.exitMoveAction.setText("Exit Move") self.exitMoveAction.setWhatsThis("Exits Move Mode") self.exitMoveAction.setCheckable(True) self.exitMoveAction.setChecked(True) self.exitMoveAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) subControlAreaActionList.append(self.exitMoveAction) separator = QtGui.QAction(self.w) separator.setSeparator(True) subControlAreaActionList.append(separator) subControlAreaActionList.append(self.w.toolsMoveMoleculeAction) subControlAreaActionList.append(self.w.rotateComponentsAction) subControlAreaActionList.append(self.w.modifyAlignCommonAxisAction) allActionsList.extend(subControlAreaActionList) #Empty actionlist for the 'Command Area' commandActionLists = [] #Append empty 'lists' in 'commandActionLists equal to the #number of actions in subControlArea for i in range(len(subControlAreaActionList)): lst = [] commandActionLists.append(lst) params = (subControlAreaActionList, commandActionLists, allActionsList) return params
def __init__(self, win): self.xmlfile = os.path.join(_sponsordir, 'sponsors.xml') self.win = win self.needToAsk = False self.downloadSponsors = False threading.Thread.__init__(self) if not self.refreshWanted(): return if env.prefs[sponsor_permanent_permission_prefs_key]: # We have a permanent answer so no need for a dialog if env.prefs[sponsor_download_permission_prefs_key]: self.downloadSponsors = True return self.needToAsk = True QDialog.__init__(self, None) self.setObjectName("Permission") self.setModal(True) #This fixes bug 2296. Mitigates bug 2297 layout = QGridLayout() self.setLayout(layout) layout.setMargin(0) layout.setSpacing(0) layout.setObjectName("PermissionLayout") self.text_browser = QTextBrowser(self) self.text_browser.setObjectName("text_browser") layout.addWidget(self.text_browser,0,0,1,4) self.text_browser.setMinimumSize(400, 80) self.setWindowTitle('May we use your network connection?') self.setWindowIcon(geticon('ui/border/MainWindow.png')) self.text_browser.setPlainText(self.text) self.accept_button = QPushButton(self) self.accept_button.setObjectName("accept_button") self.accept_button.setText("Always OK") self.accept_once_button = QPushButton(self) self.accept_once_button.setObjectName("accept_once_button") self.accept_once_button.setText("OK now") self.decline_once_button = QPushButton(self) self.decline_once_button.setObjectName("decline_once_button") self.decline_once_button.setText("Not now") self.decline_always_button = QPushButton(self) self.decline_always_button.setObjectName("decline_always_button") self.decline_always_button.setText("Never") layout.addWidget(self.accept_button,1,0) layout.addWidget(self.accept_once_button,1,1) layout.addWidget(self.decline_once_button,1,2) layout.addWidget(self.decline_always_button,1,3) self.connect(self.accept_button,SIGNAL("clicked()"),self.acceptAlways) self.connect(self.accept_once_button,SIGNAL("clicked()"),self.acceptJustOnce) self.connect(self.decline_once_button,SIGNAL("clicked()"),self.declineJustOnce) self.connect(self.decline_always_button,SIGNAL("clicked()"),self.declineAlways)
def _createModelProteinsActions(self, parentWidget): """ Create the actions to be included in flyout toolbar, when the 'Model Proteins' is active. @see: self._createActions() where this is called. """ self.subControlActionGroupForModelProtein = QActionGroup(parentWidget) # Shouldn't the parent be self.win? # Isn't parentWidget = BuildProteinPropertyManager? # Ask Bruce about this. --Mark 2008-12-07. self.subControlActionGroupForModelProtein.setExclusive(True) self.buildPeptideAction = \ NE1_QWidgetAction(self.subControlActionGroupForModelProtein, win = self.win) self.buildPeptideAction.setText("Insert Peptide") self.buildPeptideAction.setCheckable(True) self.buildPeptideAction.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/InsertPeptide.png")) self.compareProteinsAction = \ NE1_QWidgetAction(self.subControlActionGroupForModelProtein, win = self.win) self.compareProteinsAction.setText("Compare") self.compareProteinsAction.setCheckable(True) self.compareProteinsAction.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/Compare.png")) self.displayProteinStyleAction = \ NE1_QWidgetAction(self.subControlActionGroupForModelProtein, win = self.win) self.displayProteinStyleAction.setText("Edit Style") self.displayProteinStyleAction.setCheckable(True) self.displayProteinStyleAction.setIcon( geticon("ui/actions/Command Toolbar/BuildProtein/EditProteinDisplayStyle.png")) self.subControlActionGroupForModelProtein.addAction(self.buildPeptideAction) self.subControlActionGroupForModelProtein.addAction(self.displayProteinStyleAction) self.subControlActionGroupForModelProtein.addAction(self.compareProteinsAction) return
def __init__(self): QWidget.__init__(self) self.setupUi(self) self.connect(self.help_tab, SIGNAL("currentChanged(int)"), self.setup_current_page) self.connect(self.close_btn, SIGNAL("clicked()"), self.close) self.setWindowIcon(geticon('ui/border/MainWindow.png')) self._setup_mouse_controls_page() self.help_tab.setCurrentIndex(0) return
def getFlyoutActionList(self): #Ninad 20070618 """ Returns a tuple that contains mode spcific actionlists in the added in the flyout toolbar of the mode. CommandToolbar._createFlyoutToolBar method calls this @return: params: A tuple that contains 3 lists: (subControlAreaActionList, commandActionLists, allActionsList)""" #'allActionsList' returns all actions in the flyout toolbar #including the subcontrolArea actions allActionsList = [] #Action List for subcontrol Area buttons. #In this mode, there is really no subcontrol area. #We will treat subcontrol area same as 'command area' #(subcontrol area buttons will have an empty list as their command area #list). We will set the Comamnd Area palette background color to the #subcontrol area. subControlAreaActionList = [] self.exitMoveAction = NE1_QWidgetAction(self.w, win=self.w) self.exitMoveAction.setText("Exit Move") self.exitMoveAction.setWhatsThis("Exits Move Mode") self.exitMoveAction.setCheckable(True) self.exitMoveAction.setChecked(True) self.exitMoveAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) subControlAreaActionList.append(self.exitMoveAction) separator = QtGui.QAction(self.w) separator.setSeparator(True) subControlAreaActionList.append(separator) subControlAreaActionList.append(self.w.toolsMoveMoleculeAction) subControlAreaActionList.append(self.w.rotateComponentsAction) subControlAreaActionList.append(self.w.modifyAlignCommonAxisAction) allActionsList.extend(subControlAreaActionList) #Empty actionlist for the 'Command Area' commandActionLists = [] #Append empty 'lists' in 'commandActionLists equal to the #number of actions in subControlArea for i in range(len(subControlAreaActionList)): lst = [] commandActionLists.append(lst) params = (subControlAreaActionList, commandActionLists, allActionsList) return params
def _createBondToolActions(self, parentWidget): """ Create the actions to be included in flyout toolbar , when the 'bonds tool' is active. Note that the object names of these action will be be used to find the Bond Tool type to which each action corresponds to. @see: self._createActions() where this is called. """ self.bondToolsActionGroup = QActionGroup(parentWidget) self.bondToolsActionGroup.setExclusive(True) self.bond1Action = \ NE1_QWidgetAction(self.bondToolsActionGroup, win = self.win) self.bond1Action.setText("Single") self.bond1Action.setIcon(geticon("ui/actions/Command Toolbar/BuildAtoms/SingleBond.png")) self.bond1Action.setObjectName('ACTION_SINGLE_BOND_TOOL') self.bond2Action = \ NE1_QWidgetAction(self.bondToolsActionGroup, win = self.win) self.bond2Action.setText("Double") self.bond2Action.setIcon(geticon("ui/actions/Command Toolbar/BuildAtoms/DoubleBond.png")) self.bond2Action.setObjectName('ACTION_DOUBLE_BOND_TOOL') self.bond3Action = \ NE1_QWidgetAction(self.bondToolsActionGroup, win = self.win) self.bond3Action.setText("Triple") self.bond3Action.setIcon(geticon("ui/actions/Command Toolbar/BuildAtoms/TripleBond.png")) self.bond3Action.setObjectName('ACTION_TRIPLE_BOND_TOOL') self.bondaAction = \ NE1_QWidgetAction(self.bondToolsActionGroup, win = self.win) self.bondaAction.setText("Aromatic") self.bondaAction.setIcon(geticon("ui/actions/Command Toolbar/BuildAtoms/AromaticBond.png")) self.bondaAction.setObjectName('ACTION_AROMATIC_BOND_TOOL') self.bondgAction = \ NE1_QWidgetAction(self.bondToolsActionGroup, win = self.win) self.bondgAction.setText("Graphitic") self.bondgAction.setIcon(geticon("ui/actions/Command Toolbar/BuildAtoms/GraphiticBond.png")) self.bondgAction.setObjectName('ACTION_GRAPHITIC_BOND_TOOL') self.cutBondsAction = \ NE1_QWidgetAction(self.bondToolsActionGroup, win = self.win) self.cutBondsAction.setText("Cut Bonds") self.cutBondsAction.setIcon(geticon("ui/actions/Command Toolbar/BuildAtoms/CutBonds.png")) self.cutBondsAction.setObjectName('ACTION_DELETE_BOND_TOOL') for action in [self.bond1Action, self.bond2Action, self.bond3Action, self.bondaAction, self.bondgAction, self.cutBondsAction ]: self.bondToolsActionGroup.addAction(action) action.setCheckable(True) return
def getFlyoutActionList(self): #Ninad 20070618 """ Returns custom actionlist that will be used in a specific mode or editing a feature etc Example: while in movie mode, the _createFlyoutToolBar method calls this. """ #'allActionsList' returns all actions in the flyout toolbar #including the subcontrolArea actions allActionsList = [] #Action List for subcontrol Area buttons. #In this mode there is really no subcontrol area. #We will treat subcontrol area same as 'command area' #(subcontrol area buttons will have an empty list as their command area #list). We will set the Comamnd Area palette background color to the #subcontrol area. subControlAreaActionList = [] self.exitMovieAction = NE1_QWidgetAction(self.w, win=self.w) self.exitMovieAction.setText("Exit Movie") self.exitMovieAction.setWhatsThis("Exits Movie Mode") self.exitMovieAction.setCheckable(True) self.exitMovieAction.setChecked(True) self.exitMovieAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) subControlAreaActionList.append(self.exitMovieAction) separator = QAction(self.w) separator.setSeparator(True) subControlAreaActionList.append(separator) subControlAreaActionList.append(self.w.simPlotToolAction) allActionsList.extend(subControlAreaActionList) #Empty actionlist for the 'Command Area' commandActionLists = [] #Append empty 'lists' in 'commandActionLists equal to the #number of actions in subControlArea for i in range(len(subControlAreaActionList)): lst = [] commandActionLists.append(lst) params = (subControlAreaActionList, commandActionLists, allActionsList) return params
def getFlyoutActionList(self): #Ninad 20070618 """ Returns custom actionlist that will be used in a specific mode or editing a feature etc Example: while in movie mode, the _createFlyoutToolBar method calls this. """ #'allActionsList' returns all actions in the flyout toolbar #including the subcontrolArea actions allActionsList = [] #Action List for subcontrol Area buttons. #In this mode there is really no subcontrol area. #We will treat subcontrol area same as 'command area' #(subcontrol area buttons will have an empty list as their command area #list). We will set the Comamnd Area palette background color to the #subcontrol area. subControlAreaActionList =[] self.exitMovieAction = NE1_QWidgetAction(self.w, win = self.w) self.exitMovieAction.setText("Exit Movie") self.exitMovieAction.setWhatsThis("Exits Movie Mode") self.exitMovieAction.setCheckable(True) self.exitMovieAction.setChecked(True) self.exitMovieAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) subControlAreaActionList.append(self.exitMovieAction) separator = QAction(self.w) separator.setSeparator(True) subControlAreaActionList.append(separator) subControlAreaActionList.append(self.w.simPlotToolAction) allActionsList.extend(subControlAreaActionList) #Empty actionlist for the 'Command Area' commandActionLists = [] #Append empty 'lists' in 'commandActionLists equal to the #number of actions in subControlArea for i in range(len(subControlAreaActionList)): lst = [] commandActionLists.append(lst) params = (subControlAreaActionList, commandActionLists, allActionsList) return params
def _createActions(self, parentWidget): self.exitProteinAction = NE1_QWidgetAction(parentWidget, win = self.win) self.exitProteinAction.setText("Exit Protein") self.exitProteinAction.setIcon( geticon("ui/actions/Toolbars/Smart/Exit.png")) self.exitProteinAction.setCheckable(True) self.buildPeptideAction = NE1_QWidgetAction(parentWidget, win = self.win) self.buildPeptideAction.setText("Peptide") self.buildPeptideAction.setCheckable(True) self.buildPeptideAction.setIcon( geticon("ui/actions/Tools/Build Structures/Peptide.png")) self.editRotamersAction = NE1_QWidgetAction(parentWidget, win = self.win) self.editRotamersAction.setText("Rotamers") self.editRotamersAction.setCheckable(True) self.editRotamersAction.setIcon( geticon("ui/actions/Tools/Build Structures/Rotamer.png")) self.editResiduesAction = NE1_QWidgetAction(parentWidget, win = self.win) self.editResiduesAction.setText("Residues") self.editResiduesAction.setCheckable(True) self.editResiduesAction.setIcon( geticon("ui/actions/Tools/Build Structures/Rotamer.png")) self.displayProteinStyleAction = NE1_QWidgetAction(parentWidget, win = self.win) self.displayProteinStyleAction.setText("Edit Style") self.displayProteinStyleAction.setCheckable(True) self.displayProteinStyleAction.setIcon( geticon("ui/actions/Edit/EditProteinDisplayStyle.png"))
def _createActions(self, parentWidget): _superclass._createActions(self, parentWidget) self.subControlActionGroup = QtGui.QActionGroup(self.parentWidget) self.subControlActionGroup.setExclusive(False) self.insertNanotubeAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.insertNanotubeAction.setText("Insert NT") self.insertNanotubeAction.setCheckable(True) self.insertNanotubeAction.setIcon( geticon("ui/actions/Tools/Build Structures/InsertNanotube.png")) self.subControlActionGroup.addAction(self.insertNanotubeAction)
def _createActions(self, parentWidget): _superclass._createActions(self, parentWidget) self.subControlActionGroup = QtGui.QActionGroup(self.parentWidget) self.subControlActionGroup.setExclusive(False) self.insertNanotubeAction = \ NE1_QWidgetAction(self.subControlActionGroup, win = self.win) self.insertNanotubeAction.setText("Insert NT") self.insertNanotubeAction.setCheckable(True) self.insertNanotubeAction.setIcon( geticon("ui/actions/Tools/Build Structures/InsertNanotube.png")) self.subControlActionGroup.addAction(self.insertNanotubeAction)
def _createActions(self, parentWidget): """ Define flyout toolbar actions for this mode. @see: self._getExitActionText() which defines text for exit action. @note: subclasses typically extend this method to define more actions. """ #@NOTE: In Build mode, some of the actions defined in this method are also #used in Build Atoms PM. (e.g. bond actions) So probably better to rename #it as _init_modeActions. Not doing that change in mmkit code cleanup #commit(other modes still implement a method by same name)-ninad20070717 self.exitModeAction = NE1_QWidgetAction(parentWidget, win = self.win) exitActionText = self._getExitActionText() self.exitModeAction.setText(exitActionText) self.exitModeAction.setIcon(geticon('ui/actions/Command Toolbar/ControlArea/Exit.png')) self.exitModeAction.setCheckable(True) self.exitModeAction.setChecked(True)
def _createActions(self, parentWidget): """ Define flyout toolbar actions for this mode. @see: self._getExitActionText() which defines text for exit action. @note: subclasses typically extend this method to define more actions. """ #@NOTE: In Build mode, some of the actions defined in this method are also #used in Build Atoms PM. (e.g. bond actions) So probably better to rename #it as _init_modeActions. Not doing that change in mmkit code cleanup #commit(other modes still implement a method by same name)-ninad20070717 self.exitModeAction = NE1_QWidgetAction(parentWidget, win=self.win) exitActionText = self._getExitActionText() self.exitModeAction.setText(exitActionText) self.exitModeAction.setIcon( geticon('ui/actions/Command Toolbar/ControlArea/Exit.png')) self.exitModeAction.setCheckable(True) self.exitModeAction.setChecked(True)
def updatePropertyManagerTab(self, tab): #Ninad 061207 "Update the Properties Manager tab with 'tab' " self.parent.glpane.gl_update_confcorner() #bruce 070627, since PM affects confcorner appearance if self.propertyManagerScrollArea.widget(): # The following is necessary to get rid of those C object # deleted errors (and the resulting bugs) lastwidgetobject = self.propertyManagerScrollArea.takeWidget() if lastwidgetobject: # bruce 071018 revised this code; see my comment on same # code in PM_Dialog try: lastwidgetobject.update_props_if_needed_before_closing except AttributeError: if 1 or debug_flags.atom_debug: msg1 = "Last PropMgr %r doesn't have method" % lastwidgetobject msg2 =" update_props_if_needed_before_closing. That's" msg3 = " OK (for now, only implemented for Plane PM). " msg4 = "Ignoring Exception: " print_compact_traceback(msg1 + msg2 + msg3 + msg4) else: lastwidgetobject.update_props_if_needed_before_closing() lastwidgetobject.hide() # @ ninad 061212 perhaps hiding the widget is not needed self.pwProjectTabWidget.removeTab( self.pwProjectTabWidget.indexOf(self.propertyManagerScrollArea)) # Set the PropertyManager tab scroll area to the appropriate widget. self.propertyManagerScrollArea.setWidget(tab) self.pwProjectTabWidget.addTab( self.propertyManagerScrollArea, geticon("ui/modeltree/Property_Manager.png"), "") self.pwProjectTabWidget.setCurrentIndex( self.pwProjectTabWidget.indexOf(self.propertyManagerScrollArea)) return
def _setup(self, display_style = diDEFAULT, disconnect = True): """ Private method. Populates self and sets the current display style. """ from utilities.debug_prefs import debug_pref, Choice_boolean_False # Add a new experimental Protein display style # if the Enable proteins debug pref is set to True. # piotr 080710 from utilities.GlobalPreferences import ENABLE_PROTEINS if display_style == diDEFAULT: display_style = env.prefs[ startupGlobalDisplayStyle_prefs_key ] if disconnect: self.disconnect( self, SIGNAL("currentIndexChanged(int)"), self._setDisplayStyle ) self.clear() ADD_DEFAULT_TEXT = False for displayName in displayNames: # Experimental display style for Proteins. if displayName == "Protein" and \ not ENABLE_PROTEINS: # Skip the Proteins style. continue basename = displayIconsDict[displayName] + ".png" iconPath = os.path.join("ui/actions/View/Display/", basename) self.addItem(geticon(iconPath), displayName) self.setCurrentIndex(displayIndexes.index(display_style)) self.connect( self, SIGNAL("currentIndexChanged(int)"), self._setDisplayStyle )