2013-05-13 2 views
0

tk inter는 특정 사용자 이름과 암호가 특정 파일을 여는 데 사용됩니다. 관리자가 로그인하면 관리자 페이지로 이동하게됩니다.tkinter python에서 사용자 이름과 암호를 설정하는 방법

from Tkinter import * 

root = Tk() 

w = Label(root, text="LiftServer(Sign-in)") 
w.pack() 

e1 = Label(root, text="******************************") 
e1.pack() 

w1 = Label(root, text="Username") 
w1.pack() 

e = Entry(root) 
e.pack() 

w2 = Label(root, text="Password") 
w2.pack() 

e1 = Entry(root) 
e1.pack() 

toolbar = Frame(root) 


b = Button(toolbar, text="Enter", width=9) 
b.pack(side=LEFT, padx=2, pady=2) 

b = Button(toolbar, text="Cancel", width=9) 
b.pack(side=LEFT, padx=2, pady=2) 

def callback(): 
    execfile("signup.txt") 
b = Button(toolbar, text="Sign-Up", command=callback, width=9) 
b.pack(side=LEFT, padx=2, pady=2) 

toolbar.pack(side=TOP, fill=X) 

mainloop() 

답변

0

완전히 확실하지

def callback(): 
    if w.get() == "Bob" and w2.get() == "password": 
     openfile('file1') 
    else: 
     openfile('file2') 
+0

예외는 Tkinter 콜백 역 추적 (가장 최근 통화 마지막)에서 .. 당신은 요구하고 있지만이이 답을 생각 : 파일 "C : \ Python27 \ DLL을 \ C :/Documents and Settings/1209131/Desktop/ftg "파일, 콜백 에있는"C :/Documents and Settings/1209131/Desktop/ftg "파일 : 반환 self.func (* args) w1.GetValue() == "Bob"및 w2.GetValue() == "password": AttributeError : 레이블 인스턴스에 없음 tribute 'GetValue'get 값이 잘못된 것처럼 보입니다. –

+0

thats 내가 말한 것 ... 텍스트 상자에 대해 "GetValue"에 사용하는 방법을 사용해야합니다. 실제로 2 초 동안 인터넷에 연결하면 get() 대신에'GetValue()'... –

관련 문제