[Tkinter-discuss] Python2.5.1+Tkinter+Tile0.8.2

Nawal <Galileon> Husnoo galileon at gmail.com
Fri Jan 2 17:17:29 CET 2009


Dear Tkinter users/developers,

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.

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?

Thanks,

Nawal.

<error>

/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.
  import apt_pkg
Traceback (most recent call last):
  File "./tktest.py", line 81, in <module>
  tkMessageBox.showwarning("Open file","Cannot open this file\n")
  File "/usr/lib/python2.5/lib-tk/tkMessageBox.py", line 85, in showwarning
  return _show(title, message, WARNING, OK, **options)
  File "/usr/lib/python2.5/lib-tk/tkMessageBox.py", line 72, in _show
  res = Message(**options).show()
  File "/usr/lib/python2.5/lib-tk/tkCommonDialog.py", line 48, in show
  s = w.tk.call(self.command, *w._options(self.options))
_tkinter.TclError: unknown option "-background"

</error>

Here's the script:

<code>

#! /usr/bin/env python

from Tkinter import *
import tkMessageBox

def callback():
  print "called the callback!"

root = Tk()
root.tk.call('package', 'require', 'tile')
root.tk.call('namespace', 'import', '-force', 'ttk::*')
root.tk.call('ttk::setTheme', 'clam')

def callback():
  print "called the callback!"

# create a toolbar
toolbar = Frame(root)

b = Button(toolbar, text="new", width=6, command=callback)
b.pack(side=LEFT, padx=2, pady=2)

b = Button(toolbar, text="open", width=6, command=callback)
b.pack(side=LEFT, padx=2, pady=2)

toolbar.pack(side=TOP, fill=X)

status = Label(root, text="", relief=SUNKEN, anchor=W)
status.pack(side=BOTTOM, fill=X)

# create a menu
menu = Menu(root)
root.config(menu=menu)

filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=callback)
filemenu.add_command(label="Open...", command=callback)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=callback)

#tkMessageBox.showwarning("Open file","Cannot open this file\n")

mainloop()
</code>

-- 
The best way to predict the future is to invent it. - Alan Kay
http://www.galileon.co.uk/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20090102/205d348b/attachment.htm>


More information about the Tkinter-discuss mailing list