On Jan 5, 11:52 am, Collin D <collin.da...@gmail.com> wrote: > On Jan 5, 6:25 am, "Djames Suhanko" <djames.suha...@gmail.com> wrote: > > > > > Hello! > > I'm sorry my terrible english (my native language is portuguese). > > I has a litle program that open another window. When I close de root > > window in quit button, I need clicking 2 times to close. is where the > > problem? > > > The source: > > 1 #!/usr/bin/env python > > 2 from Tkinter import * > > 3 import sys > > 4 import random > > 5 class App: > > 6 def __init__(self, master): > > 7 frame = Frame(master) > > 8 frame.pack() > > 9 rotulo = Label(frame, text="Clique em 'Gerar' e boa > > sorte!",borderwidth=2,bg="gray",justify=C ENTER,relief=SUNKEN) > > 10 rotulo.pack() > > 11 > > 12 self.button = Button(frame, text="Sair", fg="red", > > command=frame.quit,borderwidth=1) > > 13 self.button.pack(side=LEFT) > > 14 self.hi_there = Button(frame, text="Gerar Numero", > > command=self.say_hi,borderwidth=1) > > 15 self.hi_there.pack(side=RIGHT,padx=2,pady=2) > > 16 > > 17 def gera_seis(self): > > 18 a = {} > > 19 for i in range(6): > > 20 a[i] = "%02d" % int (random.randint(0,60)) > > 21 resultadoA = "%s-%s-%s-%s-%s-%s" % > > (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) > > 22 return resultadoA > > 23 > > 24 def say_hi(self): > > 25 resultado = self.gera_seis() > > 26 raiz = Tk() > > 27 F = Frame(raiz) > > 28 F.pack() > > 29 hello = Label(F, text=resultado) > > 30 hello.pack() > > 31 F.mainloop() > > 32 > > 33 root = Tk() > > 34 root.title("$$$ Loteria $$$") > > 35 app = App(root) > > 36 root.mainloop() > > > -- > > Djames Suhanko > > LinuxUser 158.760 > > Also for style, you might want to group the import lines so they look > like this: > > from Tkinter import * > import sys, random > > A bit more pythonic. :P
In that case you probably want to take out the 'from' import and: import Tkinter, sys, random in order to avoid any namespace issues especially if you have a large project with lots of gui manipulations. But that's just me being pedantic. ;) -- http://mail.python.org/mailman/listinfo/python-list