Hi,
On Wed, 7 Apr 2010 08:00:38 -0700 (PDT)
Nemes Andrei <[email protected]> wrote:
> I'm sorry for being such a beginner in this, but could not find where
> to download the winico. Is it included in Tk already?
I think you will have to download winico-0.6.zip from
http://sourceforge.net/projects/tktable/files/
and copy the winico-0.6 folder into your Python's Tcl folder so that Tk
can find it. Unfortunately there does not seem to be a Tkinter wrapper
available, so you will have to write it yourself :(
>From a quick glance at the winico manpage a quick'n'dirty wrapper could
look like this (untested!):
############# file Winico.py ##############################
import Tkinter
class Winico:
def __init__(self, filename):
master = Tkinter._default_root
if not master:
raise RuntimeError, 'Too early to create icon'
self.WinicoVersion = master.tk.call('package', 'require', 'winico')
self.tk = master.tk
def createfrom(self, filename):
return self.tk.call('winico', 'createfrom', filename)
def delete(self, id_):
self.tk.call('winico', 'delete', id_)
def load(self, resourcename, filename=None):
return self.tk.call('winico', 'load', resourcename, filename)
def info(self, id_=None):
# the output should of course be formatted somehow
return self.tk.call('winico', 'info', id_)
def setwindow(self, size='big', pos=None):
return self.tk.call('winico', 'setwindow', size, pos)
def taskbar_add(self, id_, callback=None, pos=None, text=None):
args = ()
if callback:
args += ('-callback', callback)
if pos:
args += ('-pos', pos)
if text:
args += ('-text', text)
return self.tk.call('winico', 'taskbar', 'add', id_, *args)
def taskbar_modify(self, id_, callback=None, pos=None, text=None):
args = ()
if callback:
args += ('-callback', callback)
if pos:
args += ('-pos', pos)
if text:
args += ('-text', text)
return self.tk.call('winico', 'taskbar', 'modify', id_, *args)
def taskbar_delete(self, id_):
return self.tk.call('winico', 'taskbar', 'delete', id_)
#########################################################
If you compare this with the winico man page from
http://tktable.sourceforge.net/winico/winico.html
you will probably see the point how this is supposed to work.
Another problem is how to write the callback function for mouse clicks
onto the icon. I guess you will have to add the percent substitutions
and register the callback manually, like:
import Tkinter, Winico
root = Tkinter.Tk()
def your_callback(icon_id, message_specifier):
if message_specifier == "WM_LBUTTONDBLCLK":
(... do something with icon_id...)
elif message_specifier == "WM_RBUTTONDOWN":
(... do something else with icon_id...)
# register the callback for Tk:
cmd = (root.register(your_callback), '%i', '%m')
# create an icon
icon = Winico.Winico()
icon_id = icon.createfrom("some.ico")
icon.taskbar_add(icon_id, callback=cmd, text="Your text here")
I think you see the point, how the percent substitutions are passed to
the callback.
I hope this helps
Michael
PS:
I forwarded this to the list, maybe it is interesting for
other people, too, I hope that's ok.
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss