Commits

iorodeo  committed ab79e9c

Added significant digits options.

  • Participants
  • Parent commits 1de2ff8

Comments (0)

Files changed (12)

File python/Colorimeter/colorimeter/colorimeter_serial.py

         cmd = '[{0}]'.format(CMD_GET_MEASUREMENT)
         rsp = self.sendCmd(cmd)
         freq = tuple(rsp[1:5])
-        trans = tuple(rsp[5:9])
-        absorb = tuple(rsp[9:])
-        return freq, trans, absorb
+        tran = tuple(rsp[5:9])
+        abso = tuple(rsp[9:])
+        return freq, tran, abso
 
     def getMeasurementRed(self):
         """
         """
         cmd = '[{0}]'.format(CMD_GET_MEASUREMENT_RED)
         rsp = self.sendCmd(cmd)
-        freq, trans, absorb = rsp[1:4]
-        return freq, trans, absorb
+        freq, tran, abso = rsp[1:4]
+        return freq, tran, abso
 
     def getMeasurementGreen(self):
         """
         """
         cmd = '[{0}]'.format(CMD_GET_MEASUREMENT_GREEN)
         rsp = self.sendCmd(cmd)
-        freq, trans, absorb = rsp[1:4]
-        return freq, trans, absorb
+        freq, tran, abso = rsp[1:4]
+        return freq, tran, abso
 
     def getMeasurementBlue(self):
         """
         """
         cmd = '[{0}]'.format(CMD_GET_MEASUREMENT_BLUE)
         rsp = self.sendCmd(cmd)
-        freq, trans, absorb = rsp[1:4]
-        return freq, trans, absorb
+        freq, tran, abso = rsp[1:4]
+        return freq, tran, abso
 
     def getMeasurementWhite(self):
         """
         """
         cmd = '[{0}]'.format(CMD_GET_MEASUREMENT_WHITE)
         rsp = self.sendCmd(cmd)
-        freq, trans, absorb = rsp[1:4]
-        return freq, trans, absorb
+        freq, tran, abso = rsp[1:4]
+        return freq, tran, abso
 
     def setNumSamples(self,value):
         """

File python/Colorimeter/colorimeter/constants.py

 PLOT_ABOUT_TEXT = 'Colorimieter Plot 0.1'
 MEASURE_ABOUT_TEXT = 'Colorimieter Measure 0.1'
 
+# Significant Digits
+SIGNIFICANT_DIGITS_LIST = [1,2,3,4] 
+DEFAULT_SIGNIFICANT_DIGIT_INDEX = 2
+
+

File python/Colorimeter/colorimeter/gui/basic/basic.py

         super(BasicMainWindow,self).initialize()
         self.measValues = None
         self.aboutText = constants.BASIC_ABOUT_TEXT
-        self.samplesValidator = QtGui.QIntValidator(0,2**16-1,self.samplesLineEdit)
-        self.samplesLineEdit.setValidator(self.samplesValidator)
         for name in constants.COLOR2LED_DICT:
             checkBox = getattr(self,'{0}CheckBox'.format(name))
             checkBox.setCheckState(QtCore.Qt.Checked)
             for y in yticks[1:]:
                 ax.plot(xlim,[y,y],'k:')
 
+            digits = self.getSignificantDigits()
             for p, a, c in zip(posList, absoList, xLabelList): 
                 colorSymb = constants.PLOT_COLOR_DICT[c]
                 ax.bar([p],[a],width=barWidth,color=colorSymb,linewidth=2)
                 textXPos = p+0.5*barWidth
                 textYPos = a+0.01
-                valueStr = '{0:1.3f}'.format(a)
+                valueStr = '{value:1.{digits}f}'.format(value=a,digits=digits)
                 ax.text(textXPos,textYPos,valueStr,ha ='center',va ='bottom')
 
             ax.set_xlim(*xlim)
             self.absorbanceTextEdit.setText('')
         else:
             freqValues, tranValues, absoValues = self.measValues
+            digits = self.getSignificantDigits()
             if self.isStandardRgbLEDMode():
                 tranStrList, absoStrList = [], []
                 colorNames = sorted(constants.COLOR2LED_DICT)
                 for c in colorNames:
                     n = constants.COLOR2LED_DICT[c] 
                     if self.isColorChecked(c):
-                        tranStrList.append('{0}:\t{1:1.3f}'.format(c, tranValues[n]))
-                        absoStrList.append('{0}:\t{1:1.3f}'.format(c, absoValues[n]))
+                        tranStr = '{color}:\t{value:1.{digits}f}'.format(
+                                color=c, 
+                                value=tranValues[n],
+                                digits=digits
+                                )
+                        tranStrList.append(tranStr)
+                        absoStr = '{color}:\t{value:1.{digits}f}'.format(
+                                color=c, 
+                                value=absoValues[n],
+                                digits=digits
+                                )
+                        absoStrList.append(absoStr)
                 tranStr = os.linesep.join(tranStrList)
                 absoStr = os.linesep.join(absoStrList)
             else:
-                tranStr = 'custom led: \t{0:1.3f}'.format(tranValues)
-                absoStr = 'custom led: \t{0:1.3f}'.format(absoValues)
+                tranStr = 'custom led: \t{value:1.{digits}f}'.format(
+                        value=tranValues,
+                        digits=digits
+                        )
+                absoStr = 'custom led: \t{value:1.{digits}f}'.format(
+                        value=absoValues,
+                        digits=digits
+                        )
             self.transmissionTextEdit.setText(tranStr)
             self.absorbanceTextEdit.setText(absoStr)
 

File python/Colorimeter/colorimeter/gui/basic/basic.ui

     <addaction name="actionStandardRgbLED"/>
     <addaction name="actionCustomLED"/>
    </widget>
+   <widget class="QMenu" name="menu_Options">
+    <property name="title">
+     <string>&amp;Options</string>
+    </property>
+    <widget class="QMenu" name="menuSignificantDigits">
+     <property name="title">
+      <string>Significant Digits</string>
+     </property>
+    </widget>
+    <addaction name="menuSignificantDigits"/>
+   </widget>
    <addaction name="menuFile"/>
    <addaction name="menuMode"/>
+   <addaction name="menu_Options"/>
    <addaction name="menu_Help"/>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
     <string>Custom LED</string>
    </property>
   </action>
+  <action name="actionSignificantDigits1">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>1</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits2">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>2</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits3">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>3</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits4">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>4</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>

File python/Colorimeter/colorimeter/gui/basic/basic_ui.py

 
 # Form implementation generated from reading ui file 'basic.ui'
 #
-# Created: Sat Apr 20 19:32:05 2013
+# Created: Thu Apr 25 19:50:27 2013
 #      by: PyQt4 UI code generator 4.7.2
 #
 # WARNING! All changes made in this file will be lost!
         self.menu_Help.setObjectName("menu_Help")
         self.menuMode = QtGui.QMenu(self.menubar)
         self.menuMode.setObjectName("menuMode")
+        self.menu_Options = QtGui.QMenu(self.menubar)
+        self.menu_Options.setObjectName("menu_Options")
+        self.menuSignificantDigits = QtGui.QMenu(self.menu_Options)
+        self.menuSignificantDigits.setObjectName("menuSignificantDigits")
         MainWindow.setMenuBar(self.menubar)
         self.statusbar = QtGui.QStatusBar(MainWindow)
         self.statusbar.setObjectName("statusbar")
         self.actionCustomLED = QtGui.QAction(MainWindow)
         self.actionCustomLED.setCheckable(True)
         self.actionCustomLED.setObjectName("actionCustomLED")
+        self.actionSignificantDigits1 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits1.setCheckable(True)
+        self.actionSignificantDigits1.setObjectName("actionSignificantDigits1")
+        self.actionSignificantDigits2 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits2.setCheckable(True)
+        self.actionSignificantDigits2.setObjectName("actionSignificantDigits2")
+        self.actionSignificantDigits3 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits3.setCheckable(True)
+        self.actionSignificantDigits3.setObjectName("actionSignificantDigits3")
+        self.actionSignificantDigits4 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits4.setCheckable(True)
+        self.actionSignificantDigits4.setObjectName("actionSignificantDigits4")
         self.menuFile.addAction(self.actionSave)
         self.menu_Help.addAction(self.actionAbout)
         self.menuMode.addAction(self.actionStandardRgbLED)
         self.menuMode.addAction(self.actionCustomLED)
+        self.menu_Options.addAction(self.menuSignificantDigits.menuAction())
         self.menubar.addAction(self.menuFile.menuAction())
         self.menubar.addAction(self.menuMode.menuAction())
+        self.menubar.addAction(self.menu_Options.menuAction())
         self.menubar.addAction(self.menu_Help.menuAction())
 
         self.retranslateUi(MainWindow)
         self.menuFile.setTitle(QtGui.QApplication.translate("MainWindow", "&File", None, QtGui.QApplication.UnicodeUTF8))
         self.menu_Help.setTitle(QtGui.QApplication.translate("MainWindow", "&Help", None, QtGui.QApplication.UnicodeUTF8))
         self.menuMode.setTitle(QtGui.QApplication.translate("MainWindow", "&Mode", None, QtGui.QApplication.UnicodeUTF8))
+        self.menu_Options.setTitle(QtGui.QApplication.translate("MainWindow", "&Options", None, QtGui.QApplication.UnicodeUTF8))
+        self.menuSignificantDigits.setTitle(QtGui.QApplication.translate("MainWindow", "Significant Digits", None, QtGui.QApplication.UnicodeUTF8))
         self.actionSave.setText(QtGui.QApplication.translate("MainWindow", "Save...", None, QtGui.QApplication.UnicodeUTF8))
         self.actionAbout.setText(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
         self.actionStandardRgbLED.setText(QtGui.QApplication.translate("MainWindow", "Standard RGB LED", None, QtGui.QApplication.UnicodeUTF8))
         self.actionCustomLED.setText(QtGui.QApplication.translate("MainWindow", "Custom LED", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits1.setText(QtGui.QApplication.translate("MainWindow", "1", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits2.setText(QtGui.QApplication.translate("MainWindow", "2", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits3.setText(QtGui.QApplication.translate("MainWindow", "3", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits4.setText(QtGui.QApplication.translate("MainWindow", "4", None, QtGui.QApplication.UnicodeUTF8))
 

File python/Colorimeter/colorimeter/gui/measure/measure.py

                 QtGui.QMessageBox.warning(self,msgTitle, msgText)
                 return
 
-        concStr = '{0:1.2f}'.format(conc)
+        digits = self.getSignificantDigits()
+        concStr = '{value:1.{digits}f}'.format(value=conc,digits=digits)
         self.measurePushButton.setFlat(False)
         self.tableWidget.addData('',concStr,selectAndEdit=True)
 
         ax = self.fig.add_subplot(111)
         ax.bar(posList,concList,width=constants.PLOT_BAR_WIDTH,color='b',linewidth=2)
 
+        digits = self.getSignificantDigits()
         for pos, value in zip(posList, concList): 
             textXPos = pos + 0.5*constants.PLOT_BAR_WIDTH
             textYPos = value + constants.PLOT_TEXT_Y_OFFSET
-            valueStr = '{0:1.3f}'.format(value)
+            valueStr = '{value:1.{digits}f}'.format(value=value,digits=digits)
             ax.text(textXPos,textYPos, valueStr, ha ='center', va ='bottom') 
 
         ax.set_xlim(*xlim)

File python/Colorimeter/colorimeter/gui/measure/measure.ui

      <addaction name="actionSampleUnitsUM"/>
      <addaction name="actionSampleUnitsPPM"/>
     </widget>
+    <widget class="QMenu" name="menuSignificantDigits">
+     <property name="title">
+      <string>Significant Digits</string>
+     </property>
+    </widget>
     <addaction name="menuSample_Units"/>
+    <addaction name="menuSignificantDigits"/>
     <addaction name="menuInclude"/>
     <addaction name="actionEditTestSolutions"/>
    </widget>
     <string>Custom LED</string>
    </property>
   </action>
+  <action name="actionSignificantDigits1">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>1</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits2">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>2</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits3">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>3</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits4">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>4</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>

File python/Colorimeter/colorimeter/gui/measure/measure_ui.py

 
 # Form implementation generated from reading ui file 'measure.ui'
 #
-# Created: Wed Apr 24 17:23:18 2013
+# Created: Thu Apr 25 19:52:34 2013
 #      by: PyQt4 UI code generator 4.7.2
 #
 # WARNING! All changes made in this file will be lost!
         self.menuInclude.setObjectName("menuInclude")
         self.menuSample_Units = QtGui.QMenu(self.menuOptions)
         self.menuSample_Units.setObjectName("menuSample_Units")
+        self.menuSignificantDigits = QtGui.QMenu(self.menuOptions)
+        self.menuSignificantDigits.setObjectName("menuSignificantDigits")
         self.menu_Help = QtGui.QMenu(self.menubar)
         self.menu_Help.setObjectName("menu_Help")
         self.menuMode = QtGui.QMenu(self.menubar)
         self.actionCustomLED = QtGui.QAction(MainWindow)
         self.actionCustomLED.setCheckable(True)
         self.actionCustomLED.setObjectName("actionCustomLED")
+        self.actionSignificantDigits1 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits1.setCheckable(True)
+        self.actionSignificantDigits1.setObjectName("actionSignificantDigits1")
+        self.actionSignificantDigits2 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits2.setCheckable(True)
+        self.actionSignificantDigits2.setObjectName("actionSignificantDigits2")
+        self.actionSignificantDigits3 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits3.setCheckable(True)
+        self.actionSignificantDigits3.setObjectName("actionSignificantDigits3")
+        self.actionSignificantDigits4 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits4.setCheckable(True)
+        self.actionSignificantDigits4.setObjectName("actionSignificantDigits4")
         self.menuFile.addAction(self.actionSave)
         self.menuFile.addAction(self.actionLoad)
         self.menuInclude.addAction(self.actionIncludeUserTestSolutions)
         self.menuSample_Units.addAction(self.actionSampleUnitsUM)
         self.menuSample_Units.addAction(self.actionSampleUnitsPPM)
         self.menuOptions.addAction(self.menuSample_Units.menuAction())
+        self.menuOptions.addAction(self.menuSignificantDigits.menuAction())
         self.menuOptions.addAction(self.menuInclude.menuAction())
         self.menuOptions.addAction(self.actionEditTestSolutions)
         self.menu_Help.addAction(self.actionAbout)
         self.menuOptions.setTitle(QtGui.QApplication.translate("MainWindow", "&Options", None, QtGui.QApplication.UnicodeUTF8))
         self.menuInclude.setTitle(QtGui.QApplication.translate("MainWindow", "Include", None, QtGui.QApplication.UnicodeUTF8))
         self.menuSample_Units.setTitle(QtGui.QApplication.translate("MainWindow", "Sample Units", None, QtGui.QApplication.UnicodeUTF8))
+        self.menuSignificantDigits.setTitle(QtGui.QApplication.translate("MainWindow", "Significant Digits", None, QtGui.QApplication.UnicodeUTF8))
         self.menu_Help.setTitle(QtGui.QApplication.translate("MainWindow", "&Help", None, QtGui.QApplication.UnicodeUTF8))
         self.menuMode.setTitle(QtGui.QApplication.translate("MainWindow", "&Mode", None, QtGui.QApplication.UnicodeUTF8))
         self.actionReloadTestSolutions.setText(QtGui.QApplication.translate("MainWindow", "Reload Test Solutions", None, QtGui.QApplication.UnicodeUTF8))
         self.actionSampleUnitsPPM.setText(QtGui.QApplication.translate("MainWindow", "ppm", None, QtGui.QApplication.UnicodeUTF8))
         self.actionStandardRgbLED.setText(QtGui.QApplication.translate("MainWindow", "Standard RGB LED", None, QtGui.QApplication.UnicodeUTF8))
         self.actionCustomLED.setText(QtGui.QApplication.translate("MainWindow", "Custom LED", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits1.setText(QtGui.QApplication.translate("MainWindow", "1", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits2.setText(QtGui.QApplication.translate("MainWindow", "2", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits3.setText(QtGui.QApplication.translate("MainWindow", "3", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits4.setText(QtGui.QApplication.translate("MainWindow", "4", None, QtGui.QApplication.UnicodeUTF8))
 
 from colorimeter.table_widget import ColorimeterTableWidget

File python/Colorimeter/colorimeter/gui/plot/plot.py

     def getMeasurement(self):
         ledNumber = constants.COLOR2LED_DICT[self.currentColor]
         if constants.DEVEL_FAKE_MEASURE:
-            abso = (random.random(),)*4
+            absoValue = (random.random(),)*4
         else:
             if self.isStandardRgbLEDMode():
                 freq, trans, abso = self.dev.getMeasurement()
             else:
                 freq, trans, abso = self.dev.getMeasurementBlue()
                 absoValue = abso
-            absoStr = '{0:1.2f}'.format(absoValue)
+        digits = self.getSignificantDigits()
+        absoStr = '{value:1.{digits}f}'.format(value=absoValue,digits=digits)
         self.measurePushButton.setFlat(False)
         self.tableWidget.addData('',absoStr,selectAndEdit=True)
 
         self.tableWidget.clean(setup=True)
         for conc, abso in dataList:
             concStr = str(conc)
-            absoStr = '{0:1.2f}'.format(abso)
+            absoStr = '{value:1.{digits}f}'.format(value=abso,digits=digits)
             self.tableWidget.addData(concStr,absoStr)
 
     def updateWidgetEnabled(self):

File python/Colorimeter/colorimeter/gui/plot/plot.ui

      <addaction name="actionConcentrationUnitsUM"/>
      <addaction name="actionConcentrationUnitsPPM"/>
     </widget>
+    <widget class="QMenu" name="menuSignificantDigits">
+     <property name="title">
+      <string>Significant Digits</string>
+     </property>
+    </widget>
     <addaction name="actionExport"/>
     <addaction name="actionImport"/>
     <addaction name="actionEditTestSolutions"/>
     <addaction name="menuFitType"/>
     <addaction name="menuConcentrationUnits"/>
+    <addaction name="menuSignificantDigits"/>
    </widget>
    <widget class="QMenu" name="menu_Help">
     <property name="title">
     <string>Custom LED</string>
    </property>
   </action>
+  <action name="actionSignificantDigits1">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>1</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits2">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>2</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits3">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>3</string>
+   </property>
+  </action>
+  <action name="actionSignificantDigits4">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>4</string>
+   </property>
+  </action>
  </widget>
  <customwidgets>
   <customwidget>

File python/Colorimeter/colorimeter/gui/plot/plot_ui.py

 
 # Form implementation generated from reading ui file 'plot.ui'
 #
-# Created: Wed Apr 24 17:26:56 2013
+# Created: Thu Apr 25 19:51:24 2013
 #      by: PyQt4 UI code generator 4.7.2
 #
 # WARNING! All changes made in this file will be lost!
         self.menuFitType.setObjectName("menuFitType")
         self.menuConcentrationUnits = QtGui.QMenu(self.menuOptions)
         self.menuConcentrationUnits.setObjectName("menuConcentrationUnits")
+        self.menuSignificantDigits = QtGui.QMenu(self.menuOptions)
+        self.menuSignificantDigits.setObjectName("menuSignificantDigits")
         self.menu_Help = QtGui.QMenu(self.menubar)
         self.menu_Help.setObjectName("menu_Help")
         self.menuMode = QtGui.QMenu(self.menubar)
         self.actionCustomLED = QtGui.QAction(MainWindow)
         self.actionCustomLED.setCheckable(True)
         self.actionCustomLED.setObjectName("actionCustomLED")
+        self.actionSignificantDigits1 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits1.setCheckable(True)
+        self.actionSignificantDigits1.setObjectName("actionSignificantDigits1")
+        self.actionSignificantDigits2 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits2.setCheckable(True)
+        self.actionSignificantDigits2.setObjectName("actionSignificantDigits2")
+        self.actionSignificantDigits3 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits3.setCheckable(True)
+        self.actionSignificantDigits3.setObjectName("actionSignificantDigits3")
+        self.actionSignificantDigits4 = QtGui.QAction(MainWindow)
+        self.actionSignificantDigits4.setCheckable(True)
+        self.actionSignificantDigits4.setObjectName("actionSignificantDigits4")
         self.menuFile.addAction(self.actionSave)
         self.menuFile.addAction(self.actionLoad)
         self.menuFitType.addAction(self.actionFitTypeLinear)
         self.menuOptions.addAction(self.actionEditTestSolutions)
         self.menuOptions.addAction(self.menuFitType.menuAction())
         self.menuOptions.addAction(self.menuConcentrationUnits.menuAction())
+        self.menuOptions.addAction(self.menuSignificantDigits.menuAction())
         self.menu_Help.addAction(self.actionAbout)
         self.menuMode.addAction(self.actionStandardRgbLED)
         self.menuMode.addAction(self.actionCustomLED)
         self.menuOptions.setTitle(QtGui.QApplication.translate("MainWindow", "&Options", None, QtGui.QApplication.UnicodeUTF8))
         self.menuFitType.setTitle(QtGui.QApplication.translate("MainWindow", "Fit Type", None, QtGui.QApplication.UnicodeUTF8))
         self.menuConcentrationUnits.setTitle(QtGui.QApplication.translate("MainWindow", "Concentration Units", None, QtGui.QApplication.UnicodeUTF8))
+        self.menuSignificantDigits.setTitle(QtGui.QApplication.translate("MainWindow", "Significant Digits", None, QtGui.QApplication.UnicodeUTF8))
         self.menu_Help.setTitle(QtGui.QApplication.translate("MainWindow", "&Help", None, QtGui.QApplication.UnicodeUTF8))
         self.menuMode.setTitle(QtGui.QApplication.translate("MainWindow", "&Mode", None, QtGui.QApplication.UnicodeUTF8))
         self.actionSave.setText(QtGui.QApplication.translate("MainWindow", "Save...", None, QtGui.QApplication.UnicodeUTF8))
         self.actionFitTypePolynomial5.setText(QtGui.QApplication.translate("MainWindow", "Polynomial (order=5)", None, QtGui.QApplication.UnicodeUTF8))
         self.actionStandardRgbLED.setText(QtGui.QApplication.translate("MainWindow", "Standard RGB LED", None, QtGui.QApplication.UnicodeUTF8))
         self.actionCustomLED.setText(QtGui.QApplication.translate("MainWindow", "Custom LED", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits1.setText(QtGui.QApplication.translate("MainWindow", "1", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits2.setText(QtGui.QApplication.translate("MainWindow", "2", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits3.setText(QtGui.QApplication.translate("MainWindow", "3", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSignificantDigits4.setText(QtGui.QApplication.translate("MainWindow", "4", None, QtGui.QApplication.UnicodeUTF8))
 
 from colorimeter.table_widget import ColorimeterTableWidget

File python/Colorimeter/colorimeter/main_window.py

 
     def connectActions(self):
         self.samplesLineEdit.editingFinished.connect(self.samplesChanged_Callback)
+        self.samplesValidator = QtGui.QIntValidator(0,2**16-1,self.samplesLineEdit)
+        self.samplesLineEdit.setValidator(self.samplesValidator)
         self.portLineEdit.editingFinished.connect(self.portChanged_Callback)
         self.connectPushButton.pressed.connect(self.connectPressed_Callback)
         self.connectPushButton.clicked.connect(self.connectClicked_Callback)
         self.actionStandardRgbLED.triggered.connect(self.standardRgbLED_Callback)
         self.actionCustomLED.triggered.connect(self.customLED_Callback)
 
+        self.significantDigitActionGroup = QtGui.QActionGroup(self)
+        self.significantDigitActionGroup.setExclusive(True)
+        self.significantDigitAction2Value = {}
+        
+        for i in constants.SIGNIFICANT_DIGITS_LIST:
+            actionName = 'actionSignificantDigits{0}'.format(i)
+            action = QtGui.QAction(self.menuSignificantDigits)
+            action.setCheckable(True)
+            action.setText('{0}'.format(i))
+            self.menuSignificantDigits.addAction(action)
+            self.significantDigitActionGroup.addAction(action)
+            if i == constants.DEFAULT_SIGNIFICANT_DIGIT_INDEX:
+                action.setChecked(True)
+            self.significantDigitAction2Value[action] = i
+
     def initialize(self):
         self.setAppSize()
         self.dev = None
             self.actionCustomLED.setEnabled(True)
             self.samplesLineEdit.setEnabled(True)
 
+    def getSignificantDigits(self):
+        for action, value in self.significantDigitAction2Value.iteritems():
+            if action.isChecked():
+                return value
+
     def main(self):
         self.show()