473,804 Members | 3,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Future Python Gui?

I've been trying to find out what the future of Python is with regard
to Tk. It seems there are several interfaces that make use of new
functionality, including "Tile" and "Ttk".

If I want to write a program that will run under the standard Python
distribution of the future, what extension module should I work with
today?

Thanks!

-- Brian

Apr 18 '07
27 2941
bc*****@pobox.c om wrote:
>On Windows, the easiest way to install Tile is to grab it from
ActiveState' s Tcl distribution
(http://www.activestate.com/products/activetcl/) and then place it with
the Tcl/Tk bits that come with Python. The Tcl/Tk build for Windows that
python.org provides doesn't ship with Tile. You'll also have to install
the Tile wrapper at the site I referenced earlier in your site-packages
directory.

For posterity's sake, here's what I did...

- install python http://www.python.org/download/
(use the Windows MSI install package)
- go to http://bruno.thoorens.free.fr/ and do the download
- instructions say to copy "tty.py" to "Tkinter" folder, but that
doesn't exist
- copy instead to C:\Python25\Lib
- copy folders as directed (to C:\Python25\Tcl )

This should also work with the ActivePython download at
http://www.activestate.com/products/activepython/ .

Within your program, you need:

# Import "Tile" theming engine
tkroot.tk.call( 'package', 'require', 'tile')
tkroot.tk.call( 'namespace', 'import', '-force', 'ttk::*')
tkroot.tk.call( 'tile::setTheme ', 'xpnative')

after your call to "tkroot = Tk()" (or "tkroot = Tkinter.Tk()" if you
just "import Tkinter").

The frustrating part is that the main reason I wanted this is because
it says it wraps a "Notebook" widget. If it does, I can't find it!
<sigh>

-- Brian
The wrapper I maintain works differently, and includes the notebook widget.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Apr 19 '07 #21
Since the Tkinter wiki is still down, here is the Tile wrapper I maintain:
#######

####November 2006: Posted by Kevin Walzer, kw@codebykevin. com. Based on
Tile wrapper by Martin Franklin. This version updates the wrapper to
reflect changes in Tile commands, and adds support for Tile-based frames
(ttk::frame). Freely reusable.

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_RegisterEle mentFactory).
"""
pass

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

def theme_create(se lf, 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):
"""Temporar ily 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(sel f):
"""Returns a list of the available themes. """
return self.tk.call("s tyle", "theme", "names")

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

class Widget(Tkinter. Widget, Style):
def __init__(self, master, widgetName=None , cnf={}, kw={}, extra=()):
if not widgetName:
## why you would ever want to create a Tile Widget is
behond me!
widgetName="ttk ::widget"
Tkinter.Widget. __init__(self, master, widgetName, cnf, kw)

def instate(self, spec=None, script=None):
"""Test the widget's state. If script is not specified, returns 1
if the widget state matches statespec and 0 otherwise. If script
is specified, equivalent to if {[pathName instate stateSpec]}
script.
"""
return self.tk.call(se lf._w, "instate", spec, script)

def state(self, spec=None):
"""Modify or inquire widget state. If stateSpec is present, sets
the widget state: for each flag in stateSpec, sets the
corresponding
flag or clears it if prefixed by an exclamation point. Returns
a new
state spec indicating which flags were changed: ''set changes
[pathName state spec] ; pathName state $changes'' will restore
pathName to the original state. If stateSpec is not specified,
returns a list of the currently-enabled state flags.
"""
return self.tk.call(se lf._w, "state", spec)

class Button(Widget, Tkinter.Button) :
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::butto n", cnf, kw)

###add frame support here--KWs
class Frame(Widget, Tkinter.Frame):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::frame ", cnf, kw)

class Checkbutton(Wid get, Tkinter.Checkbu tton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::checkbutt on", cnf, kw)

class Combobox(Widget , Tkinter.Entry):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::combobox" , cnf, kw)

def current(self, index=None):
"""If index is supplied, sets the combobox value to the element
at position newIndex in the list of -values. Otherwise, returns
the index of the current value in the list of -values or -1 if
the current value does not appear in the list.
"""
return self.tk.call(se lf._w, "current", index)

class Entry(Widget, Tkinter.Entry):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::entry ", cnf, kw)

def validate(self):
"""Force revalidation, independent of the conditions specified by
the -validate option. Returns 0 if the -validatecommand returns a
false value, or 1 if it returns a true value or is not specified.
"""
return self.tk.call(se lf._w, "validate")

class Label(Widget, Tkinter.Label):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::label ", cnf, kw)

###add LabelFrame class here--KW
class LabelFrame(Widg et, Tkinter.Label):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::labelfram e", cnf, kw)

class Menubutton(Widg et, Tkinter.Menubut ton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::menubutto n", cnf, kw)

class Notebook(Widget ):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::notebook" , cnf, kw)

def add(self, child, cnf=(), **kw):
"""Adds a new tab to the notebook. When the tab is selected, the
child window will be displayed. child must be a direct child of
the notebook window. See TAB OPTIONS for the list of available
options.
"""

return self.tk.call((s elf._w, "add", child) +
self._options(c nf, kw))

def forget(self, index):
"""Removes the tab specified by index, unmaps and unmanages the
associated child window.
"""
return self.tk.call(se lf._w, "forget", index)

def index(self, index):
"""Returns the numeric index of the tab specified by index, or
the total number of tabs if index is the string "end".
"""
return self.tk.call(se lf._w, "index")

def select(self, index):
"""Selects the specified tab; the associated child pane will
be displayed, and the previously-selected pane (if different)
is unmapped.
"""
return self.tk.call(se lf._w, "select", index)
def tab(self, index, **kw):
"""Query or modify the options of the specific tab. If no
-option is specified, returns a dictionary of the tab option
values. If one -option is specified, returns the value of tha
t option. Otherwise, sets the -options to the corresponding
values. See TAB OPTIONS for the available options.
"""
return self.tk.call((s elf._w, "tab", index) + self._options(k w))

def tabs(self):
"""Returns a list of all pane windows managed by the widget."""
return self.tk.call(se lf._w, "tabs")

class Paned(Widget):
"""
WIDGET OPTIONS
Name Database name Database class
-orient orient Orient
Specifies the orientation of the window. If vertical, subpanes
are stacked top-to-bottom; if horizontal, subpanes are stacked
left-to-right.

PANE OPTIONS
The following options may be specified for each pane:
Name Database name Database class
-weight weight Weight
An integer specifying the relative stretchability of the pane.
When the paned window is resized, the extra space is added or
subracted to each pane proportionally to its -weight
"""
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::paned ", cnf, kw)

def add(self, subwindow, **kw):
"""Adds a new pane to the window. subwindow must be a direct
child of
the paned window pathname. See PANE OPTIONS for the list of
available
options.
"""
return self.tk.call((s elf._w, "add", subwindow) +
self._options(k w))

def forget(self, pane):
"""Removes the specified subpane from the widget. pane is
either an
integer index or the name of a managed subwindow.
"""
self.tk.call(se lf._w, "forget", pane)

def insert(self, pos, subwindow, **kw):
"""Inserts a pane at the specified position. pos is either the
string
end, an integer index, or the name of a managed subwindow. If
subwindow
is already managed by the paned window, moves it to the specified
position. See PANE OPTIONS for the list of available options.
"""
return self.tk.call((s elf._w, "insert", pos, subwindow) +
self._options(k w))

def pane(self, pane, **kw):
"""Query or modify the options of the specified pane, where
pane is
either an integer index or the name of a managed subwindow. If no
-option is specified, returns a dictionary of the pane option
values.
If one -option is specified, returns the value of that option.
Otherwise, sets the -options to the corresponding values.
"""
return self.tk.call((s elf._w, "pane", pane) + self._options(k w))

class Progressbar(Wid get):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::progressb ar", cnf, kw)

def step(self, amount=1.0):
"""Incremen ts the -value by amount. amount defaults to 1.0
if omitted. """
return self.tk.call(se lf._w, "step", amount)

def start(self):
self.tk.call("t tk::progressbar ::start", self._w)

def stop(self):
self.tk.call("t tk::progressbar ::stop", self._w)

class Radiobutton(Wid get, Tkinter.Radiobu tton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::radiobutt on", cnf, kw)

class Scrollbar(Widge t, Tkinter.Scrollb ar):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::scrollbar ", cnf, kw)

class Separator(Widge t):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::separator ", cnf, kw)

class Treeview(Widget , Tkinter.Listbox ):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, 'ttk::treeview' , cnf, kw)

def children(self, item, newchildren=Non e):
"""If newchildren is not specified, returns the list of
children belonging to item.

If newchildren is specified, replaces item's child list
with newchildren. Items in the old child list not present
in the new child list are detached from the tree. None of
the items in newchildren may be an ancestor of item.
"""
return self.tk.call(se lf._w, "children", item, newchildren)

def column(self, column, **kw):
"""Query or modify the options for the specified column.
If no options are specified, returns a dictionary of
option/value pairs. If a single option is specified,
returns the value of that option. Otherwise, the options
are updated with the specified values. The following
options may be set on each column:

-id name
The column name. This is a read-only option. For example,
[$pathname column #n -id] returns the data column
associated with data column #n.
-anchor
Specifies how the text in this column should be aligned
with respect to the cell. One of n, ne, e, se, s, sw, w,
nw, or center.
-width w
The width of the column in pixels. Default is something
reasonable, probably 200 or so.
"""
pass

def delete(self, items):
"""Deletes each of the items and all of their descendants.
The root item may not be deleted. See also: detach.
"""
return self.tk.call(se lf._w, "delete", items)

def detach(self, items):
"""Unlinks all of the specified items from the tree. The
items and all of their descendants are still present and
may be reinserted at another point in the tree but will
not be displayed. The root item may not be detached. See
also: delete.
"""
return self.tk.call(se lf._w, "detach", items)

def exists(self, item):
"""Returns 1 if the specified item is present in the
tree, 0 otherwise.
"""
return self.tk.call(se lf._w, "exists", item)

def focus(self, item=None):
"""If item is specified, sets the focus item to item.
Otherwise, returns the current focus item, or {} if there
is none.
"""
return self.tk.call(se lf._w, "focus", item)

def heading(self, column, **kw):
"""Query or modify the heading options for the specified
column. Valid options are:

-text text
The text to display in the column heading.
-image imageName
Specifies an image to display to the right of the column
heading.
-command script
A script to evaluate when the heading label is pressed.
"""
pass

def identify(self, x, y):
"""Returns a description of the widget component under the
point given
by x and y. The return value is a list with one of the
following forms:

heading #n
The column heading for display column #n.
separator #n
The border to the right of display column #n.
cell itemid #n
The data value for item itemid in display column #n.
item itemid element
The tree label for item itemid; element is one of text,
image, or
indicator, or another element name depending on the style.
row itemid
The y position is over the item but x does not identify any
element
or displayed data value.
nothing
The coordinates are not over any identifiable object.

See COLUMN IDENTIFIERS for a discussion of display columns and
data
columns.
"""
pass

def index(self, item):
"""Returns the integer index of item within its parent's list of
children.
"""
pass

def insert(self, parent, index, id=None, **kw):
"""Creates a new item. parent is the item ID of the parent
item, or
the empty string {} to create a new top-level item. index is an
integer, or the value end, specifying where in the list of
parent's
children to insert the new item. If index is less than or equal to
zero, the new node is inserted at the beginning; if index is
greater
than or equal to the current number of children, it is inserted
at the
end. If -id is specified, it is used as the item identifier; id
must
not already exist in the tree. Otherwise, a new unique
identifier is
generated.
returns the item identifier of the newly created item. See ITEM
OPTIONS for the list of available options.
"""
pass
def item(item, **kw):
"""Query or modify the options for the specified item. If no
-option
is specified, returns a dictionary of option/value pairs. If a
single
-option is specified, returns the value of that option.
Otherwise, the
item's options are updated with the specified values. See ITEM
OPTIONS
for the list of available options.
"""
pass

def move(self, item, parent, index):
"""Moves item to position index in parent's list of children.
It is
illegal to move an item under one of its descendants.

If index is less than or equal to zero, item is moved to the
beginning; if greater than or equal to the number of children,
it's
moved to the end.
"""
pass

def next(self, item):
"""Returns the identifier of item's next sibling, or {} if item
is the
last child of its parent.
"""
pass

def parent(self, item):
"""Returns the ID of the parent of item, or {} if item is at
the top
level of the hierarchy.
"""
pass

def prev(self, item):
"""Returns the identifier of item's previous sibling, or {} if
item is
the first child of its parent.
"""
pass
def selection(self) :
"""Returns the list of selected items"""
pass

def selection_set(s elf, items):
"""items becomes the new selection. """
pass

def selection_add(s elf, items):
"""Add items to the selection """
pass

def selection_remov e(self, items):
"""Remove items from the selection """
pass

def selection_toggl e(self, items):
"""Toggle the selection state of each item in items. """
pass

def set(self, item, column, value=None):
"""If value is specified, sets the value of column column in
item item,
otherwise returns the current value. See COLUMN IDENTIFIERS.
"""
pass

if __name__=="__ma in__":
def callback():
print "Hello"

root = Tkinter.Tk()
root.tk.call("p ackage", "require", "tile")

f = Frame(root, width=150)
f.pack(fill="bo th", expand="yes")

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

#~ c = Checkbutton(roo t)
#~ c.pack()
#~ print b.theme_names()

#~ cb = Combobox(root)
#~ cb.pack()

#~ e = Entry(root)
#~ e.validate()
#~ e.pack()

#~ l = Label(root, text="Tile Label")
#~ l.pack()
#~ mb = Menubutton(root )
#~ mb.pack()
#~ nb = Notebook(root)

#~ f1 = Label(nb, text="page1")
#~ nb.add(f1, text="Page1")
#~ f1.pack()

#~ f2 = Label(nb, text="page2")
#~ nb.add(f2, text="Page 2")
#~ f2.pack()

#~ nb.pack()
pb = Progressbar(roo t, mode="indetermi nate")
pb.pack()
pb.start()
b = Button(root, text="Start", command=pb.star t)
b.pack()
b = Button(root, text="Stop", command=pb.stop )
b.pack()

#~ rb = Radiobutton(roo t)
#~ rb.pack()

#~ text = Tkinter.Text(ro ot)
#~ scrol = Scrollbar(root)
#~ text.pack(side= "left", fill="both", expand="yes")
#~ scrol.pack(side ="left", fill="y")
#~ text['yscrollcommand '] = scrol.set
#~ scrol['command'] = text.yview
#~ l = Label(root, text="Label1")
#~ l.pack()
#~ s = Separator(root)
#~ s.pack(fill="x" )
#~ l = Label(root, text="Label2")
#~ l.pack()
#b.theme_use("d efault")

#~ b1 = Tkinter.Button( root, text="Tk Button", command=callbac k)
#~ b1.pack()
panes = Paned(root)
panes.pack(fill ="both", expand="yes")

label1 = Label(panes, text="pane1")
label2 = Label(panes, text="Pane2")
panes.add(label 1)
panes.add(label 2)


#~ tree = Treeview(root, columns=("One", "Two", "Three"))

#~ tree.insert(Non e, "end", text="Hello")

#~ tree.pack()

root.mainloop()

Apr 19 '07 #22
This should be saved as "Tile.py." Sorry.
#######

####November 2006: Posted by Kevin Walzer, kw@codebykevin. com. Based on
Tile wrapper by Martin Franklin. This version updates the wrapper to
reflect changes in Tile commands, and adds support for Tile-based frames
(ttk::frame). Freely reusable.

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_RegisterEle mentFactory).
"""
pass

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

def theme_create(se lf, 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):
"""Temporar ily 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(sel f):
"""Returns a list of the available themes. """
return self.tk.call("s tyle", "theme", "names")

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

class Widget(Tkinter. Widget, Style):
def __init__(self, master, widgetName=None , cnf={}, kw={}, extra=()):
if not widgetName:
## why you would ever want to create a Tile Widget is
behond me!
widgetName="ttk ::widget"
Tkinter.Widget. __init__(self, master, widgetName, cnf, kw)

def instate(self, spec=None, script=None):
"""Test the widget's state. If script is not specified, returns 1
if the widget state matches statespec and 0 otherwise. If script
is specified, equivalent to if {[pathName instate stateSpec]}
script.
"""
return self.tk.call(se lf._w, "instate", spec, script)

def state(self, spec=None):
"""Modify or inquire widget state. If stateSpec is present, sets
the widget state: for each flag in stateSpec, sets the
corresponding
flag or clears it if prefixed by an exclamation point. Returns
a new
state spec indicating which flags were changed: ''set changes
[pathName state spec] ; pathName state $changes'' will restore
pathName to the original state. If stateSpec is not specified,
returns a list of the currently-enabled state flags.
"""
return self.tk.call(se lf._w, "state", spec)

class Button(Widget, Tkinter.Button) :
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::butto n", cnf, kw)

###add frame support here--KWs
class Frame(Widget, Tkinter.Frame):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::frame ", cnf, kw)

class Checkbutton(Wid get, Tkinter.Checkbu tton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::checkbutt on", cnf, kw)

class Combobox(Widget , Tkinter.Entry):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::combobox" , cnf, kw)

def current(self, index=None):
"""If index is supplied, sets the combobox value to the element
at position newIndex in the list of -values. Otherwise, returns
the index of the current value in the list of -values or -1 if
the current value does not appear in the list.
"""
return self.tk.call(se lf._w, "current", index)

class Entry(Widget, Tkinter.Entry):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::entry ", cnf, kw)

def validate(self):
"""Force revalidation, independent of the conditions specified by
the -validate option. Returns 0 if the -validatecommand returns a
false value, or 1 if it returns a true value or is not specified.
"""
return self.tk.call(se lf._w, "validate")

class Label(Widget, Tkinter.Label):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::label ", cnf, kw)

###add LabelFrame class here--KW
class LabelFrame(Widg et, Tkinter.Label):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::labelfram e", cnf, kw)

class Menubutton(Widg et, Tkinter.Menubut ton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::menubutto n", cnf, kw)

class Notebook(Widget ):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::notebook" , cnf, kw)

def add(self, child, cnf=(), **kw):
"""Adds a new tab to the notebook. When the tab is selected, the
child window will be displayed. child must be a direct child of
the notebook window. See TAB OPTIONS for the list of available
options.
"""

return self.tk.call((s elf._w, "add", child) +
self._options(c nf, kw))

def forget(self, index):
"""Removes the tab specified by index, unmaps and unmanages the
associated child window.
"""
return self.tk.call(se lf._w, "forget", index)

def index(self, index):
"""Returns the numeric index of the tab specified by index, or
the total number of tabs if index is the string "end".
"""
return self.tk.call(se lf._w, "index")

def select(self, index):
"""Selects the specified tab; the associated child pane will
be displayed, and the previously-selected pane (if different)
is unmapped.
"""
return self.tk.call(se lf._w, "select", index)
def tab(self, index, **kw):
"""Query or modify the options of the specific tab. If no
-option is specified, returns a dictionary of the tab option
values. If one -option is specified, returns the value of tha
t option. Otherwise, sets the -options to the corresponding
values. See TAB OPTIONS for the available options.
"""
return self.tk.call((s elf._w, "tab", index) + self._options(k w))

def tabs(self):
"""Returns a list of all pane windows managed by the widget."""
return self.tk.call(se lf._w, "tabs")

class Paned(Widget):
"""
WIDGET OPTIONS
Name Database name Database class
-orient orient Orient
Specifies the orientation of the window. If vertical, subpanes
are stacked top-to-bottom; if horizontal, subpanes are stacked
left-to-right.

PANE OPTIONS
The following options may be specified for each pane:
Name Database name Database class
-weight weight Weight
An integer specifying the relative stretchability of the pane.
When the paned window is resized, the extra space is added or
subracted to each pane proportionally to its -weight
"""
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::paned ", cnf, kw)

def add(self, subwindow, **kw):
"""Adds a new pane to the window. subwindow must be a direct
child of
the paned window pathname. See PANE OPTIONS for the list of
available
options.
"""
return self.tk.call((s elf._w, "add", subwindow) +
self._options(k w))

def forget(self, pane):
"""Removes the specified subpane from the widget. pane is
either an
integer index or the name of a managed subwindow.
"""
self.tk.call(se lf._w, "forget", pane)

def insert(self, pos, subwindow, **kw):
"""Inserts a pane at the specified position. pos is either the
string
end, an integer index, or the name of a managed subwindow. If
subwindow
is already managed by the paned window, moves it to the specified
position. See PANE OPTIONS for the list of available options.
"""
return self.tk.call((s elf._w, "insert", pos, subwindow) +
self._options(k w))

def pane(self, pane, **kw):
"""Query or modify the options of the specified pane, where
pane is
either an integer index or the name of a managed subwindow. If no
-option is specified, returns a dictionary of the pane option
values.
If one -option is specified, returns the value of that option.
Otherwise, sets the -options to the corresponding values.
"""
return self.tk.call((s elf._w, "pane", pane) + self._options(k w))

class Progressbar(Wid get):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::progressb ar", cnf, kw)

def step(self, amount=1.0):
"""Incremen ts the -value by amount. amount defaults to 1.0
if omitted. """
return self.tk.call(se lf._w, "step", amount)

def start(self):
self.tk.call("t tk::progressbar ::start", self._w)

def stop(self):
self.tk.call("t tk::progressbar ::stop", self._w)

class Radiobutton(Wid get, Tkinter.Radiobu tton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::radiobutt on", cnf, kw)

class Scrollbar(Widge t, Tkinter.Scrollb ar):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::scrollbar ", cnf, kw)

class Separator(Widge t):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, "ttk::separator ", cnf, kw)

class Treeview(Widget , Tkinter.Listbox ):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__ (self, master, 'ttk::treeview' , cnf, kw)

def children(self, item, newchildren=Non e):
"""If newchildren is not specified, returns the list of
children belonging to item.

If newchildren is specified, replaces item's child list
with newchildren. Items in the old child list not present
in the new child list are detached from the tree. None of
the items in newchildren may be an ancestor of item.
"""
return self.tk.call(se lf._w, "children", item, newchildren)

def column(self, column, **kw):
"""Query or modify the options for the specified column.
If no options are specified, returns a dictionary of
option/value pairs. If a single option is specified,
returns the value of that option. Otherwise, the options
are updated with the specified values. The following
options may be set on each column:

-id name
The column name. This is a read-only option. For example,
[$pathname column #n -id] returns the data column
associated with data column #n.
-anchor
Specifies how the text in this column should be aligned
with respect to the cell. One of n, ne, e, se, s, sw, w,
nw, or center.
-width w
The width of the column in pixels. Default is something
reasonable, probably 200 or so.
"""
pass

def delete(self, items):
"""Deletes each of the items and all of their descendants.
The root item may not be deleted. See also: detach.
"""
return self.tk.call(se lf._w, "delete", items)

def detach(self, items):
"""Unlinks all of the specified items from the tree. The
items and all of their descendants are still present and
may be reinserted at another point in the tree but will
not be displayed. The root item may not be detached. See
also: delete.
"""
return self.tk.call(se lf._w, "detach", items)

def exists(self, item):
"""Returns 1 if the specified item is present in the
tree, 0 otherwise.
"""
return self.tk.call(se lf._w, "exists", item)

def focus(self, item=None):
"""If item is specified, sets the focus item to item.
Otherwise, returns the current focus item, or {} if there
is none.
"""
return self.tk.call(se lf._w, "focus", item)

def heading(self, column, **kw):
"""Query or modify the heading options for the specified
column. Valid options are:

-text text
The text to display in the column heading.
-image imageName
Specifies an image to display to the right of the column
heading.
-command script
A script to evaluate when the heading label is pressed.
"""
pass

def identify(self, x, y):
"""Returns a description of the widget component under the
point given
by x and y. The return value is a list with one of the
following forms:

heading #n
The column heading for display column #n.
separator #n
The border to the right of display column #n.
cell itemid #n
The data value for item itemid in display column #n.
item itemid element
The tree label for item itemid; element is one of text,
image, or
indicator, or another element name depending on the style.
row itemid
The y position is over the item but x does not identify any
element
or displayed data value.
nothing
The coordinates are not over any identifiable object.

See COLUMN IDENTIFIERS for a discussion of display columns and
data
columns.
"""
pass

def index(self, item):
"""Returns the integer index of item within its parent's list of
children.
"""
pass

def insert(self, parent, index, id=None, **kw):
"""Creates a new item. parent is the item ID of the parent
item, or
the empty string {} to create a new top-level item. index is an
integer, or the value end, specifying where in the list of
parent's
children to insert the new item. If index is less than or equal to
zero, the new node is inserted at the beginning; if index is
greater
than or equal to the current number of children, it is inserted
at the
end. If -id is specified, it is used as the item identifier; id
must
not already exist in the tree. Otherwise, a new unique
identifier is
generated.
returns the item identifier of the newly created item. See ITEM
OPTIONS for the list of available options.
"""
pass
def item(item, **kw):
"""Query or modify the options for the specified item. If no
-option
is specified, returns a dictionary of option/value pairs. If a
single
-option is specified, returns the value of that option.
Otherwise, the
item's options are updated with the specified values. See ITEM
OPTIONS
for the list of available options.
"""
pass

def move(self, item, parent, index):
"""Moves item to position index in parent's list of children.
It is
illegal to move an item under one of its descendants.

If index is less than or equal to zero, item is moved to the
beginning; if greater than or equal to the number of children,
it's
moved to the end.
"""
pass

def next(self, item):
"""Returns the identifier of item's next sibling, or {} if item
is the
last child of its parent.
"""
pass

def parent(self, item):
"""Returns the ID of the parent of item, or {} if item is at
the top
level of the hierarchy.
"""
pass

def prev(self, item):
"""Returns the identifier of item's previous sibling, or {} if
item is
the first child of its parent.
"""
pass
def selection(self) :
"""Returns the list of selected items"""
pass

def selection_set(s elf, items):
"""items becomes the new selection. """
pass

def selection_add(s elf, items):
"""Add items to the selection """
pass

def selection_remov e(self, items):
"""Remove items from the selection """
pass

def selection_toggl e(self, items):
"""Toggle the selection state of each item in items. """
pass

def set(self, item, column, value=None):
"""If value is specified, sets the value of column column in
item item,
otherwise returns the current value. See COLUMN IDENTIFIERS.
"""
pass

if __name__=="__ma in__":
def callback():
print "Hello"

root = Tkinter.Tk()
root.tk.call("p ackage", "require", "tile")

f = Frame(root, width=150)
f.pack(fill="bo th", expand="yes")

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

#~ c = Checkbutton(roo t)
#~ c.pack()
#~ print b.theme_names()

#~ cb = Combobox(root)
#~ cb.pack()

#~ e = Entry(root)
#~ e.validate()
#~ e.pack()

#~ l = Label(root, text="Tile Label")
#~ l.pack()
#~ mb = Menubutton(root )
#~ mb.pack()
#~ nb = Notebook(root)

#~ f1 = Label(nb, text="page1")
#~ nb.add(f1, text="Page1")
#~ f1.pack()

#~ f2 = Label(nb, text="page2")
#~ nb.add(f2, text="Page 2")
#~ f2.pack()

#~ nb.pack()
pb = Progressbar(roo t, mode="indetermi nate")
pb.pack()
pb.start()
b = Button(root, text="Start", command=pb.star t)
b.pack()
b = Button(root, text="Stop", command=pb.stop )
b.pack()

#~ rb = Radiobutton(roo t)
#~ rb.pack()

#~ text = Tkinter.Text(ro ot)
#~ scrol = Scrollbar(root)
#~ text.pack(side= "left", fill="both", expand="yes")
#~ scrol.pack(side ="left", fill="y")
#~ text['yscrollcommand '] = scrol.set
#~ scrol['command'] = text.yview
#~ l = Label(root, text="Label1")
#~ l.pack()
#~ s = Separator(root)
#~ s.pack(fill="x" )
#~ l = Label(root, text="Label2")
#~ l.pack()
#b.theme_use("d efault")

#~ b1 = Tkinter.Button( root, text="Tk Button", command=callbac k)
#~ b1.pack()
panes = Paned(root)
panes.pack(fill ="both", expand="yes")

label1 = Label(panes, text="pane1")
label2 = Label(panes, text="Pane2")
panes.add(label 1)
panes.add(label 2)


#~ tree = Treeview(root, columns=("One", "Two", "Three"))

#~ tree.insert(Non e, "end", text="Hello")

#~ tree.pack()

root.mainloop()
Apr 19 '07 #23
The wrapper I maintain works differently, and includes the notebook widget.

I've seen the page. You can get to it via Google's cache; just put
the url in the box and the one search result returned usually has a
"cached" link.

However, that file is completely useless without instructions on how
to use it, and there are no instructions within the page or file.

That is:
- exactly where does it get installed
- what else needs to get installed (eg. some dll)
- where do you find these other things
- where does that something else get installed
- how do you import this module
- how does use of Tkinter change (if at all) once imported

I know all this stuff is obvious to those that have been working with
it for a while, but for those of us just getting started with Python,
it's immensely frustrating that we're assumed to know all these steps.

-- Brian

Apr 19 '07 #24
bc*****@pobox.c om wrote:
However, that file is completely useless without instructions on how
to use it, and there are no instructions within the page or file.

That is:
- exactly where does it get installed
In your Python site-packages directory.
- what else needs to get installed (eg. some dll)
The Tile package. Install ActiveTcl from http://www.activestate.com,
find the Tile package, and copy it to Python's installation of Tcl/Tk
(find the libs directory--I'm not on a Windows box ATM and don't
remember exactly).
- where do you find these other things
http://www.activestate.com
- where does that something else get installed
See above.
- how do you import this module
import Tile
- how does use of Tkinter change (if at all) once imported
It shouldn't change at all. I use Frame for Tkinter frames and
Tile.Frame for Tile frames, since a lot of the widgets have the same
names. Here's a sample:

from Tkinter import *
import Tile
root = Tk()
root.tk.call('p ackage', 'require', 'tile')

def printme():
print "You clicked me"
frame = Tile.Frame(root )
frame.pack(fill =BOTH, expand=TRUE)

button = Tile.Button(fra me, text="Print", command=printme )
button.pack()

root.mainloop()

HTH,
Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Apr 19 '07 #25
It shouldn't change at all. I use Frame for Tkinter frames and
Tile.Frame for Tile frames, since a lot of the widgets have the same
names. Here's a sample:

from Tkinter import *
import Tile
Thanks for all the info.

I'm a little confused about using both Tkinter and Tile at the same
time. Do the calls to Tkinter now get themed?

What is the benefit of calling similar widgets for both modules within
the same code? Why wouldn't I call everything via Tile? (i.e. "from
Tile import *" and not import Tkinter at all)

Thanks!

-- Brian

Apr 19 '07 #26
bc*****@pobox.c om wrote:
What is the benefit of calling similar widgets for both modules within
the same code? Why wouldn't I call everything via Tile? (i.e. "from
Tile import *" and not import Tkinter at all)
Because Tile depends on Tkinter, and also, not everything from Tkinter
is in Tile (text widget, menus, etc).
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Apr 19 '07 #27
Jarek Zgoda wrote:
I am not a hacker, just a software developer, but I'd have no problems
in either installing PyGTK on Ubuntu box (sudo apt-get install
python-gtk2, but it's installed by default anyway) or on Windows XP
machine (double click on installer icon). "Simple user" is not an idiot
either and if she can read English, she wouldn't have hard time too.

The rumours on "problems installing GUI toolkits" are greatly exagerated
IMO.
It might not be a big deal for your own computer,
but if you are distributing software professionally
to a bunch of customers, things get more complex.

Let's say your customers use RHEL4 for instance. If you
would like to use a recent PyGTK, this means that the
GTK libs in RHEL4 aren't new enough. Upgrading GTK will
force you to upgrade a bunch of other libraries as well.

That means that the system will no longer be the vanilla
RHEL4 with your additions. Bugs might pop up in other
applications on the system than yours, because they
assumed other versions of shared objects. You can
(perhaps) install the newer versions of the libs in
non-standard locations and set LD_LIBRARY_PATH to
that location for your program, but that means that
things brake fairly easy, and if you for instance have
a larger system, where Python scripts relying on this
new PyGTK are started from a Python interpreter embedded
in some big application, this big application will also
see the newer versions of all those shared objects that
PyGKT pulled in. Unless you are very careful, other
programs that you start up from within your application
(maybe it's possible to spawn a new shell from your app
with the embedded Python interpreter and start arbitrary
applications from there) will also get the non-standard
shared objects.

If you just install the shared objects the new PyGTK rely
on in the standard locations, you have probably removed
security patches and bug fixes added to the software by
Red Hat from the system. Any application might cease to
work, and the customer might have problem getting support
from Red Hat on the system. You might end up with a lot
more support and maintenance work than intended, or get
very unhappy customers.

Now imagine that you have half a dozen other platforms
besides RHEL4 on x86_64 that you need to support...

This is a problem you need to deal with if you develop
software for Unix. It's not impossible to solve all these
problems, but there is certainly a cost in this. If you
handle it well, there is a cost in testing and adapting
the systems. If you don't handle it well, there might
be a big cost in handling emergencies and dealing with
unhappy customers or users.
Apr 20 '07 #28

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1514
by: R.Marquez | last post by:
I finally got around to start testing some of my old apps with Python 2.3. I've had no problems so far, but I did get one intriging warning. The following is from the Python Command Line: Python 2.3c1 (#44, Jul 18 2003, 14:32:36) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32com.client >>> ie=win32com.client.DispatchEx('InternetExplorer.Application.1') >>>...
30
4531
by: David Mertz | last post by:
Pythonistas, My loyal fans :-) will remember that I did a Python IDE roundup for _Charming Python_ a couple years back. Now I have another such roundup lined up... not the very next article, but it's there on the list. In the intervening years, I've hardly touched anything one might call an IDE. I've looked at screenshots from time to time, and read various announcements. But really I just use text editors and command lines.
52
3869
by: Neuruss | last post by:
It seems there are quite a few projects aimed to improve Python's speed and, therefore, eliminate its main limitation for mainstream acceptance. I just wonder what do you all think? Will Python (and dynamic languages in general) be someday close to compiled languages speed? What will be the future of Psyco, Pypy, Starkiller, Ironpython and all the other projects currently on development?
76
3807
by: Nick Coghlan | last post by:
GvR has commented that he want to get rid of the lambda keyword for Python 3.0. Getting rid of lambda seems like a worthy goal, but I'd prefer to see it dropped in favour of a different syntax, rather than completely losing the ability to have anonymous functions. Anyway, I'm looking for feedback on a def-based syntax that came up in a recent c.l.p discussion:...
0
1860
by: Fuzzyman | last post by:
Hello all, The following is a copy of a blog entry. It's asking a question about future statements and the built in compile function. I'd appreciate any pointers or comments about possible approaches. `Movable Python <http://www.voidspace.org.uk/python/movpy/>`_ supports running both Python scripts and ``.pyc`` bytecode files. It does this by compiling scripts to bytecode, or extracting the code object from bytecode files, and then...
1
1841
by: brianlum | last post by:
Hi, If I try to print a negative integer as a hexadecimal, I get the following error: FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up For example: >>> print "%X" % -1 __main__:1: FutureWarning: %u/%o/%x/%X of negative int will return a
190
8214
by: blangela | last post by:
If you had asked me 5 years ago about the future of C++, I would have told you that its future was assured for many years to come. Recently, I have been starting to wonder. I have been teaching C++ at a local polytechnical school here in Vancouver, Canada for approximately 8 years. Six years ago, at the height (or should I say volume?) of the internet bubble, I had 80+ students per semester in my C++ course. Now I am fortunate to have...
75
3225
by: kwikius | last post by:
My hunch is my posts to clc++ are disappearing down a hole, so I post here instead. Future of C++ thread on clc++ "Abhishek" <nospam_abhishekpandey@yahoo.comwrote in message news:g77cj6$eij$1@aioe.org... AFAICS C++ is very much about a "craft" approach to software development.
2
4017
by: varunkumarid | last post by:
Hello Everybody, Now i would join the Programmer for developing the web based applications in Python In India. I dont know exactly the scope of the Python.. So please tell me the Future scope of the python
0
10335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.