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_ OptionsWindowTi tle)
b1 = Button(root, text = msgForgotPasswo rd, 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_acco unt(login, password, secretq, secreta):
print login, password, secretq, secreta
if os.path.exists( os.path.join(da ta_path, login)):
tkMessageBox.sh owerror(title = msgError, message =
msgPasswordLogi nExists)
elif login == '':
pass
else:
os.mkdir(os.pat h.join(data_pat h, login))
fd = file(os.path.jo in(data_path, login, data_info_file_ name),
'wb')
fd.write(passwo rd + os.linesep)
fd.write(secret q + os.linesep)
fd.write(secret a + os.linesep)
fd.close()
tkMessageBox.sh owinfo(title = msgInfoAccountC reated, message =
msgInfoAccountC reated2)
def newlogin():
"""
"""
root = Tk()
root.title(msg_ NewLoginWindowT itle)
l1 = Label(root, text = msgLogin).grid( padx = 5, pady = 5, column = 0,
row = 0, sticky = E)
l2 = Label(root, text = msgPassword).gr id(padx = 5, pady = 5, column =
0, row = 1, sticky = E)
l3 = Label(root, text = msgConfirmPassw ord).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 = msgKeyQuestionA nswer).grid(pad x = 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.sh owerror(title = msgError, message =
msgPasswordConf irmError)
print v1.get(), v2.get(), v4.get(), v5.get()
create_new_acco unt(v1.get(), v2.get(), v4.get(), v5.get())
b1 = Button(root, text = msgCreateNewLog inButton, command =
b1_cmd).grid(pa dx = 5, pady = 5, column = 0, row = 5)
b2 = Button(root, text = msgCancelButton , command =
root.destroy).g rid(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')
msgMainWindowTi tle = u('Менеджер сохранялок клуба B 4\\2')
msgLogin = u('Логин')
msgPassword = u('Пароль')
msgGameNumber = u('Номер игры')
msgSaveButton = u(' Сохранить ')
msgLoadButton = u(' Загрузить ')
msgOptionsButto n = u(' Дополнительно ')
msg_OptionsWind owTitle = u('Дополнительн о')
msgForgotPasswo rd = u(' Забыл пароль ')
msgNewLogin = u(' Новый логин ')
msg_NewLoginWin dowTitle = u('Создание нового логина')
msgConfirmPassw ord = u('Еще раз пароль')
msgKeyQuestion = u('Секретный вопрос - ответ на
который знаете только вы - на случай, если вы забудете пароль')
msgKeyQuestionA nswer = u('Ответ на секретный вопрос')
msgCreateNewLog inButton = u(' Создать ')
msgCancelButton = u(' Отмена ')
msgError = u('Ошибка')
msgPasswordConf irmError = u('Пароли не совпадают.')
msgPasswordLogi nExists = u('Такой логин уже существует.')
msgInfoAccountC reated = u('Логин успешно зарегестрирован ')
msgInfoAccountC reated2 = u('Вы можете использовать этот логин
и пароль для сохранения и востановления своих сохранялок.')
msgInvalidGameN umber = u('Неправильный номер игры.')
msgInvalidPassw ord = u('Неправильный пароль.')
msgInvalidLogin = u('Логин не существует.')
msgSaveError = u('Не удалось скопировать.')
msgSuccess = u('Сохранено')
msgSuccessCopy = u('Сохранялки успешно сохранены на
сервер, теперь вы можете восстановить их на любом компьютере.')
data_path = '\\\\192.168.1. 1\\Сохранялки\\ '
data_info_file_ name = 'info'
info_path = 'info'
======== 1 2275
These lines if __name__ == '__main__': OptionsWindow()
mean "if this source code is the main program (not an imported module),
call OptionsWindow() ". So the behavior should be different when the
source code is the main program ('python opt_newlogin.py ') and when it's
imported ('python -c "import opt_newlogin"')
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFB/FvxJd01MZaTXX0R Al2AAJ9iWlFnPqV t30HvP37aJGgTQD SVYACaAvY+
UOjhSVekewUunon NAEZOMko=
=vqW0
-----END PGP SIGNATURE----- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Josh |
last post by:
Caution, newbie approaching...
I'm trying to come up with a very simple Tkinter test application that
consists of a window with a drop-down menu bar at the top and a grid
of colored rectangles filling the remainder of the window. Mind you,
this is a contrived test application to help me understand Tkinter and
Python, not an actual application yet. I've trivially subclassed
Tkinter.Canvas into ColorCanvas, added a bunch of ColorCanvases...
|
by: srijit |
last post by:
Hello,
Any idea - why the following code crashes on my Win 98 machine with
Python 2.3? Everytime I run this code, I have to reboot my machine.
I also have Win32all-157 installed.
from Tkinter import *
class App:
|
by: Paul A. Wilson |
last post by:
I'm new to Tkinter programming and am having trouble creating a
reusable button bar... I want to be able to feed my class a dictionary
of button names and function names, which the class will make.
My button bar is implemented a Frame subclass, which takes the button
dictionary as an argument and displays the buttons on the screen:
class OptionsBar(Frame):
def __init__(self, buttonDict, parent=None)
Frame.__init__(self, parent)
|
by: SeeBelow |
last post by:
Do many people think that wxPython should replace Tkinter? Is this
likely to happen?
I ask because I have just started learning Tkinter, and I wonder if I
should abandon it in favor of wxPython.
Mitchell Timin
--
"Many are stubborn in pursuit of the path they have chosen, few in
|
by: syed_saqib_ali |
last post by:
Below is a simple code snippet showing a Tkinter Window bearing a
canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine.
When you shrink/resize the window the scrollbars adjust accordingly.
However, what I really want to happen is that the area of the canvas
that the scrollbars show (the Scrollregion) should expand as the window
grows. It doesn't currently do this. although, if the window shrinks
smaller than the...
| |
by: Stewart Midwinter |
last post by:
this has me puzzled; I've created a small test app to show the problem
I'm having.
I want to use subprocess to execute system commands from inside a
Tkinter app running under Cygwin.
When I open a python interpreter and run my subprocess command, all is
well. But when I run the same command from inside a Tkinter app, I'm
getting errors.
|
by: Michael Yanowitz |
last post by:
Hello:
Below I have included a stripped down version of the GUI I am working on.
It contains 2 dialog boxes - one main and one settings. It has the following
problems, probably all related, that I am hoping someone knows what I am
doing wrong:
1) Pressing the Settings.. Button multiple times, brings up many instances
of the Settings Panel. I just want it to bring up one. Is there an easy
way to do that?
|
by: vigacmoe |
last post by:
Hi all,
I'm trying to write a simple tkinter program, then this problem popped
up. The followin code will describe the problem.
------------------------------------------
import Tkinter
class countdown(Tkinter.Frame):
|
by: wolfonenet |
last post by:
Hi All,
My setup is:
WinXP
Python 2.5.1
TKinter version: $Revision: 50704 $
Tcl: 8.4
Debugger: WinPdb
|
by: J-Burns |
last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in
programming itself... :P. Need some help here.
Problem 1:
How do I make something appear on 2 separate windows using Tkinter? By
this I mean that the format would be something like this:
You have Page1 : This has 2-3 buttons on it.
Clicking on each button opens up a new window respectively having
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we▓ll explore What is ONU, What Is Router, ONU & Router▓s main usage, and What is the difference between ONU and Router. Let▓s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |