<p>Dear Tkinter users/developers,</p><p>I'm just starting out in Python Tkinter programming, and I tried to use the Tile module to improve the looks of the Tk program I am writing.</p><p>When I run the script written in <code></code> below, it works fine, using the Tile module to make the Tk look ok. However, when I try to use tkMessageBox.showwarning() as in the script, it fails with the error below. I've tried to cat | grep for "background" in the files mentionned in the error, but nothing turns up. I can't find where the "-background" switch is getting stuck in. I know the "background" switch doesn't work with Tile, but I can't find it to remove it. Any ideas please?</p>
<p>Thanks,</p><p>Nawal.</p><p><error></p><p>/usr/lib/python2.4/site-packages/apt/__init__.py:2: RuntimeWarning: Python C API version mismatch for module apt_pkg: This Python has API version 1013, module apt_pkg has version 1012.<br>
import apt_pkg<br>Traceback (most recent call last):<br> File "./tktest.py", line 81, in <module><br> tkMessageBox.showwarning("Open file","Cannot open this file\n")<br> File "/usr/lib/python2.5/lib-tk/tkMessageBox.py", line 85, in showwarning<br>
return _show(title, message, WARNING, OK, **options)<br> File "/usr/lib/python2.5/lib-tk/tkMessageBox.py", line 72, in _show<br> res = Message(**options).show()<br> File "/usr/lib/python2.5/lib-tk/tkCommonDialog.py", line 48, in show<br>
s = w.tk.call(self.command, *w._options(self.options))<br>_tkinter.TclError: unknown option "-background"<br><br></error></p><p></p><p>Here's the script:</p><p><code></p><p>#! /usr/bin/env python<br>
<br>from Tkinter import *<br>import tkMessageBox<br><br>def callback():<br> print "called the callback!"<br><br>root = Tk()<br>root.tk.call('package', 'require', 'tile')<br>root.tk.call('namespace', 'import', '-force', 'ttk::*')<br>
root.tk.call('ttk::setTheme', 'clam')<br><br>def callback():<br> print "called the callback!"<br><br># create a toolbar<br>toolbar = Frame(root)<br><br>b = Button(toolbar, text="new", width=6, command=callback)<br>
b.pack(side=LEFT, padx=2, pady=2)<br><br>b = Button(toolbar, text="open", width=6, command=callback)<br>b.pack(side=LEFT, padx=2, pady=2)<br><br>toolbar.pack(side=TOP, fill=X)<br><br>status = Label(root, text="", relief=SUNKEN, anchor=W)<br>
status.pack(side=BOTTOM, fill=X)<br><br># create a menu<br>menu = Menu(root)<br>root.config(menu=menu)<br><br>filemenu = Menu(menu)<br>menu.add_cascade(label="File", menu=filemenu)<br>filemenu.add_command(label="New", command=callback)<br>
filemenu.add_command(label="Open...", command=callback)<br>filemenu.add_separator()<br>filemenu.add_command(label="Exit", command=callback)<br><br>#tkMessageBox.showwarning("Open file","Cannot open this file\n")<br>
<br>mainloop()<br></code></p><p></p><p>-- <br></p>The best way to predict the future is to invent it. - Alan Kay<br><a href="http://www.galileon.co.uk/">http://www.galileon.co.uk/</a><br>