Tkinter wrappers for TkTreeCtrl and Tile

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Mar 15 09:39:28 EST 2005


Harlin Seritt wrote:
> (snip)
> 
>>>That said I have got a Tile Button example working (and I can change
>>>it's style) so perhaps not that much work
> 
> 
> Do you happen to have a sampling of this that I can get my hands on??
> 
> 
>>>I've cc'd the tkinter mailing list to see if there is any more
> 
> interest 
> 
>>>over there... 
> 
> 
> Thanks for doing so!
> 
> Harlin
> 


Harlin,

Sure here is all 90 lines of it:-


######################################


import Tkinter
from Tkconstants import *


class Style:
     def default(self, style, **kw):
         """Sets the default value of the specified option(s) in style"""
         pass

     def map_style(self, **kw):
         """Sets dynamic values of the specified option(s) in style. See
         "STATE MAPS", below."""
         pass

     def layout(self, style, layoutSpec):
         """Define the widget layout for style style. See "LAYOUTS" below
         for the format of layoutSpec. If layoutSpec is omitted, return the
         layout specification for style style. """
         pass

     def element_create(self, name, type, *args):
         """Creates a new element in the current theme of type type. The
         only built-in element type is image (see image(n)), although
         themes may define other element types (see
         Ttk_RegisterElementFactory).
         """
         pass

     def element_names(self):
         """Returns a list of all elements defined in the current theme. 
  """
         pass

     def theme_create(self, name, parent=None, basedon=None):
         """Creates a new theme. It is an error if themeName already 
exists.
         If -parent is specified, the new theme will inherit styles, 
elements,
         and layouts from the parent theme basedon. If -settings is 
present,
         script is evaluated in the context of the new theme as per 
style theme
         settings.
         """
         pass

     def theme_settings(self, name, script):
         """Temporarily sets the current theme to themeName, evaluate 
script,
         then restore the previous theme. Typically script simply 
defines styles
         and elements, though arbitrary Tcl code may appear.
         """
         pass

     def theme_names(self):
         """Returns a list of the available themes. """
         return self.tk.call("style", "theme", "names")

     def theme_use(self, theme):
         """Sets the current theme to themeName, and refreshes all 
widgets."""
         return self.tk.call("style", "theme", "use", theme)



class Button(Tkinter.Widget, Style):
     def __init__(self, master=None, cnf={}, **kw):
         master.tk.call("package", "require", "tile")
         Tkinter.Widget.__init__(self, master, 'ttk::button', cnf, kw)

class Treeview(Tkinter.Widget):
     def __init__(self, master=None, cnf={}, **kw):
         master.tk.call("package", "require", "tile")
         Tkinter.Widget.__init__(self, master, 'ttk::treeview', cnf, kw)



def callback():
     print "Hello"

root = Tkinter.Tk()

b = Button(root, text="Tile Button", command=callback)
b.pack()

print b.theme_names()

b.theme_use("step")

b1 = Tkinter.Button(root, text="Tk Button", command=callback)
b1.pack()

tree = Treeview(root)
tree.pack()

root.mainloop()


##############################




More information about the Python-list mailing list