Пример #1
0
 def __init__(self, parent=None):
     QtGui.QWidget.__init__(self, parent)
     self.setWindowTitle('ConvertAll')
     icons.setupIcons()
     self.setWindowIcon(icons.iconDict['convert'])
     self.helpView = None
     self.findDlg = None
     self.option = Option('convertall', 20)
     self.option.loadAll(optiondefaults.defaultList)
     try:
         ConvertDlg.unitData.readData()
     except unitdata.UnitDataError, text:
         QtGui.QMessageBox.warning(self, 'ConvertAll',
                                   'Error in unit data - %s' % text)
         sys.exit(1)
Пример #2
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.calc = CalcCore()
        self.setWindowTitle('rpCalc')
        icons.setupIcons()
        self.setWindowIcon(icons.iconDict['calc'])
        self.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.helpView = None
        self.extraView = None
        self.regView = None
        self.histView = None
        self.memView = None
        self.altBaseView = None
        self.optDlg = None
        self.popupMenu = QtGui.QMenu(self)
        self.popupMenu.addAction('Registers on &LCD', self.toggleReg)
        self.popupMenu.addSeparator()
        self.popupMenu.addAction('Show &Register List', self.viewReg)
        self.popupMenu.addAction('Show &History List', self.viewHist)
        self.popupMenu.addAction('Show &Memory List', self.viewMem)
        self.popupMenu.addSeparator()
        self.popupMenu.addAction('Show Other &Bases', self.viewAltBases)
        self.popupMenu.addSeparator()
        self.popupMenu.addAction('Show ReadMe &File', self.help)
        self.popupMenu.addAction('&About rpCalc', self.about)
        self.popupMenu.addSeparator()
        self.popupMenu.addAction('&Quit', self.close)
        topLay = QtGui.QVBoxLayout(self)
        self.setLayout(topLay)
        topLay.setSpacing(4)
        topLay.setMargin(6)
        lcdBox = LcdBox()
        topLay.addWidget(lcdBox)
        lcdLay = QtGui.QGridLayout(lcdBox)
        lcdLay.setColumnStretch(1, 1)
        lcdLay.setRowStretch(3, 1)
        self.extraLabels = [QtGui.QLabel(' T:',), QtGui.QLabel(' Z:',),
                            QtGui.QLabel(' Y:',)]
        for i in range(3):
            lcdLay.addWidget(self.extraLabels[i], i, 0, QtCore.Qt.AlignLeft)
        self.extraLcds = [Lcd(1.5, 13), Lcd(1.5, 13), Lcd(1.5, 13)]
        lcdLay.addWidget(self.extraLcds[2], 0, 1, QtCore.Qt.AlignRight)
        lcdLay.addWidget(self.extraLcds[1], 1, 1, QtCore.Qt.AlignRight)
        lcdLay.addWidget(self.extraLcds[0], 2, 1, QtCore.Qt.AlignRight)
        if not self.calc.option.boolData('ViewRegisters'):
            for w in self.extraLabels + self.extraLcds:
                w.hide()
        self.lcd = Lcd(2.0, 13)
        lcdLay.addWidget(self.lcd, 3, 0, 1, 2, QtCore.Qt.AlignRight)
        self.setLcdHighlight()
        self.updateLcd()
        self.updateColors()

        self.cmdLay = QtGui.QGridLayout()
        topLay.addLayout(self.cmdLay)
        self.cmdDict = {}
        self.addCmdButton('x^2', 0, 0)
        self.addCmdButton('sqRT', 0, 1)
        self.addCmdButton('y^X', 0, 2)
        self.addCmdButton('xRT', 0, 3)
        self.addCmdButton('RCIP', 0, 4)
        self.addCmdButton('SIN', 1, 0)
        self.addCmdButton('COS', 1, 1)
        self.addCmdButton('TAN', 1, 2)
        self.addCmdButton('LN', 1, 3)
        self.addCmdButton('e^X', 1, 4)
        self.addCmdButton('ASIN', 2, 0)
        self.addCmdButton('ACOS', 2, 1)
        self.addCmdButton('ATAN', 2, 2)
        self.addCmdButton('LOG', 2, 3)
        self.addCmdButton('tn^X', 2, 4)
        self.addCmdButton('STO', 3, 0)
        self.addCmdButton('RCL', 3, 1)
        self.addCmdButton('R<', 3, 2)
        self.addCmdButton('R>', 3, 3)
        self.addCmdButton('x<>y', 3, 4)
        self.addCmdButton('SHOW', 4, 0)
        self.addCmdButton('CLR', 4, 1)
        self.addCmdButton('PLCS', 4, 2)
        self.addCmdButton('SCI', 4, 3)
        self.addCmdButton('DEG', 4, 4)
        self.addCmdButton('EXIT', 5, 0)
        self.addCmdButton('Pi', 5, 1)
        self.addCmdButton('EXP', 5, 2)
        self.addCmdButton('CHS', 5, 3)
        self.addCmdButton('<-', 5, 4)

        self.mainLay = QtGui.QGridLayout()
        topLay.addLayout(self.mainLay)
        self.mainDict = {}
        self.addMainButton(0, 'OPT', 0, 0)
        self.addMainButton(QtCore.Qt.Key_Slash, '/', 0, 1)
        self.addMainButton(QtCore.Qt.Key_Asterisk, '*', 0, 2)
        self.addMainButton(QtCore.Qt.Key_Minus, '-', 0, 3)
        self.addMainButton(QtCore.Qt.Key_7, '7', 1, 0)
        self.addMainButton(QtCore.Qt.Key_8, '8', 1, 1)
        self.addMainButton(QtCore.Qt.Key_9, '9', 1, 2)
        self.addMainButton(QtCore.Qt.Key_Plus, '+', 1, 3, 1, 0)
        self.addMainButton(QtCore.Qt.Key_4, '4', 2, 0)
        self.addMainButton(QtCore.Qt.Key_5, '5', 2, 1)
        self.addMainButton(QtCore.Qt.Key_6, '6', 2, 2)
        self.addMainButton(QtCore.Qt.Key_1, '1', 3, 0)
        self.addMainButton(QtCore.Qt.Key_2, '2', 3, 1)
        self.addMainButton(QtCore.Qt.Key_3, '3', 3, 2)
        self.addMainButton(QtCore.Qt.Key_Enter, 'ENT', 3, 3, 1, 0)
        self.addMainButton(QtCore.Qt.Key_0, '0', 4, 0, 0, 1)
        self.addMainButton(QtCore.Qt.Key_Period, '.', 4, 2)

        self.mainDict[QtCore.Qt.Key_Return] = \
                     self.mainDict[QtCore.Qt.Key_Enter]
        # added for european keyboards:
        self.mainDict[QtCore.Qt.Key_Comma] = \
                     self.mainDict[QtCore.Qt.Key_Period]
        self.cmdDict['ENT'] = self.mainDict[QtCore.Qt.Key_Enter]
        self.cmdDict['OPT'] = self.mainDict[0]

        self.entryStr = ''
        self.showMode = False

        statusBox = QtGui.QFrame()
        statusBox.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
        statusBox.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                                  QtGui.QSizePolicy.Preferred))
        topLay.addWidget(statusBox)
        statusLay = QtGui.QHBoxLayout(statusBox)
        self.entryLabel = QtGui.QLabel(statusBox)
        statusLay.addWidget(self.entryLabel)
        statusLay.setMargin(1)
        self.statusLabel = QtGui.QLabel(statusBox)
        self.statusLabel.setAlignment(QtCore.Qt.AlignRight)
        statusLay.addWidget(self.statusLabel)

        if self.calc.option.boolData('ExtraViewStartup'):
            self.viewReg()
        if self.calc.option.boolData('AltBaseStartup'):
            self.viewAltBases()

        xSize = self.calc.option.intData('MainDlgXSize', 0, 10000)
        ySize = self.calc.option.intData('MainDlgYSize', 0, 10000)
        if xSize and ySize:
            self.resize(xSize, ySize)
        self.move(self.calc.option.intData('MainDlgXPos', 0, 10000),
                  self.calc.option.intData('MainDlgYPos', 0, 10000))

        self.updateEntryLabel('rpCalc Version %s' % __version__)
        QtCore.QTimer.singleShot(5000, self.updateEntryLabel)