File indexing completed on 2024-12-22 04:17:10
0001 #!/usr/bin/python 0002 0003 # demonstrate buttons and line inputs: 0004 # plot an equation the user inputs 0005 0006 import sip 0007 sip.setapi('QString', 1) 0008 import pykst as kst 0009 import sys 0010 import random 0011 from PyQt4 import QtCore, QtNetwork, QtGui 0012 0013 class KsNspire: 0014 text="" 0015 def __init__(self,client): 0016 self.client=client 0017 self.s=QtNetwork.QLocalSocket() 0018 self.s.readyRead.connect(self.create) 0019 self.s2=QtNetwork.QLocalSocket() 0020 self.s2.readyRead.connect(self.changeValue) 0021 self.l=kst.LineEdit(client,"",self.s2,0.47,0.975,0.93,0.025) 0022 self.b=kst.Button(client,"Go!",self.s,0.97,0.975,0.05,0.025) 0023 self.plot=client.new_plot((0.5,0.4885),(0.9,0.8)) 0024 self.genVec=client.new_generated_vector(-100,100,1000) 0025 0026 def create(self): 0027 eq = client.new_equation(self.genVec, self.text) 0028 c = client.new_curve(eq.x(), eq.y()) 0029 self.plot.add(c) 0030 0031 def changeValue(self): 0032 strx=QtCore.QString(self.s2.read(8000)) 0033 if strx.contains("valueSet:"): 0034 strx.remove("valueSet:") 0035 self.text=str(strx) 0036 0037 client=kst.Client() 0038 app=QtGui.QApplication(sys.argv) 0039 m=KsNspire(client) 0040 0041 app.exec_()