예제 #1
0
    def __init__(self):

        # create GUI
        QtGui.QMainWindow.__init__(self)
        self.setWindowTitle('Information Aquisition')

        # Set the window dimensions
        self.resize(250,50)
        self.setGeometry(500, 300, 200, 60)
        
        # vertical layout for widgets
        self.vbox = QtGui.QVBoxLayout()
        self.setLayout(self.vbox)
        self.combo = QtGui.QComboBox()

#-----------------------------------------------------------
#Scenario 1 is from newSignalInput.py. A dropdown menu for true or false is created.
        if scenario==1: 
           self.ok=QtGui.QPushButton('OK')
           self.cancel=QtGui.QPushButton('Skip')
           self.combo.addItem('true')
           self.combo.addItem('false')
           self.ok.clicked.connect(lambda: combo_chosen(self,friend,self.combo.currentText(),variable,signal,True))
           self.cancel.clicked.connect(lambda: combo_chosen(self,friend,self.combo.currentText(),variable,signal,False))
           self.labez=QtGui.QLabel('Enter '+variable+' state')
#------------------------------------------------------------        
#Scenario 2 is from delete attributes button at the bottom of radioClickEvent.py
#A dropdown menu of potential attributes is generated, then the selected attribute is removed
        if scenario == 2:
           self.labez=QtGui.QLabel('Select attribute to remove from '+variable)
           self.ok=QtGui.QPushButton('Remove')
           self.cancel=QtGui.QPushButton('Cancel')
           self.ok.clicked.connect(lambda: rematt(signal,variable,self.combo.currentText(),friend,self,True))
           self.cancel.clicked.connect(lambda: rematt(signal,variable,self.combo.currentText(),friend,self,False))

           #Get attributes
           entries=getInfo.getinfo()
           for entry in entries:
               if entry[1]==variable:
                 for item in entry[0][1:]:
                    self.combo.addItem(item)

#--------------------------------------------------------------
#Scenario 3 is to add an attribute. Connected in radioClickEvent.py, at the bottom of the file
#Find current variable attributes, find all possible attributes, display possible attributes that aren't current


#==================================================================================================

        self.hbox=QtGui.QHBoxLayout()
        self.hbox.addWidget(self.ok)
        self.hbox.addWidget(self.cancel)
        
        # Create a combo box and add it to our layout
        self.vbox.addWidget(self.labez)
        self.vbox.addWidget(self.combo)
        self.vbox.addLayout(self.hbox)
예제 #2
0
def delete(signame,self,num):
   entries=getInfo.getinfo(fileName())
   quit_messge='Are you sure you want to delete '+signame
   reply=QtGui.QMessageBox.question(self, 'Warning: altering varDB', quit_messge, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
   if reply == QtGui.QMessageBox.Yes:
      from addSignal import addsignal
      from radioClickEvent import lookingAt
      from radioClickEvent import clearRightInfoHub
      clearRightInfoHub()
      #lookingAt(-1,self)
      addsignal(signame,self,num,{'action':'delete'})
예제 #3
0
def generateButtons(self,filtering,num):
           global rightInfoHub
           #removes buttons from left
           self.left.scrollAreaWidgetContents.clear()
           entries=getinfo(fileName())
           i=0
           while i<len(entries): 

              #displayed buttons must start with filter phrase
              if filtering.upper() in str(entries[i][1]).upper() or filtering=='':
                    self.left.scrollAreaWidgetContents.addItem(entries[i][1])
              i+=1
           if num>=0:
              self.left.scrollAreaWidgetContents.setItemSelected(self.left.scrollAreaWidgetContents.item(num),True)
              try:self.left.scrollAreaWidgetContents.scrollToItem(self.left.scrollAreaWidgetContents.selectedItems()[0])
              except:pass
예제 #4
0
def rem(num,self):
      from generateButtons import generateButtons
      varDB=open('varDB.txt','r')
      lines = [line.strip() for line in varDB]
      varDB.close()
      entries=getinfo()
      varDB2=open('varDB.txt','w')
      for i in reversed(range(self.left.verticalLayoutScroll.count())): #Remove buttons
         self.left.verticalLayoutScroll.itemAt(i).widget().setParent(None)
      i=0
      while i < len(lines):
         if i<num:
            varDB2.write(lines[i]+"\n")
         if i>num: #Prevent data shift
            varDB2.write(lines[i]+"\n")
         i+=1
      varDB2.close()
      generateButtons(self,self.searchText.text(),0)
      print "Remove succesful: ",lines[num]
예제 #5
0
def lookingAt(self):
   global previousnum
   global bools
   global reftex
   global headers

   entries=getInfo.getinfo(fileName())
   dictionary=getInfo.getDictionary(fileName())

   #Stiffle error message when no signal is selected
   try:text= str(self.left.scrollAreaWidgetContents.selectedItems()[0].text())
   except:return

   #get current selection's position in vdb
   i=0
   while i<len(entries):
      if entries[i][1]==text:
         num=i
      i+=1

   #Checks for changes to text boxes with bool
   #num =-1 is a flag that a variable is being deleted, and not to save changes made
   if bools==True and num!=-1:
      bools=False
      saveChanges(self,headers,num)
      return

   #If num is set as flag -1, reset it to 0
   #This indicates not to save changes, so bool is set to False
   if num==-1:
      bools=False
      num=0

   #Get attributes
   #headers=entries[num][0]
   headers=getInfo.getDictionary(fileName())

   #CLEAR RIGHT SIDE INFORMATION HUB
   clearRightInfoHub()

   #Create framework for upright side information hub
   makeRightInfoHub(self,headers)

   #Get signal's attribute info
   i=1
   signals=[]
   while i<len(entries[num][0])+1:
     
     signals.append(entries[num][i])
     i+=1
   i=0

   #write attribute info to screen
   while i<len(entries[num][0]):
      if entries[num][0][i] in headers:
        labler(entries[num][0][i],signals[i],self,i)
        headers.remove(entries[num][0][i])
      else:
        labler(dictionary[0],'',self,i)
      i+=1

   #Disconnect buttons
   try: 
      self.deleteButton.clicked.disconnect()
   except Exception: pass
   try: 
      self.saveButton.clicked.disconnect()
   except Exception: pass


   #Connect buttons
   self.deleteButton.clicked.connect(lambda: delete(str(rightInfoHub['textBoxes']['name'].text()),self,num)) 
   self.saveButton.clicked.connect(lambda: saveChanges(self,headers,num))

   clearRightInfoHub()
   previousnum=num
   bools=False