summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/tabpage.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-12-14 01:24:44 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-12-14 01:24:44 (GMT)
commit380532117c2547bb0dedf6f85efa66d18a9abb88 (patch)
tree33e690cd422859aa0272fbe0a9d1f163e77fbaf2 /Lib/idlelib/tabpage.py
parent8a78cadf561ea67649a84d9b4055dd4c24e2e0ba (diff)
downloadcpython-380532117c2547bb0dedf6f85efa66d18a9abb88.zip
cpython-380532117c2547bb0dedf6f85efa66d18a9abb88.tar.gz
cpython-380532117c2547bb0dedf6f85efa66d18a9abb88.tar.bz2
Merged revisions 59465-59487 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59467 | georg.brandl | 2007-12-11 17:32:49 +0100 (Tue, 11 Dec 2007) | 2 lines Add another GHOP contributor. ........ r59468 | kurt.kaiser | 2007-12-11 20:35:12 +0100 (Tue, 11 Dec 2007) | 3 lines IDLE_tabbedpages.071101.patch Tal Einat Cosmetic changes, one bug. Remove tabpage.py, replaced by tabbedpages.py ........ r59471 | gerhard.haering | 2007-12-11 22:07:40 +0100 (Tue, 11 Dec 2007) | 9 lines Forward-port of commit 59184. - Backported a workaround for a bug in SQLite 3.2.x/3.3.x versions where a statement recompilation with no bound parameters lead to a segfault - Backported a fix necessary because of an SQLite API change in version 3.5. This prevents segfaults when executing empty queries, like our test suite does ........ r59475 | christian.heimes | 2007-12-12 19:09:06 +0100 (Wed, 12 Dec 2007) | 1 line Fixed a nasty problem in the xxmodule.c ........ r59478 | raymond.hettinger | 2007-12-13 01:08:37 +0100 (Thu, 13 Dec 2007) | 1 line Fix bug 1604. deque.__init__() did not clear existing contents like list.__init__. Not a backport candidate. ........ r59480 | alexandre.vassalotti | 2007-12-13 18:58:23 +0100 (Thu, 13 Dec 2007) | 2 lines Fix issue #1313119: urlparse "caches" parses regardless of encoding ........ r59482 | christian.heimes | 2007-12-13 20:23:16 +0100 (Thu, 13 Dec 2007) | 1 line Fixed bug #1613: Makefile's VPATH feature is broken ........ r59484 | guido.van.rossum | 2007-12-13 21:50:10 +0100 (Thu, 13 Dec 2007) | 3 lines Patch #1608. Someone with access to autoconf 2.61 or higher needs to run it and check in the resulting configure file. ........ r59485 | thomas.heller | 2007-12-13 22:20:29 +0100 (Thu, 13 Dec 2007) | 1 line Ran autoconf. ........ r59486 | raymond.hettinger | 2007-12-13 23:55:52 +0100 (Thu, 13 Dec 2007) | 1 line Simplify implementation of __replace__() ........ r59487 | raymond.hettinger | 2007-12-14 00:52:59 +0100 (Fri, 14 Dec 2007) | 1 line Small speedup ........
Diffstat (limited to 'Lib/idlelib/tabpage.py')
-rw-r--r--Lib/idlelib/tabpage.py113
1 files changed, 0 insertions, 113 deletions
diff --git a/Lib/idlelib/tabpage.py b/Lib/idlelib/tabpage.py
deleted file mode 100644
index 105ef90..0000000
--- a/Lib/idlelib/tabpage.py
+++ /dev/null
@@ -1,113 +0,0 @@
-"""
-a couple of classes for implementing partial tabbed-page like behaviour
-"""
-
-from Tkinter import *
-
-class InvalidTabPage(Exception): pass
-class AlreadyExists(Exception): pass
-
-class PageTab(Frame):
- """
- a 'page tab' like framed button
- """
- def __init__(self,parent):
- Frame.__init__(self, parent,borderwidth=2,relief=RIDGE)
- self.button=Radiobutton(self,padx=5,pady=5,takefocus=FALSE,
- indicatoron=FALSE,highlightthickness=0,
- borderwidth=0,selectcolor=self.cget('bg'))
- self.button.pack()
-
-class TabPageSet(Frame):
- """
- a set of 'pages' with TabButtons for controlling their display
- """
- def __init__(self,parent,pageNames=[],**kw):
- """
- pageNames - a list of strings, each string will be the dictionary key
- to a page's data, and the name displayed on the page's tab. Should be
- specified in desired page order. The first page will be the default
- and first active page.
- """
- Frame.__init__(self, parent, kw)
- self.grid_location(0,0)
- self.columnconfigure(0,weight=1)
- self.rowconfigure(1,weight=1)
- self.tabBar=Frame(self)
- self.tabBar.grid(row=0,column=0,sticky=EW)
- self.activePage=StringVar(self)
- self.defaultPage=''
- self.pages={}
- for name in pageNames:
- self.AddPage(name)
-
- def ChangePage(self,pageName=None):
- if pageName:
- if pageName in self.pages:
- self.activePage.set(pageName)
- else:
- raise InvalidTabPage('Invalid TabPage Name')
- ## pop up the active 'tab' only
- for page in self.pages:
- self.pages[page]['tab'].config(relief=RIDGE)
- self.pages[self.GetActivePage()]['tab'].config(relief=RAISED)
- ## switch page
- self.pages[self.GetActivePage()]['page'].lift()
-
- def GetActivePage(self):
- return self.activePage.get()
-
- def AddPage(self,pageName):
- if pageName in self.pages.keys():
- raise AlreadyExists('TabPage Name Already Exists')
- self.pages[pageName]={'tab':PageTab(self.tabBar),
- 'page':Frame(self,borderwidth=2,relief=RAISED)}
- self.pages[pageName]['tab'].button.config(text=pageName,
- command=self.ChangePage,variable=self.activePage,
- value=pageName)
- self.pages[pageName]['tab'].pack(side=LEFT)
- self.pages[pageName]['page'].grid(row=1,column=0,sticky=NSEW)
- if len(self.pages)==1: # adding first page
- self.defaultPage=pageName
- self.activePage.set(self.defaultPage)
- self.ChangePage()
-
- def RemovePage(self,pageName):
- if not pageName in self.pages:
- raise InvalidTabPage('Invalid TabPage Name')
- self.pages[pageName]['tab'].pack_forget()
- self.pages[pageName]['page'].grid_forget()
- self.pages[pageName]['tab'].destroy()
- self.pages[pageName]['page'].destroy()
- del(self.pages[pageName])
- # handle removing last remaining, or default, or active page
- if not self.pages: # removed last remaining page
- self.defaultPage=''
- return
- if pageName==self.defaultPage: # set a new default page
- self.defaultPage=\
- self.tabBar.winfo_children()[0].button.cget('text')
- if pageName==self.GetActivePage(): # set a new active page
- self.activePage.set(self.defaultPage)
- self.ChangePage()
-
-if __name__ == '__main__':
- #test dialog
- root=Tk()
- tabPage=TabPageSet(root,pageNames=['Foobar','Baz'])
- tabPage.pack(expand=TRUE,fill=BOTH)
- Label(tabPage.pages['Foobar']['page'],text='Foo',pady=20).pack()
- Label(tabPage.pages['Foobar']['page'],text='Bar',pady=20).pack()
- Label(tabPage.pages['Baz']['page'],text='Baz').pack()
- entryPgName=Entry(root)
- buttonAdd=Button(root,text='Add Page',
- command=lambda:tabPage.AddPage(entryPgName.get()))
- buttonRemove=Button(root,text='Remove Page',
- command=lambda:tabPage.RemovePage(entryPgName.get()))
- labelPgName=Label(root,text='name of page to add/remove:')
- buttonAdd.pack(padx=5,pady=5)
- buttonRemove.pack(padx=5,pady=5)
- labelPgName.pack(padx=5)
- entryPgName.pack(padx=5)
- tabPage.ChangePage()
- root.mainloop()