[Python-checkins] r63399 - in sandbox/trunk/ttk-gsoc: Doc/library/tk.rst.diff Doc/library/ttk.rst Lib README samples/combo_themes.py samples/dirbrowser.py samples/listbox_scrollcmd.py samples/mac_searchentry.py samples/notebook_closebtn.py samples/roundframe.py samples/theme_selector.py samples/treeview_multicolumn.py samples/widget_state.py src/2.x/ttk.py src/3.x/ttk.py src/README
guilherme.polo
python-checkins at python.org
Sat May 17 04:01:51 CEST 2008
Author: guilherme.polo
Date: Sat May 17 04:01:51 2008
New Revision: 63399
Log:
Changed directory strucutre a bit:
Lib/lib-tk -> src/2.x
Lib/tkinter -> src/3.x
README -> src/README
Both versions have a ttk module now;
Updated 3.x version to match current 2.x version;
Updated README to match the new structure;
Updated ttk.rst to deal with this Ttk -> ttk renaming;
Updated tk.rst.diff so it matches the latest tk.rst from python-trunk;
Updated samples and doc to deal with this module renaming;
Added:
sandbox/trunk/ttk-gsoc/src/2.x/ttk.py
- copied unchanged from r63398, /sandbox/trunk/ttk-gsoc/Lib/lib-tk/Ttk.py
sandbox/trunk/ttk-gsoc/src/3.x/ttk.py
- copied, changed from r63254, /sandbox/trunk/ttk-gsoc/Lib/tkinter/ttk.py
sandbox/trunk/ttk-gsoc/src/README
- copied, changed from r63232, /sandbox/trunk/ttk-gsoc/README
Removed:
sandbox/trunk/ttk-gsoc/Lib/
sandbox/trunk/ttk-gsoc/README
Modified:
sandbox/trunk/ttk-gsoc/Doc/library/tk.rst.diff
sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
sandbox/trunk/ttk-gsoc/samples/combo_themes.py
sandbox/trunk/ttk-gsoc/samples/dirbrowser.py
sandbox/trunk/ttk-gsoc/samples/listbox_scrollcmd.py
sandbox/trunk/ttk-gsoc/samples/mac_searchentry.py
sandbox/trunk/ttk-gsoc/samples/notebook_closebtn.py
sandbox/trunk/ttk-gsoc/samples/roundframe.py
sandbox/trunk/ttk-gsoc/samples/theme_selector.py
sandbox/trunk/ttk-gsoc/samples/treeview_multicolumn.py
sandbox/trunk/ttk-gsoc/samples/widget_state.py
Modified: sandbox/trunk/ttk-gsoc/Doc/library/tk.rst.diff
==============================================================================
--- sandbox/trunk/ttk-gsoc/Doc/library/tk.rst.diff (original)
+++ sandbox/trunk/ttk-gsoc/Doc/library/tk.rst.diff Sat May 17 04:01:51 2008
@@ -1,22 +1,23 @@
Index: Doc/library/tk.rst
===================================================================
---- Doc/library/tk.rst (revision 63156)
+--- Doc/library/tk.rst (revision 63398)
+++ Doc/library/tk.rst (working copy)
-@@ -12,7 +12,8 @@
+@@ -12,8 +12,8 @@
Tk/Tcl has long been an integral part of Python. It provides a robust and
platform independent windowing toolkit, that is available to Python programmers
--using the :mod:`Tkinter` module, and its extension, the :mod:`Tix` module.
-+using the :mod:`Tkinter` module, its extension, the :mod:`Tix` module and the
-+:mod:`Ttk` module for using themed widgets.
+-using the :mod:`tkinter` package, and its extension, the :mod:`tkinter.tix`
+-module.
++using the :mod:`tkinter` package, its extension, the :mod:`tkinter.tix` module
++and the :mod:`ttk` module for using themed widgets.
- The :mod:`Tkinter` module is a thin object-oriented layer on top of Tcl/Tk. To
- use :mod:`Tkinter`, you don't need to write Tcl code, but you will need to
-@@ -32,6 +33,7 @@
- .. toctree::
-
- tkinter.rst
+ The :mod:`tkinter` package is a thin object-oriented layer on top of Tcl/Tk. To
+ use :mod:`tkinter`, you don't need to write Tcl code, but you will need to
+@@ -36,6 +36,7 @@
+ tkinter.tix.rst
+ tkinter.scrolledtext.rst
+ tkinter.turtle.rst
+ ttk.rst
- tix.rst
- scrolledtext.rst
- turtle.rst
+ idle.rst
+ othergui.rst
+
Modified: sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
==============================================================================
--- sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst (original)
+++ sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst Sat May 17 04:01:51 2008
@@ -1,21 +1,21 @@
-:mod:`Ttk` --- Tk themed widgets
+:mod:`ttk` --- Tk themed widgets
================================
-.. module:: Ttk
+.. module:: ttk
:synopsis: Tk themed widget set
.. sectionauthor:: Guilherme Polo <ggpolo at gmail.com>
-.. index:: single: Ttk
+.. index:: single: ttk
-The :mod:`Ttk` module provides access to the Tk themed widget set, which
+The :mod:`ttk` module provides access to the Tk themed widget set, which
has been introduced in Tk 8.5. If you do not have Python compiled against
Tk 8.5 you may still use this module as long as you have Tile installed and
you will also miss other features of the new Tk, like anti-aliased font
rendering under X11, window transparency (on X11 you will need a composition
window manager), and others.
-The basic idea of :mod:`Ttk` is to separate, to the extent possible, the code
+The basic idea of :mod:`ttk` is to separate, to the extent possible, the code
implementing a widget's behavior from the code implementing its appearance.
@@ -30,18 +30,18 @@
Basically, to start using Ttk, you have to import its module::
- import Ttk
+ import ttk
But if you already have some code that does::
- from Tkinter import *
+ from tkinter import *
You may optionally want to use::
- from Tkinter import *
- from Ttk import *
+ from tkinter import *
+ from ttk import *
-So several :mod:`Ttk` widgets (:class:`Button`, :class:`Entry`, :class:`Frame`,
+So several :mod:`ttk` widgets (:class:`Button`, :class:`Entry`, :class:`Frame`,
:class:`Label`, :class:`LabelFrame`, :class:`Menubutton`, :class:`PanedWindow`,
:class:`Radiobutton`, :class:`Scrollbar`) will automatically substitute the Tk
widgets.
@@ -70,17 +70,17 @@
Tk code::
- l1 = Tkinter.Label(text="Test", fg="black", bg="white")
- l2 = Tkinter.Label(text="Test", fg="black", bg="white")
+ l1 = tkinter.Label(text="Test", fg="black", bg="white")
+ l2 = tkinter.Label(text="Test", fg="black", bg="white")
Ttk code::
- style = Ttk.Style()
+ style = ttk.Style()
style.configure("BW.TLabel", foreground="black", background="white")
- l1 = Ttk.Label(text="Test", style="BW.TLabel")
- l2 = Ttk.Label(text="Test", style="BW.TLabel")
+ l1 = ttk.Label(text="Test", style="BW.TLabel")
+ l2 = ttk.Label(text="Test", style="BW.TLabel")
For more information about TtkStyling_ read the :class:`Style` class
documentation.
@@ -88,14 +88,14 @@
Widget
------
-:class:`Ttk.Widget` defines standard options and methods supported by Tk
+:class:`ttk.Widget` defines standard options and methods supported by Tk
themed widgets.
Standard Options
^^^^^^^^^^^^^^^^
-:class:`Ttk.Widget` accepts the following options, as well all the other Ttk
+:class:`ttk.Widget` accepts the following options, as well all the other Ttk
widgets:
+-----------+--------------------------------------------------------------+
@@ -239,11 +239,11 @@
an exclamation point indicating that the bit is off.
-Ttk.Widget
+ttk.Widget
^^^^^^^^^^
-Besides the methods described below, :class:`Ttk.Widget` supports the
-methods :meth:`Tkinter.Widget.cget` and :meth:`Tkinter.Widget.configure`.
+Besides the methods described below, :class:`ttk.Widget` supports the
+methods :meth:`tkinter.Widget.cget` and :meth:`tkinter.Widget.configure`.
.. class:: Widget
@@ -284,7 +284,7 @@
and :meth:`Widget.state`, and the following inherited from :class:`Entry`:
:meth:`Entry.bbox`, :meth:`Entry.delete`, :meth:`Entry.icursor`,
:meth:`Entry.index`, :meth:`Entry.inset`, :meth:`Entry.selection`,
-:meth:`Entry.xview`, it has some other methods, described at `Ttk.Combobox`_.
+:meth:`Entry.xview`, it has some other methods, described at `ttk.Combobox`_.
Options
^^^^^^^
@@ -317,7 +317,7 @@
| textvariable | Specifies a name whose value is linked to the widget |
| | value. Whenever the value associated with that name |
| | changes, the widget value is updated, and vice versa. |
- | | See :class:`Tkinter.StringVar`. |
+ | | See :class:`tkinter.StringVar`. |
+-----------------+--------------------------------------------------------+
| values | Specifies the list of values to display in the |
| | drop-down listbox. |
@@ -335,7 +335,7 @@
when the user selects an element from the list of values.
-Ttk.Combobox
+ttk.Combobox
^^^^^^^^^^^^
.. class:: Combobox
@@ -430,7 +430,7 @@
Tab Identifiers
^^^^^^^^^^^^^^^
-The tab_id present in several methods of :class:`Ttk.Notebook` may take any
+The tab_id present in several methods of :class:`ttk.Notebook` may take any
of the following forms:
* An integer between zero and the number of tabs
@@ -448,7 +448,7 @@
tab is selected.
-Ttk.Notebook
+ttk.Notebook
^^^^^^^^^^^^
.. class:: Notebook
@@ -586,7 +586,7 @@
+----------+---------------------------------------------------------------+
-Ttk.Progressbar
+ttk.Progressbar
^^^^^^^^^^^^^^^
.. class:: Progressbar
@@ -616,7 +616,7 @@
Ttk Separator widget displays a horizontal or vertical separator bar.
-It has no other method besides the ones inherited from :class:`Ttk.Widget`.
+It has no other method besides the ones inherited from :class:`ttk.Widget`.
Options
@@ -823,7 +823,7 @@
determine the affected item or items.
-Ttk.Treeview
+ttk.Treeview
^^^^^^^^^^^^
.. class:: Treeview
@@ -1098,15 +1098,15 @@
For example, to change every default button to be a flat button with
some padding and a different background color you could do::
- import Ttk
- import Tkinter
+ import ttk
+ import tkinter
- root = Tkinter.Tk()
+ root = tkinter.Tk()
- Ttk.Style().configure("TButton", padding=6, relief="flat",
+ ttk.Style().configure("TButton", padding=6, relief="flat",
background="#ccc")
- btn = Ttk.Button(text="Sample")
+ btn = ttk.Button(text="Sample")
btn.pack()
root.mainloop()
@@ -1124,12 +1124,12 @@
An example may make it more understandable::
- import Tkinter
- import Ttk
+ import tkinter
+ import ttk
- root = Tkinter.Tk()
+ root = tkinter.Tk()
- style = Ttk.Style()
+ style = ttk.Style()
style.map("C.TButton",
foreground=[('pressed', 'red'),
('active', 'blue')],
@@ -1137,7 +1137,7 @@
('active', 'white')]
)
- colored_btn = Ttk.Button(text="Test", style="C.TButton").pack()
+ colored_btn = ttk.Button(text="Test", style="C.TButton").pack()
root.mainloop()
@@ -1164,9 +1164,9 @@
To check what font a Button uses by default, you would do::
- import Ttk
+ import ttk
- print Ttk.Style().lookup("TButton", "font")
+ print ttk.Style().lookup("TButton", "font")
.. method:: layout(style[, layoutspec=None])
@@ -1246,12 +1246,12 @@
As an example, lets change the Combobox for the default theme a bit::
- import Ttk
- import Tkinter
+ import ttk
+ import tkinter
- root = Tkinter.Tk()
+ root = tkinter.Tk()
- style = Ttk.Style()
+ style = ttk.Style()
style.theme_settings("default", {
"TCombobox": {
"configure": {"padding": 5},
@@ -1265,7 +1265,7 @@
}
})
- combo = Ttk.Combobox().pack()
+ combo = ttk.Combobox().pack()
root.mainloop()
Deleted: sandbox/trunk/ttk-gsoc/README
==============================================================================
--- sandbox/trunk/ttk-gsoc/README Sat May 17 04:01:51 2008
+++ (empty file)
@@ -1,50 +0,0 @@
-Testing Code
-============
-
-You will need Python with a _tkinter compiled against Tcl/Tk 8.5
-otherwise Tile[1] has to be installed. I have tested it under Linux
-with python 2.5.2 (Ubuntu package), python-trunk, release25-maint and
-py3k repos and under Windows XP with python 2.5.1.
-
-Given that you meet the requirements, you should be able to run the
-samples passing the appropriate PYTHONPATH (ttk-gsoc/Lib/lib-tk for
-python 2.x and ttk-gsoc/Lib/ for python 3.x) or placing the Ttk module
-somewhere in sys.path.
-
-[1] I've tested it with Tile 0.8.2 and it works, but I would recommend
- upgrading to Tcl/Tk 8.5 so you get antialiased fonts and other
- nice features. If you are testing this wrapper with Tile, it will
- look for the environment variable TILE_LIBRARY, which you can set
- to your tile library path if you installed it in a custom place.
-
-
-Reading the Documentation
-=========================
-
-There are just ttk.rst and tk.rst.diff files at Doc/library and while you
-could read the ttk.rst with any editor you will probably want to read it
-nicely formatted as html.
-To generate this html, you will have to checkout the python trunk
-repository (the one I tested with the docs):
-
- $ svn co http://svn.python.org/projects/python/trunk python-trunk
-
-And then, optionally, apply tk.rst.diff using patch -p0 < file.diff. Next
-you have to place ttk-gsoc/Doc/library/ttk.rst in python-trunk/Doc/library
-and then cd into python-trunk/Doc/library and do:
-
- $ make html
-
-After it completes, you can use your browser to read the Ttk documentation.
-The path to the ttk.html will be something like:
-file:///SOMEPATH/python-trunk/Doc/build/html/library/ttk.html
-
-
-References
-==========
-
-What I'm using as a reference to know how complete the project is:
-
-Changes in Tcl/Tk 8.5 http://wiki.tcl.tk/10630
-Tk Commands http://www.tcl.tk/man/tcl8.5/TkCmd/contents.htm
-Tk source code http://tktoolkit.cvs.sourceforge.net/tktoolkit/
Modified: sandbox/trunk/ttk-gsoc/samples/combo_themes.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/combo_themes.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/combo_themes.py Sat May 17 04:01:51 2008
@@ -3,12 +3,7 @@
Although it is a theme selector, you won't notice many changes since
there is only a combobox and a frame around.
"""
-import sys
-
-if sys.version_info[0] > 2:
- from tkinter import ttk
-else:
- import Ttk as ttk
+import ttk
class App(ttk.Frame):
def __init__(self):
Modified: sandbox/trunk/ttk-gsoc/samples/dirbrowser.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/dirbrowser.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/dirbrowser.py Sat May 17 04:01:51 2008
@@ -4,14 +4,10 @@
http://bitwalk.blogspot.com/2008/01/ttktreeview.html
"""
import os
-import sys
import glob
import Tkinter
-if sys.version_info[0] > 2:
- from tkinter import ttk
-else:
- import Ttk as ttk
+import ttk
def populate_tree(tree, node):
if tree.set(node, "type") != 'directory':
Modified: sandbox/trunk/ttk-gsoc/samples/listbox_scrollcmd.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/listbox_scrollcmd.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/listbox_scrollcmd.py Sat May 17 04:01:51 2008
@@ -10,23 +10,23 @@
.l insert end "Line $i of 100"
}
"""
-
import Tkinter
-import Ttk
+
+import ttk
root = Tkinter.Tk()
l = Tkinter.Listbox(height=5)
l.grid(column=0, row=0, sticky='nwes')
-s = Ttk.Scrollbar(command=l.yview, orient='vertical')
+s = ttk.Scrollbar(command=l.yview, orient='vertical')
l['yscrollcommand'] = s.set
s.grid(column=1, row=0, sticky="ns")
-stat = Ttk.Label(text="Status message here", anchor='w')
+stat = ttk.Label(text="Status message here", anchor='w')
stat.grid(column=0, row=1, sticky='we')
-sz = Ttk.Sizegrip()
+sz = ttk.Sizegrip()
sz.grid(column=1, row=1, sticky='se')
root.grid_columnconfigure(0, weight=1)
Modified: sandbox/trunk/ttk-gsoc/samples/mac_searchentry.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/mac_searchentry.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/mac_searchentry.py Sat May 17 04:01:51 2008
@@ -1,13 +1,9 @@
"""Mac style search widget
Translated from Tcl code by Schelte Bron, http://wiki.tcl.tk/18188"""
-import sys
import Tkinter
-if sys.version_info[0] > 2:
- from tkinter import ttk
-else:
- import Ttk as ttk
+import ttk
root = Tkinter.Tk()
Modified: sandbox/trunk/ttk-gsoc/samples/notebook_closebtn.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/notebook_closebtn.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/notebook_closebtn.py Sat May 17 04:01:51 2008
@@ -3,13 +3,9 @@
Based on an example by patthoyts, http://paste.tclers.tk/896
"""
import os
-import sys
import Tkinter
-if sys.version_info[0] > 2:
- from tkinter import ttk
-else:
- import Ttk as ttk
+import ttk
root = Tkinter.Tk()
Modified: sandbox/trunk/ttk-gsoc/samples/roundframe.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/roundframe.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/roundframe.py Sat May 17 04:01:51 2008
@@ -1,13 +1,9 @@
"""Ttk Frame with rounded corners.
Based on an example by Bryan Oakley, found at: http://wiki.tcl.tk/20152"""
-import sys
import Tkinter
-if sys.version_info[0] > 2:
- from tkinter import ttk
-else:
- import Ttk as ttk
+import ttk
root = Tkinter.Tk()
Modified: sandbox/trunk/ttk-gsoc/samples/theme_selector.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/theme_selector.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/theme_selector.py Sat May 17 04:01:51 2008
@@ -7,10 +7,7 @@
import sys
import Tkinter
-if sys.version_info[0] > 2:
- from tkinter import ttk
-else:
- import Ttk as ttk
+import ttk
class App(ttk.Frame):
def __init__(self):
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 Sat May 17 04:01:51 2008
@@ -1,12 +1,8 @@
"""Demo based on the demo mclist.tcl included with tk source distribution."""
-import sys
import Tkinter
import tkFont
-if sys.version_info[0] > 2:
- from tkinter import ttk
-else:
- import Ttk as ttk
+import ttk
tree_columns = ("country", "capital", "currency")
tree_data = [
Modified: sandbox/trunk/ttk-gsoc/samples/widget_state.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/samples/widget_state.py (original)
+++ sandbox/trunk/ttk-gsoc/samples/widget_state.py Sat May 17 04:01:51 2008
@@ -1,13 +1,9 @@
"""Sample demo showing widget states and some font styling."""
import sys
-if sys.version_info[0] > 2:
- from tkinter import ttk
- PY3K = True
-else:
- import Ttk as ttk
- PY3K = False
+import ttk
+PY3K = True if sys.version_info[0] > 2 else False
states = ['active', 'disabled', 'focus', 'pressed', 'selected',
'background', 'readonly', 'alternate', 'invalid']
Copied: sandbox/trunk/ttk-gsoc/src/3.x/ttk.py (from r63254, /sandbox/trunk/ttk-gsoc/Lib/tkinter/ttk.py)
==============================================================================
--- /sandbox/trunk/ttk-gsoc/Lib/tkinter/ttk.py (original)
+++ sandbox/trunk/ttk-gsoc/src/3.x/ttk.py Sat May 17 04:01:51 2008
@@ -364,15 +364,15 @@
# Microsoft Visual Styles API which is responsible for the
# themed styles on Windows XP and Vista.
# Availability: Tk 8.6, Windows XP and Vista.
- className, partId = args[:2]
+ class_name, part_id = args[:2]
statemap = _format_mapdict({None: args[2:]})[1]
- spec = "%s %s %s" % (className, partId, statemap)
+ spec = "%s %s %s" % (class_name, part_id, statemap)
opts = _format_optdict(kw)
elif etype == "from": # clone an element
# it expects a themename and optionally an element to clone from,
- # otherwise it will clone {} (empty)
+ # otherwise it will clone {} (empty element)
spec = args[0] # theme name
if len(args) > 1: # elementfrom specified
opts = (args[1], )
@@ -1037,10 +1037,6 @@
return self.tk.call(self._w, "bbox", item, column)
- # XXX Treeview has a command named "children", but it conflicts with
- # Tkinter.Tk.children. I've renamed and split "children" into
- # get_children and set_children
-
def get_children(self, item):
"""Returns a tuple of children belonging to item."""
return self.tk.call(self._w, "children", item)
@@ -1098,7 +1094,7 @@
Valid options/values are:
text: text
The text to display in the column heading
- image: imageName
+ image: image_name
Specifies an image to display to the right of the column
heading
anchor: anchor
@@ -1121,14 +1117,14 @@
def identify_row(self, y):
"""Returns the item ID of the item at position y."""
- return self.tk.call(self._w, "identify", "row", 0, y)
+ return self.identify("row", 0, y)
def identify_column(self, x):
"""Returns the data column identifier of the cell at position x.
The tree column has ID #0."""
- return self.tk.call(self._w, "identify", "column", x, 0)
+ return self.identify("column", x, 0)
def index(self, item):
@@ -1220,22 +1216,22 @@
def selection_set(self, items):
"""items becomes the new selection."""
- self.tk.call(self._w, "selection", "set", items)
+ self.selection("set", items)
def selection_add(self, items):
"""Add items to the selection."""
- self.tk.call(self._w, "selection", "add", items)
+ self.selection("add", items)
def selection_remove(self, items):
"""Remove items from the selection."""
- self.tk.call(self._w, "selection", "remove", items)
+ self.selection("remove", items)
def selection_toggle(self, items):
"""Toggle the selection state of each item in items."""
- self.tk.call(self._w, "selection", "toggle", items)
+ self.selection("toggle", items)
def set(self, item, column=None, value=None):
Copied: sandbox/trunk/ttk-gsoc/src/README (from r63232, /sandbox/trunk/ttk-gsoc/README)
==============================================================================
--- /sandbox/trunk/ttk-gsoc/README (original)
+++ sandbox/trunk/ttk-gsoc/src/README Sat May 17 04:01:51 2008
@@ -7,9 +7,9 @@
py3k repos and under Windows XP with python 2.5.1.
Given that you meet the requirements, you should be able to run the
-samples passing the appropriate PYTHONPATH (ttk-gsoc/Lib/lib-tk for
-python 2.x and ttk-gsoc/Lib/ for python 3.x) or placing the Ttk module
-somewhere in sys.path.
+samples passing the appropriate PYTHONPATH (ttk-gsoc/src/2.x or
+ttk-gsoc/src/3.x depending on your python version) or placing the ttk
+module somewhere in sys.path.
[1] I've tested it with Tile 0.8.2 and it works, but I would recommend
upgrading to Tcl/Tk 8.5 so you get antialiased fonts and other
More information about the Python-checkins
mailing list