Commits

Aleš Erjavec committed bbcc478

- Initial porting to PyQt4

  • Participants
  • Parent commits 2d48265

Comments (0)

Files changed (7)

File widgets/OWBagofWords.py

         OWGUI.radioButtonsInBox(self.controlArea, self, "norm", ["None", "L1 (Sum of elements)", "L2 (Euclidean)"], "Normalization", addSpace = True)
         
         self.attributesCombo = OWGUI.comboBox(self.controlArea, self, "textAttribute", box="Text attribute", callback=self.apply)
+        OWGUI.rubber(self.controlArea)
         self.adjustSize()        
         
     def dataset(self, data):
             k = 0
             for (indx, att) in enumerate(data.domain.attributes):
                 if isinstance(att, orange.StringVariable):
-                    self.attributesCombo.insertItem(att.name)
+                    self.attributesCombo.addItem(att.name)
                     self.textAttribute = indx
                     k += 1
             if not self.textAttribute:

File widgets/OWLetterNgram.py

         
         OWGUI.radioButtonsInBox(self.controlArea, self, "size", box = "Ngram size", btnLabels = ["2", "3", "4"], addSpace = True)
         OWGUI.button(self.controlArea, self, "Apply", self.apply)
-        self.lblFeatureNo = QLabel("\nNo. of features: ", self.controlArea)
+        self.lblFeatureNo = OWGUI.widgetLabel(self.controlArea, "\nNo. of features: ") # QLabel("\nNo. of features: ", self.controlArea)
         self.adjustSize()
         
         box = OWGUI.widgetBox(self.controlArea, "Text attribute", addSpace = True)
         self.textAttributePos = None
         self.attributesCombo = OWGUI.comboBox(box, self, "textAttributePos", callback = self.setTextAttribute)
-
+        OWGUI.rubber(self.controlArea)
         
-
     def dataset(self, data):
         if data:
                 self.textAttributePos = None
                 for i in range(0, len(data.domain.attributes)):
                     if isinstance(data.domain.attributes[i], orange.StringVariable):
-                        self.attributesCombo.insertItem(data.domain.attributes[i].name)
+                        self.attributesCombo.addItem(data.domain.attributes[i].name)
                         self.textAttributePos = i
                 if self.textAttributePos == None:
                     #if no attribute is chosen as text attribute, then take the one named "text"
                 self.textAttribute = name
                 break
 
-
-
-
 if __name__ == "__main__":
     t = orngText.loadFromXML(r'c:\test\msnbc.xml')
     a = QApplication(sys.argv)

File widgets/OWTextDistance.py

         OWGUI.radioButtonsInBox(self.controlArea, self, "distanceType", box = "Matrix type",
             btnLabels = ["Similarity [cos(fi)]", "Distance [1/cos(fi)]"], addSpace = True)
         OWGUI.button(self.controlArea, self, "Apply", self.apply)
+        OWGUI.rubber(self.controlArea)
         self.adjustSize()
 
     def dataset(self, data):

File widgets/OWTextFeatureSelection.py

         #GUI
         #ca=QFrame(self.controlArea)
         #gl=QGridLayout(ca)
-        selectionbox = OWGUI.QHGroupBox('Feature selection', self.controlArea)
+        selectionbox = OWGUI.widgetBox(self.controlArea, "Feature selection", "horizontal") #OWGUI.QHGroupBox('Feature selection', self.controlArea)
 
         OWGUI.listBox(selectionbox, self, 'chosenMeasure', 'measures', box = 'Select measure', callback = self.selectionChanged)
         OWGUI.listBox(selectionbox, self, 'chosenOp', 'operators', box = 'Select operator', callback = self.selectionChanged)
 
-        boxAttrStat = QVGroupBox("Statistics for features", self.controlArea)
-        self.lblFeatNo = QLabel("No. of features: ", boxAttrStat)
-        self.lblMin = QLabel("Min: ", boxAttrStat)
-        self.lblAvg = QLabel("Avg: ", boxAttrStat)
-        self.lblMax = QLabel("Max: ", boxAttrStat)
+        boxAttrStat = OWGUI.widgetBox(self.controlArea, "Statistics for features") #QVGroupBox("Statistics for features", self.controlArea)
+        self.lblFeatNo = OWGUI.widgetLabel(boxAttrStat, "No. of features: ") #QLabel("No. of features: ", boxAttrStat)
+        self.lblMin = OWGUI.widgetLabel(boxAttrStat, "Min: ") #QLabel("Min: ", boxAttrStat)
+        self.lblAvg = OWGUI.widgetLabel(boxAttrStat, "Avg: ") #QLabel("Avg: ", boxAttrStat)
+        self.lblMax = OWGUI.widgetLabel(boxAttrStat, "Max: ") #QLabel("Max: ", boxAttrStat)
 
-        boxDocStat = QVGroupBox("Statistics for documents", self.controlArea)
-        self.lblDocNo = QLabel("No. of documents: ", boxDocStat)
-        self.lblDocAvg = QLabel("Avg: ", boxDocStat)
-        self.lblDocMax = QLabel("Max: ", boxDocStat)
-        self.lblDocMin = QLabel("Min: ", boxDocStat)
+        boxDocStat = OWGUI.widgetBox(self.controlArea, "Statistics for documents") #QVGroupBox("Statistics for documents", self.controlArea)
+        self.lblDocNo = OWGUI.widgetLabel(boxDocStat, "No. of documents: ") #QLabel("No. of documents: ", boxDocStat)
+        self.lblDocAvg = OWGUI.widgetLabel(boxDocStat, "Avg: ") #QLabel("Avg: ", boxDocStat)
+        self.lblDocMax = OWGUI.widgetLabel(boxDocStat, "Max: ") #QLabel("Max: ", boxDocStat)
+        self.lblDocMin = OWGUI.widgetLabel(boxDocStat, "Min: ") #QLabel("Min: ", boxDocStat)
 
-        optionBox = OWGUI.QVGroupBox('', selectionbox)        
+        optionBox = OWGUI.widgetBox(selectionbox, "") #OWGUI.QVGroupBox('', selectionbox)        
 
         self.applyButton = OWGUI.button(optionBox, self, "Apply", self.apply)
         self.applyButton.setDisabled(1)
         OWGUI.checkBox(optionBox, self, "perc", "percentage", callback = self.selectionChanged)
         #OWGUI.spin(optionBox, self, "threshold", 0, 10000, label="Threshold:", callback = None)
         OWGUI.lineEdit(optionBox, self, "threshold", orientation="horizontal", valueType=float, box="Threshold", callback = self.selectionChanged)
-
+        OWGUI.rubber(self.controlArea)
         self.controlArea.adjustSize()
 
 

File widgets/OWTextFile.py

 
 import orange
 import OWGUI
-from qt import *
+
 from OWWidget import *
 
 class OWTextFile(OWWidget):	
         else:
             lastPath = "."
 
-        fn = str(QFileDialog.getOpenFileName(lastPath, "Text files (*.*)", None, "Open Text Files"))
+        fn = str(QFileDialog.getOpenFileName(self, "Open Text Files", lastPath, "Text files (*.*)"))#, None, "Open Text Files"))
         if not fn:
             return
         
 
         self.filecombo.clear()
         for file in self.recentFiles:
-            self.filecombo.insertItem(os.path.split(file)[1])
+            self.filecombo.addItem(os.path.split(file)[1])
         self.filecombo.updateGeometry()
 
         self.error()

File widgets/OWTextPreprocess.py

 
         self.langCombo = OWGUI.comboBox(self.controlArea, self, "selectedLanguage", box="Language", addSpace=True)
         for (i, label) in enumerate(btnLabels):
-            self.langCombo.insertItem(QPixmap(os.path.dirname(__file__) + "/icons/" + self.langDict[i] +".png"), label)
-        self.langCombo.setCurrentItem(self.selectedLanguage)
+            self.langCombo.addItem(QIcon(QPixmap(os.path.dirname(__file__) + "/icons/" + self.langDict[i] +".png")), label)
+#        self.langCombo.setCurrentItem(self.selectedLanguage)
         
         self.attributesCombo = OWGUI.comboBox(self.controlArea, self, "textAttribute", box="Text attribute", callback=self.apply)
-        self.adjustSize()       
+        OWGUI.rubber(self.controlArea)
+        self.adjustSize()  
         
     def dataset(self, data):
         self.closeContext()
             k = 0
             for (indx, att) in enumerate(data.domain.attributes):
                 if isinstance(att, orange.StringVariable):
-                    self.attributesCombo.insertItem(att.name)
+                    self.attributesCombo.addItem(att.name)
                     self.textAttribute = indx
                     k += 1
             if not self.textAttribute:

File widgets/OWWordNgram.py

         self.measureDict = {0: 'FREQ', 1: 'MI', 2: 'DICE', 3: 'CHI', 4: 'LL'}
 
         #GUI        
-        optionBox = QHGroupBox('', self.controlArea)
+        optionBox = OWGUI.widgetBox(self.controlArea, "", "horizontal") #QHGroupBox('', self.controlArea)
         OWGUI.radioButtonsInBox(optionBox, self, "size", box = "No. of words", btnLabels = ["2", "3", "4", "Named entities"], addSpace = True, callback = self.radioChanged)
         self.ambox = OWGUI.radioButtonsInBox(optionBox, self, "measure", box = "Association measure", btnLabels = ["Frequency", "Mutual information", "Dice coefficient", "Chi square", "Log likelihood"], addSpace = True)
         self.ambox.setEnabled(self.size - 3)
-        box = QVGroupBox('', optionBox)
+        box = OWGUI.widgetBox(optionBox, "") #QVGroupBox('', optionBox)
         OWGUI.lineEdit(box, self, "threshold", orientation="horizontal", valueType=float, box="Threshold")
 
         stopbox = OWGUI.widgetBox(box, "Stopwords File")
-        stophbox = OWGUI.widgetBox(stopbox, orientation = 1)
+        stophbox = OWGUI.widgetBox(stopbox, orientation="horizontal") #1)
         self.filecombo = OWGUI.comboBox(stophbox, self, "fileIndex", callback = self.loadFile)
         OWGUI.button(stophbox, self, '...', callback = self.browseFile)
         OWGUI.button(self.controlArea, self, "Apply", self.apply)
-        self.lblFeatureNo = QLabel("\nNo. of features: ", self.controlArea)
+        self.lblFeatureNo = OWGUI.widgetLabel(self.controlArea, "\nNo. of features: ") #QLabel("\nNo. of features: ", self.controlArea)
+        OWGUI.rubber(self.controlArea)
         self.adjustSize()
 
         if self.recentFiles:
         else:
             lastPath = "."
 
-        fn = str(QFileDialog.getOpenFileName(lastPath, "Text files (*.*)", None, "Open Text Files"))
+        fn = str(QFileDialog.getOpenFileName(self, "Open Text Files", lastPath, "Text files (*.*)")) #, None, "Open Text Files"))
         if not fn:
             return
         
 
         self.filecombo.clear()
         for file in self.recentFiles:
-            self.filecombo.insertItem(os.path.split(file)[1])
+            self.filecombo.addItem(os.path.split(file)[1])
         self.filecombo.updateGeometry()
 
         self.error()
             self.send("Example Table", newdata)
         else:
             self.send("Example Table", None)
-
-
             
-
 if __name__ == "__main__":
     t = orngText.loadFromXML(r'c:\test\msnbc.xml')
     a = QApplication(sys.argv)