text
stringlengths 1
93.6k
|
|---|
self.butn('CLR', 7, 30, self.clearall, clr=myred)
|
self.butn('0', 8, 0, lambda state, c='0': self.keyin(c), clr=myblue1)
|
self.butn('.', 8, 6, lambda state, c='.': self.keyin(c), clr=myblue2)
|
self.butn('+/-', 8, 12, lambda state, op='+/-': self.calculate(op), clr=myblue2)
|
self.butn('/', 8, 18, lambda state, c='/': self.calculate(c), clr=myblue2)
|
self.butn('ENTER', 8, 24, self.enter, clr=mygold, colspan=12)
|
self.butn('Sin', 9, 0,
|
lambda state, op='math.sin(x)': self.func(op, in_cnvrt=1),
|
clr=mygold, colspan=8)
|
self.butn('Cos', 9, 8,
|
lambda state, op='math.cos(x)': self.func(op, in_cnvrt=1),
|
clr=mygold, colspan=8)
|
self.butn('Tan', 9, 16,
|
lambda state, op='math.tan(x)': self.func(op, in_cnvrt=1),
|
clr=mygold, colspan=8)
|
self.butn('x^2', 9, 24,
|
lambda state, op='x*x': self.func(op), clr=mygold)
|
self.butn('10^x', 9, 30, lambda state, op='10**x': self.func(op), clr=mygold)
|
self.butn('ASin', 10, 0,
|
lambda state, op='math.asin(x)': self.func(op, out_cnvrt=1),
|
clr=mygold, colspan=8)
|
self.butn('ACos', 10, 8,
|
lambda state, op='math.acos(x)': self.func(op, out_cnvrt=1),
|
clr=mygold, colspan=8)
|
self.butn('ATan', 10, 16,
|
lambda state, op='math.atan(x)': self.func(op, out_cnvrt=1),
|
clr=mygold, colspan=8)
|
self.butn('Sqrt x', 10, 24, lambda state, op='math.sqrt(x)': self.func(op), clr=mygold)
|
self.butn('y^x', 10, 30, lambda state, op='y**x': self.func(op), clr=mygold)
|
self.butn('Dist', 11, 0, self.caller.distPtPt, clr=mygray, colspan=8)
|
self.butn('Len', 11, 8, self.caller.edgeLen, clr=mygray, colspan=8)
|
self.butn('Rad', 11, 16, self.noop, clr=mygray, colspan=8)
|
self.butn('Ang', 11, 24, self.noop, clr=mygray)
|
self.butn('', 11, 30, self.noop, clr=mygray)
|
self.setLayout(self.mainLayout)
|
def butn(self, text, row, col, com=None, clr='dimgray', rowspan=1, colspan=6):
|
b = Button(text)
|
b.clicked.connect(com)
|
b.setStyleSheet('color: white; background-color: %s' % clr)
|
self.mainLayout.addWidget(b, row, col, rowspan, colspan)
|
def display(self):
|
d = QLineEdit('0')
|
d.setAlignment(QtCore.Qt.AlignRight)
|
d.setMaxLength(18)
|
font = d.font()
|
font.setPointSize(font.pointSize() + 2)
|
d.setFont(font)
|
return d
|
def closeEvent(self, event):
|
print('calculator closing')
|
try:
|
self.caller.calculator = None
|
except:
|
pass
|
event.accept()
|
def pr(self, register):
|
"""Send value to caller."""
|
value = eval('self.'+register)
|
if self.caller:
|
self.caller.valueFromCalc(value)
|
else:
|
print(value)
|
self.keip = False
|
self.needrup = True
|
def keyin(self, c):
|
if self.keip:
|
dispVal = self.xdisplay.text()+c
|
self.xdisplay.setText(dispVal)
|
self.x = float(dispVal)
|
else:
|
self.keip = True
|
if self.needrup:
|
self.rotateup(loop=0)
|
self.xdisplay.setText('')
|
if c == '.':
|
c = '0.'
|
self.keyin(c)
|
def pi(self):
|
self.rotateup()
|
self.x = math.pi
|
self.updateDisplays()
|
self.needrup = True
|
def updateDisplays(self):
|
self.xdisplay.setText(str(self.x))
|
self.ydisplay.setText(str(self.y))
|
self.zdisplay.setText(str(self.z))
|
self.tdisplay.setText(str(self.t))
|
def enter(self):
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.