Jump to content
Sign in to follow this  
Gooden

2 problemas com Python tk.

Recommended Posts

Gooden

BOm são 2 problemitas que me andam a chatiar 1 cadinho :)

1º O tk não está a funcionar no linux :| será de não reiniciar a maquina?

2º tou tentando fazer 1 mesagebox com o tk mas dame erro no modulo abaixo o código:

from Tkinter import *

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        self.button = Button(frame, text="Oi", command=self.diz_oi)
        self.button.pack(side=LEFT)
        
        self.button2 = Button(frame, text="Ola", command=self.diz_ola)
        self.button2.pack(side=LEFT)
        
        self.button3 = Button(frame, text="Especial", command=self.especial)
        self.button3.pack(side=LEFT)

    def diz_oi(self):
        tkMessageBox.showwarning("ola ","ola Meninos ")
        
    def diz_ola(self):
        tkMessageBox.showwarning("ola ","ola Meninos ")
        
    def especial(self):
        tkMessageBox.showwarning("ola ","ola Meninos ")

root = Tk()

app = App(root)

root.mainloop()

erro:

Exception in Tkinter callback

Traceback (most recent call last):

  File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__

    return self.func(*args)

  File "C:\Documents and Settings\Bruno Pacheco\Ambiente de trabalho\a.py", line 26, in especial

    tkMessageBox.showwarning("ola :D ","ola Meninos :D ")

NameError: global name 'tkMessageBox' is not defined

agradecido se me ajudassem oh grandes mestres xD

Share this post


Link to post
Share on other sites
Gooden

essa solução não faz bem o que eu quero zero. :| isso imprime na propria form um texto. o meu objectivo e uma message box :\

EDIT:

Já descobri :(

import tkMessageBox

faltava importar a messagetk DAHHH

Share this post


Link to post
Share on other sites
CuotlX

por acaso tambem estava com o mesmo problema que tu, pensava que a TkMessageBox pertencia ao modulo Tkinter

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.