Beispiel #1
0
    def set_multiplicity(self, val):
        """
        Enable/disable widgets when user changes Multiplicity.
        """
        if val != 0:
            qt4todo("if scftyp[self.scftyp_btngrp.selectedId()] != 'RHF':")
            #if scftyp[self.scftyp_btngrp.selectedId()] != 'RHF':
            #    self.rhf_radiobtn.setEnabled(0)
            #    return

            ret = QMessageBox.warning(
                self, "Multiplicity Conflict",
                "If Multiplicity is greater than 1, then <b>UHF</b> or <b>ROHF</b> must be selected.\n"
                "Select Cancel to keep <b>RHF</b>.", "&UHF", "&ROHF", "Cancel",
                0, 2)

            if ret == 0:  # UHF
                self.uhf_radiobtn.toggle()
                self.rhf_radiobtn.setEnabled(0)

            elif ret == 1:  # ROHF
                self.rohf_radiobtn.toggle()
                self.rhf_radiobtn.setEnabled(0)

            elif ret == 2:  # Cancel
                self.multi_combox.setCurrentIndex(0)

        elif val == 0:
            self.rhf_radiobtn.setEnabled(1)
Beispiel #2
0
    def __init__(self, *args, **kws):
        #k why was i not allowed to put 'for_a_length = 0' into this arglist??
        for_a_length = kws.pop('for_a_length',0)
        assert not kws, "keyword arguments are not supported by QSpinBox"

        # QSpinBox.__init__(self, *args) #k #e note, if the args can affect the range, we'll mess that up below
        QSpinBox.__init__(self) #k #e note, if the args can affect the range, we'll mess that up below
        assert len(args) is 2
        assert type(args[1]) is type('abc')
        self.setObjectName(args[1])
        qt4warning('QSpinBox() ignoring args: ' + repr(args))

        ## self.setValidator(0) # no keystrokes are prevented from being entered
            ## TypeError: argument 1 of QSpinBox.setValidator() has an invalid type -- hmm, manual didn't think so -- try None? #e

        qt4todo('self.setValidator( QDoubleValidator( - self.range_angstroms, self.range_angstroms, 2, self ))')

            # QDoubleValidator has a bug: it turns 10.2 into 10.19! But mostly it works. Someday we'll need our own. [bruce 041009]
        if not for_a_length:
            self.setRange( - int(self.range_angstroms * self.precision_angstroms),
                             int(self.range_angstroms * self.precision_angstroms) )
        else:
            self.setRange( int(self.min_length * self.precision_angstroms),
                           int(self.max_length * self.precision_angstroms) )
        qt4todo('self.setSteps( self.precision_angstroms, self.precision_angstroms * 10 ) # set linestep and pagestep')
Beispiel #3
0
    def __init__(self, parent=None, name=None, modal=1, fl=0):
        #QDialog.__init__(self,parent,name,modal,fl)
        QDialog.__init__(self, parent)
        self.setModal(modal)
        qt4todo("handle flags in TextMessageBox.__init__")

        if name is None: name = "TextMessageBox"
        self.setObjectName(name)
        self.setWindowTitle(name)

        TextMessageLayout = QVBoxLayout(self)
        TextMessageLayout.setMargin(5)
        TextMessageLayout.setSpacing(1)

        self.text_edit = QTextEdit(self)

        TextMessageLayout.addWidget(self.text_edit)

        self.close_button = QPushButton(self)
        self.close_button.setText("Close")
        TextMessageLayout.addWidget(self.close_button)

        self.resize(QSize(350, 300).expandedTo(self.minimumSizeHint()))
        # Width changed from 300 to 350. Now hscrollbar doesn't appear in
        # Help > Graphics Info textbox. mark 060322
        qt4todo('self.clearWState(Qt.WState_Polished)')  # what is this?

        self.connect(self.close_button, SIGNAL("clicked()"), self.close)
Beispiel #4
0
    def __init__(self, *args, **kws):
        #k why was i not allowed to put 'for_a_length = 0' into this arglist??
        for_a_length = kws.pop('for_a_length', 0)
        assert not kws, "keyword arguments are not supported by QSpinBox"

        # QSpinBox.__init__(self, *args) #k #e note, if the args can affect the range, we'll mess that up below
        QSpinBox.__init__(
            self
        )  #k #e note, if the args can affect the range, we'll mess that up below
        assert len(args) is 2
        assert type(args[1]) is type('abc')
        self.setObjectName(args[1])
        qt4warning('QSpinBox() ignoring args: ' + repr(args))

        ## self.setValidator(0) # no keystrokes are prevented from being entered
        ## TypeError: argument 1 of QSpinBox.setValidator() has an invalid type -- hmm, manual didn't think so -- try None? #e

        qt4todo(
            'self.setValidator( QDoubleValidator( - self.range_angstroms, self.range_angstroms, 2, self ))'
        )

        # QDoubleValidator has a bug: it turns 10.2 into 10.19! But mostly it works. Someday we'll need our own. [bruce 041009]
        if not for_a_length:
            self.setRange(
                -int(self.range_angstroms * self.precision_angstroms),
                int(self.range_angstroms * self.precision_angstroms))
        else:
            self.setRange(int(self.min_length * self.precision_angstroms),
                          int(self.max_length * self.precision_angstroms))
        qt4todo(
            'self.setSteps( self.precision_angstroms, self.precision_angstroms * 10 ) # set linestep and pagestep'
        )
Beispiel #5
0
    def _addHistoryWidget(self):
        """
        Sets up and adds the history widget.
        """
        histfile = make_history_filename() 
            #@@@ ninad 061213 This is likely a new bug for multipane concept 
            # as each file in a session will have its own history widget
        qt4todo('histfile = make_history_filename()')

        #bruce 050913 renamed self.history to self.history_object, and
        # deprecated direct access to self.history; code should use env.history
        # to emit messages, self.history_widget to see the history widget,
        # or self.history_object to see its owning object per se
        # rather than as a place to emit messages (this is rarely needed).
        self.history_object = HistoryWidget(self, filename = histfile, mkdirs = 1)
            # this is not a Qt widget, but its owner;
            # use self.history_widget for Qt calls that need the widget itself.
        self.history_widget = self.history_object.widget
        self.history_widget.setSizePolicy(QSizePolicy.Ignored,QSizePolicy.Ignored)
            # bruce 050913, in case future code splits history widget 
            # (as main window subwidget) from history message recipient
            # (the global object env.history).
        env.history = self.history_object #bruce 050727, revised 050913
        
        self.historyTabLayout.addWidget(self.history_widget)
    def _addHistoryWidget(self):
        """
        Sets up and adds the history widget.
        """
        histfile = make_history_filename() 
            #@@@ ninad 061213 This is likely a new bug for multipane concept 
            # as each file in a session will have its own history widget
        qt4todo('histfile = make_history_filename()')

        #bruce 050913 renamed self.history to self.history_object, and
        # deprecated direct access to self.history; code should use env.history
        # to emit messages, self.history_widget to see the history widget,
        # or self.history_object to see its owning object per se
        # rather than as a place to emit messages (this is rarely needed).
        self.history_object = HistoryWidget(self, filename = histfile, mkdirs = 1)
            # this is not a Qt widget, but its owner;
            # use self.history_widget for Qt calls that need the widget itself.
        self.history_widget = self.history_object.widget
        self.history_widget.setSizePolicy(QSizePolicy.Ignored,QSizePolicy.Ignored)
            # bruce 050913, in case future code splits history widget 
            # (as main window subwidget) from history message recipient
            # (the global object env.history).
        env.history = self.history_object #bruce 050727, revised 050913
        
        self.historyTabLayout.addWidget(self.history_widget)
Beispiel #7
0
    def __init__(self, parent = None, name = None, modal = 1, fl = 0):
        #QDialog.__init__(self,parent,name,modal,fl)
        QDialog.__init__(self,parent)
        self.setModal(modal)
        qt4todo("handle flags in TextMessageBox.__init__")

        if name is None: name = "TextMessageBox"
        self.setObjectName(name)
        self.setWindowTitle(name)

        TextMessageLayout = QVBoxLayout(self)
        TextMessageLayout.setMargin(5)
        TextMessageLayout.setSpacing(1)

        self.text_edit = QTextEdit(self)

        TextMessageLayout.addWidget(self.text_edit)

        self.close_button = QPushButton(self)
        self.close_button.setText("Close")
        TextMessageLayout.addWidget(self.close_button)

        self.resize(QSize(350, 300).expandedTo(self.minimumSizeHint()))
            # Width changed from 300 to 350. Now hscrollbar doesn't appear in
            # Help > Graphics Info textbox. mark 060322
        qt4todo('self.clearWState(Qt.WState_Polished)') # what is this?

        self.connect(self.close_button, SIGNAL("clicked()"),self.close)
    def set_multiplicity(self, val):
        """
        Enable/disable widgets when user changes Multiplicity.
        """
        if val != 0:
            qt4todo("if scftyp[self.scftyp_btngrp.selectedId()] != 'RHF':")
            #if scftyp[self.scftyp_btngrp.selectedId()] != 'RHF':
            #    self.rhf_radiobtn.setEnabled(0)
            #    return

            ret = QMessageBox.warning( self, "Multiplicity Conflict",
                "If Multiplicity is greater than 1, then <b>UHF</b> or <b>ROHF</b> must be selected.\n"
                "Select Cancel to keep <b>RHF</b>.",
                "&UHF", "&ROHF", "Cancel",
                0, 2 )

            if ret == 0: # UHF
                self.uhf_radiobtn.toggle()
                self.rhf_radiobtn.setEnabled(0)

            elif ret == 1: # ROHF
                self.rohf_radiobtn.toggle()
                self.rhf_radiobtn.setEnabled(0)

            elif ret == 2: # Cancel
                self.multi_combox.setCurrentIndex(0)

        elif val == 0:
            self.rhf_radiobtn.setEnabled(1)
Beispiel #9
0
 def setDisplay(self, value):
     qt4todo('self.elementButtonGroup.setButton(value)')
     self.updateElemGraphDisplay()
     self.original_color = self.color
     
     element_color = RGBf_to_QColor(self.color)
     self.update_sliders_and_spinboxes(element_color)
     self.restorePB.setEnabled(0) # Disable Restore button.
Beispiel #10
0
    def setDisplay(self, value):
        qt4todo('self.elementButtonGroup.setButton(value)')
        self.updateElemGraphDisplay()
        self.original_color = self.color

        element_color = RGBf_to_QColor(self.color)
        self.update_sliders_and_spinboxes(element_color)
        self.restorePB.setEnabled(0)  # Disable Restore button.
 def __init__(self):
     QDialog.__init__(self)
     self.setupUi(self)
     self.connect(self.new_btn,SIGNAL("clicked()"),self.addServer)
     self.connect(self.exit_btn,SIGNAL("clicked()"),self.close)
     self.connect(self.server_listview,SIGNAL("currentChanged(QListViewItem*)"),self.changeServer)
     self.connect(self.engine_combox,SIGNAL("activated(const QString&)"),self.engineChanged)
     self.connect(self.del_btn,SIGNAL("clicked()"),self.deleteServer)
     qt4todo('self.server_listview.setSorting(-1)')
     ## The ordered server list
     self.servers = self._loadServerList()
     return
Beispiel #12
0
    def fullName(self):
        if self.p:
            if not hasattr(self.p, 'fullName'):
                qt4todo('Make the parent a Directory instead of a DirView')
                s = self.f
            else:
                s = self.p.fullName() + self.f
        else:
            s = self.f

        if not s.endswith('/'):
            s += '/'
        return s
Beispiel #13
0
 def setup(self, comment=None):
     '''Show Comment dialog with currect comment text. 
     <comment> - the comment node object.
     '''
     self.comment = comment
     
     if self.comment:
         self.comment_textedit.setPlainText(self.comment.get_text())
             # Load comment text.
         qt4todo('self.comment_textedit.moveCursor(QTextEdit.MoveEnd, False)')
             # Sets cursor position to the end of the textedit document.
     
     QDialog.exec_(self)
Beispiel #14
0
 def fullName(self):
     if self.p:
         if not hasattr(self.p, 'fullName'):
             qt4todo('Make the parent a Directory instead of a DirView')
             s = self.f
         else:
             s = self.p.fullName() + self.f 
     else:
         s = self.f
     
     if not s.endswith('/'):
         s += '/'
     return s
Beispiel #15
0
    def setup(self, comment=None):
        '''Show Comment dialog with currect comment text. 
        <comment> - the comment node object.
        '''
        self.comment = comment

        if self.comment:
            self.comment_textedit.setPlainText(self.comment.get_text())
            # Load comment text.
            qt4todo(
                'self.comment_textedit.moveCursor(QTextEdit.MoveEnd, False)')
            # Sets cursor position to the end of the textedit document.

        QDialog.exec_(self)
Beispiel #16
0
 def __init__(self):
     QDialog.__init__(self)
     self.setupUi(self)
     self.connect(self.new_btn, SIGNAL("clicked()"), self.addServer)
     self.connect(self.exit_btn, SIGNAL("clicked()"), self.close)
     self.connect(self.server_listview,
                  SIGNAL("currentChanged(QListViewItem*)"),
                  self.changeServer)
     self.connect(self.engine_combox, SIGNAL("activated(const QString&)"),
                  self.engineChanged)
     self.connect(self.del_btn, SIGNAL("clicked()"), self.deleteServer)
     qt4todo('self.server_listview.setSorting(-1)')
     ## The ordered server list
     self.servers = self._loadServerList()
     return
Beispiel #17
0
 def setup(self, comment = None):
     """
     Show Comment dialog with current Comment text, for editing
     properties of an existing Comment node or creating a new one.
     
     @param comment: the comment node to edit, or None to create a new one.
     """
     self.comment = comment
     
     if self.comment:
         self.comment_textedit.setPlainText(self.comment.get_text())
             # Load comment text.
         qt4todo("self.comment_textedit.moveCursor(QTextEdit.MoveEnd, False)")
             # Sets cursor position to the end of the textedit document.
     
     QDialog.exec_(self)
Beispiel #18
0
    def setup(self, comment = None):
        """
        Show Comment dialog with current Comment text, for editing
        properties of an existing Comment node or creating a new one.

        @param comment: the comment node to edit, or None to create a new one.
        """
        self.comment = comment

        if self.comment:
            self.comment_textedit.setPlainText(self.comment.get_text())
                # Load comment text.
            qt4todo("self.comment_textedit.moveCursor(QTextEdit.MoveEnd, False)")
                # Sets cursor position to the end of the textedit document.

        QDialog.exec_(self)
Beispiel #19
0
    def setOpen(self, o):
        if o:
            self.setIcon(0, folderOpenIcon)
        else:
            self.setIcon(0, folderClosedIcon)

        if o and not self.childCount():
            s = self.fullName()
            thisDir = QDir(s)
            if not thisDir.isReadable():
                self.readable = 0
                return

            files = thisDir.entryInfoList()
            if files:
                for f in files:
                    # f is a QFileInfo
                    # f.fileName is '.' or '..' or 'bearings' or...
                    fileName = str(f.fileName())
                    if fileName == '.' or fileName == '..':
                        continue
                    elif f.isSymLink():
                        d = QTreeWidgetItem(self,
                                            fileName)  #, 'Symbolic Link')
                        d.setIcon(0, fileIcon)
                    elif f.isDir():
                        if fileName == 'CVS':
                            #bruce 060319 skip CVS directories, so developers see same set of directories as end-users
                            # (implements NFR I recently reported)
                            # WARNING: this is only legitimate for some applications of this module.
                            # For now that's ok (we only use it in MMKit). Later this feature should be turned on
                            # by an optional argument to __init__, and generalized to a list of files to not show
                            # or to a filter function.
                            continue
                        d = Directory(self, fileName)
                    else:
                        if f.isFile():
                            s = 'File'
                        else:
                            s = 'Special'
                        if not fileName[-3:] in self.filterList:
                            continue
                        d = FileItem(self, f.absFilePath(), fileName)
                        d.setIcon(0, fileIcon)

        qt4todo('QTreeWidgetItem.setOpen(self, o)')
 def set_widgets_from_update_data(self, update_data):
     if update_data:
         update_number, update_units, update_as_fast_as_possible_data, enable = update_data
         if self.checkbox:
             self.checkbox.setChecked(enable)
         if self.checkbox_prefs_key:  # k could be elif, if we connected them above
             env.prefs[self.checkbox_prefs_key] = enable
         qt4todo("self.watch_motion_buttongroup.setButton( update_as_fast_as_possible_data")
         self.update_number_spinbox.setValue(update_number)
         for i in range(self.update_units_combobox.count()):
             if self.update_units_combobox.itemText(i) == update_units:
                 self.update_units_combobox.setCurrentIndex(i)
                 return
         raise Exception("update_units_combobox has no such option: " + update_units)
     else:
         pass  # rely on whatever is already in them (better than guessing here)
     return
Beispiel #21
0
    def setOpen(self, o):
        if  o: 
            self.setIcon(0, folderOpenIcon)
        else:
            self.setIcon(0, folderClosedIcon)

        if o and not self.childCount():
            s = self.fullName()
            thisDir = QDir(s)
            if not thisDir.isReadable():
                self.readable = 0
                return

            files = thisDir.entryInfoList()
            if files:
                for f in files:
                    # f is a QFileInfo
                    # f.fileName is '.' or '..' or 'bearings' or...
                    fileName = str(f.fileName())
                    if fileName == '.' or fileName == '..':
                        continue
                    elif f.isSymLink():
                        d = QTreeWidgetItem(self, fileName)#, 'Symbolic Link')
                        d.setIcon(0, fileIcon)
                    elif f.isDir():
                        if fileName == 'CVS':
                            #bruce 060319 skip CVS directories, so developers see same set of directories as end-users
                            # (implements NFR I recently reported)
                            # WARNING: this is only legitimate for some applications of this module.
                            # For now that's ok (we only use it in MMKit). Later this feature should be turned on
                            # by an optional argument to __init__, and generalized to a list of files to not show
                            # or to a filter function.
                            continue
                        d = Directory(self, fileName)
                    else:
                        if f.isFile():
                            s = 'File'
                        else:
                            s = 'Special'
                        if not fileName[-3:] in self.filterList:
                            continue
                        d = FileItem(self, f.absFilePath(), fileName)
                        d.setIcon(0, fileIcon)
    
        qt4todo('QTreeWidgetItem.setOpen(self, o)')
Beispiel #22
0
 def set_widgets_from_update_data(self, update_data):
     if update_data:
         update_number, update_units, update_as_fast_as_possible_data, enable = update_data
         if self.checkbox:
             self.checkbox.setChecked(enable)
         if self.checkbox_prefs_key:  #k could be elif, if we connected them above
             env.prefs[self.checkbox_prefs_key] = enable
         qt4todo(
             'self.watch_motion_buttongroup.setButton( update_as_fast_as_possible_data'
         )
         self.update_number_spinbox.setValue(update_number)
         for i in range(self.update_units_combobox.count()):
             if self.update_units_combobox.itemText(i) == update_units:
                 self.update_units_combobox.setCurrentIndex(i)
                 return
         raise Exception("update_units_combobox has no such option: " +
                         update_units)
     else:
         pass  # rely on whatever is already in them (better than guessing here)
     return
    def __init__(self, win):
        QStatusBar.__init__(self, win)
        self.statusMsgLabel = QLabel()

        self.statusMsgLabel.setMinimumWidth(200)
        self.statusMsgLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.addPermanentWidget(self.statusMsgLabel)

        self.progressBar = QProgressBar(win)
        self.progressBar.setMaximumWidth(250)
        qt4todo('StatusBar.progressBar.setCenterIndicator(True)')
        self.addPermanentWidget(self.progressBar)
        self.progressBar.hide()

        self.simAbortButton = QToolButton(win)
        self.simAbortButton.setIcon(
            geticon("ui/actions/Simulation/Stopsign.png"))
        self.simAbortButton.setMaximumWidth(32)
        self.addPermanentWidget(self.simAbortButton)
        self.connect(self.simAbortButton, SIGNAL("clicked()"), self.simAbort)
        self.simAbortButton.hide()

        self.dispbarLabel = QLabel(win)
        #self.dispbarLabel.setFrameStyle( QFrame.Panel | QFrame.Sunken )
        self.dispbarLabel.setText("Global display style:")
        self.addPermanentWidget(self.dispbarLabel)

        # Global display styles combobox
        self.globalDisplayStylesComboBox = GlobalDisplayStylesComboBox(win)
        self.addPermanentWidget(self.globalDisplayStylesComboBox)

        # Selection lock button. It always displays the selection lock state
        # and it is available to click.
        self.selectionLockButton = QToolButton(win)
        self.selectionLockButton.setDefaultAction(win.selectLockAction)
        self.addPermanentWidget(self.selectionLockButton)

        # Only use of this appears to be commented out in MWsemantics as of 2007/12/14
        self.modebarLabel = QLabel(win)
        self.addPermanentWidget(self.modebarLabel)
        self.abortableCommands = {}
Beispiel #24
0
    def __init__(self, win):
        QStatusBar.__init__(self, win)
        self.statusMsgLabel = QLabel()

        self.statusMsgLabel.setMinimumWidth(200)
        self.statusMsgLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)
        self.addPermanentWidget(self.statusMsgLabel)

        self.progressBar = QProgressBar(win)
        self.progressBar.setMaximumWidth(250)
        qt4todo("StatusBar.progressBar.setCenterIndicator(True)")
        self.addPermanentWidget(self.progressBar)
        self.progressBar.hide()

        self.simAbortButton = QToolButton(win)
        self.simAbortButton.setIcon(geticon("ui/actions/Simulation/Stopsign.png"))
        self.simAbortButton.setMaximumWidth(32)
        self.addPermanentWidget(self.simAbortButton)
        self.connect(self.simAbortButton, SIGNAL("clicked()"), self.simAbort)
        self.simAbortButton.hide()

        self.dispbarLabel = QLabel(win)
        # self.dispbarLabel.setFrameStyle( QFrame.Panel | QFrame.Sunken )
        self.dispbarLabel.setText("Global display style:")
        self.addPermanentWidget(self.dispbarLabel)

        # Global display styles combobox
        self.globalDisplayStylesComboBox = GlobalDisplayStylesComboBox(win)
        self.addPermanentWidget(self.globalDisplayStylesComboBox)

        # Selection lock button. It always displays the selection lock state
        # and it is available to click.
        self.selectionLockButton = QToolButton(win)
        self.selectionLockButton.setDefaultAction(win.selectLockAction)
        self.addPermanentWidget(self.selectionLockButton)

        # Only use of this appears to be commented out in MWsemantics as of 2007/12/14
        self.modebarLabel = QLabel(win)
        self.addPermanentWidget(self.modebarLabel)
        self.abortableCommands = {}
Beispiel #25
0
    def __init__(self, parent=None, name=None):
        QTreeWidget.__init__(self, parent) 
        global folderClosedIcon, folderLockedIcon, folderOpenIcon, fileIcon

        folderClosedIcon = QIcon(QPixmap(folder_closed_image))
        folderLockedIcon = QIcon(QPixmap(folder_locked_image))
        folderOpenIcon = QIcon(QPixmap(folder_open_image))
        fileIcon = QIcon(QPixmap(pix_file_image))

        self.setHeaderLabels(["", "Name"])
        #self.addColumn("Name", 150) # added 150. mark 060303. [bruce then changed 'width=150' to '150' to avoid exception]
            # Calling addColumn() here causes DirView to change size after its parent (MMKit) is shown.
            # I've not been successful figuring out how to control the height of the DirView (QTreeWidget) 
            # after adding this column. See comments in MWsemantics._findGoodLocation() for more 
            # information about how I compensate for this. Mark 060222.
        #self.setGeometry(QRect(7,-1,191,150))
        self.setMinimumSize(QSize(160,150)) 
            # Trying to force height to be 150, but addColumn() overrides this.  To see the problem,
            # simply comment out addColumn() above and enter Build mode. mark 060222.
        #self.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.MinimumExpanding,0,0,self.sizePolicy().hasHeightForWidth()))
        qt4todo('self.setTreeStepSize(20)')
        qt4todo('self.setColumnWidth(0, 150)') # Force the column width to 150 again. Fixes bug 1613. mark 060303.
Beispiel #26
0
    def __init__(self, parent=None, name=None):
        QTreeWidget.__init__(self, parent)
        global folderClosedIcon, folderLockedIcon, folderOpenIcon, fileIcon

        folderClosedIcon = QIcon(QPixmap(folder_closed_image))
        folderLockedIcon = QIcon(QPixmap(folder_locked_image))
        folderOpenIcon = QIcon(QPixmap(folder_open_image))
        fileIcon = QIcon(QPixmap(pix_file_image))

        self.setHeaderLabels(["", "Name"])
        #self.addColumn("Name", 150) # added 150. mark 060303. [bruce then changed 'width=150' to '150' to avoid exception]
            # Calling addColumn() here causes DirView to change size after its parent (MMKit) is shown.
            # I've not been successful figuring out how to control the height of the DirView (QTreeWidget)
            # after adding this column. See comments in MWsemantics._findGoodLocation() for more
            # information about how I compensate for this. Mark 060222.
        #self.setGeometry(QRect(7,-1,191,150))
        self.setMinimumSize(QSize(160,150))
            # Trying to force height to be 150, but addColumn() overrides this.  To see the problem,
            # simply comment out addColumn() above and enter Build mode. mark 060222.
        #self.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.MinimumExpanding,0,0,self.sizePolicy().hasHeightForWidth()))
        qt4todo('self.setTreeStepSize(20)')
        qt4todo('self.setColumnWidth(0, 150)') # Force the column width to 150 again. Fixes bug 1613. mark 060303.
Beispiel #27
0
folderClosedIcon = 0
folderLockedIcon = 0
folderOpenIcon = 0
fileIcon = 0

qt4todo("""The QListView, QListViewItem, QCheckListItem, and
QListViewItemIterator classes have been renamed Q3ListView,
Q3ListViewItem, Q3CheckListItem, and Q3ListViewItemIterator, and have
been moved to the Qt3Support library. New Qt applications should use
one of the following four classes instead: QTreeView or QTreeWidget
for tree-like structures; QListWidget or the new QListView class for
one-dimensional lists.

See Model/View Programming for an overview of the new item view
classes.
http://doc.trolltech.com/4.0/model-view-programming.html

Examples involving QTreeWidgetItem:
Qt-4.1.4/examples/network/torrent/mainwindow.cpp
Qt-4.1.4/examples/tools/plugandpaint/plugindialog.cpp
--> Qt-4.1.4/examples/tools/settingseditor/settingstree.cpp <--
Qt-4.1.4/examples/xml/dombookmarks/xbeltree.cpp
Qt-4.1.4/examples/xml/saxbookmarks/xbelgenerator.cpp
Qt-4.1.4/examples/xml/saxbookmarks/xbelhandler.cpp""")

class FileItem(QTreeWidgetItem):
    def __init__(self, parent, fio, name=None):
        QTreeWidgetItem.__init__(self)
        parent.addChild(self)
        if name is not None:
Beispiel #28
0
    def __init__(self,
                 parent=None,
                 desc=None,
                 name=None,
                 modal=0,
                 fl=0,
                 env=None,
                 type="QDialog"):
        if env is None:
            import foundation.env as env  # this is a little weird... probably it'll be ok, and logically it seems correct.

        self.desc = desc

        self.typ = type
        if type == "QDialog":
            QDialog.__init__(self, parent, name, modal, fl)
        elif type == "QTextEdit":
            QTextEdit.__init__(self, parent, name)
        elif type == "QFrame":
            QFrame.__init__(self, parent, name)
        else:
            print "don't know about type == %r" % (type, )

        self.image1 = QPixmap()
        self.image1.loadFromData(image1_data,
                                 "PNG")  # should be: title_icon ####
        self.image3 = QPixmap()
        self.image3.loadFromData(image3_data, "PNG")
        self.image4 = QPixmap()
        self.image4.loadFromData(image4_data, "PNG")
        self.image5 = QPixmap()
        self.image5.loadFromData(image5_data, "PNG")
        self.image6 = QPixmap()
        self.image6.loadFromData(image6_data, "PNG")
        self.image7 = QPixmap()
        self.image7.loadFromData(image7_data, "PNG")
        self.image0 = QPixmap(image0_data)  # should be: border_icon ####
        self.image2 = QPixmap(image2_data)  # should be: sponsor_pixmap ####

        try:
            ####@@@@
            title_icon_name = self.desc.options.get('title_icon')
            border_icon_name = self.desc.options.get('border_icon')
            if title_icon_name:
                self.image1 = imagename_to_pixmap(
                    title_icon_name)  ###@@@ pass icon_path
                ###@@@ import imagename_to_pixmap or use env function
                # or let that func itself be an arg, or have an env arg for it
                ###e rename it icon_name_to_pixmap, or find_icon? (the latter only if it's ok if it returns an iconset)
                ###e use iconset instead?
            if border_icon_name:
                self.image0 = imagename_to_pixmap(border_icon_name)
        except:
            print_compact_traceback(
                "bug in icon-setting code, using fallback icons: ")
            pass

        if not name:
            self.setName("parameter_dialog_or_frame")  ###

        ###k guess this will need: if type == 'QDialog'
        self.setIcon(self.image0)  # should be: border_icon ####

        nanotube_dialogLayout = QVBoxLayout(self, 0, 0,
                                            "nanotube_dialogLayout")

        self.heading_frame = QFrame(self, "heading_frame")
        self.heading_frame.setPaletteBackgroundColor(QColor(122, 122, 122))
        self.heading_frame.setFrameShape(QFrame.NoFrame)
        self.heading_frame.setFrameShadow(QFrame.Plain)
        heading_frameLayout = QHBoxLayout(self.heading_frame, 0, 3,
                                          "heading_frameLayout")

        self.heading_pixmap = QLabel(self.heading_frame, "heading_pixmap")
        self.heading_pixmap.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0,
                        self.heading_pixmap.sizePolicy().hasHeightForWidth()))
        self.heading_pixmap.setPixmap(
            self.image1)  # should be: title_icon ####
        self.heading_pixmap.setScaledContents(1)
        heading_frameLayout.addWidget(self.heading_pixmap)

        self.heading_label = QLabel(self.heading_frame, "heading_label")
        self.heading_label.setPaletteForegroundColor(QColor(255, 255, 255))
        heading_label_font = QFont(self.heading_label.font())
        heading_label_font.setPointSize(12)
        heading_label_font.setBold(1)
        self.heading_label.setFont(heading_label_font)
        heading_frameLayout.addWidget(self.heading_label)
        nanotube_dialogLayout.addWidget(self.heading_frame)

        self.body_frame = QFrame(self, "body_frame")
        self.body_frame.setFrameShape(QFrame.StyledPanel)
        self.body_frame.setFrameShadow(QFrame.Raised)
        body_frameLayout = QVBoxLayout(self.body_frame, 3, 3,
                                       "body_frameLayout")

        self.sponsor_frame = QFrame(self.body_frame, "sponsor_frame")
        self.sponsor_frame.setPaletteBackgroundColor(QColor(255, 255, 255))
        self.sponsor_frame.setFrameShape(QFrame.StyledPanel)
        self.sponsor_frame.setFrameShadow(QFrame.Raised)
        sponsor_frameLayout = QHBoxLayout(self.sponsor_frame, 0, 0,
                                          "sponsor_frameLayout")

        self.sponsor_btn = QPushButton(self.sponsor_frame, "sponsor_btn")
        self.sponsor_btn.setAutoDefault(0)  #bruce 060703 bugfix
        self.sponsor_btn.setSizePolicy(
            QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred, 0, 0,
                        self.sponsor_btn.sizePolicy().hasHeightForWidth()))
        self.sponsor_btn.setPaletteBackgroundColor(QColor(255, 255, 255))
        self.sponsor_btn.setPixmap(
            self.image2
        )  # should be: sponsor_pixmap #### [also we'll need to support >1 sponsor]
        self.sponsor_btn.setFlat(1)
        sponsor_frameLayout.addWidget(self.sponsor_btn)
        body_frameLayout.addWidget(self.sponsor_frame)

        layout59 = QHBoxLayout(None, 0, 6, "layout59")
        left_spacer = QSpacerItem(20, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        layout59.addItem(left_spacer)

        self.done_btn = QToolButton(self.body_frame, "done_btn")
        self.done_btn.setIcon(QIcon(self.image3))
        layout59.addWidget(self.done_btn)

        self.abort_btn = QToolButton(self.body_frame, "abort_btn")
        self.abort_btn.setIcon(QIcon(self.image4))
        layout59.addWidget(self.abort_btn)

        self.preview_btn = QToolButton(self.body_frame, "preview_btn")
        self.preview_btn.setIcon(QIcon(self.image5))
        layout59.addWidget(self.preview_btn)

        self.whatsthis_btn = QToolButton(self.body_frame, "whatsthis_btn")
        self.whatsthis_btn.setIcon(QIcon(self.image6))
        layout59.addWidget(self.whatsthis_btn)
        right_spacer = QSpacerItem(20, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        layout59.addItem(right_spacer)
        body_frameLayout.addLayout(layout59)

        self.groups = []
        self.param_getters = {
        }  # map from param name to get-function (which gets current value out of its widget or controller)

        for group_desc in self.desc.kids('group'):

            # == start parameters_grpbox ### this will differ for Windows style

            header_refs = [
            ]  # keep python refcounted refs to all objects we make (at least the ones pyuic stored in self attrs)

            self.parameters_grpbox = QGroupBox(self.body_frame,
                                               "parameters_grpbox")
            self.parameters_grpbox.setFrameShape(QGroupBox.StyledPanel)
            self.parameters_grpbox.setFrameShadow(QGroupBox.Sunken)
            self.parameters_grpbox.setMargin(0)
            self.parameters_grpbox.setColumnLayout(0, Qt.Vertical)
            self.parameters_grpbox.layout().setSpacing(1)
            self.parameters_grpbox.layout().setMargin(4)
            parameters_grpboxLayout = QVBoxLayout(
                self.parameters_grpbox.layout())
            parameters_grpboxLayout.setAlignment(Qt.AlignTop)

            layout20 = QHBoxLayout(None, 0, 6, "layout20")

            self.nt_parameters_grpbtn = QPushButton(self.parameters_grpbox,
                                                    "nt_parameters_grpbtn")
            self.nt_parameters_grpbtn.setSizePolicy(
                QSizePolicy(
                    QSizePolicy.Minimum, QSizePolicy.Fixed, 0, 0,
                    self.nt_parameters_grpbtn.sizePolicy().hasHeightForWidth())
            )
            self.nt_parameters_grpbtn.setMaximumSize(QSize(16, 16))
            self.nt_parameters_grpbtn.setAutoDefault(0)
            self.nt_parameters_grpbtn.setIcon(QIcon(
                self.image7))  ### not always right, but doesn't matter
            self.nt_parameters_grpbtn.setFlat(1)
            layout20.addWidget(self.nt_parameters_grpbtn)

            self.parameters_grpbox_label = QLabel(self.parameters_grpbox,
                                                  "parameters_grpbox_label")
            self.parameters_grpbox_label.setSizePolicy(
                QSizePolicy(
                    QSizePolicy.Preferred, QSizePolicy.Minimum, 0, 0,
                    self.parameters_grpbox_label.sizePolicy().
                    hasHeightForWidth()))
            self.parameters_grpbox_label.setAlignment(QLabel.AlignVCenter)
            layout20.addWidget(self.parameters_grpbox_label)
            gbx_spacer1 = QSpacerItem(67, 16, QSizePolicy.Expanding,
                                      QSizePolicy.Minimum)
            layout20.addItem(gbx_spacer1)
            parameters_grpboxLayout.addLayout(layout20)

            nt_parameters_body_layout = QGridLayout(
                None, 1, 1, 0, 6, "nt_parameters_body_layout"
            )  ### what is 6 -- is it related to number of items???
            # is it 6 in all the ones we got, but that could be a designer error so i better look it up sometime.

            # == start its kids

            # will use from above: self.parameters_grpbox, nt_parameters_body_layout

            nextrow = 0  # which row of the QGridLayout to start filling next (loop variable)
            hidethese = [
            ]  # set of objects to hide or show, when this group is closed or opened

            for param in group_desc.kids('parameter'):
                # param (a group subobj desc) is always a parameter, but we already plan to extend this beyond that,
                # so we redundantly test for this here.
                getter = None
                paramname = None
                # set these for use by uniform code at the end (e.g. for tooltips)
                editfield = None
                label = None
                if param.isa('parameter'):
                    label = QLabel(self.parameters_grpbox, "members_label")
                    label.setAlignment(QLabel.AlignVCenter | QLabel.AlignRight)
                    nt_parameters_body_layout.addWidget(label, nextrow, 0)
                    hidethese.append(label)
                    thisrow = nextrow
                    nextrow += 1
                    #e following should be known in a place that knows the input language, not here
                    paramname = param.options.get('name') or (
                        param.args and param.args[0]) or "?"
                    paramlabel = param.options.get(
                        'label'
                    ) or paramname  ##e wrong, label "" or none ought to be possible
                    # QtGui.QApplication.translate(self.__class__.__name__, "xyz")
                    label.setText(
                        QtGui.QApplication.translate(self.__class__.__name__,
                                                     paramlabel))

                if param.isa('parameter',
                             widget='combobox',
                             type=('str', None)):
                    self.members_combox = QComboBox(
                        0, self.parameters_grpbox,
                        "members_combox")  ###k  what's 0?
                    editfield = self.members_combox
                    #### it probably needs a handler class, and then that could do this setup
                    self.members_combox.clear()
                    default = param.options.get(
                        'default', None)  # None is not equal to any string
                    thewidgetkid = param.kids(
                        'widget'
                    )[-1]  # kluge; need to think what the desc method for this should be
                    for item in thewidgetkid.kids('item'):
                        itemval = item.args[0]
                        itemtext = itemval
                        self.members_combox.insertItem(
                            QtGui.QApplication.translate(
                                self.__class__.__name__,
                                itemtext))  #k __tr ok??
                        if itemval == default:  #k or itemtext?
                            pass  ##k i find no setItem in our py code, so not sure yet what to do for this.
                    nt_parameters_body_layout.addWidget(
                        self.members_combox, thisrow, 1)
                    hidethese.append(self.members_combox)
                    getter = (lambda combobox=self.members_combox: str(
                        combobox.currentText()))
                    ##e due to __tr or non-str values, it might be better to use currentIndex and look it up in a table
                    # (though whether __tr is good here might depend on what it's used for)

                elif param.isa('parameter',
                               widget=('lineedit', None),
                               type=('str', None)):
                    # this covers explicit str|lineedit, and 3 default cases str, lineedit, neither.
                    # (i.e. if you say parameter and nothing else, it's str lineedit by default.)
                    self.length_linedit = QLineEdit(self.parameters_grpbox,
                                                    "length_linedit")
                    editfield = self.length_linedit
                    nt_parameters_body_layout.addWidget(
                        self.length_linedit, thisrow, 1)
                    hidethese.append(self.length_linedit)
                    default = str(param.options.get('default', ""))
                    self.length_linedit.setText(
                        QtGui.QApplication.translate(self.__class__.__name__,
                                                     default))  # __tr ok?
                    getter = (lambda lineedit=self.length_linedit: str(
                        lineedit.text()))

                elif param.isa('parameter',
                               widget=('lineedit', None),
                               type='float'):
                    self.length_linedit = QLineEdit(self.parameters_grpbox,
                                                    "length_linedit")
                    editfield = self.length_linedit
                    nt_parameters_body_layout.addWidget(
                        self.length_linedit, thisrow, 1)
                    hidethese.append(self.length_linedit)
                    controller = FloatLineeditController_Qt(
                        self, param, self.length_linedit)
                    header_refs.append(controller)
                    getter = controller.get_value

                elif param.isa('parameter', widget = ('spinbox', None), type = 'int') or \
                     param.isa('parameter', widget = ('spinbox'), type = None):
                    self.chirality_N_spinbox = QSpinBox(
                        self.parameters_grpbox, "chirality_N_spinbox"
                    )  # was chirality_m_spinbox, now chirality_N_spinbox
                    editfield = self.chirality_N_spinbox
                    ### seems like Qt defaults for min and max are 0,100 -- way too small a range!
                    if param.options.has_key('min') or 1:
                        self.chirality_N_spinbox.setMinimum(
                            param.options.get('min', -999999999))  # was 0
                    if param.options.has_key('max') or 1:
                        self.chirality_N_spinbox.setMaximum(
                            param.options.get(
                                'max',
                                +999999999))  # wasn't in egcode, but needed
                    self.chirality_N_spinbox.setValue(
                        param.options.get('default', 0))  # was 5
                    ##e note: i suspect this default 0 should come from something that knows this desc grammar.
                    suffix = param.options.get('suffix', '')
                    if suffix:
                        self.chirality_N_spinbox.setSuffix(
                            QtGui.QApplication.translate(
                                self.__class__.__name__, suffix))
                    else:
                        self.chirality_N_spinbox.setSuffix(
                            QString.null)  # probably not needed
                    nt_parameters_body_layout.addWidget(
                        self.chirality_N_spinbox, thisrow, 1)
                    hidethese.append(self.chirality_N_spinbox)
                    getter = self.chirality_N_spinbox.value  # note: it also has .text, which includes suffix

                else:
                    print "didn't match:", param  ###e improve this

                # things done the same way for all kinds of param-editing widgets
                if 1:  #bruce 060703 moved this down here, as bugfix
                    # set tooltip (same one for editfield and label)
                    tooltip = param.options.get('tooltip', '')
                    ###e do it for more kinds of params; share the code somehow; do it in controller, or setup-aid?
                    ###k QToolTip appropriateness; tooltip option might be entirely untested
                    if tooltip and label:
                        QToolTip.add(
                            label,
                            QtGui.QApplication.translate(
                                self.__class__.__name__, tooltip))
                    if tooltip and editfield:
                        QToolTip.add(
                            editfield,
                            QtGui.QApplication.translate(
                                self.__class__.__name__, tooltip)
                        )  ##k ok?? review once not all params have same-row labels.

                if getter and paramname and paramname != '?':
                    self.param_getters[paramname] = getter
                ### also bind these params to actions...
                continue  # next param

            header_refs.extend([
                self.parameters_grpbox, self.nt_parameters_grpbtn,
                self.parameters_grpbox_label
            ])

            # now create the logic/control object for the group
            group = CollapsibleGroupController_Qt(self, group_desc,
                                                  header_refs, hidethese,
                                                  self.nt_parameters_grpbtn)
            ### maybe ask env for the class to use for this?
            self.groups.append(
                group
            )  ### needed?? only for scanning the params, AFAIK -- oh, and to maintain a python refcount.

            # from languageChange:
            if 1:  # i don't know if these are needed:
                self.parameters_grpbox.setTitle(QString.null)
                self.nt_parameters_grpbtn.setText(QString.null)
            self.parameters_grpbox_label.setText(
                QtGui.QApplication.translate(
                    self.__class__.__name__,
                    group_desc.args[0]))  # was "Nanotube Parameters"
            ##e note that it's questionable in the syntax design for this property of a group (overall group label)
            # to be in that position (desc arg 0).

            # == end its kids

            parameters_grpboxLayout.addLayout(nt_parameters_body_layout)
            body_frameLayout.addWidget(self.parameters_grpbox)

            # == end parameters groupbox

            continue  # next group

        nanotube_dialogLayout.addWidget(self.body_frame)
        spacer14 = QSpacerItem(20, 20, QSizePolicy.Minimum,
                               QSizePolicy.Expanding)
        nanotube_dialogLayout.addItem(spacer14)

        layout42 = QHBoxLayout(None, 4, 6, "layout42")
        btm_spacer = QSpacerItem(59, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        layout42.addItem(btm_spacer)

        self.cancel_btn = QPushButton(self, "cancel_btn")
        self.cancel_btn.setAutoDefault(0)  #bruce 060703 bugfix
        layout42.addWidget(self.cancel_btn)

        self.ok_btn = QPushButton(self, "ok_btn")
        self.ok_btn.setAutoDefault(0)  #bruce 060703 bugfix
        layout42.addWidget(self.ok_btn)
        nanotube_dialogLayout.addLayout(layout42)

        self.languageChange()

        self.resize(
            QSize(246, 618).expandedTo(self.minimumSizeHint())
        )  ### this size will need to be adjusted (guess -- it's only place overall size is set)
        qt4todo('self.clearWState(Qt.WState_Polished)')

        ## self.connect(self.nt_parameters_grpbtn,SIGNAL("clicked()"),self.toggle_nt_parameters_grpbtn) ####

        # new:
        for button, methodname in (
            (self.sponsor_btn,
             'do_sponsor_btn'),  #e generalize to more than one sponsor button
            (self.done_btn, 'do_done_btn'),
            (self.abort_btn, 'do_abort_btn'),
            (self.preview_btn, 'do_preview_btn'),
            (self.whatsthis_btn, 'do_whatsthis_btn'),
            (self.cancel_btn, 'do_cancel_btn'),
            (self.ok_btn, 'do_ok_btn')):
            if hasattr(self, methodname):
                self.connect(button, SIGNAL("clicked()"),
                             getattr(self, methodname))
        return
Beispiel #29
0
    def __init__(self, parent = None, desc = None, name = None, modal = 0, fl = 0, env = None, type = "QDialog"):
        if env is None:
            import foundation.env as env # this is a little weird... probably it'll be ok, and logically it seems correct.
        
        self.desc = desc

        self.typ = type
        if type == "QDialog":
            QDialog.__init__(self,parent,name,modal,fl)
        elif type == "QTextEdit":
            QTextEdit.__init__(self, parent, name)
        elif type == "QFrame":
            QFrame.__init__(self,parent,name)
        else:
            print "don't know about type == %r" % (type,)
        
        self.image1 = QPixmap()
        self.image1.loadFromData(image1_data,"PNG") # should be: title_icon ####
        self.image3 = QPixmap()
        self.image3.loadFromData(image3_data,"PNG")
        self.image4 = QPixmap()
        self.image4.loadFromData(image4_data,"PNG")
        self.image5 = QPixmap()
        self.image5.loadFromData(image5_data,"PNG")
        self.image6 = QPixmap()
        self.image6.loadFromData(image6_data,"PNG")
        self.image7 = QPixmap()
        self.image7.loadFromData(image7_data,"PNG")
        self.image0 = QPixmap(image0_data) # should be: border_icon ####
        self.image2 = QPixmap(image2_data) # should be: sponsor_pixmap ####

        try:
            ####@@@@
            title_icon_name = self.desc.options.get('title_icon')
            border_icon_name = self.desc.options.get('border_icon')
            if title_icon_name:
                self.image1 = imagename_to_pixmap(title_icon_name) ###@@@ pass icon_path
                    ###@@@ import imagename_to_pixmap or use env function
                    # or let that func itself be an arg, or have an env arg for it
                    ###e rename it icon_name_to_pixmap, or find_icon? (the latter only if it's ok if it returns an iconset)
                    ###e use iconset instead?
            if border_icon_name:
                self.image0 = imagename_to_pixmap(border_icon_name)
        except:
            print_compact_traceback("bug in icon-setting code, using fallback icons: ")
            pass

        if not name:
            self.setName("parameter_dialog_or_frame") ###

        ###k guess this will need: if type == 'QDialog'
        self.setIcon(self.image0) # should be: border_icon ####

        nanotube_dialogLayout = QVBoxLayout(self,0,0,"nanotube_dialogLayout")

        self.heading_frame = QFrame(self,"heading_frame")
        self.heading_frame.setPaletteBackgroundColor(QColor(122,122,122))
        self.heading_frame.setFrameShape(QFrame.NoFrame)
        self.heading_frame.setFrameShadow(QFrame.Plain)
        heading_frameLayout = QHBoxLayout(self.heading_frame,0,3,"heading_frameLayout")

        self.heading_pixmap = QLabel(self.heading_frame,"heading_pixmap")
        self.heading_pixmap.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.heading_pixmap.sizePolicy().hasHeightForWidth()))
        self.heading_pixmap.setPixmap(self.image1) # should be: title_icon ####
        self.heading_pixmap.setScaledContents(1)
        heading_frameLayout.addWidget(self.heading_pixmap)

        self.heading_label = QLabel(self.heading_frame,"heading_label")
        self.heading_label.setPaletteForegroundColor(QColor(255,255,255))
        heading_label_font = QFont(self.heading_label.font())
        heading_label_font.setPointSize(12)
        heading_label_font.setBold(1)
        self.heading_label.setFont(heading_label_font)
        heading_frameLayout.addWidget(self.heading_label)
        nanotube_dialogLayout.addWidget(self.heading_frame)

        self.body_frame = QFrame(self,"body_frame")
        self.body_frame.setFrameShape(QFrame.StyledPanel)
        self.body_frame.setFrameShadow(QFrame.Raised)
        body_frameLayout = QVBoxLayout(self.body_frame,3,3,"body_frameLayout")

        self.sponsor_frame = QFrame(self.body_frame,"sponsor_frame")
        self.sponsor_frame.setPaletteBackgroundColor(QColor(255,255,255))
        self.sponsor_frame.setFrameShape(QFrame.StyledPanel)
        self.sponsor_frame.setFrameShadow(QFrame.Raised)
        sponsor_frameLayout = QHBoxLayout(self.sponsor_frame,0,0,"sponsor_frameLayout")

        self.sponsor_btn = QPushButton(self.sponsor_frame,"sponsor_btn")
        self.sponsor_btn.setAutoDefault(0) #bruce 060703 bugfix
        self.sponsor_btn.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Preferred,0,0,self.sponsor_btn.sizePolicy().hasHeightForWidth()))
        self.sponsor_btn.setPaletteBackgroundColor(QColor(255,255,255))
        self.sponsor_btn.setPixmap(self.image2) # should be: sponsor_pixmap #### [also we'll need to support >1 sponsor]
        self.sponsor_btn.setFlat(1)
        sponsor_frameLayout.addWidget(self.sponsor_btn)
        body_frameLayout.addWidget(self.sponsor_frame)

        layout59 = QHBoxLayout(None,0,6,"layout59")
        left_spacer = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
        layout59.addItem(left_spacer)

        self.done_btn = QToolButton(self.body_frame,"done_btn")
        self.done_btn.setIcon(QIcon(self.image3))
        layout59.addWidget(self.done_btn)

        self.abort_btn = QToolButton(self.body_frame,"abort_btn")
        self.abort_btn.setIcon(QIcon(self.image4))
        layout59.addWidget(self.abort_btn)

        self.preview_btn = QToolButton(self.body_frame,"preview_btn")
        self.preview_btn.setIcon(QIcon(self.image5))
        layout59.addWidget(self.preview_btn)

        self.whatsthis_btn = QToolButton(self.body_frame,"whatsthis_btn")
        self.whatsthis_btn.setIcon(QIcon(self.image6))
        layout59.addWidget(self.whatsthis_btn)
        right_spacer = QSpacerItem(20,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
        layout59.addItem(right_spacer)
        body_frameLayout.addLayout(layout59)

        self.groups = []
        self.param_getters = {} # map from param name to get-function (which gets current value out of its widget or controller)

        for group_desc in self.desc.kids('group'):
            
            # == start parameters_grpbox ### this will differ for Windows style

            header_refs = [] # keep python refcounted refs to all objects we make (at least the ones pyuic stored in self attrs)
            
            self.parameters_grpbox = QGroupBox(self.body_frame,"parameters_grpbox")
            self.parameters_grpbox.setFrameShape(QGroupBox.StyledPanel)
            self.parameters_grpbox.setFrameShadow(QGroupBox.Sunken)
            self.parameters_grpbox.setMargin(0)
            self.parameters_grpbox.setColumnLayout(0,Qt.Vertical)
            self.parameters_grpbox.layout().setSpacing(1)
            self.parameters_grpbox.layout().setMargin(4)
            parameters_grpboxLayout = QVBoxLayout(self.parameters_grpbox.layout())
            parameters_grpboxLayout.setAlignment(Qt.AlignTop)

            layout20 = QHBoxLayout(None,0,6,"layout20")

            self.nt_parameters_grpbtn = QPushButton(self.parameters_grpbox,"nt_parameters_grpbtn")
            self.nt_parameters_grpbtn.setSizePolicy(QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Fixed,0,0,self.nt_parameters_grpbtn.sizePolicy().hasHeightForWidth()))
            self.nt_parameters_grpbtn.setMaximumSize(QSize(16,16))
            self.nt_parameters_grpbtn.setAutoDefault(0)
            self.nt_parameters_grpbtn.setIcon(QIcon(self.image7)) ### not always right, but doesn't matter
            self.nt_parameters_grpbtn.setFlat(1)
            layout20.addWidget(self.nt_parameters_grpbtn)

            self.parameters_grpbox_label = QLabel(self.parameters_grpbox,"parameters_grpbox_label")
            self.parameters_grpbox_label.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Minimum,0,0,self.parameters_grpbox_label.sizePolicy().hasHeightForWidth()))
            self.parameters_grpbox_label.setAlignment(QLabel.AlignVCenter)
            layout20.addWidget(self.parameters_grpbox_label)
            gbx_spacer1 = QSpacerItem(67,16,QSizePolicy.Expanding,QSizePolicy.Minimum)
            layout20.addItem(gbx_spacer1)
            parameters_grpboxLayout.addLayout(layout20)

            nt_parameters_body_layout = QGridLayout(None,1,1,0,6,"nt_parameters_body_layout") ### what is 6 -- is it related to number of items???
                # is it 6 in all the ones we got, but that could be a designer error so i better look it up sometime.

            # == start its kids

            # will use from above: self.parameters_grpbox, nt_parameters_body_layout
            
            nextrow = 0 # which row of the QGridLayout to start filling next (loop variable)
            hidethese = [] # set of objects to hide or show, when this group is closed or opened
            
            for param in group_desc.kids('parameter'):
                # param (a group subobj desc) is always a parameter, but we already plan to extend this beyond that,
                # so we redundantly test for this here.
                getter = None
                paramname = None
                # set these for use by uniform code at the end (e.g. for tooltips)
                editfield = None
                label = None
                if param.isa('parameter'):
                    label = QLabel(self.parameters_grpbox,"members_label")
                    label.setAlignment(QLabel.AlignVCenter | QLabel.AlignRight)
                    nt_parameters_body_layout.addWidget(label,nextrow,0)
                    hidethese.append(label)
                    thisrow = nextrow
                    nextrow += 1
                    #e following should be known in a place that knows the input language, not here
                    paramname = param.options.get('name') or (param.args and param.args[0]) or "?"
                    paramlabel = param.options.get('label') or paramname ##e wrong, label "" or none ought to be possible
                    # QtGui.QApplication.translate(self.__class__.__name__, "xyz")
                    label.setText(QtGui.QApplication.translate(self.__class__.__name__, paramlabel))
                    
                if param.isa('parameter', widget = 'combobox', type = ('str',None)):
                    self.members_combox = QComboBox(0,self.parameters_grpbox,"members_combox") ###k  what's 0?
                    editfield = self.members_combox
                    #### it probably needs a handler class, and then that could do this setup
                    self.members_combox.clear()
                    default = param.options.get('default', None) # None is not equal to any string
                    thewidgetkid = param.kids('widget')[-1] # kluge; need to think what the desc method for this should be
                    for item in thewidgetkid.kids('item'):
                        itemval = item.args[0]
                        itemtext = itemval
                        self.members_combox.insertItem(QtGui.QApplication.translate(self.__class__.__name__, itemtext)) #k __tr ok??
                        if itemval == default: #k or itemtext?
                            pass ##k i find no setItem in our py code, so not sure yet what to do for this.
                    nt_parameters_body_layout.addWidget(self.members_combox,thisrow,1)
                    hidethese.append(self.members_combox)
                    getter = (lambda combobox = self.members_combox: str(combobox.currentText()))
                        ##e due to __tr or non-str values, it might be better to use currentIndex and look it up in a table
                        # (though whether __tr is good here might depend on what it's used for)
                                    
                elif param.isa('parameter', widget = ('lineedit', None), type = ('str',None)):
                    # this covers explicit str|lineedit, and 3 default cases str, lineedit, neither.
                    # (i.e. if you say parameter and nothing else, it's str lineedit by default.)
                    self.length_linedit = QLineEdit(self.parameters_grpbox,"length_linedit")
                    editfield = self.length_linedit
                    nt_parameters_body_layout.addWidget(self.length_linedit,thisrow,1)
                    hidethese.append(self.length_linedit)
                    default = str(param.options.get('default', ""))
                    self.length_linedit.setText(QtGui.QApplication.translate(self.__class__.__name__, default)) # __tr ok?
                    getter = (lambda lineedit = self.length_linedit: str(lineedit.text()))
                    
                elif param.isa('parameter', widget = ('lineedit', None), type = 'float'):
                    self.length_linedit = QLineEdit(self.parameters_grpbox,"length_linedit")
                    editfield = self.length_linedit
                    nt_parameters_body_layout.addWidget(self.length_linedit,thisrow,1)
                    hidethese.append(self.length_linedit)
                    controller = FloatLineeditController_Qt(self, param, self.length_linedit)
                    header_refs.append(controller)
                    getter = controller.get_value
                    
                elif param.isa('parameter', widget = ('spinbox', None), type = 'int') or \
                     param.isa('parameter', widget = ('spinbox'), type = None):
                    self.chirality_N_spinbox = QSpinBox(self.parameters_grpbox,"chirality_N_spinbox") # was chirality_m_spinbox, now chirality_N_spinbox
                    editfield = self.chirality_N_spinbox
                    ### seems like Qt defaults for min and max are 0,100 -- way too small a range!
                    if param.options.has_key('min') or 1:
                        self.chirality_N_spinbox.setMinimum(param.options.get('min', -999999999)) # was 0
                    if param.options.has_key('max') or 1:
                        self.chirality_N_spinbox.setMaximum(param.options.get('max', +999999999)) # wasn't in egcode, but needed
                    self.chirality_N_spinbox.setValue(param.options.get('default', 0)) # was 5
                        ##e note: i suspect this default 0 should come from something that knows this desc grammar.
                    suffix = param.options.get('suffix', '')
                    if suffix:
                        self.chirality_N_spinbox.setSuffix(QtGui.QApplication.translate(self.__class__.__name__, suffix))
                    else:
                        self.chirality_N_spinbox.setSuffix(QString.null) # probably not needed
                    nt_parameters_body_layout.addWidget(self.chirality_N_spinbox,thisrow,1)
                    hidethese.append(self.chirality_N_spinbox)
                    getter = self.chirality_N_spinbox.value # note: it also has .text, which includes suffix
                    
                else:
                    print "didn't match:",param ###e improve this

                # things done the same way for all kinds of param-editing widgets
                if 1: #bruce 060703 moved this down here, as bugfix
                    # set tooltip (same one for editfield and label)
                    tooltip = param.options.get('tooltip', '')
                    ###e do it for more kinds of params; share the code somehow; do it in controller, or setup-aid?
                    ###k QToolTip appropriateness; tooltip option might be entirely untested
                    if tooltip and label:
                        QToolTip.add(label, QtGui.QApplication.translate(self.__class__.__name__, tooltip))
                    if tooltip and editfield:
                        QToolTip.add(editfield, QtGui.QApplication.translate(self.__class__.__name__, tooltip)) ##k ok?? review once not all params have same-row labels.
                
                if getter and paramname and paramname != '?':
                    self.param_getters[paramname] = getter
                ### also bind these params to actions...
                continue # next param

            header_refs.extend( [self.parameters_grpbox, self.nt_parameters_grpbtn, self.parameters_grpbox_label] )
            
            # now create the logic/control object for the group
            group = CollapsibleGroupController_Qt(self, group_desc, header_refs, hidethese, self.nt_parameters_grpbtn)
                ### maybe ask env for the class to use for this?
            self.groups.append(group) ### needed?? only for scanning the params, AFAIK -- oh, and to maintain a python refcount.

            # from languageChange:
            if 1: # i don't know if these are needed:
                self.parameters_grpbox.setTitle(QString.null)
                self.nt_parameters_grpbtn.setText(QString.null)
            self.parameters_grpbox_label.setText(QtGui.QApplication.translate(self.__class__.__name__, group_desc.args[0])) # was "Nanotube Parameters"
                ##e note that it's questionable in the syntax design for this property of a group (overall group label)
                # to be in that position (desc arg 0).
        
            # == end its kids
            
            parameters_grpboxLayout.addLayout(nt_parameters_body_layout)
            body_frameLayout.addWidget(self.parameters_grpbox)

            # == end parameters groupbox
            
            continue # next group

        nanotube_dialogLayout.addWidget(self.body_frame)
        spacer14 = QSpacerItem(20,20,QSizePolicy.Minimum,QSizePolicy.Expanding)
        nanotube_dialogLayout.addItem(spacer14)

        layout42 = QHBoxLayout(None,4,6,"layout42")
        btm_spacer = QSpacerItem(59,20,QSizePolicy.Expanding,QSizePolicy.Minimum)
        layout42.addItem(btm_spacer)

        self.cancel_btn = QPushButton(self,"cancel_btn")
        self.cancel_btn.setAutoDefault(0) #bruce 060703 bugfix
        layout42.addWidget(self.cancel_btn)

        self.ok_btn = QPushButton(self,"ok_btn")
        self.ok_btn.setAutoDefault(0) #bruce 060703 bugfix
        layout42.addWidget(self.ok_btn)
        nanotube_dialogLayout.addLayout(layout42)

        self.languageChange()

        self.resize(QSize(246,618).expandedTo(self.minimumSizeHint())) ### this size will need to be adjusted (guess -- it's only place overall size is set)
        qt4todo('self.clearWState(Qt.WState_Polished)')

        ## self.connect(self.nt_parameters_grpbtn,SIGNAL("clicked()"),self.toggle_nt_parameters_grpbtn) ####

        # new:
        for button, methodname in ((self.sponsor_btn, 'do_sponsor_btn'),  #e generalize to more than one sponsor button
                                   (self.done_btn, 'do_done_btn'),
                                   (self.abort_btn, 'do_abort_btn'),
                                   (self.preview_btn, 'do_preview_btn'),
                                   (self.whatsthis_btn, 'do_whatsthis_btn'),
                                   (self.cancel_btn, 'do_cancel_btn'),
                                   (self.ok_btn, 'do_ok_btn')):
            if hasattr(self, methodname):
                self.connect(button, SIGNAL("clicked()"), getattr(self, methodname))
        return
Beispiel #30
0
    def __init__(self, win, part, previous_movie = None, suffix = ""):
        """
        use previous_movie (if passed) for default values,
        otherwise use the same ones last ok'd by user
        (whether or not that sim got aborted), or default values if that never happened in this session;
        on success or failure, make a new Movie and store it as self.movie
        """
        QDialog.__init__(self, win) # win is parent.
        self.setupUi(self)

        self.setWindowIcon(geticon('ui/border/RunDynamics.png'))

        self.whatsthis_btn.setIcon(
            geticon('ui/actions/Properties Manager/WhatsThis.png'))
        self.whatsthis_btn.setIconSize(QSize(22, 22))
        self.whatsthis_btn.setToolTip('Enter "What\'s This?" help mode')

        self.connect(self.whatsthis_btn,
                     SIGNAL("clicked()"),
                     QWhatsThis.enterWhatsThisMode)

        self.watch_motion_buttongroup = QButtonGroup()
        self.watch_motion_buttongroup.setExclusive(True)
        for obj in self.watch_motion_groupbox.children():
            if isinstance(obj, QAbstractButton):
                self.watch_motion_buttongroup.addButton(obj)
        self.connect(self.run_sim_btn,SIGNAL("clicked()"),self.createMoviePressed)
        self.connect(self.cancel_btn,SIGNAL("clicked()"),self.close)
        qt4todo('self.connect(self.watch_motion_groupbox,SIGNAL("toggled(bool)"),self.setEnabled) ???')
        self.watch_motion_groupbox.setEnabled(True)
        ## self.part = part
            # not yet needed, though in future we might display info
            # about this Part in the dialog, to avoid confusion
            # if it's not the main Part.
        connect_checkbox_with_boolean_pref(self.potential_energy_checkbox,
                                           Potential_energy_tracefile_prefs_key)

        connect_checkbox_with_boolean_pref(
            self.electrostaticsForDnaDuringDynamics_checkBox,
            electrostaticsForDnaDuringDynamics_prefs_key)

        self.assy = part.assy # used only for assy.filename
        self.suffix = suffix
        self.previous_movie = previous_movie or _stickyParams or Movie(self.assy) # used only for its parameter settings
            # note: as of bruce 060601 fixing bug 1840, previous_movie is no longer ever passed by caller.
        self.movie = Movie(self.assy) # public attr used by client code after we return; always a Movie even on failure.
            # (we need it here since no extra method runs on failure, tho that could probably be fixed)
            # bruce 050325 changes:
            # We make a new Movie here (but only when we return with success).
            # But we use default param settings from prior movie.
            # Caller should pass info about default filename (including uniqueness
            #  when on selection or in clipboard item) -- i.e. the suffix.
            # We should set the params and filename using a Movie method, or warn it we did so,
            # or do them in its init... not yet cleaned up. ###@@@
            # self.movie is now a public attribute.
            #bruce 050329 comment: couldn't we set .movie to None, until we learn we succeeded? ###e ###@@@
        self.setup()
        self.watch_motion_groupbox.setWhatsThis(
            """<b>Watch motion in real time</b>
            <p>
            Enables real time graphical updates during simulation runs.
            """)
        self.update_number_spinbox.setWhatsThis(
            """<b>Update every <i>n units.</u></b>
            <p>
            Specify how often to update the model during the simulation.
            This allows the user to monitor simulation results while the
            simulation is running.
            </p>""")
        self.update_units_combobox.setWhatsThis(
            """<b>Update every <i>n units.</u></b>
            <p>
            Specify how often to update the model during the simulation.
            This allows the user to monitor simulation results while the
            simulation is running.
            </p>""")
        self.update_every_rbtn.setWhatsThis(
            """<b>Update every <i>n units.</u></b>
            <p>
            Specify how often to update the model during the simulation.
            This allows the user to monitor simulation results while the
            simulation is running.</p>""")
        self.update_asap_rbtn.setWhatsThis(
            """<b>Update as fast as possible</b>
            <p>
            Update every 2 seconds, or faster (up to 20x/sec) if it doesn't
            slow down the simulation by more than 20%.
            </p>""")
        self.temperatureSpinBox.setWhatsThis(
            """<b>Temperature</b>
            <p>
            The temperature of the simulation in Kelvin
            (300 K = room temperature)</p>""")
        self.totalFramesSpinBox.setWhatsThis(
            """<b>Total frames</b>
            <p>
            The total number of (movie) frames to create for the simulation run.
            </p>""")
        self.stepsPerFrameDoubleSpinBox.setWhatsThis(
            """<b>Steps per frame</b>
            <p>
            The time duration between frames in femtoseconds.
            </p>""")
        self.setWhatsThis(
            """<b>Run Dynamics</b>
            <p>
            The is the main dialog for configuring and launching a
            Molecular Dynamics simulation run. Specify the simulation parameters
            and click <b>Run Simulation</b> to launch.</p>
            <p>
            <img source=\"ui/actions/Simulation/PlayMovie.png\"><br>
            The <b>Play Movie</b> command can be used to play back the
            simulation.
            </p>""")

        if not debug_pref("GROMACS: Enable for Run Dynamics", Choice_boolean_False,
                          prefs_key=True):
            # Hide the Simulation engine groupbox altogether.
            self.md_engine_groupbox.setHidden(True)

        self.exec_()
Beispiel #31
0
folderClosedIcon = 0
folderLockedIcon = 0
folderOpenIcon = 0
fileIcon = 0

qt4todo("""The QListView, QListViewItem, QCheckListItem, and
QListViewItemIterator classes have been renamed Q3ListView,
Q3ListViewItem, Q3CheckListItem, and Q3ListViewItemIterator, and have
been moved to the Qt3Support library. New Qt applications should use
one of the following four classes instead: QTreeView or QTreeWidget
for tree-like structures; QListWidget or the new QListView class for
one-dimensional lists.

See Model/View Programming for an overview of the new item view
classes.
http://doc.trolltech.com/4.0/model-view-programming.html

Examples involving QTreeWidgetItem:
Qt-4.1.4/examples/network/torrent/mainwindow.cpp
Qt-4.1.4/examples/tools/plugandpaint/plugindialog.cpp
--> Qt-4.1.4/examples/tools/settingseditor/settingstree.cpp <--
Qt-4.1.4/examples/xml/dombookmarks/xbeltree.cpp
Qt-4.1.4/examples/xml/saxbookmarks/xbelgenerator.cpp
Qt-4.1.4/examples/xml/saxbookmarks/xbelhandler.cpp""")


class FileItem(QTreeWidgetItem):
    def __init__(self, parent, fio, name=None):
        QTreeWidgetItem.__init__(self)
        parent.addChild(self)
Beispiel #32
0
    def __init__(self, win):
        qt4todo('what to do with all those options?')
        ## ElementColorsDialog.__init__(self, win, None, 0,
        ##   Qt.WStyle_Customize | Qt.WStyle_NormalBorder | 
        ##   Qt.WStyle_Title | Qt.WStyle_SysMenu)
        QDialog.__init__(self, win)
        self.setupUi(self)
        self.connect(self.okButton, SIGNAL("clicked()"), self.ok)
        self.connect(self.loadColorsPB, SIGNAL("clicked()"), self.read_element_rgb_table)
        self.connect(self.saveColorsPB, SIGNAL("clicked()"), self.write_element_rgb_table)
        self.connect(self.cancelButton, SIGNAL("clicked()"), self.reject)
        self.connect(self.defaultButton, SIGNAL("clicked()"), self.loadDefaultProp)
        self.connect(self.alterButton, SIGNAL("clicked()"), self.loadAlterProp)
        self.connect(self.elementButtonGroup, SIGNAL("clicked(int)"), self.setElementInfo)
        self.connect(self.previewPB, SIGNAL("clicked()"), self.preview_color_change)
        self.connect(self.restorePB, SIGNAL("clicked()"), self.restore_current_color)
        self.w = win
        self.fileName = None
        self.isElementModified = False
        self.isFileSaved = False
        self.oldTable = PeriodicTable.deepCopy()
        self.elemTable = PeriodicTable
        self.displayMode = self._displayList[0]
        # The next line fixes a bug. Thumbview expects self.gridLayout on
        # line 117 of Thumbview.py. Mark 2007-10-19.
        self.gridLayout = self.gridlayout 
        self.elemGLPane = ElementView(self, "element glPane", self.w.glpane)
        # Put the GL widget inside the frame
        flayout = QVBoxLayout(self.elementFrame)
        flayout.setMargin(1)
        flayout.setSpacing(1)
        flayout.addWidget(self.elemGLPane, 1)
        
        def elementId(symbol):
            return PeriodicTable.getElement(symbol).eltnum
        self.toolButton6.setChecked(True)
        self.elementButtonGroup.setId(self.toolButton6, elementId("C"))
        self.elementButtonGroup.setId(self.toolButton8, elementId("O"))
        self.elementButtonGroup.setId(self.toolButton10, elementId("Ne"))
        self.elementButtonGroup.setId(self.toolButton9, elementId("F"))
        self.elementButtonGroup.setId(self.toolButton13, elementId("Al"))
        self.elementButtonGroup.setId(self.toolButton17, elementId("Cl"))
        self.elementButtonGroup.setId(self.toolButton5, elementId("B"))
        self.elementButtonGroup.setId(self.toolButton10_2, elementId("Ar"))
        self.elementButtonGroup.setId(self.toolButton15, elementId("P"))
        self.elementButtonGroup.setId(self.toolButton16, elementId("S"))
        self.elementButtonGroup.setId(self.toolButton14, elementId("Si"))
        self.elementButtonGroup.setId(self.toolButton33, elementId("As"))
        self.elementButtonGroup.setId(self.toolButton34, elementId("Se"))
        self.elementButtonGroup.setId(self.toolButton35, elementId("Br"))
        self.elementButtonGroup.setId(self.toolButton36, elementId("Kr"))
        self.elementButtonGroup.setId(self.toolButton32, elementId("Ge"))
        self.elementButtonGroup.setId(self.toolButton7, elementId("N"))
        self.elementButtonGroup.setId(self.toolButton2, elementId("He"))
        self.elementButtonGroup.setId(self.toolButton1, elementId("H"))
        self.elementButtonGroup.setId(self.toolButton0, elementId("X"))

        self.connect(self.toolButton6, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton8, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton10, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton9, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton13, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton17, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton5, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton10_2, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton15, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton16, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton14, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton33, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton34, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton35, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton36, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton32, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton7, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton2, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton1, SIGNAL("clicked()"), self.updateElemColorDisplay)
        self.connect(self.toolButton0, SIGNAL("clicked()"), self.updateElemColorDisplay)
        
        self.connectChangingControls()
        self.saveColorsPB.setWhatsThis(
            """Save the current color settings for elements in a text file.""")
        self.defaultButton.setWhatsThis(
            """Restore current element colors to the default colors.""")
        self.loadColorsPB.setWhatsThis(
            """Load element colors from an external text file.""")
        self.alterButton.setWhatsThis(
            """Set element colors to the alternate color set.""")
Beispiel #33
0
    def __init__(self, win):
        qt4todo('what to do with all those options?')
        ## ElementColorsDialog.__init__(self, win, None, 0,
        ##   Qt.WStyle_Customize | Qt.WStyle_NormalBorder |
        ##   Qt.WStyle_Title | Qt.WStyle_SysMenu)
        QDialog.__init__(self, win)
        self.setupUi(self)
        self.connect(self.okButton, SIGNAL("clicked()"), self.ok)
        self.connect(self.loadColorsPB, SIGNAL("clicked()"),
                     self.read_element_rgb_table)
        self.connect(self.saveColorsPB, SIGNAL("clicked()"),
                     self.write_element_rgb_table)
        self.connect(self.cancelButton, SIGNAL("clicked()"), self.reject)
        self.connect(self.defaultButton, SIGNAL("clicked()"),
                     self.loadDefaultProp)
        self.connect(self.alterButton, SIGNAL("clicked()"), self.loadAlterProp)
        self.connect(self.elementButtonGroup, SIGNAL("clicked(int)"),
                     self.setElementInfo)
        self.connect(self.previewPB, SIGNAL("clicked()"),
                     self.preview_color_change)
        self.connect(self.restorePB, SIGNAL("clicked()"),
                     self.restore_current_color)
        self.w = win
        self.fileName = None
        self.isElementModified = False
        self.isFileSaved = False
        self.oldTable = PeriodicTable.deepCopy()
        self.elemTable = PeriodicTable
        self.displayMode = self._displayList[0]
        # The next line fixes a bug. Thumbview expects self.gridLayout on
        # line 117 of Thumbview.py. Mark 2007-10-19.
        self.gridLayout = self.gridlayout
        self.elemGLPane = ElementView(self, "element glPane", self.w.glpane)
        # Put the GL widget inside the frame
        flayout = QVBoxLayout(self.elementFrame)
        flayout.setMargin(1)
        flayout.setSpacing(1)
        flayout.addWidget(self.elemGLPane, 1)

        def elementId(symbol):
            return PeriodicTable.getElement(symbol).eltnum

        self.toolButton6.setChecked(True)
        self.elementButtonGroup.setId(self.toolButton6, elementId("C"))
        self.elementButtonGroup.setId(self.toolButton8, elementId("O"))
        self.elementButtonGroup.setId(self.toolButton10, elementId("Ne"))
        self.elementButtonGroup.setId(self.toolButton9, elementId("F"))
        self.elementButtonGroup.setId(self.toolButton13, elementId("Al"))
        self.elementButtonGroup.setId(self.toolButton17, elementId("Cl"))
        self.elementButtonGroup.setId(self.toolButton5, elementId("B"))
        self.elementButtonGroup.setId(self.toolButton10_2, elementId("Ar"))
        self.elementButtonGroup.setId(self.toolButton15, elementId("P"))
        self.elementButtonGroup.setId(self.toolButton16, elementId("S"))
        self.elementButtonGroup.setId(self.toolButton14, elementId("Si"))
        self.elementButtonGroup.setId(self.toolButton33, elementId("As"))
        self.elementButtonGroup.setId(self.toolButton34, elementId("Se"))
        self.elementButtonGroup.setId(self.toolButton35, elementId("Br"))
        self.elementButtonGroup.setId(self.toolButton36, elementId("Kr"))
        self.elementButtonGroup.setId(self.toolButton32, elementId("Ge"))
        self.elementButtonGroup.setId(self.toolButton7, elementId("N"))
        self.elementButtonGroup.setId(self.toolButton2, elementId("He"))
        self.elementButtonGroup.setId(self.toolButton1, elementId("H"))
        self.elementButtonGroup.setId(self.toolButton0, elementId("X"))

        self.connect(self.toolButton6, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton8, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton10, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton9, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton13, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton17, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton5, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton10_2, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton15, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton16, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton14, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton33, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton34, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton35, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton36, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton32, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton7, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton2, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton1, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)
        self.connect(self.toolButton0, SIGNAL("clicked()"),
                     self.updateElemColorDisplay)

        self.connectChangingControls()
        self.saveColorsPB.setWhatsThis(
            """Save the current color settings for elements in a text file.""")
        self.defaultButton.setWhatsThis(
            """Restore current element colors to the default colors.""")
        self.loadColorsPB.setWhatsThis(
            """Load element colors from an external text file.""")
        self.alterButton.setWhatsThis(
            """Set element colors to the alternate color set.""")