Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from tkinter import *
- from math import *
- resy=480
- resx=int((resy/9)*16)
- window = Tk()
- canvas = Canvas(window, width=resx, height=resy, bg="#000000")
- canvas.pack()
- img = PhotoImage(width=resx, height=resy)
- item = canvas.create_image((int((resx/2)), int((resy/2))), image=img, state="normal")
- txt = "cos(radians(x))*100"
- def strt():
- global resx
- global img
- global canvas
- x=resx
- while x>=0:
- img.put("#9A1409", (x,int((resy/2))))
- x=x-1
- x=resx
- while x>=0:
- img.put("#9A1409", (int((resx/2)),x))
- x=x-1
- w1 = Scale(window, from_=-int(resx/2), to=int(resx/2),orient=HORIZONTAL,resolution=0.5, length=resx+25)
- w1.pack()
- var=StringVar()
- var.set(txt)
- R=Label(window, textvariable=var, height=1, width=50)
- R.pack()
- def callback():
- global txt
- global x
- global canvas
- global item
- global img
- global item
- canvas.delete(item)
- img = PhotoImage(width=resx, height=resy)
- item = canvas.create_image((int((resx/2)), int((resy/2))), image=img, state="normal")
- strt()
- x=-int((resx/2))
- txt = e.get()
- x=-int((resx/2))
- def text(txt):
- global var
- x = w1.get()
- exec("var.set("+txt+")")
- def update():
- global x
- global var
- global txt
- global img
- if x>=-int((resx/2)) and x<=int((resx/2)):
- y=eval(str(txt))
- z=int(y)
- if y < int((resy/2)) and y > -int((resy/2)):
- img.put("#00ff00", (int(x)+int((resx/2)),int((resy/2))-(z)))
- if x<int(resx/2):
- x=x+0.1
- text(txt)
- window.after(1,update)
- e = Entry(window)
- e.pack()
- b = Button(window, text = "OK", width = 10, command = callback)
- b.pack()
- strt()
- window.after(1,update)
- window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement