[Python-checkins] r63474 - in sandbox/trunk/ttk-gsoc: samples/treeview_multicolumn.py src/2.x/ttk.py src/3.x/ttk.py
guilherme.polo
python-checkins at python.org
Tue May 20 04:24:00 CEST 2008
Author: guilherme.polo
Date: Tue May 20 04:23:59 2008
New Revision: 63474
Log:
_dict_from_tcltuple deals more correctly with ttk::style map return now;
I've removed all these cnf={} which doesn't seem to be needed, for this
module at least;
Modified:
sandbox/trunk/ttk-gsoc/samples/treeview_multicolumn.py
sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
Modified: sandbox/trunk/ttk-gsoc/samples/treeview_multicolumn.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/treeview_multicolumn.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/treeview_multicolumn.py Tue May 20 04:23:59 2008
@@ -70,13 +70,10 @@
self.tree = ttk.Treeview(columns=tree_columns, show="headings")
vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview)
hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview)
- self.tree.configure(yscroll=vsb.set, xscroll=hsb.set)
- self.tree.grid_configure(**{'in': container})
- self.tree.grid(column=0, row=0, sticky='nsew')
- vsb.grid_configure(**{'in': container})
- vsb.grid(column=1, row=0, sticky='ns')
- hsb.grid_configure(**{'in': container})
- hsb.grid(column=0, row=1, sticky='ew')
+ self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
+ self.tree.grid(column=0, row=0, sticky='nsew', in_=container)
+ vsb.grid(column=1, row=0, sticky='ns', in_=container)
+ hsb.grid(column=0, row=1, sticky='ew', in_=container)
container.grid_columnconfigure(0, weight=1)
container.grid_rowconfigure(0, weight=1)
Modified: sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/2.x/ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/src/2.x/ttk.py Tue May 20 04:23:59 2008
@@ -28,7 +28,7 @@
def _loadttk(loadtk):
# This extends the default Tkinter.Tk._loadtk method so we can be
- # sure that Ttk is available for use, or not.
+ # sure that ttk is available for use, or not.
def f(self):
loadtk(self)
if REQUIRE_TILE:
@@ -254,10 +254,17 @@
elif hasattr(value, "__len__") and hasattr(value[0], "typename"):
if value[0].typename == "StateSpec":
- value = [[str(value[0]).split(), value[1]]]
+ v = []
+ for m in range(len(value) / 2):
+ state, sval = value[m * 2: m * 2 + 2]
+ state = str(state).split()
+ if len(state) < 2:
+ state = state[0]
+ v.append((state, sval))
+ value = v
opts.append((str(opt), value))
-
+
# the supposed '-' prefixing options will be removed if cut_minus is True.
return dict((opt[1 if cut_minus else 0:], val) for opt, val in opts)
@@ -459,7 +466,7 @@
class Widget(Tkinter.Widget):
"""Base class for Tk themed widgets."""
- def __init__(self, master, widgetname, cnf={}, kw={}, extra=()):
+ def __init__(self, master, widgetname, kw=None):
"""Constructs a Ttk Widget with the parent master.
STANDARD OPTIONS
@@ -479,7 +486,7 @@
active, disabled, focus, pressed, selected, background,
readonly, alternate, invalid
"""
- Tkinter.Widget.__init__(self, master, widgetname, cnf, kw, extra)
+ Tkinter.Widget.__init__(self, master, widgetname, kw=kw)
def identify(self, x, y):
@@ -521,7 +528,7 @@
"""Ttk Button widget, displays a textual label and/or image, and
evaluates a command when pressed."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Button widget with the parent master.
STANDARD OPTIONS
@@ -533,13 +540,13 @@
command, default, width
"""
- Widget.__init__(self, master, "ttk::button", cnf, kw)
+ Widget.__init__(self, master, "ttk::button", kw)
class Checkbutton(Widget):
"""Ttk Checkbutton widget which is either in on- or off-state."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Checkbutton widget with the parent master.
STANDARD OPTIONS
@@ -551,7 +558,7 @@
command, offvalue, onvalue, variable
"""
- Widget.__init__(self, master, "ttk::checkbutton", cnf, kw)
+ Widget.__init__(self, master, "ttk::checkbutton", kw)
def invoke(self):
@@ -569,7 +576,7 @@
"""Ttk Entry widget displays a one-line text string and allows that
string to be edited by the user."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Constructs a Ttk Entry widget with the parent master.
STANDARD OPTIONS
@@ -585,7 +592,7 @@
none, key, focus, focusin, focusout, all
"""
- Widget.__init__(self, master, "ttk::entry", cnf, kw)
+ Widget.__init__(self, master, "ttk::entry", kw)
def bbox(self, index):
@@ -611,7 +618,7 @@
"""Ttk Combobox widget combines a text field with a pop-down list of
values."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Combobox widget with the parent master.
STANDARD OPTIONS
@@ -623,7 +630,7 @@
exportselection, justify, height, postcommand, state,
textvariable, values, width
"""
- Widget.__init__(self, master, "ttk::combobox", cnf, kw)
+ Widget.__init__(self, master, "ttk::combobox", kw)
def current(self, newindex=None):
@@ -643,7 +650,7 @@
"""Ttk Frame widget is a container, used to group other widgets
together."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Frame with parent master.
STANDARD OPTIONS
@@ -654,13 +661,13 @@
borderwidth, relief, padding, width, height
"""
- Widget.__init__(self, master, "ttk::frame", cnf, kw)
+ Widget.__init__(self, master, "ttk::frame", kw)
class Label(Widget):
"""Ttk Label widget displays a textual label and/or image."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Label with parent master.
STANDARD OPTIONS
@@ -673,7 +680,7 @@
anchor, background, font, foreground, justify, padding,
relief, text, wraplength
"""
- Widget.__init__(self, master, "ttk::label", cnf, kw)
+ Widget.__init__(self, master, "ttk::label", kw)
class Labelframe(Widget):
@@ -681,7 +688,7 @@
together. It has an optional label, which may be a plain text string
or another widget."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Labelframe with parent master.
STANDARD OPTIONS
@@ -692,7 +699,7 @@
labelanchor, text, underline, padding, labelwidget, width,
height
"""
- Widget.__init__(self, master, "ttk::labelframe", cnf, kw)
+ Widget.__init__(self, master, "ttk::labelframe", kw)
LabelFrame = Labelframe # Tkinter name compatibility
@@ -701,7 +708,7 @@
"""Ttk Menubutton widget displays a textual label and/or image, and
displays a menu when pressed."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Menubutton with parent master.
STANDARD OPTIONS
@@ -713,7 +720,7 @@
direction, menu
"""
- Widget.__init__(self, master, "ttk::menubutton", cnf, kw)
+ Widget.__init__(self, master, "ttk::menubutton", kw)
class Notebook(Widget):
@@ -721,7 +728,7 @@
a single one at a time. Each child window is associated with a tab,
which the user may select to change the currently-displayed window."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Notebook with parent master.
STANDARD OPTIONS
@@ -750,7 +757,7 @@
* The string "end", which returns the number of tabs (only
valid for method index)
"""
- Widget.__init__(self, master, "ttk::notebook", cnf, kw)
+ Widget.__init__(self, master, "ttk::notebook", kw)
def add(self, child, **kw):
@@ -851,7 +858,7 @@
"""Ttk Panedwindow widget displays a number of subwindows, stacked
either vertically or horizontally."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Panedwindow with parent master.
STANDARD OPTIONS
@@ -866,7 +873,7 @@
weight
"""
- Widget.__init__(self, master, "ttk::panedwindow", cnf, kw)
+ Widget.__init__(self, master, "ttk::panedwindow", kw)
forget = Tkinter.PanedWindow.remove
@@ -911,7 +918,7 @@
indeterminate mode provides an animated display to let the user know
that something is happening."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Progressbar with parent master.
STANDARD OPTIONS
@@ -922,7 +929,7 @@
orient, length, mode, maximum, value, variable, phase
"""
- Widget.__init__(self, master, "ttk::progressbar", cnf, kw)
+ Widget.__init__(self, master, "ttk::progressbar", kw)
def start(self, interval=None):
@@ -950,7 +957,7 @@
"""Ttk Radiobutton widgets are used in groups to show or change a
set of mutually-exclusive options."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Radiobutton with parent master.
STANDARD OPTIONS
@@ -962,7 +969,7 @@
command, value, variable
"""
- Widget.__init__(self, master, "ttk::radiobutton", cnf, kw)
+ Widget.__init__(self, master, "ttk::radiobutton", kw)
def invoke(self):
@@ -977,7 +984,7 @@
class Scrollbar(Widget, Tkinter.Scrollbar):
"""Ttk Scrollbar controls the viewport of a scrollable widget."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Scrollbar with parent master.
STANDARD OPTIONS
@@ -988,14 +995,14 @@
command, orient
"""
- Widget.__init__(self, master, "ttk::scrollbar", cnf, kw)
+ Widget.__init__(self, master, "ttk::scrollbar", kw)
class Separator(Widget):
"""Ttk Separator widget displays a horizontal or vertical separator
bar."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Separator with parent master.
STANDARD OPTIONS
@@ -1006,21 +1013,21 @@
orient
"""
- Widget.__init__(self, master, "ttk::separator", cnf, kw)
+ Widget.__init__(self, master, "ttk::separator", kw)
class Sizegrip(Widget):
"""Ttk Sizegrip allows the user to resize the containing toplevel
window by pressing and dragging the grip."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Sizegrip with parent master.
STANDARD OPTIONS
class, cursor, state, style, takefocus
"""
- Widget.__init__(self, master, "ttk::sizegrip", cnf, kw)
+ Widget.__init__(self, master, "ttk::sizegrip", kw)
class Treeview(Widget):
@@ -1030,7 +1037,7 @@
of data values. The data values are displayed in successive columns
after the tree label."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Treeview with parent master.
STANDARD OPTIONS
@@ -1050,7 +1057,7 @@
foreground, background, font, image
"""
- Widget.__init__(self, master, "ttk::treeview", cnf, kw)
+ Widget.__init__(self, master, "ttk::treeview", kw)
def bbox(self, item, column=None):
Modified: sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/3.x/ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/src/3.x/ttk.py Tue May 20 04:23:59 2008
@@ -28,7 +28,7 @@
def _loadttk(loadtk):
# This extends the default tkinter.Tk._loadtk method so we can be
- # sure that Ttk is available for use, or not.
+ # sure that ttk is available for use, or not.
def f(self):
loadtk(self)
if REQUIRE_TILE:
@@ -226,7 +226,7 @@
# find where args end, and where kwargs start
argc = 1 # etype was the first one
- while argc < len(eopts) and not hasattr(eopts[argc], 'items'):
+ while argc < len(eopts) and not hasattr(eopts[argc], 'iteritems'):
argc += 1
elemargs = eopts[1:argc]
@@ -254,10 +254,17 @@
elif hasattr(value, "__len__") and hasattr(value[0], "typename"):
if value[0].typename == "StateSpec":
- value = [[str(value[0]).split(), value[1]]]
+ v = []
+ for m in range(len(value) // 2):
+ state, sval = value[m * 2: m * 2 + 2]
+ state = str(state).split()
+ if len(state) < 2:
+ state = state[0]
+ v.append((state, sval))
+ value = v
opts.append((str(opt), value))
-
+
# the supposed '-' prefixing options will be removed if cut_minus is True.
return dict((opt[1 if cut_minus else 0:], val) for opt, val in opts)
@@ -459,7 +466,7 @@
class Widget(tkinter.Widget):
"""Base class for Tk themed widgets."""
- def __init__(self, master, widgetname, cnf={}, kw={}, extra=()):
+ def __init__(self, master, widgetname, kw=None):
"""Constructs a Ttk Widget with the parent master.
STANDARD OPTIONS
@@ -479,7 +486,7 @@
active, disabled, focus, pressed, selected, background,
readonly, alternate, invalid
"""
- tkinter.Widget.__init__(self, master, widgetname, cnf, kw, extra)
+ tkinter.Widget.__init__(self, master, widgetname, kw=kw)
def identify(self, x, y):
@@ -521,7 +528,7 @@
"""Ttk Button widget, displays a textual label and/or image, and
evaluates a command when pressed."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Button widget with the parent master.
STANDARD OPTIONS
@@ -533,13 +540,13 @@
command, default, width
"""
- Widget.__init__(self, master, "ttk::button", cnf, kw)
+ Widget.__init__(self, master, "ttk::button", kw)
class Checkbutton(Widget):
"""Ttk Checkbutton widget which is either in on- or off-state."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Checkbutton widget with the parent master.
STANDARD OPTIONS
@@ -551,7 +558,7 @@
command, offvalue, onvalue, variable
"""
- Widget.__init__(self, master, "ttk::checkbutton", cnf, kw)
+ Widget.__init__(self, master, "ttk::checkbutton", kw)
def invoke(self):
@@ -569,7 +576,7 @@
"""Ttk Entry widget displays a one-line text string and allows that
string to be edited by the user."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Constructs a Ttk Entry widget with the parent master.
STANDARD OPTIONS
@@ -585,7 +592,7 @@
none, key, focus, focusin, focusout, all
"""
- Widget.__init__(self, master, "ttk::entry", cnf, kw)
+ Widget.__init__(self, master, "ttk::entry", kw)
def bbox(self, index):
@@ -611,7 +618,7 @@
"""Ttk Combobox widget combines a text field with a pop-down list of
values."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Combobox widget with the parent master.
STANDARD OPTIONS
@@ -623,7 +630,7 @@
exportselection, justify, height, postcommand, state,
textvariable, values, width
"""
- Widget.__init__(self, master, "ttk::combobox", cnf, kw)
+ Widget.__init__(self, master, "ttk::combobox", kw)
def current(self, newindex=None):
@@ -643,7 +650,7 @@
"""Ttk Frame widget is a container, used to group other widgets
together."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Frame with parent master.
STANDARD OPTIONS
@@ -654,13 +661,13 @@
borderwidth, relief, padding, width, height
"""
- Widget.__init__(self, master, "ttk::frame", cnf, kw)
+ Widget.__init__(self, master, "ttk::frame", kw)
class Label(Widget):
"""Ttk Label widget displays a textual label and/or image."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Label with parent master.
STANDARD OPTIONS
@@ -673,7 +680,7 @@
anchor, background, font, foreground, justify, padding,
relief, text, wraplength
"""
- Widget.__init__(self, master, "ttk::label", cnf, kw)
+ Widget.__init__(self, master, "ttk::label", kw)
class Labelframe(Widget):
@@ -681,7 +688,7 @@
together. It has an optional label, which may be a plain text string
or another widget."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Labelframe with parent master.
STANDARD OPTIONS
@@ -692,7 +699,7 @@
labelanchor, text, underline, padding, labelwidget, width,
height
"""
- Widget.__init__(self, master, "ttk::labelframe", cnf, kw)
+ Widget.__init__(self, master, "ttk::labelframe", kw)
LabelFrame = Labelframe # tkinter name compatibility
@@ -701,7 +708,7 @@
"""Ttk Menubutton widget displays a textual label and/or image, and
displays a menu when pressed."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Menubutton with parent master.
STANDARD OPTIONS
@@ -713,7 +720,7 @@
direction, menu
"""
- Widget.__init__(self, master, "ttk::menubutton", cnf, kw)
+ Widget.__init__(self, master, "ttk::menubutton", kw)
class Notebook(Widget):
@@ -721,7 +728,7 @@
a single one at a time. Each child window is associated with a tab,
which the user may select to change the currently-displayed window."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Notebook with parent master.
STANDARD OPTIONS
@@ -750,7 +757,7 @@
* The string "end", which returns the number of tabs (only
valid for method index)
"""
- Widget.__init__(self, master, "ttk::notebook", cnf, kw)
+ Widget.__init__(self, master, "ttk::notebook", kw)
def add(self, child, **kw):
@@ -851,7 +858,7 @@
"""Ttk Panedwindow widget displays a number of subwindows, stacked
either vertically or horizontally."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Panedwindow with parent master.
STANDARD OPTIONS
@@ -866,7 +873,7 @@
weight
"""
- Widget.__init__(self, master, "ttk::panedwindow", cnf, kw)
+ Widget.__init__(self, master, "ttk::panedwindow", kw)
forget = tkinter.PanedWindow.remove
@@ -911,7 +918,7 @@
indeterminate mode provides an animated display to let the user know
that something is happening."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Progressbar with parent master.
STANDARD OPTIONS
@@ -922,7 +929,7 @@
orient, length, mode, maximum, value, variable, phase
"""
- Widget.__init__(self, master, "ttk::progressbar", cnf, kw)
+ Widget.__init__(self, master, "ttk::progressbar", kw)
def start(self, interval=None):
@@ -950,7 +957,7 @@
"""Ttk Radiobutton widgets are used in groups to show or change a
set of mutually-exclusive options."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Radiobutton with parent master.
STANDARD OPTIONS
@@ -962,7 +969,7 @@
command, value, variable
"""
- Widget.__init__(self, master, "ttk::radiobutton", cnf, kw)
+ Widget.__init__(self, master, "ttk::radiobutton", kw)
def invoke(self):
@@ -977,7 +984,7 @@
class Scrollbar(Widget, tkinter.Scrollbar):
"""Ttk Scrollbar controls the viewport of a scrollable widget."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Scrollbar with parent master.
STANDARD OPTIONS
@@ -988,14 +995,14 @@
command, orient
"""
- Widget.__init__(self, master, "ttk::scrollbar", cnf, kw)
+ Widget.__init__(self, master, "ttk::scrollbar", kw)
class Separator(Widget):
"""Ttk Separator widget displays a horizontal or vertical separator
bar."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Separator with parent master.
STANDARD OPTIONS
@@ -1006,21 +1013,21 @@
orient
"""
- Widget.__init__(self, master, "ttk::separator", cnf, kw)
+ Widget.__init__(self, master, "ttk::separator", kw)
class Sizegrip(Widget):
"""Ttk Sizegrip allows the user to resize the containing toplevel
window by pressing and dragging the grip."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Sizegrip with parent master.
STANDARD OPTIONS
class, cursor, state, style, takefocus
"""
- Widget.__init__(self, master, "ttk::sizegrip", cnf, kw)
+ Widget.__init__(self, master, "ttk::sizegrip", kw)
class Treeview(Widget):
@@ -1030,7 +1037,7 @@
of data values. The data values are displayed in successive columns
after the tree label."""
- def __init__(self, master=None, cnf={}, **kw):
+ def __init__(self, master=None, **kw):
"""Construct a Ttk Treeview with parent master.
STANDARD OPTIONS
@@ -1050,7 +1057,7 @@
foreground, background, font, image
"""
- Widget.__init__(self, master, "ttk::treeview", cnf, kw)
+ Widget.__init__(self, master, "ttk::treeview", kw)
def bbox(self, item, column=None):
More information about the Python-checkins
mailing list