How to fix that error? 'NoneType' object has no attribute '_root' [duplicate]
This question already has an answer here:
Tkinter radiobutton IntVar Attribute error
1 answer
I don't know how to solve this problem and have no idea why she appeared.
What to do to fix it?
Other people's similar problems are somehow related to the StringVar
variable, I think this code is not the same error.
import matplotlib
from math import *
import pylab
from matplotlib import mlab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import tkinter as tk
from tkinter import ttk
from tkinter import *
g = 9.81
class MyData():
v = IntVar()
angle = IntVar()
x0 = IntVar()
y0 = IntVar()
v2 = IntVar()
angle2 = IntVar()
x02 = IntVar()
y02 = IntVar()
v3 = IntVar()
angle3 = IntVar()
x03 = IntVar()
y03 = IntVar()
class Fly(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.wm_title(self, "Fly")
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames =
data = MyData
for F in (StartPage, PageOne):
frame = F(container, self, data)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Начальная страница")
label.pack(pady=10, padx=10)
button = ttk.Button(self, text="Visit Page 1",
command=lambda: controller.show_frame(PageOne))
button.pack()
frame2 = Frame(self, borderwidth=4, relief=GROOVE)
frame2.pack()
first = Label(self, text='Данные для первого графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x0)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y0)
entry.pack()
frame3 = Frame(self, borderwidth=4, relief=GROOVE)
frame3.pack()
first = Label(self, text='Данные для второго графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v2)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle2)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x02)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y02)
entry.pack()
first = Label(self, text='Данные для третьего графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v3)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle3)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x03)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y03)
entry.pack()
class PageOne(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Generate")
label.pack(pady=10, padx=10)
button1 = ttk.Button(self, text="Поменять значения",
command=lambda: controller.show_frame(StartPage))
button1.pack()
f = Figure(figsize=(5, 5), dpi=100)
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
t = ((2 * data.v * sin(data.angle)) / g)
vx = data.v * cos(data.angle)
t2 = ((2 * data.v2 * sin(data.angle2)) / g)
vx2 = data.v2 * cos(data.angle2)
t3 = ((2 * data.v3 * sin(data.angle3)) / g)
vx3 = data.v3 * cos(data.angle3)
dx = 0.01
xmin = data.x0
xmax = vx * t * cos(data.angle)
xmin2 = data.x02
xmax2 = vx2 * t2 * cos(data.angle2)
xmin3 = data.x03
xmax3 = vx3 * t3 * cos(data.angle3)
def func(x0, v, y0, angle):
y = x0 * tan(angle) - (1 / (2 * v ** 2)) * ((g * x0 ** 2) / (cos(angle) ** 2)) + y0
if y == 0:
return 0.0
return y
def func2(x02, v2, y02, angle2):
y2 = x02 * tan(angle2) - (1 / (2 * v2 ** 2)) * ((g * x02 ** 2) / (cos(angle2) ** 2)) + y02
if y2 == 0:
return 0.0
return y2
def func3(x03, v3, y03, angle3):
y3 = x03 * tan(angle3) - (1 / (2 * v3 ** 2)) * ((g * x03 ** 2) / (cos(angle3) ** 2)) + y03
if y3 == 0:
return 0.0
return y3
xlist = mlab.frange(xmin, xmax, dx)
xlist2 = mlab.frange(xmin2, xmax2, dx)
xlist3 = mlab.frange(xmin3, xmax3, dx)
ylist = [func(x0, data.v, data.y0, data.angle) for x0 in xlist]
ylist2 = [func2(x02, data.v2, data.y02, data.angle2) for x02 in xlist2]
ylist3 = [func3(x03, data.v3, data.y03, data.angle3) for x03 in xlist3]
pylab.plot(xlist, ylist)
pylab.plot(xlist2, ylist2)
pylab.plot(xlist3, ylist3)
pylab.show()
app = Fly()
app.mainloop()
Full error:
Traceback (most recent call last):
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 12, in <module>
class MyData():
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 13, in MyData
v = IntVar()
File "D:Anaconda3libtkinter__init__.py", line 499, in __init__
Variable.__init__(self, master, value, name)
File "D:Anaconda3libtkinter__init__.py", line 314, in __init__
self._root = master._root()
AttributeError: 'NoneType' object has no attribute '_root'
Is this error resolved or will I have to make another decision algorithm?
Just yesterday, I had another problem with global
andnonlocal
python python-3.x matplotlib tkinter
marked as duplicate by Bryan Oakley
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 16 '18 at 12:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Tkinter radiobutton IntVar Attribute error
1 answer
I don't know how to solve this problem and have no idea why she appeared.
What to do to fix it?
Other people's similar problems are somehow related to the StringVar
variable, I think this code is not the same error.
import matplotlib
from math import *
import pylab
from matplotlib import mlab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import tkinter as tk
from tkinter import ttk
from tkinter import *
g = 9.81
class MyData():
v = IntVar()
angle = IntVar()
x0 = IntVar()
y0 = IntVar()
v2 = IntVar()
angle2 = IntVar()
x02 = IntVar()
y02 = IntVar()
v3 = IntVar()
angle3 = IntVar()
x03 = IntVar()
y03 = IntVar()
class Fly(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.wm_title(self, "Fly")
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames =
data = MyData
for F in (StartPage, PageOne):
frame = F(container, self, data)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Начальная страница")
label.pack(pady=10, padx=10)
button = ttk.Button(self, text="Visit Page 1",
command=lambda: controller.show_frame(PageOne))
button.pack()
frame2 = Frame(self, borderwidth=4, relief=GROOVE)
frame2.pack()
first = Label(self, text='Данные для первого графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x0)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y0)
entry.pack()
frame3 = Frame(self, borderwidth=4, relief=GROOVE)
frame3.pack()
first = Label(self, text='Данные для второго графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v2)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle2)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x02)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y02)
entry.pack()
first = Label(self, text='Данные для третьего графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v3)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle3)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x03)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y03)
entry.pack()
class PageOne(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Generate")
label.pack(pady=10, padx=10)
button1 = ttk.Button(self, text="Поменять значения",
command=lambda: controller.show_frame(StartPage))
button1.pack()
f = Figure(figsize=(5, 5), dpi=100)
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
t = ((2 * data.v * sin(data.angle)) / g)
vx = data.v * cos(data.angle)
t2 = ((2 * data.v2 * sin(data.angle2)) / g)
vx2 = data.v2 * cos(data.angle2)
t3 = ((2 * data.v3 * sin(data.angle3)) / g)
vx3 = data.v3 * cos(data.angle3)
dx = 0.01
xmin = data.x0
xmax = vx * t * cos(data.angle)
xmin2 = data.x02
xmax2 = vx2 * t2 * cos(data.angle2)
xmin3 = data.x03
xmax3 = vx3 * t3 * cos(data.angle3)
def func(x0, v, y0, angle):
y = x0 * tan(angle) - (1 / (2 * v ** 2)) * ((g * x0 ** 2) / (cos(angle) ** 2)) + y0
if y == 0:
return 0.0
return y
def func2(x02, v2, y02, angle2):
y2 = x02 * tan(angle2) - (1 / (2 * v2 ** 2)) * ((g * x02 ** 2) / (cos(angle2) ** 2)) + y02
if y2 == 0:
return 0.0
return y2
def func3(x03, v3, y03, angle3):
y3 = x03 * tan(angle3) - (1 / (2 * v3 ** 2)) * ((g * x03 ** 2) / (cos(angle3) ** 2)) + y03
if y3 == 0:
return 0.0
return y3
xlist = mlab.frange(xmin, xmax, dx)
xlist2 = mlab.frange(xmin2, xmax2, dx)
xlist3 = mlab.frange(xmin3, xmax3, dx)
ylist = [func(x0, data.v, data.y0, data.angle) for x0 in xlist]
ylist2 = [func2(x02, data.v2, data.y02, data.angle2) for x02 in xlist2]
ylist3 = [func3(x03, data.v3, data.y03, data.angle3) for x03 in xlist3]
pylab.plot(xlist, ylist)
pylab.plot(xlist2, ylist2)
pylab.plot(xlist3, ylist3)
pylab.show()
app = Fly()
app.mainloop()
Full error:
Traceback (most recent call last):
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 12, in <module>
class MyData():
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 13, in MyData
v = IntVar()
File "D:Anaconda3libtkinter__init__.py", line 499, in __init__
Variable.__init__(self, master, value, name)
File "D:Anaconda3libtkinter__init__.py", line 314, in __init__
self._root = master._root()
AttributeError: 'NoneType' object has no attribute '_root'
Is this error resolved or will I have to make another decision algorithm?
Just yesterday, I had another problem with global
andnonlocal
python python-3.x matplotlib tkinter
marked as duplicate by Bryan Oakley
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 16 '18 at 12:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Nonetype
usually means the function expected a value, but it got none, which meansmaster
should be holding a value, which it isn't, hence the error.
– Infected Drake
Nov 16 '18 at 7:45
add a comment |
This question already has an answer here:
Tkinter radiobutton IntVar Attribute error
1 answer
I don't know how to solve this problem and have no idea why she appeared.
What to do to fix it?
Other people's similar problems are somehow related to the StringVar
variable, I think this code is not the same error.
import matplotlib
from math import *
import pylab
from matplotlib import mlab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import tkinter as tk
from tkinter import ttk
from tkinter import *
g = 9.81
class MyData():
v = IntVar()
angle = IntVar()
x0 = IntVar()
y0 = IntVar()
v2 = IntVar()
angle2 = IntVar()
x02 = IntVar()
y02 = IntVar()
v3 = IntVar()
angle3 = IntVar()
x03 = IntVar()
y03 = IntVar()
class Fly(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.wm_title(self, "Fly")
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames =
data = MyData
for F in (StartPage, PageOne):
frame = F(container, self, data)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Начальная страница")
label.pack(pady=10, padx=10)
button = ttk.Button(self, text="Visit Page 1",
command=lambda: controller.show_frame(PageOne))
button.pack()
frame2 = Frame(self, borderwidth=4, relief=GROOVE)
frame2.pack()
first = Label(self, text='Данные для первого графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x0)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y0)
entry.pack()
frame3 = Frame(self, borderwidth=4, relief=GROOVE)
frame3.pack()
first = Label(self, text='Данные для второго графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v2)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle2)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x02)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y02)
entry.pack()
first = Label(self, text='Данные для третьего графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v3)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle3)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x03)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y03)
entry.pack()
class PageOne(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Generate")
label.pack(pady=10, padx=10)
button1 = ttk.Button(self, text="Поменять значения",
command=lambda: controller.show_frame(StartPage))
button1.pack()
f = Figure(figsize=(5, 5), dpi=100)
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
t = ((2 * data.v * sin(data.angle)) / g)
vx = data.v * cos(data.angle)
t2 = ((2 * data.v2 * sin(data.angle2)) / g)
vx2 = data.v2 * cos(data.angle2)
t3 = ((2 * data.v3 * sin(data.angle3)) / g)
vx3 = data.v3 * cos(data.angle3)
dx = 0.01
xmin = data.x0
xmax = vx * t * cos(data.angle)
xmin2 = data.x02
xmax2 = vx2 * t2 * cos(data.angle2)
xmin3 = data.x03
xmax3 = vx3 * t3 * cos(data.angle3)
def func(x0, v, y0, angle):
y = x0 * tan(angle) - (1 / (2 * v ** 2)) * ((g * x0 ** 2) / (cos(angle) ** 2)) + y0
if y == 0:
return 0.0
return y
def func2(x02, v2, y02, angle2):
y2 = x02 * tan(angle2) - (1 / (2 * v2 ** 2)) * ((g * x02 ** 2) / (cos(angle2) ** 2)) + y02
if y2 == 0:
return 0.0
return y2
def func3(x03, v3, y03, angle3):
y3 = x03 * tan(angle3) - (1 / (2 * v3 ** 2)) * ((g * x03 ** 2) / (cos(angle3) ** 2)) + y03
if y3 == 0:
return 0.0
return y3
xlist = mlab.frange(xmin, xmax, dx)
xlist2 = mlab.frange(xmin2, xmax2, dx)
xlist3 = mlab.frange(xmin3, xmax3, dx)
ylist = [func(x0, data.v, data.y0, data.angle) for x0 in xlist]
ylist2 = [func2(x02, data.v2, data.y02, data.angle2) for x02 in xlist2]
ylist3 = [func3(x03, data.v3, data.y03, data.angle3) for x03 in xlist3]
pylab.plot(xlist, ylist)
pylab.plot(xlist2, ylist2)
pylab.plot(xlist3, ylist3)
pylab.show()
app = Fly()
app.mainloop()
Full error:
Traceback (most recent call last):
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 12, in <module>
class MyData():
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 13, in MyData
v = IntVar()
File "D:Anaconda3libtkinter__init__.py", line 499, in __init__
Variable.__init__(self, master, value, name)
File "D:Anaconda3libtkinter__init__.py", line 314, in __init__
self._root = master._root()
AttributeError: 'NoneType' object has no attribute '_root'
Is this error resolved or will I have to make another decision algorithm?
Just yesterday, I had another problem with global
andnonlocal
python python-3.x matplotlib tkinter
This question already has an answer here:
Tkinter radiobutton IntVar Attribute error
1 answer
I don't know how to solve this problem and have no idea why she appeared.
What to do to fix it?
Other people's similar problems are somehow related to the StringVar
variable, I think this code is not the same error.
import matplotlib
from math import *
import pylab
from matplotlib import mlab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import tkinter as tk
from tkinter import ttk
from tkinter import *
g = 9.81
class MyData():
v = IntVar()
angle = IntVar()
x0 = IntVar()
y0 = IntVar()
v2 = IntVar()
angle2 = IntVar()
x02 = IntVar()
y02 = IntVar()
v3 = IntVar()
angle3 = IntVar()
x03 = IntVar()
y03 = IntVar()
class Fly(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
tk.Tk.wm_title(self, "Fly")
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames =
data = MyData
for F in (StartPage, PageOne):
frame = F(container, self, data)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Начальная страница")
label.pack(pady=10, padx=10)
button = ttk.Button(self, text="Visit Page 1",
command=lambda: controller.show_frame(PageOne))
button.pack()
frame2 = Frame(self, borderwidth=4, relief=GROOVE)
frame2.pack()
first = Label(self, text='Данные для первого графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x0)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y0)
entry.pack()
frame3 = Frame(self, borderwidth=4, relief=GROOVE)
frame3.pack()
first = Label(self, text='Данные для второго графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v2)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle2)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x02)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y02)
entry.pack()
first = Label(self, text='Данные для третьего графика')
first.pack()
second = Label(self, text='Начальная скорость')
second.pack()
entry = Entry(self, width=10, textvariable=data.v3)
entry.pack()
third = Label(self, text='Угол выстрела')
third.pack()
entry = Entry(self, width=10, textvariable=data.angle3)
entry.pack()
fourth = Label(self, text='Начальная координата x')
fourth.pack()
entry = Entry(self, width=10, textvariable=data.x03)
entry.pack()
fifth = Label(self, text='Начальная координата y')
fifth.pack()
entry = Entry(self, width=10, textvariable=data.y03)
entry.pack()
class PageOne(tk.Frame):
def __init__(self, parent, controller, data):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Generate")
label.pack(pady=10, padx=10)
button1 = ttk.Button(self, text="Поменять значения",
command=lambda: controller.show_frame(StartPage))
button1.pack()
f = Figure(figsize=(5, 5), dpi=100)
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
t = ((2 * data.v * sin(data.angle)) / g)
vx = data.v * cos(data.angle)
t2 = ((2 * data.v2 * sin(data.angle2)) / g)
vx2 = data.v2 * cos(data.angle2)
t3 = ((2 * data.v3 * sin(data.angle3)) / g)
vx3 = data.v3 * cos(data.angle3)
dx = 0.01
xmin = data.x0
xmax = vx * t * cos(data.angle)
xmin2 = data.x02
xmax2 = vx2 * t2 * cos(data.angle2)
xmin3 = data.x03
xmax3 = vx3 * t3 * cos(data.angle3)
def func(x0, v, y0, angle):
y = x0 * tan(angle) - (1 / (2 * v ** 2)) * ((g * x0 ** 2) / (cos(angle) ** 2)) + y0
if y == 0:
return 0.0
return y
def func2(x02, v2, y02, angle2):
y2 = x02 * tan(angle2) - (1 / (2 * v2 ** 2)) * ((g * x02 ** 2) / (cos(angle2) ** 2)) + y02
if y2 == 0:
return 0.0
return y2
def func3(x03, v3, y03, angle3):
y3 = x03 * tan(angle3) - (1 / (2 * v3 ** 2)) * ((g * x03 ** 2) / (cos(angle3) ** 2)) + y03
if y3 == 0:
return 0.0
return y3
xlist = mlab.frange(xmin, xmax, dx)
xlist2 = mlab.frange(xmin2, xmax2, dx)
xlist3 = mlab.frange(xmin3, xmax3, dx)
ylist = [func(x0, data.v, data.y0, data.angle) for x0 in xlist]
ylist2 = [func2(x02, data.v2, data.y02, data.angle2) for x02 in xlist2]
ylist3 = [func3(x03, data.v3, data.y03, data.angle3) for x03 in xlist3]
pylab.plot(xlist, ylist)
pylab.plot(xlist2, ylist2)
pylab.plot(xlist3, ylist3)
pylab.show()
app = Fly()
app.mainloop()
Full error:
Traceback (most recent call last):
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 12, in <module>
class MyData():
File "C:/Users/Максим/PycharmProjects/test/test1.py", line 13, in MyData
v = IntVar()
File "D:Anaconda3libtkinter__init__.py", line 499, in __init__
Variable.__init__(self, master, value, name)
File "D:Anaconda3libtkinter__init__.py", line 314, in __init__
self._root = master._root()
AttributeError: 'NoneType' object has no attribute '_root'
Is this error resolved or will I have to make another decision algorithm?
Just yesterday, I had another problem with global
andnonlocal
This question already has an answer here:
Tkinter radiobutton IntVar Attribute error
1 answer
python python-3.x matplotlib tkinter
python python-3.x matplotlib tkinter
asked Nov 16 '18 at 6:53
MxxnMxxn
104
104
marked as duplicate by Bryan Oakley
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 16 '18 at 12:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Bryan Oakley
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 16 '18 at 12:35
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Nonetype
usually means the function expected a value, but it got none, which meansmaster
should be holding a value, which it isn't, hence the error.
– Infected Drake
Nov 16 '18 at 7:45
add a comment |
Nonetype
usually means the function expected a value, but it got none, which meansmaster
should be holding a value, which it isn't, hence the error.
– Infected Drake
Nov 16 '18 at 7:45
Nonetype
usually means the function expected a value, but it got none, which means master
should be holding a value, which it isn't, hence the error.– Infected Drake
Nov 16 '18 at 7:45
Nonetype
usually means the function expected a value, but it got none, which means master
should be holding a value, which it isn't, hence the error.– Infected Drake
Nov 16 '18 at 7:45
add a comment |
1 Answer
1
active
oldest
votes
You need to create the root widget before creating the IntVar object, please check here.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to create the root widget before creating the IntVar object, please check here.
add a comment |
You need to create the root widget before creating the IntVar object, please check here.
add a comment |
You need to create the root widget before creating the IntVar object, please check here.
You need to create the root widget before creating the IntVar object, please check here.
answered Nov 16 '18 at 7:00
yunfengyunfeng
6615
6615
add a comment |
add a comment |
Nonetype
usually means the function expected a value, but it got none, which meansmaster
should be holding a value, which it isn't, hence the error.– Infected Drake
Nov 16 '18 at 7:45