我在使用类abd的tkinter我在添加产品时遇到了问题
class Add_Page():
def __init__(self, child):
self.child = child
child.title = "Ajouter"
self.l1=Label(child,text="Ajouter produit :",bg="blue").grid(row=0,columnspan=2)
self.l2=Label(child,text="Matricule").grid(row=1,column=0)
self.vlrm = StringVar()
self.en2 = Entry(child, textvariable=self.vlrm, width=30).grid(row=1,column=1)
self.l3=Label(child,text="Nom").grid(row=2,column=0)
self.vlrn = StringVar()
self.en3 = Entry(child, textvariable=self.vlrn, width=30).grid(row=2,column=1)
self.l4=Label(child,text="Prix").grid(row=3,column=0)
self.vlrp = IntVar()
self.en4 = Entry(child, textvariable=self.vlrp, width=30).grid(row=3,column=1)
self.b2=Button(child,text="Valider",command=self.add_p).grid(row=4,columnspan=2)
#Add product function
def add_p(self):
print(self.vlrm.get())
print(self.vlrp.get())
结果是一个空链和0 我似乎没有发现这个问题,特别是我在users类中使用了get方法,它工作得很好 希普
你不需要创建一个变量来输入,只需要为radiobutton或checkbutton创建一个变量。你可以改变tkinter对象的创建,就像这样
改变这个
为了这个
如果将来需要使用.config或.get()进行一些更改,则可以在第一个示例中进行更改。您可以继续使用variable,但我不建议这样做,如果您进行此更改,get()现在就可以工作了
我在tkinter中做了一个简单的画法,可以使用也可以修改,是针对Python2的
相关问题 更多 >
编程相关推荐