On Mon, 05 Jan 2009 12:25:53 -0200, Djames Suhanko wrote: > 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? > > […] > > 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
Not the problem but unnecessary complex. `random.randint()` already returns an int, no need to call `int()` on it. The string formatting with ``%`` returns strings, so there is no need to call `str()` on the values. Even if the values where not strings: The '%s' place holder implies a call to `str()` while formatting. If you put something into a dictionary with consecutive `int` keys, you might use a list instead. All this can be written as a simple one liner:: '-'.join(str(random.randint(0, 60)) for dummy in xrange(6)) > 24 def say_hi(self): > 25 resultado = self.gera_seis() > 26 raiz = Tk() The problem is here… > 27 F = Frame(raiz) > 28 F.pack() > 29 hello = Label(F, text=resultado) 30 hello.pack() > 31 F.mainloop() …and here. There is only one `Tk` instance and mainloop allowed per `Tkinter` application. Otherwise really strange things can happen. Additional windows have to be created as `Toplevel` instances. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list