Текущее:
Код: Выделить всё
from tkinter import *
class LoginWindow(object):
def __init__(self, parent):
self.parent=parent
self.data=None #Default value, to say its not been set yet
self.root=Toplevel(self.parent)
self.root.transient(self.parent)
self.username=Entry(self.root)
self.password=Entry(self.root, show="*")
self.ok=Button(self.root, text="Continue", command=self.check_pass); self.ok.grid(row=5, column=2, sticky="ew")
self.cancel=Button(self.root, text="Cancel", command=self.cancel_pass); self.cancel.grid(row=5, column=1, sticky="ew")
def check_pass(self):
self.data=(self.username.get(), self.password.get())
self.root.quit()
def cancel_pass(self):
self.data=False
self.root.quit()
parent=Tk()
pass_window=LoginWindow(parent)
#....? how do I get pass_window.data from the window, considering it will only be defined
#to be something besides None once the user has clicked the continue button
Есть идеи?
Подробнее здесь: https://stackoverflow.com/questions/285 ... put-window