[Tkinter] problem
Club-B42
club4_2 at mail.ru
Sat Jan 29 21:20:16 EST 2005
when i start opt_newlogin.py directly it works fine(outputs '1 1 1 1'),
but if i start it from options.py there is an error(outputs '').
========
opt_newlogin.py
========
from config import *
from Tkinter import *
from opt_newlogin import newlogin
def OptionsWindow():
"""
"""
root = Tk()
root.title(msg_OptionsWindowTitle)
b1 = Button(root, text = msgForgotPassword, width = 40).grid(padx = 5,
pady = 5, column = 0, row = 0)
b2 = Button(root, text = msgNewLogin, command = newlogin, width =
40).grid(padx = 5, pady = 5, column = 0, row = 1)
root.mainloop()
if __name__ == '__main__':
OptionsWindow()
========
========
options.py
========
from config import *
from Tkinter import *
import tkMessageBox, os.path
def create_new_account(login, password, secretq, secreta):
print login, password, secretq, secreta
if os.path.exists(os.path.join(data_path, login)):
tkMessageBox.showerror(title = msgError, message =
msgPasswordLoginExists)
elif login == '':
pass
else:
os.mkdir(os.path.join(data_path, login))
fd = file(os.path.join(data_path, login, data_info_file_name),
'wb')
fd.write(password + os.linesep)
fd.write(secretq + os.linesep)
fd.write(secreta + os.linesep)
fd.close()
tkMessageBox.showinfo(title = msgInfoAccountCreated, message =
msgInfoAccountCreated2)
def newlogin():
"""
"""
root = Tk()
root.title(msg_NewLoginWindowTitle)
l1 = Label(root, text = msgLogin).grid(padx = 5, pady = 5, column = 0,
row = 0, sticky = E)
l2 = Label(root, text = msgPassword).grid(padx = 5, pady = 5, column =
0, row = 1, sticky = E)
l3 = Label(root, text = msgConfirmPassword).grid(padx = 5, pady = 5,
column = 0, row = 2, sticky = E)
l4 = Message(root, text = msgKeyQuestion, width = 250).grid(padx = 5,
pady = 5, column = 0, row = 3, sticky = E)
l5 = Label(root, text = msgKeyQuestionAnswer).grid(padx = 5, pady = 5,
column = 0, row = 4, sticky = E)
v1 = StringVar()
v2 = StringVar()
v3 = StringVar()
v4 = StringVar()
v5 = StringVar()
e1 = Entry(root, width = 50, textvariable = v1)
e1.grid(padx = 5, pady = 5, column = 1, row = 0)
e1.focus_force()
e2 = Entry(root, width = 50, textvariable = v2, show = '*')
e2.grid(padx = 5, pady = 5, column = 1, row = 1)
e3 = Entry(root, width = 50, textvariable = v3, show = '*')
e3.grid(padx = 5, pady = 5, column = 1, row = 2)
e4 = Entry(root, width = 50, textvariable = v4)
e4.grid(padx = 5, pady = 5, column = 1, row = 3)
e5 = Entry(root, width = 50, textvariable = v5, show = '*')
e5.grid(padx = 5, pady = 5, column = 1, row = 4)
def b1_cmd():
if v2.get() <> v3.get():
tkMessageBox.showerror(title = msgError, message =
msgPasswordConfirmError)
print v1.get(), v2.get(), v4.get(), v5.get()
create_new_account(v1.get(), v2.get(), v4.get(), v5.get())
b1 = Button(root, text = msgCreateNewLoginButton, command =
b1_cmd).grid(padx = 5, pady = 5, column = 0, row = 5)
b2 = Button(root, text = msgCancelButton, command =
root.destroy).grid(padx = 5, pady = 5, column = 1, row = 5)
root.mainloop()
if __name__ == '__main__':
newlogin()
========
========
config.py
========
# codepage = cp1251
#
#
#
def u(s):
return unicode(s, 'cp1251')
msgMainWindowTitle = u('Менеджер сохранялок клуба B 4\\2')
msgLogin = u('Логин')
msgPassword = u('Пароль')
msgGameNumber = u('Номер игры')
msgSaveButton = u(' Сохранить ')
msgLoadButton = u(' Загрузить ')
msgOptionsButton = u(' Дополнительно ')
msg_OptionsWindowTitle = u('Дополнительно')
msgForgotPassword = u(' Забыл пароль ')
msgNewLogin = u(' Новый логин ')
msg_NewLoginWindowTitle = u('Создание нового логина')
msgConfirmPassword = u('Еще раз пароль')
msgKeyQuestion = u('Секретный вопрос - ответ на
который знаете только вы - на случай, если вы забудете пароль')
msgKeyQuestionAnswer = u('Ответ на секретный вопрос')
msgCreateNewLoginButton = u(' Создать ')
msgCancelButton = u(' Отмена ')
msgError = u('Ошибка')
msgPasswordConfirmError = u('Пароли не совпадают.')
msgPasswordLoginExists = u('Такой логин уже существует.')
msgInfoAccountCreated = u('Логин успешно зарегестрирован')
msgInfoAccountCreated2 = u('Вы можете использовать этот логин
и пароль для сохранения и востановления своих сохранялок.')
msgInvalidGameNumber = u('Неправильный номер игры.')
msgInvalidPassword = u('Неправильный пароль.')
msgInvalidLogin = u('Логин не существует.')
msgSaveError = u('Не удалось скопировать.')
msgSuccess = u('Сохранено')
msgSuccessCopy = u('Сохранялки успешно сохранены на
сервер, теперь вы можете восстановить их на любом компьютере.')
data_path = '\\\\192.168.1.1\\Сохранялки\\'
data_info_file_name = 'info'
info_path = 'info'
========
More information about the Python-list
mailing list