[Python-checkins] r63650 - in sandbox/trunk/ttk-gsoc: README src/idlelib_ttk.diff

guilherme.polo python-checkins at python.org
Sun May 25 22:56:53 CEST 2008


Author: guilherme.polo
Date: Sun May 25 22:56:52 2008
New Revision: 63650

Log:
Initial idlelib move to ttk widgets

Added:
   sandbox/trunk/ttk-gsoc/src/idlelib_ttk.diff
Modified:
   sandbox/trunk/ttk-gsoc/README

Modified: sandbox/trunk/ttk-gsoc/README
==============================================================================
--- sandbox/trunk/ttk-gsoc/README	(original)
+++ sandbox/trunk/ttk-gsoc/README	Sun May 25 22:56:52 2008
@@ -55,3 +55,22 @@
 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/
+
+
+Experimental Tile
+=================
+
+Another part of the project is moving the idlelib to use the new ttk
+widgets and to add the possibility to use tabs instead of windows to
+display multiple shells and files.
+
+
+Testing it
+----------
+
+You will find a idlelib_ttk.diff inside the src/ directory. In order to
+apply it you will need to checkout the python-trunk repo, the same you did
+at `Reading the Documentation`_.
+After applying it you just have to run idle doing, something like this:
+
+$ PYTHONPATH=~/ttk-gsoc/src/2.x ./python Tools/scripts/idle

Added: sandbox/trunk/ttk-gsoc/src/idlelib_ttk.diff
==============================================================================
--- (empty file)
+++ sandbox/trunk/ttk-gsoc/src/idlelib_ttk.diff	Sun May 25 22:56:52 2008
@@ -0,0 +1,1454 @@
+Index: Lib/idlelib/AutoCompleteWindow.py
+===================================================================
+--- Lib/idlelib/AutoCompleteWindow.py	(revision 63649)
++++ Lib/idlelib/AutoCompleteWindow.py	(working copy)
+@@ -2,6 +2,7 @@
+ An auto-completion window for IDLE, used by the AutoComplete extension
+ """
+ from Tkinter import *
++from ttk import *
+ from MultiCall import MC_SHIFT
+ import AutoComplete
+ 
+Index: Lib/idlelib/ToolTip.py
+===================================================================
+--- Lib/idlelib/ToolTip.py	(revision 63649)
++++ Lib/idlelib/ToolTip.py	(working copy)
+@@ -3,7 +3,8 @@
+ # may be useful for some purposes in (or almost in ;) the current project scope
+ # Ideas gleaned from PySol
+ 
+-from Tkinter import *
++from Tkinter import END, Listbox, Tk, Toplevel
++from ttk import Button, Label
+ 
+ class ToolTipBase:
+ 
+Index: Lib/idlelib/configSectionNameDialog.py
+===================================================================
+--- Lib/idlelib/configSectionNameDialog.py	(revision 63649)
++++ Lib/idlelib/configSectionNameDialog.py	(working copy)
+@@ -3,6 +3,7 @@
+ Used to get new highlight theme and keybinding set names.
+ """
+ from Tkinter import *
++from ttk import *
+ import tkMessageBox
+ 
+ class GetCfgSectionNameDialog(Toplevel):
+@@ -46,7 +47,7 @@
+         entryName.focus_set()
+         self.messageInfo.pack(padx=5,pady=5)#,expand=TRUE,fill=BOTH)
+         entryName.pack(padx=5,pady=5)
+-        frameButtons=Frame(self)
++        frameButtons=Frame(self, style='RootColor.TFrame')
+         frameButtons.pack(side=BOTTOM,fill=X)
+         self.buttonOk = Button(frameButtons,text='Ok',
+                 width=8,command=self.Ok)
+Index: Lib/idlelib/PyShell.py
+===================================================================
+--- Lib/idlelib/PyShell.py	(revision 63649)
++++ Lib/idlelib/PyShell.py	(working copy)
+@@ -18,6 +18,7 @@
+ 
+ try:
+     from Tkinter import *
++    from ttk import *
+ except ImportError:
+     print>>sys.__stderr__, "** IDLE can't import Tkinter.  " \
+                            "Your Python may not be configured for Tk. **"
+@@ -1381,6 +1382,23 @@
+     # start editor and/or shell windows:
+     root = Tk(className="Idle")
+ 
++    # create base styles used along idle files
++    style = Style()
++    #if root.tk.eval("tk windowingsystem") == 'x11':
++    #    try:
++    #        style.theme_use("clam")
++    #    except TclError:
++    #        pass
++
++    x = style.map('.')
++    r = {'background': []}
++    for sspec in x['background']:
++        if 'active' in sspec[:-1]:
++            r['background'].append(('!disabled', sspec[-1]))
++            break
++    style.map('RootColor.TFrame', **r)
++    # end styles
++
+     fixwordbreaks(root)
+     root.withdraw()
+     flist = PyShellFileList(root)
+Index: Lib/idlelib/Debugger.py
+===================================================================
+--- Lib/idlelib/Debugger.py	(revision 63649)
++++ Lib/idlelib/Debugger.py	(working copy)
+@@ -2,6 +2,7 @@
+ import bdb
+ import types
+ from Tkinter import *
++from ttk import *
+ from WindowList import ListedToplevel
+ from ScrolledList import ScrolledList
+ import macosxSupport
+Index: Lib/idlelib/configDialog.py
+===================================================================
+--- Lib/idlelib/configDialog.py	(revision 63649)
++++ Lib/idlelib/configDialog.py	(working copy)
+@@ -10,6 +10,7 @@
+ 
+ """
+ from Tkinter import *
++from ttk import *
+ import tkMessageBox, tkColorChooser, tkFont
+ import string
+ 
+@@ -47,6 +48,7 @@
+             'Shell Stderr Text':('stderr','12'),
+             }
+         self.ResetChangedItems() #load initial values in changed items dict
++        self.SetupStyles()
+         self.CreateWidgets()
+         self.resizable(height=FALSE,width=FALSE)
+         self.transient(parent)
+@@ -64,32 +66,36 @@
+         self.wm_deiconify()
+         self.wait_window()
+ 
++    def SetupStyles(self):
++        style = Style(self.master)
++        #style.configure('S.TFrame', padding=[0, 2])
++        style.configure('S.TButton', padding=[6, 3])
++        style.configure('S2.TFrame', padding=2)
++        style.configure('Color.TFrame', background='blue')
++        self.ttkstyle = style
++
+     def CreateWidgets(self):
+         self.tabPages = TabbedPageSet(self,
+                 page_names=['Fonts/Tabs','Highlighting','Keys','General'])
+-        frameActionButtons = Frame(self,pady=2)
++        frameActionButtons = Frame(self, style='RootColor.TFrame')
+         #action buttons
+         self.buttonHelp = Button(frameActionButtons,text='Help',
+-                command=self.Help,takefocus=FALSE,
+-                padx=6,pady=3)
+-        self.buttonOk = Button(frameActionButtons,text='Ok',
+-                command=self.Ok,takefocus=FALSE,
+-                padx=6,pady=3)
+-        self.buttonApply = Button(frameActionButtons,text='Apply',
+-                command=self.Apply,takefocus=FALSE,
+-                padx=6,pady=3)
+-        self.buttonCancel = Button(frameActionButtons,text='Cancel',
+-                command=self.Cancel,takefocus=FALSE,
+-                padx=6,pady=3)
++                command=self.Help, takefocus=FALSE, style='S.TButton')
++        self.buttonOk = Button(frameActionButtons, text='Ok',
++                command=self.Ok, takefocus=FALSE, style='S.TButton')
++        self.buttonApply = Button(frameActionButtons, text='Apply',
++                command=self.Apply, takefocus=FALSE, style='S.TButton')
++        self.buttonCancel = Button(frameActionButtons, text='Cancel',
++                command=self.Cancel, takefocus=FALSE, style='S.TButton')
+         self.CreatePageFontTab()
+         self.CreatePageHighlight()
+         self.CreatePageKeys()
+         self.CreatePageGeneral()
+-        self.buttonHelp.pack(side=RIGHT,padx=5)
+-        self.buttonOk.pack(side=LEFT,padx=5)
+-        self.buttonApply.pack(side=LEFT,padx=5)
+-        self.buttonCancel.pack(side=LEFT,padx=5)
+-        frameActionButtons.pack(side=BOTTOM)
++        self.buttonHelp.pack(side=LEFT, pady=6)
++        self.buttonApply.pack(side=RIGHT, pady=6)
++        self.buttonOk.pack(side=RIGHT, padx=6, pady=6)
++        self.buttonCancel.pack(side=RIGHT, pady=6)
++        frameActionButtons.pack(side=BOTTOM, fill=X, expand=TRUE)
+         Frame(self, height=2, borderwidth=0).pack(side=BOTTOM)
+         self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
+ 
+@@ -127,7 +133,7 @@
+         frameFontSample=Frame(frameFont,relief=SOLID,borderwidth=1)
+         self.labelFontSample=Label(frameFontSample,
+                 text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
+-                justify=LEFT,font=self.editFont)
++                justify=LEFT, font=self.editFont)
+         #frameIndent
+         frameIndentSize=Frame(frameIndent)
+         labelSpaceNumTitle=Label(frameIndentSize, justify=LEFT,
+@@ -149,7 +155,7 @@
+         self.optMenuFontSize.pack(side=LEFT,anchor=W)
+         checkFontBold.pack(side=LEFT,anchor=W,padx=20)
+         frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
+-        self.labelFontSample.pack(expand=TRUE,fill=BOTH)
++        self.labelFontSample.pack(expand=1, fill=Y)
+         #frameIndent
+         frameIndentSize.pack(side=TOP,fill=X)
+         labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5)
+@@ -174,7 +180,7 @@
+                               text=' Highlighting Theme ')
+         #frameCustom
+         self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1,
+-            font=('courier',12,''),cursor='hand2',width=21,height=10,
++            font=('courier',12,''), cursor='hand2', width=21, height=11,
+             takefocus=FALSE,highlightthickness=0,wrap=NONE)
+         text=self.textHighlightSample
+         text.bind('<Double-Button-1>',lambda e: 'break')
+@@ -197,12 +203,14 @@
+                 lambda event,elem=element: event.widget.winfo_toplevel()
+                 .highlightTarget.set(elem))
+         text.config(state=DISABLED)
+-        self.frameColourSet=Frame(frameCustom,relief=SOLID,borderwidth=1)
++
++        self.frameColourSet=Frame(frameCustom, relief=SOLID, borderwidth=1,
++            style="Color.TFrame")
+         frameFgBg=Frame(frameCustom)
+         buttonSetColour=Button(self.frameColourSet,text='Choose Colour for :',
+-            command=self.GetColour,highlightthickness=0)
++            command=self.GetColour) # XXX
+         self.optMenuHighlightTarget=DynOptionMenu(self.frameColourSet,
+-            self.highlightTarget,None,highlightthickness=0)#,command=self.SetHighlightTargetBinding
++            self.highlightTarget, None) # XXX
+         self.radioFg=Radiobutton(frameFgBg,variable=self.fgHilite,
+             value=1,text='Foreground',command=self.SetColourSampleBinding)
+         self.radioBg=Radiobutton(frameFgBg,variable=self.fgHilite,
+@@ -275,7 +283,7 @@
+         self.buttonNewKeys=Button(frameCustom,text='Get New Keys for Selection',
+             command=self.GetNewKeys,state=DISABLED)
+         #frameKeySets
+-        frames = [Frame(frameKeySets, padx=2, pady=2, borderwidth=0)
++        frames = [Frame(frameKeySets, borderwidth=0, style='S2.TFrame')
+                   for i in range(2)]
+         self.radioKeysBuiltin=Radiobutton(frames[0],variable=self.keysAreBuiltin,
+             value=1,command=self.SetKeysType,text='Use a Built-in Key Set')
+@@ -748,14 +756,14 @@
+ 
+     def GetColour(self):
+         target=self.highlightTarget.get()
+-        prevColour=self.frameColourSet.cget('bg')
++        prevColour = self.ttkstyle.configure('Color.TFrame', 'background')
+         rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
+             title='Pick new colour for : '+target,initialcolor=prevColour)
+         if colourString and (colourString!=prevColour):
+             #user didn't cancel, and they chose a new colour
+             if self.themeIsBuiltin.get(): #current theme is a built-in
+-                message=('Your changes will be saved as a new Custom Theme. '+
+-                        'Enter a name for your new Custom Theme below.')
++                message=("Your changes will be saved as a new Custom Theme. "
++                         "Enter a name for your new Custom Theme below.")
+                 newTheme=self.GetNewThemeName(message)
+                 if not newTheme: #user cancelled custom theme creation
+                     return
+@@ -767,7 +775,7 @@
+ 
+     def OnNewColourSet(self):
+         newColour=self.colour.get()
+-        self.frameColourSet.config(bg=newColour)#set sample
++        self.ttkstyle.configure('Color.TFrame', background=newColour)
+         if self.fgHilite.get(): plane='foreground'
+         else: plane='background'
+         sampleElement=self.themeElements[self.highlightTarget.get()][0]
+@@ -777,6 +785,7 @@
+         self.AddChangedItem('highlight',theme,themeElement,newColour)
+ 
+     def GetNewThemeName(self,message):
++        # XXX idle bug here
+         usedNames=(idleConf.GetSectionList('user','highlight')+
+                 idleConf.GetSectionList('default','highlight'))
+         newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
+@@ -846,7 +855,7 @@
+         if self.fgHilite.get(): plane='foreground'
+         else: plane='background'
+         colour=self.textHighlightSample.tag_cget(tag,plane)
+-        self.frameColourSet.config(bg=colour)
++        self.ttkstyle.configure('Color.TFrame', background=colour)
+ 
+     def PaintThemeSample(self):
+         if self.themeIsBuiltin.get(): #a default theme
+Index: Lib/idlelib/SearchEngine.py
+===================================================================
+--- Lib/idlelib/SearchEngine.py	(revision 63649)
++++ Lib/idlelib/SearchEngine.py	(working copy)
+@@ -1,5 +1,6 @@
+ import re
+ from Tkinter import *
++from ttk import *
+ import tkMessageBox
+ 
+ def get(root):
+Index: Lib/idlelib/ReplaceDialog.py
+===================================================================
+--- Lib/idlelib/ReplaceDialog.py	(revision 63649)
++++ Lib/idlelib/ReplaceDialog.py	(working copy)
+@@ -11,9 +11,12 @@
+     dialog.open(text)
+ 
+ class ReplaceDialog(SearchDialogBase):
+-
+     title = "Replace Dialog"
+     icon = "Replace"
++    bottom_btns = [("Find", 'find_it'),
++                   ("Replace", 'replace_it'),
++                   ("Replace+Find", 'default_command', 1),
++                   ("Replace All", 'replace_all')]
+ 
+     def __init__(self, root, engine):
+         SearchDialogBase.__init__(self, root, engine)
+@@ -36,14 +39,10 @@
+ 
+     def create_entries(self):
+         SearchDialogBase.create_entries(self)
+-        self.replent = self.make_entry("Replace with:", self.replvar)
++        self.replent = self.make_entry("Replace with", self.replvar)
+ 
+     def create_command_buttons(self):
+         SearchDialogBase.create_command_buttons(self)
+-        self.make_button("Find", self.find_it)
+-        self.make_button("Replace", self.replace_it)
+-        self.make_button("Replace+Find", self.default_command, 1)
+-        self.make_button("Replace All", self.replace_all)
+ 
+     def find_it(self, event=None):
+         self.do_find(0)
+Index: Lib/idlelib/tabbedpages.py
+===================================================================
+--- Lib/idlelib/tabbedpages.py	(revision 63649)
++++ Lib/idlelib/tabbedpages.py	(working copy)
+@@ -1,360 +1,28 @@
+-"""An implementation of tabbed pages using only standard Tkinter.
++"""Classes exported:
+ 
+-Originally developed for use in IDLE. Based on tabpage.py.
+-
+-Classes exported:
+-TabbedPageSet -- A Tkinter implementation of a tabbed-page widget.
+-TabSet -- A widget containing tabs (buttons) in one or more rows.
+-
++TabbedPageSet -- A custom ttk.Notebook used by IDLE.
+ """
+ from Tkinter import *
++from ttk import *
+ 
+ class InvalidNameError(Exception): pass
+ class AlreadyExistsError(Exception): pass
+ 
++class FramePage(object):
++    def __init__(self, notebook):
++        self.frame = Frame(notebook)
+ 
+-class TabSet(Frame):
+-    """A widget containing tabs (buttons) in one or more rows.
+-
+-    Only one tab may be selected at a time.
+-
++class TabbedPageSet(Notebook):
+     """
+-    def __init__(self, page_set, select_command,
+-                 tabs=None, n_rows=1, max_tabs_per_row=5,
+-                 expand_tabs=False, **kw):
+-        """Constructor arguments:
+-
+-        select_command -- A callable which will be called when a tab is
+-        selected. It is called with the name of the selected tab as an
+-        argument.
+-
+-        tabs -- A list of strings, the names of the tabs. Should be specified in
+-        the desired tab order. The first tab will be the default and first
+-        active tab. If tabs is None or empty, the TabSet will be initialized
+-        empty.
+-
+-        n_rows -- Number of rows of tabs to be shown. If n_rows <= 0 or is
+-        None, then the number of rows will be decided by TabSet. See
+-        _arrange_tabs() for details.
+-
+-        max_tabs_per_row -- Used for deciding how many rows of tabs are needed,
+-        when the number of rows is not constant. See _arrange_tabs() for
+-        details.
+-
+-        """
+-        Frame.__init__(self, page_set, **kw)
+-        self.select_command = select_command
+-        self.n_rows = n_rows
+-        self.max_tabs_per_row = max_tabs_per_row
+-        self.expand_tabs = expand_tabs
+-        self.page_set = page_set
+-
+-        self._tabs = {}
+-        self._tab2row = {}
+-        if tabs:
+-            self._tab_names = list(tabs)
+-        else:
+-            self._tab_names = []
+-        self._selected_tab = None
+-        self._tab_rows = []
+-
+-        self.padding_frame = Frame(self, height=2,
+-                                   borderwidth=0, relief=FLAT,
+-                                   background=self.cget('background'))
+-        self.padding_frame.pack(side=TOP, fill=X, expand=False)
+-
+-        self._arrange_tabs()
+-
+-    def add_tab(self, tab_name):
+-        """Add a new tab with the name given in tab_name."""
+-        if not tab_name:
+-            raise InvalidNameError("Invalid Tab name: '%s'" % tab_name)
+-        if tab_name in self._tab_names:
+-            raise AlreadyExistsError("Tab named '%s' already exists" %tab_name)
+-
+-        self._tab_names.append(tab_name)
+-        self._arrange_tabs()
+-
+-    def remove_tab(self, tab_name):
+-        """Remove the tab named <tab_name>"""
+-        if not tab_name in self._tab_names:
+-            raise KeyError("No such Tab: '%s" % page_name)
+-
+-        self._tab_names.remove(tab_name)
+-        self._arrange_tabs()
+-
+-    def set_selected_tab(self, tab_name):
+-        """Show the tab named <tab_name> as the selected one"""
+-        if tab_name == self._selected_tab:
+-            return
+-        if tab_name is not None and tab_name not in self._tabs:
+-            raise KeyError("No such Tab: '%s" % page_name)
+-
+-        # deselect the current selected tab
+-        if self._selected_tab is not None:
+-            self._tabs[self._selected_tab].set_normal()
+-        self._selected_tab = None
+-
+-        if tab_name is not None:
+-            # activate the tab named tab_name
+-            self._selected_tab = tab_name
+-            tab = self._tabs[tab_name]
+-            tab.set_selected()
+-            # move the tab row with the selected tab to the bottom
+-            tab_row = self._tab2row[tab]
+-            tab_row.pack_forget()
+-            tab_row.pack(side=TOP, fill=X, expand=0)
+-
+-    def _add_tab_row(self, tab_names, expand_tabs):
+-        if not tab_names:
+-            return
+-
+-        tab_row = Frame(self)
+-        tab_row.pack(side=TOP, fill=X, expand=0)
+-        self._tab_rows.append(tab_row)
+-
+-        for tab_name in tab_names:
+-            tab = TabSet.TabButton(tab_name, self.select_command,
+-                                   tab_row, self)
+-            if expand_tabs:
+-                tab.pack(side=LEFT, fill=X, expand=True)
+-            else:
+-                tab.pack(side=LEFT)
+-            self._tabs[tab_name] = tab
+-            self._tab2row[tab] = tab_row
+-
+-        # tab is the last one created in the above loop
+-        tab.is_last_in_row = True
+-
+-    def _reset_tab_rows(self):
+-        while self._tab_rows:
+-            tab_row = self._tab_rows.pop()
+-            tab_row.destroy()
+-        self._tab2row = {}
+-
+-    def _arrange_tabs(self):
+-        """
+-        Arrange the tabs in rows, in the order in which they were added.
+-
+-        If n_rows >= 1, this will be the number of rows used. Otherwise the
+-        number of rows will be calculated according to the number of tabs and
+-        max_tabs_per_row. In this case, the number of rows may change when
+-        adding/removing tabs.
+-
+-        """
+-        # remove all tabs and rows
+-        for tab_name in self._tabs.keys():
+-            self._tabs.pop(tab_name).destroy()
+-        self._reset_tab_rows()
+-
+-        if not self._tab_names:
+-            return
+-
+-        if self.n_rows is not None and self.n_rows > 0:
+-            n_rows = self.n_rows
+-        else:
+-            # calculate the required number of rows
+-            n_rows = (len(self._tab_names) - 1) // self.max_tabs_per_row + 1
+-
+-        # not expanding the tabs with more than one row is very ugly
+-        expand_tabs = self.expand_tabs or n_rows > 1
+-        i = 0 # index in self._tab_names
+-        for row_index in xrange(n_rows):
+-            # calculate required number of tabs in this row
+-            n_tabs = (len(self._tab_names) - i - 1) // (n_rows - row_index) + 1
+-            tab_names = self._tab_names[i:i + n_tabs]
+-            i += n_tabs
+-            self._add_tab_row(tab_names, expand_tabs)
+-
+-        # re-select selected tab so it is properly displayed
+-        selected = self._selected_tab
+-        self.set_selected_tab(None)
+-        if selected in self._tab_names:
+-            self.set_selected_tab(selected)
+-
+-    class TabButton(Frame):
+-        """A simple tab-like widget."""
+-
+-        bw = 2 # borderwidth
+-
+-        def __init__(self, name, select_command, tab_row, tab_set):
+-            """Constructor arguments:
+-
+-            name -- The tab's name, which will appear in its button.
+-
+-            select_command -- The command to be called upon selection of the
+-            tab. It is called with the tab's name as an argument.
+-
+-            """
+-            Frame.__init__(self, tab_row, borderwidth=self.bw, relief=RAISED)
+-
+-            self.name = name
+-            self.select_command = select_command
+-            self.tab_set = tab_set
+-            self.is_last_in_row = False
+-
+-            self.button = Radiobutton(
+-                self, text=name, command=self._select_event,
+-                padx=5, pady=1, takefocus=FALSE, indicatoron=FALSE,
+-                highlightthickness=0, selectcolor='', borderwidth=0)
+-            self.button.pack(side=LEFT, fill=X, expand=True)
+-
+-            self._init_masks()
+-            self.set_normal()
+-
+-        def _select_event(self, *args):
+-            """Event handler for tab selection.
+-
+-            With TabbedPageSet, this calls TabbedPageSet.change_page, so that
+-            selecting a tab changes the page.
+-
+-            Note that this does -not- call set_selected -- it will be called by
+-            TabSet.set_selected_tab, which should be called when whatever the
+-            tabs are related to changes.
+-
+-            """
+-            self.select_command(self.name)
+-            return
+-
+-        def set_selected(self):
+-            """Assume selected look"""
+-            self._place_masks(selected=True)
+-
+-        def set_normal(self):
+-            """Assume normal look"""
+-            self._place_masks(selected=False)
+-
+-        def _init_masks(self):
+-            page_set = self.tab_set.page_set
+-            background = page_set.pages_frame.cget('background')
+-            # mask replaces the middle of the border with the background color
+-            self.mask = Frame(page_set, borderwidth=0, relief=FLAT,
+-                              background=background)
+-            # mskl replaces the bottom-left corner of the border with a normal
+-            # left border
+-            self.mskl = Frame(page_set, borderwidth=0, relief=FLAT,
+-                              background=background)
+-            self.mskl.ml = Frame(self.mskl, borderwidth=self.bw,
+-                                 relief=RAISED)
+-            self.mskl.ml.place(x=0, y=-self.bw,
+-                               width=2*self.bw, height=self.bw*4)
+-            # mskr replaces the bottom-right corner of the border with a normal
+-            # right border
+-            self.mskr = Frame(page_set, borderwidth=0, relief=FLAT,
+-                              background=background)
+-            self.mskr.mr = Frame(self.mskr, borderwidth=self.bw,
+-                                 relief=RAISED)
+-
+-        def _place_masks(self, selected=False):
+-            height = self.bw
+-            if selected:
+-                height += self.bw
+-
+-            self.mask.place(in_=self,
+-                            relx=0.0, x=0,
+-                            rely=1.0, y=0,
+-                            relwidth=1.0, width=0,
+-                            relheight=0.0, height=height)
+-
+-            self.mskl.place(in_=self,
+-                            relx=0.0, x=-self.bw,
+-                            rely=1.0, y=0,
+-                            relwidth=0.0, width=self.bw,
+-                            relheight=0.0, height=height)
+-
+-            page_set = self.tab_set.page_set
+-            if selected and ((not self.is_last_in_row) or
+-                             (self.winfo_rootx() + self.winfo_width() <
+-                              page_set.winfo_rootx() + page_set.winfo_width())
+-                             ):
+-                # for a selected tab, if its rightmost edge isn't on the
+-                # rightmost edge of the page set, the right mask should be one
+-                # borderwidth shorter (vertically)
+-                height -= self.bw
+-
+-            self.mskr.place(in_=self,
+-                            relx=1.0, x=0,
+-                            rely=1.0, y=0,
+-                            relwidth=0.0, width=self.bw,
+-                            relheight=0.0, height=height)
+-
+-            self.mskr.mr.place(x=-self.bw, y=-self.bw,
+-                               width=2*self.bw, height=height + self.bw*2)
+-
+-            # finally, lower the tab set so that all of the frames we just
+-            # placed hide it
+-            self.tab_set.lower()
+-
+-class TabbedPageSet(Frame):
+-    """A Tkinter tabbed-pane widget.
+-
+-    Constains set of 'pages' (or 'panes') with tabs above for selecting which
+-    page is displayed. Only one page will be displayed at a time.
+-
+     Pages may be accessed through the 'pages' attribute, which is a dictionary
+     of pages, using the name given as the key. A page is an instance of a
+-    subclass of Tk's Frame widget.
++    subclass of ttk's Frame widget.
+ 
+-    The page widgets will be created (and destroyed when required) by the
+-    TabbedPageSet. Do not call the page's pack/place/grid/destroy methods.
+-
+     Pages may be added or removed at any time using the add_page() and
+     remove_page() methods.
+-
+     """
+-    class Page(object):
+-        """Abstract base class for TabbedPageSet's pages.
+ 
+-        Subclasses must override the _show() and _hide() methods.
+-
+-        """
+-        uses_grid = False
+-
+-        def __init__(self, page_set):
+-            self.frame = Frame(page_set, borderwidth=2, relief=RAISED)
+-
+-        def _show(self):
+-            raise NotImplementedError
+-
+-        def _hide(self):
+-            raise NotImplementedError
+-
+-    class PageRemove(Page):
+-        """Page class using the grid placement manager's "remove" mechanism."""
+-        uses_grid = True
+-
+-        def _show(self):
+-            self.frame.grid(row=0, column=0, sticky=NSEW)
+-
+-        def _hide(self):
+-            self.frame.grid_remove()
+-
+-    class PageLift(Page):
+-        """Page class using the grid placement manager's "lift" mechanism."""
+-        uses_grid = True
+-
+-        def __init__(self, page_set):
+-            super(TabbedPageSet.PageLift, self).__init__(page_set)
+-            self.frame.grid(row=0, column=0, sticky=NSEW)
+-            self.frame.lower()
+-
+-        def _show(self):
+-            self.frame.lift()
+-
+-        def _hide(self):
+-            self.frame.lower()
+-
+-    class PagePackForget(Page):
+-        """Page class using the pack placement manager's "forget" mechanism."""
+-        def _show(self):
+-            self.frame.pack(fill=BOTH, expand=True)
+-
+-        def _hide(self):
+-            self.frame.pack_forget()
+-
+-    def __init__(self, parent, page_names=None, page_class=PageLift,
+-                 n_rows=1, max_tabs_per_row=5, expand_tabs=False,
+-                 **kw):
++    def __init__(self, master, page_names=None, **kw):
+         """Constructor arguments:
+ 
+         page_names -- A list of strings, each will be the dictionary key to a
+@@ -362,56 +30,13 @@
+         specified in the desired page order. The first page will be the default
+         and first active page. If page_names is None or empty, the
+         TabbedPageSet will be initialized empty.
+-
+-        n_rows, max_tabs_per_row -- Parameters for the TabSet which will
+-        manage the tabs. See TabSet's docs for details.
+-
+-        page_class -- Pages can be shown/hidden using three mechanisms:
+-
+-        * PageLift - All pages will be rendered one on top of the other. When
+-          a page is selected, it will be brought to the top, thus hiding all
+-          other pages. Using this method, the TabbedPageSet will not be resized
+-          when pages are switched. (It may still be resized when pages are
+-          added/removed.)
+-
+-        * PageRemove - When a page is selected, the currently showing page is
+-          hidden, and the new page shown in its place. Using this method, the
+-          TabbedPageSet may resize when pages are changed.
+-
+-        * PagePackForget - This mechanism uses the pack placement manager.
+-          When a page is shown it is packed, and when it is hidden it is
+-          unpacked (i.e. pack_forget). This mechanism may also cause the
+-          TabbedPageSet to resize when the page is changed.
+-
+         """
+-        Frame.__init__(self, parent, **kw)
++        Notebook.__init__(self, master, **kw)
+ 
+-        self.page_class = page_class
+         self.pages = {}
+-        self._pages_order = []
+-        self._current_page = None
+-        self._default_page = None
++        for name in page_names:
++            self.add_page(name)
+ 
+-        self.columnconfigure(0, weight=1)
+-        self.rowconfigure(1, weight=1)
+-
+-        self.pages_frame = Frame(self)
+-        self.pages_frame.grid(row=1, column=0, sticky=NSEW)
+-        if self.page_class.uses_grid:
+-            self.pages_frame.columnconfigure(0, weight=1)
+-            self.pages_frame.rowconfigure(0, weight=1)
+-
+-        # the order of the following commands is important
+-        self._tab_set = TabSet(self, self.change_page, n_rows=n_rows,
+-                               max_tabs_per_row=max_tabs_per_row,
+-                               expand_tabs=expand_tabs)
+-        if page_names:
+-            for name in page_names:
+-                self.add_page(name)
+-        self._tab_set.grid(row=0, column=0, sticky=NSEW)
+-
+-        self.change_page(self._default_page)
+-
+     def add_page(self, page_name):
+         """Add a new page with the name given in page_name."""
+         if not page_name:
+@@ -420,62 +45,32 @@
+             raise AlreadyExistsError(
+                 "TabPage named '%s' already exists" % page_name)
+ 
+-        self.pages[page_name] = self.page_class(self.pages_frame)
+-        self._pages_order.append(page_name)
+-        self._tab_set.add_tab(page_name)
++        fpage = FramePage(self)
++        self.pages[page_name] = fpage
++        self.add(fpage.frame, text=page_name, padding=6)
+ 
+-        if len(self.pages) == 1: # adding first page
+-            self._default_page = page_name
+-            self.change_page(page_name)
++        # workaround for bug #1878298 at tktoolkit sf bug tracker
++        self.event_generate('<Expose>')
+ 
+     def remove_page(self, page_name):
+-        """Destroy the page whose name is given in page_name."""
+         if not page_name in self.pages:
+             raise KeyError("No such TabPage: '%s" % page_name)
+ 
+-        self._pages_order.remove(page_name)
++        self.forget(self.index(self.pages[page_name].frame))
++        del self.pages[page_name]
+ 
+-        # handle removing last remaining, default, or currently shown page
+-        if len(self._pages_order) > 0:
+-            if page_name == self._default_page:
+-                # set a new default page
+-                self._default_page = self._pages_order[0]
+-        else:
+-            self._default_page = None
++        # workaround for bug #1878298 at tktoolkit sf bug tracker
++        self.event_generate('<Expose>')
+ 
+-        if page_name == self._current_page:
+-            self.change_page(self._default_page)
+-
+-        self._tab_set.remove_tab(page_name)
+-        page = self.pages.pop(page_name)
+-        page.frame.destroy()
+-
+-    def change_page(self, page_name):
+-        """Show the page whose name is given in page_name."""
+-        if self._current_page == page_name:
+-            return
+-        if page_name is not None and page_name not in self.pages:
+-            raise KeyError("No such TabPage: '%s'" % page_name)
+-
+-        if self._current_page is not None:
+-            self.pages[self._current_page]._hide()
+-        self._current_page = None
+-
+-        if page_name is not None:
+-            self._current_page = page_name
+-            self.pages[page_name]._show()
+-
+-        self._tab_set.set_selected_tab(page_name)
+-
+ if __name__ == '__main__':
+     # test dialog
+     root=Tk()
+-    tabPage=TabbedPageSet(root, page_names=['Foobar','Baz'], n_rows=0,
+-                          expand_tabs=False,
+-                          )
++    style = Style()
++    style.configure('C.TLabel', padding=20)
++    tabPage=TabbedPageSet(root, page_names=['Foobar','Baz'])
+     tabPage.pack(side=TOP, expand=TRUE, fill=BOTH)
+-    Label(tabPage.pages['Foobar'].frame, text='Foo', pady=20).pack()
+-    Label(tabPage.pages['Foobar'].frame, text='Bar', pady=20).pack()
++    Label(tabPage.pages['Foobar'].frame, text='Foo', style='C.TLabel').pack()
++    Label(tabPage.pages['Foobar'].frame, text='Bar', style='C.TLabel').pack()
+     Label(tabPage.pages['Baz'].frame, text='Baz').pack()
+     entryPgName=Entry(root)
+     buttonAdd=Button(root, text='Add Page',
+Index: Lib/idlelib/keybindingDialog.py
+===================================================================
+--- Lib/idlelib/keybindingDialog.py	(revision 63649)
++++ Lib/idlelib/keybindingDialog.py	(working copy)
+@@ -2,6 +2,7 @@
+ Dialog for building Tkinter accelerator key bindings
+ """
+ from Tkinter import *
++from ttk import *
+ import tkMessageBox
+ import string
+ 
+@@ -48,7 +49,7 @@
+     def CreateWidgets(self):
+         frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
+         frameMain.pack(side=TOP,expand=TRUE,fill=BOTH)
+-        frameButtons=Frame(self)
++        frameButtons=Frame(self, style='RootColor.TFrame')
+         frameButtons.pack(side=BOTTOM,fill=X)
+         self.buttonOK = Button(frameButtons,text='OK',
+                 width=8,command=self.OK)
+Index: Lib/idlelib/configHelpSourceEdit.py
+===================================================================
+--- Lib/idlelib/configHelpSourceEdit.py	(revision 63649)
++++ Lib/idlelib/configHelpSourceEdit.py	(working copy)
+@@ -4,6 +4,7 @@
+ import sys
+ 
+ from Tkinter import *
++from ttk import *
+ import tkMessageBox
+ import tkFileDialog
+ 
+@@ -25,6 +26,7 @@
+         self.protocol("WM_DELETE_WINDOW", self.Cancel)
+         self.parent = parent
+         self.result = None
++
+         self.CreateWidgets()
+         self.menu.set(menuItem)
+         self.path.set(filePath)
+@@ -64,11 +66,11 @@
+         browseButton = Button(self.frameMain, text='Browse', width=8,
+                               command=self.browseFile)
+         browseButton.pack(pady=3)
+-        frameButtons = Frame(self)
++        frameButtons = Frame(self, style='RootColor.TFrame')
+         frameButtons.pack(side=BOTTOM, fill=X)
+         self.buttonOk = Button(frameButtons, text='OK',
+                                width=8, default=ACTIVE,  command=self.Ok)
+-        self.buttonOk.grid(row=0, column=0, padx=5,pady=5)
++        self.buttonOk.grid(row=0, column=0, pady=5)
+         self.buttonCancel = Button(frameButtons, text='Cancel',
+                                    width=8, command=self.Cancel)
+         self.buttonCancel.grid(row=0, column=1, padx=5, pady=5)
+Index: Lib/idlelib/GrepDialog.py
+===================================================================
+--- Lib/idlelib/GrepDialog.py	(revision 63649)
++++ Lib/idlelib/GrepDialog.py	(working copy)
+@@ -2,6 +2,7 @@
+ import fnmatch
+ import sys
+ from Tkinter import *
++from ttk import *
+ import SearchEngine
+ from SearchDialogBase import SearchDialogBase
+ 
+@@ -15,10 +16,10 @@
+     dialog.open(text, searchphrase, io)
+ 
+ class GrepDialog(SearchDialogBase):
+-
+     title = "Find in Files Dialog"
+     icon = "Grep"
+     needwrapbutton = 0
++    bottom_btns = [("Search Files", 'default_command', 1)]
+ 
+     def __init__(self, root, engine, flist):
+         SearchDialogBase.__init__(self, root, engine)
+@@ -40,20 +41,18 @@
+ 
+     def create_entries(self):
+         SearchDialogBase.create_entries(self)
+-        self.globent = self.make_entry("In files:", self.globvar)
++        self.globent = self.make_entry("In files", self.globvar)
+ 
+     def create_other_buttons(self):
+         f = self.make_frame()
+ 
+-        btn = Checkbutton(f, anchor="w",
+-                variable=self.recvar,
++        btn = Checkbutton(f, variable=self.recvar,
+                 text="Recurse down subdirectories")
+         btn.pack(side="top", fill="both")
+-        btn.select()
++        btn.invoke()
+ 
+     def create_command_buttons(self):
+         SearchDialogBase.create_command_buttons(self)
+-        self.make_button("Search Files", self.default_command, 1)
+ 
+     def default_command(self, event=None):
+         prog = self.engine.getprog()
+@@ -126,8 +125,3 @@
+             for subdir in subdirs:
+                 list.extend(self.findfiles(subdir, base, rec))
+         return list
+-
+-    def close(self, event=None):
+-        if self.top:
+-            self.top.grab_release()
+-            self.top.withdraw()
+Index: Lib/idlelib/EditorWindow.py
+===================================================================
+--- Lib/idlelib/EditorWindow.py	(revision 63649)
++++ Lib/idlelib/EditorWindow.py	(working copy)
+@@ -4,6 +4,7 @@
+ import imp
+ from itertools import count
+ from Tkinter import *
++from ttk import *
+ import tkSimpleDialog
+ import tkMessageBox
+ from MultiCall import MultiCallCreator
+@@ -365,7 +366,7 @@
+         self.menudict = menudict = {}
+         for name, label in self.menu_specs:
+             underline, label = prepstr(label)
+-            menudict[name] = menu = Menu(mbar, name=name)
++            menudict[name] = menu = Menu(mbar, name=name, tearoff=0)
+             mbar.add_cascade(label=label, menu=menu, underline=underline)
+ 
+         if sys.platform == 'darwin' and '.framework' in sys.executable:
+Index: Lib/idlelib/aboutDialog.py
+===================================================================
+--- Lib/idlelib/aboutDialog.py	(revision 63649)
++++ Lib/idlelib/aboutDialog.py	(working copy)
+@@ -3,6 +3,7 @@
+ """
+ 
+ from Tkinter import *
++from ttk import *
+ import os
+ import os.path
+ import textView
+@@ -15,10 +16,16 @@
+     def __init__(self,parent,title):
+         Toplevel.__init__(self, parent)
+         self.configure(borderwidth=5)
++
+         self.geometry("+%d+%d" % (parent.winfo_rootx()+30,
+                                   parent.winfo_rooty()+30))
+         self.bg = "#707070"
+         self.fg = "#ffffff"
++
++        style = Style()
++        style.configure('Color.TLabel', foreground=self.fg, background=self.bg)
++        style.configure('Color.TFrame', background=self.bg)
++
+         self.CreateWidgets()
+         self.resizable(height=FALSE, width=FALSE)
+         self.title(title)
+@@ -31,40 +38,36 @@
+         self.bind('<Escape>',self.Ok) #dismiss dialog
+         self.wait_window()
+ 
++
+     def CreateWidgets(self):
+         frameMain = Frame(self, borderwidth=2, relief=SUNKEN)
+-        frameButtons = Frame(self)
+-        frameButtons.pack(side=BOTTOM, fill=X)
++        frameButtons = Frame(self, style='RootColor.TFrame')
++        frameButtons.pack(side=BOTTOM, pady=3)
+         frameMain.pack(side=TOP, expand=TRUE, fill=BOTH)
+         self.buttonOk = Button(frameButtons, text='Close',
+                                command=self.Ok)
+-        self.buttonOk.pack(padx=5, pady=5)
+-        #self.picture = Image('photo', data=self.pictureData)
+-        frameBg = Frame(frameMain, bg=self.bg)
++        self.buttonOk.pack()
++        frameBg = Frame(frameMain, style='Color.TFrame')
+         frameBg.pack(expand=TRUE, fill=BOTH)
+-        labelTitle = Label(frameBg, text='IDLE', fg=self.fg, bg=self.bg,
++        labelTitle = Label(frameBg, text='IDLE', style='Color.TLabel',
+                            font=('courier', 24, 'bold'))
+         labelTitle.grid(row=0, column=0, sticky=W, padx=10, pady=10)
+-        #labelPicture = Label(frameBg, text='[picture]')
+-        #image=self.picture, bg=self.bg)
+-        #labelPicture.grid(row=1, column=1, sticky=W, rowspan=2,
+-        #                  padx=0, pady=3)
+         byline = "Python's Integrated DeveLopment Environment" + 5*'\n'
+         labelDesc = Label(frameBg, text=byline, justify=LEFT,
+-                          fg=self.fg, bg=self.bg)
++                          style='Color.TLabel')
+         labelDesc.grid(row=2, column=0, sticky=W, columnspan=3, padx=10, pady=5)
+         labelEmail = Label(frameBg, text='email:  idle-dev at python.org',
+-                           justify=LEFT, fg=self.fg, bg=self.bg)
++                           justify=LEFT, style='Color.TLabel')
+         labelEmail.grid(row=6, column=0, columnspan=2,
+                         sticky=W, padx=10, pady=0)
+         labelWWW = Label(frameBg, text='www:  http://www.python.org/idle/',
+-                         justify=LEFT, fg=self.fg, bg=self.bg)
++                         justify=LEFT, style='Color.TLabel')
+         labelWWW.grid(row=7, column=0, columnspan=2, sticky=W, padx=10, pady=0)
+         Frame(frameBg, borderwidth=1, relief=SUNKEN,
+-              height=2, bg=self.bg).grid(row=8, column=0, sticky=EW,
++              height=2, style='Color.TFrame').grid(row=8, column=0, sticky=EW,
+                                          columnspan=3, padx=5, pady=5)
+         labelPythonVer = Label(frameBg, text='Python version:  ' + \
+-                               sys.version.split()[0], fg=self.fg, bg=self.bg)
++                               sys.version.split()[0], style='Color.TLabel')
+         labelPythonVer.grid(row=9, column=0, sticky=W, padx=10, pady=0)
+         # handle weird tk version num in windoze python >= 1.6 (?!?)
+         tkVer = repr(TkVersion).split('.')
+@@ -73,40 +76,34 @@
+             tkVer[len(tkVer)-1] = '0'
+         tkVer = '.'.join(tkVer)
+         labelTkVer = Label(frameBg, text='Tk version:  '+
+-                           tkVer, fg=self.fg, bg=self.bg)
++                           tkVer, style='Color.TLabel')
+         labelTkVer.grid(row=9, column=1, sticky=W, padx=2, pady=0)
+-        py_button_f = Frame(frameBg, bg=self.bg)
++        py_button_f = Frame(frameBg, style='Color.TFrame')
+         py_button_f.grid(row=10, column=0, columnspan=2, sticky=NSEW)
+         buttonLicense = Button(py_button_f, text='License', width=8,
+-                               highlightbackground=self.bg,
+                                command=self.ShowLicense)
+         buttonLicense.pack(side=LEFT, padx=10, pady=10)
+         buttonCopyright = Button(py_button_f, text='Copyright', width=8,
+-                                 highlightbackground=self.bg,
+                                  command=self.ShowCopyright)
+         buttonCopyright.pack(side=LEFT, padx=10, pady=10)
+         buttonCredits = Button(py_button_f, text='Credits', width=8,
+-                               highlightbackground=self.bg,
+                                command=self.ShowPythonCredits)
+         buttonCredits.pack(side=LEFT, padx=10, pady=10)
+         Frame(frameBg, borderwidth=1, relief=SUNKEN,
+-              height=2, bg=self.bg).grid(row=11, column=0, sticky=EW,
+-                                         columnspan=3, padx=5, pady=5)
++              height=2, style='Color.TFrame').grid(row=11, column=0, sticky=EW,
++                                                   columnspan=3, padx=5, pady=5)
+         idle_v = Label(frameBg, text='IDLE version:   ' + idlever.IDLE_VERSION,
+-                       fg=self.fg, bg=self.bg)
++                       style='Color.TLabel')
+         idle_v.grid(row=12, column=0, sticky=W, padx=10, pady=0)
+-        idle_button_f = Frame(frameBg, bg=self.bg)
++        idle_button_f = Frame(frameBg, style='Color.TFrame')
+         idle_button_f.grid(row=13, column=0, columnspan=3, sticky=NSEW)
+         idle_about_b = Button(idle_button_f, text='README', width=8,
+-                                highlightbackground=self.bg,
+                                 command=self.ShowIDLEAbout)
+         idle_about_b.pack(side=LEFT, padx=10, pady=10)
+         idle_news_b = Button(idle_button_f, text='NEWS', width=8,
+-                                highlightbackground=self.bg,
+                                 command=self.ShowIDLENEWS)
+         idle_news_b.pack(side=LEFT, padx=10, pady=10)
+         idle_credits_b = Button(idle_button_f, text='Credits', width=8,
+-                                highlightbackground=self.bg,
+                                 command=self.ShowIDLECredits)
+         idle_credits_b.pack(side=LEFT, padx=10, pady=10)
+ 
+Index: Lib/idlelib/IOBinding.py
+===================================================================
+--- Lib/idlelib/IOBinding.py	(revision 63649)
++++ Lib/idlelib/IOBinding.py	(working copy)
+@@ -14,6 +14,7 @@
+ import tkMessageBox
+ import re
+ from Tkinter import *
++from ttk import *
+ from SimpleDialog import SimpleDialog
+ 
+ from configHandler import idleConf
+Index: Lib/idlelib/ScrolledList.py
+===================================================================
+--- Lib/idlelib/ScrolledList.py	(revision 63649)
++++ Lib/idlelib/ScrolledList.py	(working copy)
+@@ -1,4 +1,5 @@
+ from Tkinter import *
++from ttk import *
+ 
+ class ScrolledList:
+ 
+Index: Lib/idlelib/FileList.py
+===================================================================
+--- Lib/idlelib/FileList.py	(revision 63649)
++++ Lib/idlelib/FileList.py	(working copy)
+@@ -1,5 +1,6 @@
+ import os
+ from Tkinter import *
++from ttk import *
+ import tkMessageBox
+ 
+ 
+Index: Lib/idlelib/textView.py
+===================================================================
+--- Lib/idlelib/textView.py	(revision 63649)
++++ Lib/idlelib/textView.py	(working copy)
+@@ -3,6 +3,7 @@
+ """
+ 
+ from Tkinter import *
++from ttk import *
+ import tkMessageBox
+ 
+ class TextViewer(Toplevel):
+@@ -38,19 +39,19 @@
+ 
+     def CreateWidgets(self):
+         frameText = Frame(self, relief=SUNKEN, height=700)
+-        frameButtons = Frame(self)
++        frameButtons = Frame(self, style='RootColor.TFrame')
+         self.buttonOk = Button(frameButtons, text='Close',
+                                command=self.Ok, takefocus=FALSE)
+         self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
+-                                       takefocus=FALSE, highlightthickness=0)
+-        self.textView = Text(frameText, wrap=WORD, highlightthickness=0,
+-                             fg=self.fg, bg=self.bg)
++                                       takefocus=FALSE)
++        self.textView = Text(frameText, wrap=WORD, fg=self.fg, bg=self.bg,
++                             highlightthickness=0)
+         self.scrollbarView.config(command=self.textView.yview)
+         self.textView.config(yscrollcommand=self.scrollbarView.set)
+         self.buttonOk.pack()
+         self.scrollbarView.pack(side=RIGHT,fill=Y)
+         self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
+-        frameButtons.pack(side=BOTTOM,fill=X)
++        frameButtons.pack(side=BOTTOM)
+         frameText.pack(side=TOP,expand=TRUE,fill=BOTH)
+ 
+     def Ok(self, event=None):
+Index: Lib/idlelib/SearchDialogBase.py
+===================================================================
+--- Lib/idlelib/SearchDialogBase.py	(revision 63649)
++++ Lib/idlelib/SearchDialogBase.py	(working copy)
+@@ -1,35 +1,37 @@
+ from Tkinter import *
++from ttk import *
+ 
+ class SearchDialogBase:
+ 
+     title = "Search Dialog"
+     icon = "Search"
+     needwrapbutton = 1
++    bottom_btns = None
+ 
+     def __init__(self, root, engine):
+         self.root = root
+         self.engine = engine
+-        self.top = None
++        self.ttop = None
+ 
+     def open(self, text, searchphrase=None):
+         self.text = text
+-        if not self.top:
++        if not self.ttop:
+             self.create_widgets()
+         else:
+-            self.top.deiconify()
+-            self.top.tkraise()
++            self.ttop.deiconify()
++            self.ttop.tkraise()
+         if searchphrase:
+-            self.ent.delete(0,"end")
+-            self.ent.insert("end",searchphrase)
++            self.ent.delete(0, "end")
++            self.ent.insert("end", searchphrase)
+         self.ent.focus_set()
+         self.ent.selection_range(0, "end")
+         self.ent.icursor(0)
+-        self.top.grab_set()
++        self.ttop.grab_set()
+ 
+     def close(self, event=None):
+-        if self.top:
+-            self.top.grab_release()
+-            self.top.withdraw()
++        if self.ttop:
++            self.ttop.grab_release()
++            self.ttop.withdraw()
+ 
+     def create_widgets(self):
+         top = Toplevel(self.root)
+@@ -38,103 +40,96 @@
+         top.protocol("WM_DELETE_WINDOW", self.close)
+         top.wm_title(self.title)
+         top.wm_iconname(self.icon)
+-        self.top = top
++        top.resizable(height=FALSE,width=FALSE)
++        self.ttop = top
++        self.top = Frame(top)
+ 
+         self.row = 0
+-        self.top.grid_columnconfigure(0, pad=2, weight=0)
+-        self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
++        self.top.grid(sticky='news')
+ 
+         self.create_entries()
+         self.create_option_buttons()
+         self.create_other_buttons()
+-        return self.create_command_buttons()
++        self.create_command_buttons()
+ 
++
+     def make_entry(self, label, var):
+         l = Label(self.top, text=label)
+-        l.grid(row=self.row, column=0, sticky="nw")
++        l.grid(row=self.row, column=0, sticky="ne", padx=6, pady=6)
+         e = Entry(self.top, textvariable=var, exportselection=0)
+-        e.grid(row=self.row, column=1, sticky="nwe")
++        e.grid(row=self.row, column=1, sticky="nwe", padx=6, pady=6)
+         self.row = self.row + 1
+         return e
+ 
+     def make_frame(self,labeltext=None):
+         if labeltext:
+             l = Label(self.top, text=labeltext)
+-            l.grid(row=self.row, column=0, sticky="nw")
++            l.grid(row=self.row, column=0, sticky="ne", padx=6, pady=6)
+         f = Frame(self.top)
+-        f.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
++        f.grid(row=self.row, column=1, columnspan=1, sticky="nwe",
++               padx=6, pady=6 if labeltext else 0)
+         self.row = self.row + 1
+         return f
+ 
+-    def make_button(self, label, command, isdef=0):
+-        b = Button(self.buttonframe,
+-                   text=label, command=command,
+-                   default=isdef and "active" or "normal")
+-        cols,rows=self.buttonframe.grid_size()
+-        b.grid(pady=1,row=rows,column=0,sticky="ew")
+-        self.buttonframe.grid(rowspan=rows+1)
+-        return b
+-
+     def create_entries(self):
+-        self.ent = self.make_entry("Find:", self.engine.patvar)
++        self.ent = self.make_entry("Find", self.engine.patvar)
+ 
+     def create_option_buttons(self):
+         f = self.make_frame("Options")
+ 
+-        btn = Checkbutton(f, anchor="w",
+-                variable=self.engine.revar,
+-                text="Regular expression")
++        btn = Checkbutton(f, variable=self.engine.revar,
++                          text="Regular expression")
+         btn.pack(side="left", fill="both")
+         if self.engine.isre():
+-            btn.select()
++            btn.invoke()
+ 
+-        btn = Checkbutton(f, anchor="w",
+-                variable=self.engine.casevar,
+-                text="Match case")
++        btn = Checkbutton(f, variable=self.engine.casevar, text="Match case")
+         btn.pack(side="left", fill="both")
+         if self.engine.iscase():
+-            btn.select()
++            btn.invoke()
+ 
+-        btn = Checkbutton(f, anchor="w",
+-                variable=self.engine.wordvar,
+-                text="Whole word")
++        btn = Checkbutton(f, variable=self.engine.wordvar, text="Whole word")
+         btn.pack(side="left", fill="both")
+         if self.engine.isword():
+-            btn.select()
++            btn.invoke()
+ 
+         if self.needwrapbutton:
+-            btn = Checkbutton(f, anchor="w",
+-                    variable=self.engine.wrapvar,
+-                    text="Wrap around")
++            btn = Checkbutton(f, variable=self.engine.wrapvar,
++                              text="Wrap around")
+             btn.pack(side="left", fill="both")
+             if self.engine.iswrap():
+-                btn.select()
++                btn.invoke()
+ 
+     def create_other_buttons(self):
+         f = self.make_frame("Direction")
+ 
+-        #lbl = Label(f, text="Direction: ")
+-        #lbl.pack(side="left")
+-
+-        btn = Radiobutton(f, anchor="w",
+-                variable=self.engine.backvar, value=1,
+-                text="Up")
+-        btn.pack(side="left", fill="both")
++        btn = Radiobutton(f, variable=self.engine.backvar, value=1, text="Up")
++        btn.pack(side="left")
+         if self.engine.isback():
+-            btn.select()
++            btn.invoke()
+ 
+-        btn = Radiobutton(f, anchor="w",
+-                variable=self.engine.backvar, value=0,
+-                text="Down")
+-        btn.pack(side="left", fill="both")
++        btn = Radiobutton(f, variable=self.engine.backvar, value=0, text="Down")
++        btn.pack(side="left")
+         if not self.engine.isback():
+-            btn.select()
++            btn.invoke()
+ 
+     def create_command_buttons(self):
+-        #
+-        # place button frame on the right
+-        f = self.buttonframe = Frame(self.top)
+-        f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
++        self.bottom_btns = self.bottom_btns or []
++        f = Frame(self.top)
++        f.grid(row=self.row, column=0, columnspan=len(self.bottom_btns) + 1,
++               pady=6)
+ 
+-        b = self.make_button("close", self.close)
+-        b.lower()
++        column = 0
++        b = Button(f, text="Close", command=self.close)
++        b.grid(row=self.row, column=column, padx=6, pady=6)
++        column += 1
++
++        btns = {}
++        for tbtn in self.bottom_btns:
++            opts = {'text': tbtn[0], 'command': getattr(self, tbtn[1])}
++            if len(tbtn) == 3:
++                opts['default'] = tbtn[2] and 'active' or 'normal'
++
++            btns[opts['text']] = Button(f, **opts).grid(row=self.row, padx=6,
++                                                        pady=6, column=column)
++            column += 1
+Index: Lib/idlelib/CallTipWindow.py
+===================================================================
+--- Lib/idlelib/CallTipWindow.py	(revision 63649)
++++ Lib/idlelib/CallTipWindow.py	(working copy)
+@@ -5,6 +5,7 @@
+ 
+ """
+ from Tkinter import *
++from ttk import *
+ 
+ HIDE_VIRTUAL_EVENT_NAME = "<<calltipwindow-hide>>"
+ HIDE_SEQUENCES = ("<Key-Escape>", "<FocusOut>")
+@@ -163,6 +164,8 @@
+     def calltip_hide(self, event):
+         self.calltip.hidetip()
+ 
++# XXX Bugged test
++
+ def main():
+     # Test code
+     c=container()
+Index: Lib/idlelib/SearchDialog.py
+===================================================================
+--- Lib/idlelib/SearchDialog.py	(revision 63649)
++++ Lib/idlelib/SearchDialog.py	(working copy)
+@@ -21,10 +21,10 @@
+     return _setup(text).find_selection(text)
+ 
+ class SearchDialog(SearchDialogBase):
++    bottom_btns = [("Find", 'default_command', 1)]
+ 
+     def create_widgets(self):
+-        f = SearchDialogBase.create_widgets(self)
+-        self.make_button("Find", self.default_command, 1)
++        SearchDialogBase.create_widgets(self)
+ 
+     def default_command(self, event=None):
+         if not self.engine.getprog():
+Index: Lib/idlelib/TreeWidget.py
+===================================================================
+--- Lib/idlelib/TreeWidget.py	(revision 63649)
++++ Lib/idlelib/TreeWidget.py	(working copy)
+@@ -16,6 +16,7 @@
+ 
+ import os
+ from Tkinter import *
++from ttk import *
+ import imp
+ 
+ import ZoomHeight
+@@ -68,6 +69,10 @@
+         self.x = self.y = None
+         self.iconimages = {} # cache of PhotoImage instances for icons
+ 
++        # XXX
++        #style = Style()
++        #style.configure("P.TLabel", padding=2, borderwidth=0)
++
+     def destroy(self):
+         for c in self.children[:]:
+             self.children.remove(c)
+@@ -248,7 +253,7 @@
+             label = self.label
+         except AttributeError:
+             # padding carefully selected (on Windows) to match Entry widget:
+-            self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2)
++            self.label = Label(self.canvas, text=text, style='P.TLabel')
+         theme = idleConf.GetOption('main','Theme','name')
+         if self.selected:
+             self.label.configure(idleConf.GetHighlight(theme, 'hilite'))
+@@ -451,6 +456,8 @@
+ 
+ # Testing functions
+ 
++# XXX Can't run these tests
++
+ def test():
+     import PyShell
+     root = Toplevel(PyShell.root)
+Index: Lib/idlelib/MultiStatusBar.py
+===================================================================
+--- Lib/idlelib/MultiStatusBar.py	(revision 63649)
++++ Lib/idlelib/MultiStatusBar.py	(working copy)
+@@ -1,4 +1,5 @@
+ from Tkinter import *
++from ttk import *
+ 
+ class MultiStatusBar(Frame):
+ 
+@@ -10,7 +11,7 @@
+ 
+     def set_label(self, name, text='', side=LEFT):
+         if not self.labels.has_key(name):
+-            label = Label(self, bd=1, relief=SUNKEN, anchor=W)
++            label = Label(self, relief=SUNKEN, anchor=W)
+             label.pack(side=side)
+             self.labels[name] = label
+         else:


More information about the Python-checkins mailing list