ผมเจอปัญหาในการทำหน้าล็อคอินเพื่อเชื่อมไปอีกหน้านึงครับ ผมทำส่วนหน้าต่าง2ก่อนครับ พอผมทำเสร็จรันใช้ได้ปกติ แต่พอมาสร้างหน้าล็อคอินก็เจอปัญหาแก้ไม่ตกครับ

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python31\lib\tkinter_init_.py", line 1399, in call
return self.func(*args)
File "C:/Users/ADMN/Desktop/as", line 5, in chkbutton_value
if (var1.get()==1):
NameError: global name 'var1' is not defined

ส่วนนี่โค๊ดครับ

from tkinter import*
from tkinter import messagebox

def chkbutton_value():
if (var1.get()==1):
spin1.configure(state=NORMAL)
elif var1.get()==0:

    E_Latte.set('0')
if (var2.get()==1):
    spin2.configure(state=NORMAL)
elif var2.get()==0:
    
    E_Mocha.set('0')
if (var3.get()==1):
    spin3.configure(state=NORMAL)
elif var3.get()==0:
    E_Iced_Tea.set('0')
if (var4.get()==1):
    spin4.configure(state=NORMAL)
elif var4.get()==0:
    E_Espresso.set('0')
if (var5.get()==1):
    spin5.configure(state=NORMAL)
elif var5.get()==0:
    E_Macchiato.set('0')
if (var6.get()==1):
    spin6.configure(state=NORMAL)
elif var6.get()==0:
    E_Green_Tea.set('0')
if (var7.get()==1):
    spin7.configure(state=NORMAL)
elif var7.get()==0:
    E_Americano.set('0')
if (var8.get()==1):
    spin8.configure(state=NORMAL)
elif var8.get()==0:
    E_Cappuccino.set('0')

def mHello():
if ertUsername.get() == "a" and ertPassword.get()=="s" :
global roots
roots = Tk()
roots.geometry('500x500+0+0')

    text_Input = StringVar()
    operator =''

    f1 = Frame(roots, width = 900, height = 650, bd=8, relief='raise')
    f1.pack(side=LEFT)
    f2 = Frame(roots, width = 440, height = 650, bd=8, relief='raise')
    f2.pack(side=RIGHT)
    f1.configure(background='Wheat')
    f2.configure(background='Wheat')

    f1a = Frame(f1, width = 900, height = 330, bd=12, relief='raise',bg='Wheat')
    f1a.pack(side=TOP)
    
    f1aa = Frame(f1a, width = 400, height = 330, bd=16,  relief='raise',bg='Light Coral')
    f1aa.pack(side=LEFT)

    var1= IntVar()
    var2= IntVar()
    var3= IntVar()
    var4= IntVar()
    var5= IntVar()
    var6= IntVar()
    var7= IntVar()
    var8= IntVar()
    var9= IntVar()
    var10= IntVar()
    var11= IntVar()
    var12= IntVar()
    var13= IntVar()
    var14= IntVar()
    var15= IntVar()
    var16= IntVar()

    E_Latte=StringVar()
    E_Mocha=StringVar()
    E_Iced_Tea=StringVar()
    E_Espresso=StringVar()
    E_Macchiato=StringVar()
    E_Green_Tea=StringVar()
    E_Americano=StringVar()
    E_Cappuccino=StringVar()

    E_Latte.set('0')
    E_Mocha.set('0')
    E_Iced_Tea.set('0')
    E_Espresso.set('0')
    E_Macchiato.set('0')
    E_Green_Tea.set('0')
    E_Americano.set('0')
    E_Cappuccino.set('0')

    Latte  = Checkbutton(f1aa,text='Latte  \t',variable = var1, onvalue = 1, offvalue = 0,
                font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=0,sticky=W)
    Mocha = Checkbutton(f1aa,text='Mocha \t\t',variable = var2, onvalue = 1, offvalue = 0,
                        font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=1,sticky=W)
    Iced_Tea = Checkbutton(f1aa,text='Iced Tea \t\t',variable = var3, onvalue = 1, offvalue = 0,
                        font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=2,sticky=W)
    Espresso = Checkbutton(f1aa,text='Espresso \t\t',variable = var4, onvalue = 1, offvalue = 0,
                        font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=3,sticky=W)
    Macchiato = Checkbutton(f1aa,text='Macchiato \t\t',variable = var5, onvalue = 1, offvalue = 0,
                        font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=4,sticky=W)
    Green_Tea = Checkbutton(f1aa,text='Green Tea \t\t',variable = var6, onvalue = 1, offvalue = 0,
                        font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=5,sticky=W)
    Americano = Checkbutton(f1aa,text='Americano \t\t',variable = var7, onvalue = 1, offvalue = 0,
                        font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=6,sticky=W)
    Cappuccino = Checkbutton(f1aa,text='Cappuccino \t\t',variable = var8, onvalue = 1, offvalue = 0,
                        font=('arial',22,'bold'),command=chkbutton_value,bg='Light Coral').grid(row=7,sticky=W)

    spin1 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,justify='left',textvariable=E_Latte ,state=DISABLED,bg='Mistyrose')
    spin1.grid(row=0,column=1)
    spin2 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,\
        justify='left',textvariable=E_Mocha,state=DISABLED,bg='Mistyrose')
    spin2.grid(row=1,column=1)
    spin3 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,\
        justify='left',textvariable=E_Iced_Tea,state=DISABLED,bg='Mistyrose')
    spin3.grid(row=2,column=1)
    spin4 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,\
        justify='left',textvariable=E_Espresso,state=DISABLED,bg='Mistyrose')
    spin4.grid(row=3,column=1)
    spin5 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,\
        justify='left',textvariable=E_Macchiato,state=DISABLED,bg='Mistyrose')
    spin5.grid(row=4,column=1)
    spin6 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,\
        justify='left',textvariable=E_Green_Tea,state=DISABLED,bg='Mistyrose')
    spin6.grid(row=5,column=1)
    spin7 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,\
        justify='left',textvariable=E_Americano,state=DISABLED,bg='Mistyrose')
    spin7.grid(row=6,column=1)
    spin8 = Spinbox(f1aa,from_=0,to=100,font=('arial',16,'bold'),bd=8,width=6,\
        justify='left',textvariable=E_Cappuccino,state=DISABLED,bg='Mistyrose')
    spin8.grid(row=7,column=1)

    pass
else :
    messagebox.showerror("Error","User Not Found")

root = Tk()
root.geometry("275x85")
root.title('Starducks Coffee Systems')
Label(text = "Username",font=('arial',13,'bold')).grid(row=0,column=2)
ertUsername = Entry(font=('arial',13,'bold'))
ertUsername.grid(row=0, column=3)
Label(text = "Password",font=('arial',13,'bold')).grid(row=1,column=2)
ertPassword = Entry(font=('arial',13,'bold'),show='*')
ertPassword.grid(row=1, column=3)

Button(text = "Login ",font=('arial',13,'bold'),command = mHello).grid(row=2, column=3,sticky=W)

root.mainloop()

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

totiz Mon, 25/12/2017 - 10:33

def chkbutton_value():
if (var1.get()==1):
spin1.configure(state=NORMAL)

ใน func chkbutton_value ตัวแปร var1 ไม่ได้ส่งค่าเข้ามา