温控系统图形化
上面已经把系统作了出来,现在加入图形:
代码如下:
from Tkinter import *
from final import *
import thread
class PaintBox(Frame):
def __init__(self):
Frame.__init__(self)
self.pack(expand = YES,fill = BOTH)
self.master.title("Temprature Control System--RockyLinux")
self.master.geometry("600x400")
self.info = Label(self,text = "Curren:0 Target:50 吴敬征")
self.info.pack(side = BOTTOM)
'''
self.input = Entry(self,text = "rockylinux")
self.input.pack(side = RIGHT)
'''
self.myCanvas = Canvas(self)
self.myCanvas.pack(expand = YES,fill = BOTH)
self.myCanvas.create_line(20,0,20,400,fill = "Black")
self.myCanvas.create_line(0,200,600,200,fill = "Black")
#self.paint_line()
thread.start_new_thread(self.paint_line,())
def paint_line(self):
(En,Ve) = (50,0)
x1,y1 = 10,En * 5 + 200
w = 0
for i in range(1,300,2):
(En,Ve,w) = result(En,Ve,w)
x2,y2 = i*2 + 10,En * 5 + 200
self.myCanvas.create_line(x1,y1,x2,y2,fill = "Red")
x1,y1 = x2,y2
#print y1-200,y2-200
def main():
PaintBox().mainloop()
if __name__ == "__main__":
print "Please waiting..."
main()
这里用了一个多线程,这样就能够显示出界面然后在逐渐打印曲线,下一步把图形改成能够输入值,能够调整的,并且转换成exe文件.