import os
import tkinter
import tkinter.font as tkFont
from tkinter import *
coord1 = "0,0"
coord2 = "0,0"
EQ = "y = mx + b"
def tkinter_window():
global coord1Entry
global coord2Entry
global coord1
global coord
tk = Tk()
tk.title("Math Graph")
#create
font1 = tkFont.Font(family="Source Code Pro", size=16)
font2 = tkFont.Font(family="Source Code Pro", size=10)
coord1Label = Label(tk, text='X coordinate 1:\n( "x,y", no parentheses )', font=font1)
coord2Label = Label(tk, text='Y coordinate 2:\n( "x,y", no parentheses )', font=font1)
This is the part where i define the two entries that seem to use the same numbers:
coord1Entry = Entry(tk, textvariable=coord1)
coord2Entry = Entry(tk, textvariable=coord2)
So the problem is, when i run the program they show nothing, as usual. But as soon as i enter one character in one of the entries, they both show the character(s). I don't understand why, they use different variables? Can someone help me?
coordButton = Button(tk, text="Done! (use coordinates)", font=font1)
equationLabel = Label(tk, text="Equation: y =", font=font1)
equationEntry = Entry(tk, textvariable=EQ, font=font1)
equationButton = Button(tk, text="Done! (use equation)", font=font1)
iwantanswersCheckbox = Checkbutton(tk, text="I want m, x, b, intercept and x-intercept", font=font1)
iwantgraphCheckbox = Checkbutton(tk, text="I want a graph", font=font1)
info1Label = Label(tk, text="***Both boxes may be checked***", font=font2)
#pack
coord1Label.grid(row=0, column=0, padx=15, pady=15)
coord2Label.grid(row=1, column=0, padx=15, pady=15)
coord1Entry.grid(row=0, column=1, padx=5, pady=5)
coord2Entry.grid(row=1, column=1, padx=5, pady=5)
coordButton.grid(row=2, columnspan=2, padx=5, pady=15)
equationLabel.grid(row=3, column=0, sticky=E, padx=5, pady=5)
equationEntry.grid(row=3, column=1, padx=5, pady=5)
equationButton.grid(row=4, columnspan=2, padx=5, pady=15)
iwantanswersCheckbox.grid(row=5, columnspan=2, padx=5, pady=5)
iwantgraphCheckbox.grid(row=6, columnspan=2)
info1Label.grid(row=7, columnspan=2)
os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
tk.mainloop()
tkinter_window()
def matplotlib_window():
import matplotlib.pyplot as plt
coordX[0] = Xcoord1Entry.get()
coordX[1] = Xcoord2Entry.get()
coordY[0] = Ycoord1Entry.get()
coordY[1] = Ycoord2Entry.get()
plt.plot(coordX, coordY)
plt.legend(loc=4)
plt.xlabel("x")
plt.ylabel("y")
plt.show()
Main area of code where the problem should be (as requested):
import tkinter
import tkinter.font as tkFont
from tkinter import *
coord1 = "0,0"
coord2 = "0,0"
def tkinter_window():
global coord1Entry
global coord2Entry
global coord1
global coord
tk = Tk()
tk.title("Math Graph")
#create
font1 = tkFont.Font(family="Source Code Pro", size=16)
font2 = tkFont.Font(family="Source Code Pro", size=10)
coord1Label = Label(tk, text='X coordinate 1:\n( "x,y", no parentheses )', font=font1)
coord2Label = Label(tk, text='Y coordinate 2:\n( "x,y", no parentheses )', font=font1)
coord1Entry = Entry(tk, textvariable=coord1)
coord2Entry = Entry(tk, textvariable=coord2)
#pack
coord1Label.grid(row=0, column=0, padx=15, pady=15)
coord2Label.grid(row=1, column=0, padx=15, pady=15)
coord1Entry.grid(row=0, column=1, padx=5, pady=5)
coord2Entry.grid(row=1, column=1, padx=5, pady=5)
tk.mainloop()
tkinter_window()