1

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

lost
  • 2,210
  • 2
  • 20
  • 34

1 Answers1

3

I think you meant this:

import tkMessageBox
tkMessageBox.showerror(message='some error')
orlp
  • 112,504
  • 36
  • 218
  • 315
  • So I did, thanks! But why, isn't tkMessageBox a submodule of the package Tkinter? – lost Sep 20 '11 at 13:59
  • 1
    @lost: I'm not sure, but I think the `Tkinter` module is just a pure port of Tcl/Tk API into Python with no new stuff, while `tkMessageBox` is a script built ontop of that API. Open up `tkMessageBox.py` and you'll see :) – orlp Sep 20 '11 at 14:02