Ejemplo n.º 1
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.main = parent

        # Widgets
        self.pages_widget = QStackedWidget()
        self.contents_widget = QListWidget()
        self.button_reset = QPushButton(_('Reset to defaults'))

        bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply |
                                QDialogButtonBox.Cancel)
        self.apply_btn = bbox.button(QDialogButtonBox.Apply)

        # Widgets setup
        # Destroying the C++ object right after closing the dialog box,
        # otherwise it may be garbage-collected in another QThread
        # (e.g. the editor's analysis thread in Spyder), thus leading to
        # a segmentation fault on UNIX or an application crash on Windows
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle(_('Preferences'))
        self.setWindowIcon(ima.icon('configure'))
        self.contents_widget.setMovement(QListView.Static)
        self.contents_widget.setSpacing(1)
        self.contents_widget.setCurrentRow(0)

        # Layout
        hsplitter = QSplitter()
        hsplitter.addWidget(self.contents_widget)
        hsplitter.addWidget(self.pages_widget)

        btnlayout = QHBoxLayout()
        btnlayout.addWidget(self.button_reset)
        btnlayout.addStretch(1)
        btnlayout.addWidget(bbox)

        vlayout = QVBoxLayout()
        vlayout.addWidget(hsplitter)
        vlayout.addLayout(btnlayout)

        self.setLayout(vlayout)

        # Signals and slots
        self.button_reset.clicked.connect(self.main.reset_spyder)
        self.pages_widget.currentChanged.connect(self.current_page_changed)
        self.contents_widget.currentRowChanged.connect(
                                             self.pages_widget.setCurrentIndex)
        bbox.accepted.connect(self.accept)
        bbox.rejected.connect(self.reject)
        bbox.clicked.connect(self.button_clicked)

        # Ensures that the config is present on spyder first run
        CONF.set('main', 'interface_language', load_lang_conf())
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        
        # Destroying the C++ object right after closing the dialog box,
        # otherwise it may be garbage-collected in another QThread
        # (e.g. the editor's analysis thread in Spyder), thus leading to
        # a segmentation fault on UNIX or an application crash on Windows
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.contents_widget = QListWidget()
        self.contents_widget.setMovement(QListView.Static)
        self.contents_widget.setSpacing(1)

        bbox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Apply
                                |QDialogButtonBox.Cancel)
        self.apply_btn = bbox.button(QDialogButtonBox.Apply)
        self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
        self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"),
                     self.button_clicked)

        self.pages_widget = QStackedWidget()
        self.connect(self.pages_widget, SIGNAL("currentChanged(int)"),
                     self.current_page_changed)

        self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"),
                     self.pages_widget.setCurrentIndex)
        self.contents_widget.setCurrentRow(0)

        hsplitter = QSplitter()
        hsplitter.addWidget(self.contents_widget)
        hsplitter.addWidget(self.pages_widget)

        btnlayout = QHBoxLayout()
        btnlayout.addStretch(1)
        btnlayout.addWidget(bbox)

        vlayout = QVBoxLayout()
        vlayout.addWidget(hsplitter)
        vlayout.addLayout(btnlayout)

        self.setLayout(vlayout)

        self.setWindowTitle(_("Preferences"))
        self.setWindowIcon(get_icon("configure.png"))
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.main = parent

        # Widgets
        self.pages_widget = QStackedWidget()
        self.contents_widget = QListWidget()
        self.button_reset = QPushButton(_('Reset to defaults'))

        bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply
                                | QDialogButtonBox.Cancel)
        self.apply_btn = bbox.button(QDialogButtonBox.Apply)

        # Widgets setup
        # Destroying the C++ object right after closing the dialog box,
        # otherwise it may be garbage-collected in another QThread
        # (e.g. the editor's analysis thread in Spyder), thus leading to
        # a segmentation fault on UNIX or an application crash on Windows
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle(_('Preferences'))
        self.setWindowIcon(ima.icon('configure'))
        self.contents_widget.setMovement(QListView.Static)
        self.contents_widget.setSpacing(1)
        self.contents_widget.setCurrentRow(0)

        # Layout
        hsplitter = QSplitter()
        hsplitter.addWidget(self.contents_widget)
        hsplitter.addWidget(self.pages_widget)

        btnlayout = QHBoxLayout()
        btnlayout.addWidget(self.button_reset)
        btnlayout.addStretch(1)
        btnlayout.addWidget(bbox)

        vlayout = QVBoxLayout()
        vlayout.addWidget(hsplitter)
        vlayout.addLayout(btnlayout)

        self.setLayout(vlayout)

        # Signals and slots
        self.button_reset.clicked.connect(self.main.reset_spyder)
        self.pages_widget.currentChanged.connect(self.current_page_changed)
        self.contents_widget.currentRowChanged.connect(
            self.pages_widget.setCurrentIndex)
        bbox.accepted.connect(self.accept)
        bbox.rejected.connect(self.reject)
        bbox.clicked.connect(self.button_clicked)

        # Ensures that the config is present on spyder first run
        CONF.set('main', 'interface_language', load_lang_conf())
Ejemplo n.º 4
0
 def get_shell_widget(self):
     if self.stand_alone is None:
         return self.shell
     else:
         self.namespacebrowser = NamespaceBrowser(self)
         settings = self.stand_alone
         self.namespacebrowser.set_shellwidget(self)
         self.namespacebrowser.setup(**settings)
         self.namespacebrowser.sig_collapse.connect(
             lambda: self.toggle_globals_explorer(False))
         # Shell splitter
         self.splitter = splitter = QSplitter(Qt.Vertical, self)
         self.splitter.splitterMoved.connect(self.splitter_moved)
         splitter.addWidget(self.shell)
         splitter.setCollapsible(0, False)
         splitter.addWidget(self.namespacebrowser)
         splitter.setStretchFactor(0, 1)
         splitter.setStretchFactor(1, 0)
         splitter.setHandleWidth(5)
         splitter.setSizes([2, 1])
         return splitter
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        # Destroying the C++ object right after closing the dialog box,
        # otherwise it may be garbage-collected in another QThread
        # (e.g. the editor's analysis thread in Spyder), thus leading to
        # a segmentation fault on UNIX or an application crash on Windows
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.contents_widget = QListWidget()
        self.contents_widget.setMovement(QListView.Static)
        self.contents_widget.setSpacing(1)

        bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply
                                | QDialogButtonBox.Cancel)
        self.apply_btn = bbox.button(QDialogButtonBox.Apply)
        self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
        self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"),
                     self.button_clicked)

        self.pages_widget = QStackedWidget()
        self.connect(self.pages_widget, SIGNAL("currentChanged(int)"),
                     self.current_page_changed)

        self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"),
                     self.pages_widget.setCurrentIndex)
        self.contents_widget.setCurrentRow(0)

        hsplitter = QSplitter()
        hsplitter.addWidget(self.contents_widget)
        hsplitter.addWidget(self.pages_widget)

        btnlayout = QHBoxLayout()
        btnlayout.addStretch(1)
        btnlayout.addWidget(bbox)

        vlayout = QVBoxLayout()
        vlayout.addWidget(hsplitter)
        vlayout.addLayout(btnlayout)

        self.setLayout(vlayout)

        self.setWindowTitle(_("Preferences"))
        self.setWindowIcon(get_icon("configure.png"))
Ejemplo n.º 6
0
    def __init__(self, parent, max_entries=100):
        """ Creates a very basic window with some text """
        """
        RATE_LAW_MESSAGE = \
            "The Plugins for Spyder consists out of three main classes: \n\n" \
            "1. HelloWorld\n\n" \
            "\tThe HelloWorld class inherits all its methods from\n" \
            "\tSpyderPluginMixin and the HelloWorldWidget and performs all\n" \
            "\tthe processing required by the GU. \n\n" \
            "2. HelloWorldConfigPage\n\n" \
            "\tThe HelloWorldConfig class inherits all its methods from\n" \
            "\tPluginConfigPage to create a configuration page that can be\n" \
            "\tfound under Tools -> Preferences\n\n" \
            "3. HelloWorldWidget\n\n" \
            "\tThe HelloWorldWidget class inherits all its methods from\n" \
            "\tQWidget to create the actual plugin GUI interface that \n" \
            "\tdisplays this message on screen\n\n"
        """
        #Testing access editor on plugin initialization
        
        
        RATE_LAW_MESSAGE = ""
        displaynamelist = []
        #displaylist = []
        infixlist = []
        desclist = []
        parameterstringlist = []
        xmldoc = minidom.parse('\\.spyder2\\ratelaw2_0_3.xml')
        #xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml')
        
        lawlistxml = xmldoc.getElementsByTagName('law')
        #i is the number of laws currently in the xml file
        i = 0
        for s in lawlistxml:
            #RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n"
            RATE_LAW_MESSAGE += s.getAttribute('display') + "\n"
            #displaynamelist[i] = s.getAttribute('displayName')
            #displaylist[i] = s.getAttribute('display')
            displaynamelist.append(s.getAttribute('displayName'))
            #displaylist.append(s.getAttribute('display'))
            infixlist.append(s.getAttribute('infixExpression'))
            desclist.append(s.getAttribute('description'))
            parameterlist = s.getElementsByTagName('listOfParameters')[0]
            #for p in parameterlist    
            parameters = parameterlist.getElementsByTagName('parameter')
            parameterstring = ""
            for param in parameters:
                parametername = param.attributes['name'].value
                parameterdesc = param.attributes['description'].value
                parameterstring = parameterstring + '\t' + parametername + ":" + '\t' + "  " + parameterdesc + "\n"
                #print('\t' + parametername + ":" + '\t' + parameterdesc)
            parameterstringlist.append(parameterstring)    
            i = i + 1
            
        
        QWidget.__init__(self, parent)
        
        self.setWindowTitle("Rate Law Library")
        
        self.output = None
        self.error_output = None
        
        self._last_wdir = None
        self._last_args = None
        self._last_pythonpath = None
        
        self.textlabel = QLabel(RATE_LAW_MESSAGE)        

        self.lawlist = QListWidget()
        self.lawpage = QStackedWidget()
        #Adding displayName items to lawlist
        for j in range(i):
            item = QListWidgetItem(displaynamelist[j])
            self.lawlist.addItem(item)
            self.lawdetailpage = QWidget()
            # Page layout will become its own function
            setup_group = QGroupBox(displaynamelist[j])
            infixmod = infixlist[j].replace("___"," ")
            setup_label = QLabel(infixmod)
            setup_label.setWordWrap(True)
            
            desc_group = QGroupBox("Description")
            desc_label = QLabel(desclist[j])
            desc_label.setWordWrap(True)
            param_label = QLabel(parameterstringlist[j])
            param_label.setWordWrap(True)

        # Warning: do not try to regroup the following QLabel contents with 
        # widgets above -- this string was isolated here in a single QLabel
        # on purpose: to fix Issue 863
            setup_layout = QVBoxLayout()
            setup_layout.addWidget(setup_label)
            setup_group.setLayout(setup_layout)
            
            desc_layout = QVBoxLayout()
            desc_layout.addWidget(desc_label)
            desc_layout.addWidget(param_label)
            desc_group.setLayout(desc_layout)

            vlayout = QVBoxLayout()
            vlayout.addWidget(setup_group)
            vlayout.addWidget(desc_group)
            vlayout.addStretch(1)
            self.lawdetailpage.setLayout(vlayout)
            
            self.lawpage.addWidget(self.lawdetailpage)
        
        #self.connect(self.lawlist, SIGNAL(self.lawlist.currentRowChanged(int)),self.lawpage,SLOT(self.lawpage.setCurrentIndex(int)))
        self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex)            
        '''
        self.lawpage = QWidget()
        '''
        self.lawlist.setCurrentRow(0)
        
        hsplitter = QSplitter()
        hsplitter.addWidget(self.lawlist)
        
        
        
        
        hlayout1 = QHBoxLayout()
        hlayout1.addWidget(self.textlabel)
        hlayout1.addStretch()
        self.lawpage.setLayout(hlayout1)
        
        hsplitter.addWidget(self.lawpage)
        
        layout = QVBoxLayout()
        layout.addWidget(hsplitter)
        self.setLayout(layout)
Ejemplo n.º 7
0
    def __init__(self, parent, max_entries=100):
        """ Creates a very basic window with some text """
        """
        RATE_LAW_MESSAGE = \
            "The Plugins for Spyder consists out of three main classes: \n\n" \
            "1. HelloWorld\n\n" \
            "\tThe HelloWorld class inherits all its methods from\n" \
            "\tSpyderPluginMixin and the HelloWorldWidget and performs all\n" \
            "\tthe processing required by the GU. \n\n" \
            "2. HelloWorldConfigPage\n\n" \
            "\tThe HelloWorldConfig class inherits all its methods from\n" \
            "\tPluginConfigPage to create a configuration page that can be\n" \
            "\tfound under Tools -> Preferences\n\n" \
            "3. HelloWorldWidget\n\n" \
            "\tThe HelloWorldWidget class inherits all its methods from\n" \
            "\tQWidget to create the actual plugin GUI interface that \n" \
            "\tdisplays this message on screen\n\n"
        """
        #Testing access editor on plugin initialization
        
        
        RATE_LAW_MESSAGE = ""
        displaynamelist = []
        #displaylist = []
        infixlist = []
        desclist = []
        parameterstringlist = []
        xmldoc = minidom.parse('\\.spyder2\\ratelaw2_0_3.xml')
        #xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml')
        
        lawlistxml = xmldoc.getElementsByTagName('law')
        #i is the number of laws currently in the xml file
        i = 0
        
        """
        Parsing xml: Acquiring rate law name, description, and list of parameter information
        """
        for s in lawlistxml:
            #RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n"
            RATE_LAW_MESSAGE += s.getAttribute('display') + "\n"
            #displaynamelist[i] = s.getAttribute('displayName')
            #displaylist[i] = s.getAttribute('display')
            displaynamelist.append(s.getAttribute('displayName'))
            #displaylist.append(s.getAttribute('display'))
            infixlist.append(s.getAttribute('infixExpression'))
            desclist.append(s.getAttribute('description'))
            parameterlist = s.getElementsByTagName('listOfParameters')[0]
            #for p in parameterlist    
            parameters = parameterlist.getElementsByTagName('parameter')
            parameterstring = ""
            for param in parameters:
                parametername = param.attributes['name'].value
                parameterdesc = param.attributes['description'].value
                parameterstring = parameterstring + '\t' + parametername + ":" + '\t' + "  " + parameterdesc + "\n"
                """Creates "description" string"""
                #print('\t' + parametername + ":" + '\t' + parameterdesc)
            parameterstringlist.append(parameterstring)    
            i = i + 1
            
        
        QWidget.__init__(self, parent)
        
        self.setWindowTitle("Rate Law Library")
        
        self.output = None
        self.error_output = None
        
        self._last_wdir = None
        self._last_args = None
        self._last_pythonpath = None
        
        self.textlabel = QLabel(RATE_LAW_MESSAGE)        

        self.lawlist = QListWidget()
        self.lawpage = QStackedWidget()
        #Adding displayName items to lawlist
        for j in range(i):
            item = QListWidgetItem(displaynamelist[j])      """Creates list entry for each rate law"""
            self.lawlist.addItem(item)                      """Adds rate law to list"""
            self.lawdetailpage = QWidget()                  """Creates page for each rate law"""
            # Page layout will become its own function
            setup_group = QGroupBox(displaynamelist[j])     """Creates box with rate law name as title"""
            infixmod = infixlist[j].replace("___"," ")      
            setup_label = QLabel(infixmod)
            setup_label.setWordWrap(True)                   """types rate law expression, removing underscores"""
            
            desc_group = QGroupBox("Description")           """creates box for description"""
            desc_label = QLabel(desclist[j])
            desc_label.setWordWrap(True)
            param_label = QLabel(parameterstringlist[j])
            param_label.setWordWrap(True)

        # Warning: do not try to regroup the following QLabel contents with 
        # widgets above -- this string was isolated here in a single QLabel
        # on purpose: to fix Issue 863
            setup_layout = QVBoxLayout()
            setup_layout.addWidget(setup_label)
            setup_group.setLayout(setup_layout)
            
            desc_layout = QVBoxLayout()
            desc_layout.addWidget(desc_label)
            desc_layout.addWidget(param_label)
            desc_group.setLayout(desc_layout)

            vlayout = QVBoxLayout()
            vlayout.addWidget(setup_group)
            vlayout.addWidget(desc_group)
            vlayout.addStretch(1)
            self.lawdetailpage.setLayout(vlayout)
            
            self.lawpage.addWidget(self.lawdetailpage)      """Formats the page shown when a rate law is selected"""
        
        #self.connect(self.lawlist, SIGNAL(self.lawlist.currentRowChanged(int)),self.lawpage,SLOT(self.lawpage.setCurrentIndex(int)))
        self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex)     """When a rate law in the list is clicked, its corresponding page is shown"""       
        '''
        self.lawpage = QWidget()
        '''
        self.lawlist.setCurrentRow(0)
        
        hsplitter = QSplitter()
        hsplitter.addWidget(self.lawlist)                   "Adds list to left side of window"
        
        
        
        
        hlayout1 = QHBoxLayout()
        hlayout1.addWidget(self.textlabel)
        hlayout1.addStretch()
        self.lawpage.setLayout(hlayout1)
        
        hsplitter.addWidget(self.lawpage)                   """Adds law page to left side of window"""
        
        layout = QVBoxLayout()
        layout.addWidget(hsplitter)
        self.setLayout(layout)
Ejemplo n.º 8
0
 def __init__(self, parent, max_entries=100):
     
     "Initialize Various list objects before assignment"
     displaylist = []
     displaynamelist = []
     infixmod = []
     infixlist = []
     desclist = []
     
     parameternamelist = []
     parameterdesclist = []
     parameterstringlist = []
     paramcountlist = []
     
     
     
     buttonlist  = []
     xmldoc = minidom.parse('C:\\Users\\Jayit\\.spyder2\\ratelaw2_0_3.xml')
     #xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml')
     
     lawlistxml = xmldoc.getElementsByTagName('law')
     
     o = 0
     for s in lawlistxml:
         o = o + 1
     
     parameternamelistlist = [0 for x in range(o)]
     parameterdesclistlist = [0 for x in range(o)]
     
     """i is the number of laws currently in the xml file"""
     i = 0
     
     """
     Parsing xml: Acquiring rate law name, description, and list of parameter information
     """
     for s in lawlistxml:
         #RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n"
         """Gets Latec Expression"""
         displaylist.append(s.getAttribute('display'))
         
         """Gets Rate-Law Name"""
         displaynamelist.append(s.getAttribute('displayName'))
         
         """"Gets Raw Rate-Law expression"""
         infixlist.append(s.getAttribute('infixExpression'))
         
         """Gets description statement"""
         desclist.append(s.getAttribute('description'))
         
         """Gets listOfParameters Object"""
         parameterlist = s.getElementsByTagName('listOfParameters')[0]
         
         """Gets a list of parameters within ListOfParameters object"""    
         parameters = parameterlist.getElementsByTagName('parameter')
         
         for param in parameters:
             parameternamelist.append(param.attributes['name'].value)
             #print(param.attributes['name'].value)
             parameterdesclist.append(param.attributes['description'].value)  
         
         parameternamelistlist[i] = parameternamelist
         #print("break")
         parameterdesclistlist[i] = parameterdesclist
         
         parameternamelist = []
         parameterdesclist = []
         i = i + 1
     
     SLElistlist = [ 0 for x in range(i)]
     PLElistlist = [ 0 for x in range(i)]
     ILElistlist = [ 0 for x in range(i)]
     paramLElistlist = [ 0 for x in range(i)]
     numlistlist = [ 0 for x in range(i)]
     
     QWidget.__init__(self, parent)
     
     self.setWindowTitle("Rate Law Library")
     
     self.output = None
     self.error_output = None
     self._last_wdir = None
     self._last_args = None
     self._last_pythonpath = None
     
     #self.textlabel = QLabel(RATE_LAW_MESSAGE)
     
     self.lawlist = QListWidget()
     self.lawpage = QStackedWidget()
     index = 0
     for j in range(i):            
         item = QListWidgetItem(displaynamelist[j])
         self.lawlist.addItem(item)
         self.lawdetailpage = QWidget()
         setup_group = QGroupBox(displaynamelist[j])
         infixmod.append(infixlist[j].replace("___"," "))      
         setup_label = QLabel(infixmod[j])
         setup_label.setWordWrap(True)
         
         desc_group = QGroupBox("Description")
         desc_label = QLabel(desclist[j])
         desc_label.setWordWrap(True)
                     
         param_label = QGridLayout()
         nm = QLabel("Name:")
         des = QLabel("Description:")
         repl = QLabel("Replace with:")
         param_label.addWidget(nm,0,0)
         param_label.addWidget(des,0,1)
         param_label.addWidget(repl,0,2)
         """g is the total number of alterable values"""
         g = 0
         """t is the total number of alterable non-parameters"""
         t = 1
         
         snum = 0
         pnum = 0
         inum = 0
         
         """range of N is the max number of possible substrates OR products"""
         N = 5
         for n in range(N):
             nl = n+1
             if (infixmod[j].find('S%s' % nl) > -1):
                 z = QLabel('S%s is present' % nl)
                 param_label.addWidget(z,t,0)
                 snum = snum + 1
                 t = t + 1
         
         for n in range(N):
             nl = n+1    
             if (infixmod[j].find('P%s' % nl) > -1):
                 z = QLabel('P%s is present' % nl)
                 param_label.addWidget(z,t,0)
                 pnum = pnum + 1
                 t = t + 1
                 
         for n in range(N):
             nl = n+1
             if (infixmod[j].find('I%s' % nl) > -1):
                 z = QLabel('I%s is present' % nl)
                 param_label.addWidget(z,t,0)
                 inum = inum + 1
                 t = t + 1
         
         """Initialize lists of list of parameter lineedit"""    
         length = len(parameternamelistlist[j])
         for b in range(length):
             p = QLabel("%s :" % parameternamelistlist[j][b])
             param_label.addWidget(p,b+t,0)
             d = QLabel("'%s'" % parameterdesclistlist[j][b])
             param_label.addWidget(d,b+t,1)
         
         g = t + length
         
         Slineeditlist = [0 for x in range(snum)]
         Plineeditlist = [0 for x in range(pnum)]
         Ilineeditlist = [0 for x in range(inum)]
         paramlineeditlist = [0 for x in range(length)]
         
         editcount = 1
         
         """Place lineedit widgets for parameters"""
         for s in range(snum):
             Slineeditlist[s] = QLineEdit()
             param_label.addWidget(Slineeditlist[s],editcount,2)
             editcount = editcount + 1
         
         SLElistlist[j] = Slineeditlist
         
         for s in range(pnum):
             Plineeditlist[s] = QLineEdit()
             param_label.addWidget(Plineeditlist[s],editcount,2)
             editcount = editcount + 1
         
         PLElistlist[j] = Plineeditlist
         
         for s in range(inum):
             Ilineeditlist[s] = QLineEdit()
             param_label.addWidget(Ilineeditlist[s],editcount,2)
             editcount = editcount + 1
            
         ILElistlist[j] = Ilineeditlist   
         
         for s in range(length):
             paramlineeditlist[s] = QLineEdit()
             param_label.addWidget(paramlineeditlist[s],editcount,2)
             editcount = editcount + 1
         
         paramLElistlist[j] = paramlineeditlist
         
         """Necessary lists for editable parameters. Housekeeping essentially."""
         stuff = paramlineeditlist[0].text()            
         numlistlist[j] = [snum, pnum, inum, length]
         charlist = ["S","P","I"]
         
         
         
         buttonlist.append(QPushButton(self))
         buttonlist[j].setText("Insert Rate Law: %s" % displaynamelist[j])
         
         
     # Warning: do not try to regroup the following QLabel contents with 
     # widgets above -- this string was isolated here in a single QLabel
     # on purpose: to fix Issue 863
         """Page formatting"""
         setup_layout = QVBoxLayout()
         setup_layout.addWidget(setup_label)
         setup_group.setLayout(setup_layout)
        
         desc_group.setLayout(param_label)
         
         vlayout = QVBoxLayout()
         vlayout.addWidget(setup_group)
         vlayout.addWidget(desc_group)
         vlayout.addWidget(buttonlist[j])
         vlayout.addStretch(1)
         self.lawdetailpage.setLayout(vlayout)
         self.lawpage.addWidget(self.lawdetailpage)
     
     """Set up button functionality"""
     for k in range(47):
         buttonlist[k].clicked.connect(pressbutton(self, infixmod[k], SLElistlist[k], PLElistlist[k],ILElistlist[k], paramLElistlist[k], parameternamelistlist[k], numlistlist[k], charlist,k))
         
     self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex)
     self.lawlist.setCurrentRow(0)
     
     
     """Set up high-level widget formatting."""
     hsplitter = QSplitter()
     hsplitter.addWidget(self.lawlist)
     hsplitter.addWidget(self.lawpage)
     
     layout = QVBoxLayout()
     layout.addWidget(hsplitter)
     self.setLayout(layout)
Ejemplo n.º 9
0
    def __init__(self, parent, max_entries=100):

        "Initialize Various list objects before assignment"
        displaylist = []
        displaynamelist = []
        infixmod = []
        infixlist = []
        desclist = []

        parameternamelist = []
        parameterdesclist = []
        parameterstringlist = []
        paramcountlist = []

        buttonlist = []
        xmldoc = minidom.parse('C:\\Users\\Jayit\\.spyder2\\ratelaw2_0_3.xml')
        #xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml')

        lawlistxml = xmldoc.getElementsByTagName('law')

        o = 0
        for s in lawlistxml:
            o = o + 1

        parameternamelistlist = [0 for x in range(o)]
        parameterdesclistlist = [0 for x in range(o)]
        """i is the number of laws currently in the xml file"""
        i = 0
        """
        Parsing xml: Acquiring rate law name, description, and list of parameter information
        """
        for s in lawlistxml:
            #RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n"
            """Gets Latec Expression"""
            displaylist.append(s.getAttribute('display'))
            """Gets Rate-Law Name"""
            displaynamelist.append(s.getAttribute('displayName'))
            """"Gets Raw Rate-Law expression"""
            infixlist.append(s.getAttribute('infixExpression'))
            """Gets description statement"""
            desclist.append(s.getAttribute('description'))
            """Gets listOfParameters Object"""
            parameterlist = s.getElementsByTagName('listOfParameters')[0]
            """Gets a list of parameters within ListOfParameters object"""
            parameters = parameterlist.getElementsByTagName('parameter')

            for param in parameters:
                parameternamelist.append(param.attributes['name'].value)
                #print(param.attributes['name'].value)
                parameterdesclist.append(param.attributes['description'].value)

            parameternamelistlist[i] = parameternamelist
            #print("break")
            parameterdesclistlist[i] = parameterdesclist

            parameternamelist = []
            parameterdesclist = []
            i = i + 1

        SLElistlist = [0 for x in range(i)]
        PLElistlist = [0 for x in range(i)]
        ILElistlist = [0 for x in range(i)]
        paramLElistlist = [0 for x in range(i)]
        numlistlist = [0 for x in range(i)]

        QWidget.__init__(self, parent)

        self.setWindowTitle("Rate Law Library")

        self.output = None
        self.error_output = None
        self._last_wdir = None
        self._last_args = None
        self._last_pythonpath = None

        #self.textlabel = QLabel(RATE_LAW_MESSAGE)

        self.lawlist = QListWidget()
        self.lawpage = QStackedWidget()
        index = 0
        for j in range(i):
            item = QListWidgetItem(displaynamelist[j])
            self.lawlist.addItem(item)
            self.lawdetailpage = QWidget()
            setup_group = QGroupBox(displaynamelist[j])
            infixmod.append(infixlist[j].replace("___", " "))
            setup_label = QLabel(infixmod[j])
            setup_label.setWordWrap(True)

            desc_group = QGroupBox("Description")
            desc_label = QLabel(desclist[j])
            desc_label.setWordWrap(True)

            param_label = QGridLayout()
            nm = QLabel("Name:")
            des = QLabel("Description:")
            repl = QLabel("Replace with:")
            param_label.addWidget(nm, 0, 0)
            param_label.addWidget(des, 0, 1)
            param_label.addWidget(repl, 0, 2)
            """g is the total number of alterable values"""
            g = 0
            """t is the total number of alterable non-parameters"""
            t = 1

            snum = 0
            pnum = 0
            inum = 0
            """range of N is the max number of possible substrates OR products"""
            N = 5
            for n in range(N):
                nl = n + 1
                if (infixmod[j].find('S%s' % nl) > -1):
                    z = QLabel('S%s is present' % nl)
                    param_label.addWidget(z, t, 0)
                    snum = snum + 1
                    t = t + 1

            for n in range(N):
                nl = n + 1
                if (infixmod[j].find('P%s' % nl) > -1):
                    z = QLabel('P%s is present' % nl)
                    param_label.addWidget(z, t, 0)
                    pnum = pnum + 1
                    t = t + 1

            for n in range(N):
                nl = n + 1
                if (infixmod[j].find('I%s' % nl) > -1):
                    z = QLabel('I%s is present' % nl)
                    param_label.addWidget(z, t, 0)
                    inum = inum + 1
                    t = t + 1
            """Initialize lists of list of parameter lineedit"""
            length = len(parameternamelistlist[j])
            for b in range(length):
                p = QLabel("%s :" % parameternamelistlist[j][b])
                param_label.addWidget(p, b + t, 0)
                d = QLabel("'%s'" % parameterdesclistlist[j][b])
                param_label.addWidget(d, b + t, 1)

            g = t + length

            Slineeditlist = [0 for x in range(snum)]
            Plineeditlist = [0 for x in range(pnum)]
            Ilineeditlist = [0 for x in range(inum)]
            paramlineeditlist = [0 for x in range(length)]

            editcount = 1
            """Place lineedit widgets for parameters"""
            for s in range(snum):
                Slineeditlist[s] = QLineEdit()
                param_label.addWidget(Slineeditlist[s], editcount, 2)
                editcount = editcount + 1

            SLElistlist[j] = Slineeditlist

            for s in range(pnum):
                Plineeditlist[s] = QLineEdit()
                param_label.addWidget(Plineeditlist[s], editcount, 2)
                editcount = editcount + 1

            PLElistlist[j] = Plineeditlist

            for s in range(inum):
                Ilineeditlist[s] = QLineEdit()
                param_label.addWidget(Ilineeditlist[s], editcount, 2)
                editcount = editcount + 1

            ILElistlist[j] = Ilineeditlist

            for s in range(length):
                paramlineeditlist[s] = QLineEdit()
                param_label.addWidget(paramlineeditlist[s], editcount, 2)
                editcount = editcount + 1

            paramLElistlist[j] = paramlineeditlist
            """Necessary lists for editable parameters. Housekeeping essentially."""
            stuff = paramlineeditlist[0].text()
            numlistlist[j] = [snum, pnum, inum, length]
            charlist = ["S", "P", "I"]

            buttonlist.append(QPushButton(self))
            buttonlist[j].setText("Insert Rate Law: %s" % displaynamelist[j])

            # Warning: do not try to regroup the following QLabel contents with
            # widgets above -- this string was isolated here in a single QLabel
            # on purpose: to fix Issue 863
            """Page formatting"""
            setup_layout = QVBoxLayout()
            setup_layout.addWidget(setup_label)
            setup_group.setLayout(setup_layout)

            desc_group.setLayout(param_label)

            vlayout = QVBoxLayout()
            vlayout.addWidget(setup_group)
            vlayout.addWidget(desc_group)
            vlayout.addWidget(buttonlist[j])
            vlayout.addStretch(1)
            self.lawdetailpage.setLayout(vlayout)
            self.lawpage.addWidget(self.lawdetailpage)
        """Set up button functionality"""
        for k in range(47):
            buttonlist[k].clicked.connect(
                pressbutton(self, infixmod[k], SLElistlist[k], PLElistlist[k],
                            ILElistlist[k], paramLElistlist[k],
                            parameternamelistlist[k], numlistlist[k], charlist,
                            k))

        self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex)
        self.lawlist.setCurrentRow(0)
        """Set up high-level widget formatting."""
        hsplitter = QSplitter()
        hsplitter.addWidget(self.lawlist)
        hsplitter.addWidget(self.lawpage)

        layout = QVBoxLayout()
        layout.addWidget(hsplitter)
        self.setLayout(layout)