I want this program:
with open('Tkintergraph.py', 'a') as f:
el = input()
ef = input()
f.write('xpoint= {}\nypoint= {}\n'.format(el,ef))
to input the writing to this code:
from tkinter import *
def checkered(canvas, line_distance):
for x in range(line_distance, canvas_width, line_distance):
canvas.create_line(x, 0, x, canvas_height, fill="black")
for y in range(line_distance,canvas_height,line_distance):
canvas.create_line(0, y, canvas_width, y, fill="black")
###############################################################################
#This is where i want to input the text
root = Tk()
canvas_width = 1000
canvas_height = 1000
w = Canvas(root,
width=canvas_width,
height=canvas_height)
checkered(w,20)
w.pack()
a = int(canvas_height / 2)
w.create_line(0, a, canvas_width, a,
fill="red",width=3)
b = int(canvas_width / 2)
w.create_line(b, 0, b,canvas_height,
fill = "red",width=3)
w.create_text(5, ((canvas_height/2)-10)
,text="x",font=12)
w.create_text(b+10 ,5
,text='y',font=12)
w.create_text(b+10,a-10
,text='0',font=10)
w.create_oval(b-5,a-5,b+5,a+5
,fill = 'black')
if xpoint < 0:
if ypoint > 0:
xplace = (canvas_width/2)-(20*abs(xpoint))
yplace = (canvas_height/2)-(20*abs(ypoint))
if ypoint == 0:
xplace = (canvas_width/2)-(20*abs(xpoint))
yplace = (canvas_height/2)-(20*abs(ypoint))
if ypoint < 0:
xplace = (canvas_width/2)-(20*abs(xpoint))
yplace = (canvas_height/2)+(20*abs(ypoint))
if xpoint == 0:
if ypoint > 0:
xplace = (canvas_width/2)-(20*abs(xpoint))
yplace = (canvas_height/2)-(20*abs(ypoint))
if ypoint == 0:
xplace = (canvas_width/2)-(20*abs(xpoint))
yplace = (canvas_height/2)-(20*abs(ypoint))
if ypoint < 0:
xplace = (canvas_width/2)-(20*abs(xpoint))
yplace = (canvas_height/2)+(20*abs(ypoint))
if xpoint > 0:
if ypoint > 0:
xplace = (canvas_width/2)+(20*abs(xpoint))
yplace = (canvas_height/2)-(20*abs(ypoint))
if ypoint == 0:
xplace = (canvas_width/2)+(20*abs(xpoint))
yplace = (canvas_height/2)-(20*abs(ypoint))
if ypoint < 0:
xplace = (canvas_width/2)+(20*abs(xpoint))
yplace = (canvas_height/2)+(20*abs(ypoint))
w.create_text(xplace,yplace,
text='•',font=('Arial',20,'bold'),fill='red')
mainloop()
I've searched for how to do this online, but i could never find out how to do it with a .py document. Just letting you all know that i am very much a novice and any help would be appreciated

New Topic/Question
Reply


MultiQuote

|