lost
lost

Reputation: 2391

Tkinter import problem

I suspect I've got something very simple wrong here but I can't spot what. The following code:

import Tkinter as Tk
Tk.tkMessageBox.showerror(message='some error')

gives:

AttributeError: 'module' object has no attribute 'tkMessageBox'

Widgets (e.g. Button, Entry) work ok. Interactively I get the same result, and also:

>>> import Tkinter as Tk
>>> print Tkinter
<module 'Tkinter' from 'C:\Python26\lib\lib-tk\Tkinter.pyc'>

and tkMessageBox.py is in C:\Python26\Lib\lib-tk. Although why is the capitalization of Lib/lib different?!

This is with Python 2.6 on windows, and running Tkinter._test() reports version 8.5

Upvotes: 1

Views: 2182

Answers (1)

orlp
orlp

Reputation: 117681

I think you meant this:

import tkMessageBox
tkMessageBox.showerror(message='some error')

Upvotes: 3

Related Questions