擅长:python、mysql、java
<p>首先创建一组<code>IntVar</code>,并将它们保存为<code>Joes_auto</code>实例的属性</p>
<pre><code>self.oil_change = tkinter.IntVar()
</code></pre>
<p>等等,但是你用</p>
^{pr2}$
<p>所以现在<code>self.oil_change</code>引用Checkbutton,而不是IntVar。这就是为什么会出现这样的错误:IntVar有一个<code>.get</code>方法,但是Checkbutton小部件没有</p>
<p>所以你需要给你的checkbutton取不同于它们相关联的IntVars的名字。或者不用给他们起永久性的名字,就这么做吧</p>
<pre><code>b = tkinter.Checkbutton(self.top_frame, text = 'Oil Change ($30)',
variable=self.oil_change)
b.pack()
b = tkinter.Checkbutton(self.top_frame, text = 'Lube Job ($20)',
variable=self.lube_job)
b.pack()
</code></pre>
<p>等等(我去掉了那些反斜杠-你不需要它们,因为你要在括号里继续一行。这也适用于方括号和大括号中)。在</p>
<hr/>
<p>顺便说一句,你可以通过改变</p>
<pre><code>import tkinter
</code></pre>
<p>到</p>
<pre><code>import tkinter as tk
</code></pre>
<p>那你就可以了</p>
<pre><code>b = tk.Checkbutton(self.top_frame, text = 'Oil Change ($30)', variable=self.oil_change)
</code></pre>
<p>等等</p>