mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue *24750: Switch all scrollbars in IDLE to ttk versions.
Where needed, add minimal tests to cover changes.
This commit is contained in:
parent
96881cd621
commit
01e35754fb
17 changed files with 211 additions and 39 deletions
|
@ -2,6 +2,7 @@
|
||||||
An auto-completion window for IDLE, used by the autocomplete extension
|
An auto-completion window for IDLE, used by the autocomplete extension
|
||||||
"""
|
"""
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
from idlelib.multicall import MC_SHIFT
|
from idlelib.multicall import MC_SHIFT
|
||||||
from idlelib.autocomplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
|
from idlelib.autocomplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
|
||||||
|
|
||||||
|
|
|
@ -2,31 +2,35 @@
|
||||||
Dialog for building Tkinter accelerator key bindings
|
Dialog for building Tkinter accelerator key bindings
|
||||||
"""
|
"""
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
import tkinter.messagebox as tkMessageBox
|
import tkinter.messagebox as tkMessageBox
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class GetKeysDialog(Toplevel):
|
class GetKeysDialog(Toplevel):
|
||||||
def __init__(self,parent,title,action,currentKeySequences,_htest=False):
|
def __init__(self, parent, title, action, currentKeySequences,
|
||||||
|
_htest=False, _utest=False):
|
||||||
"""
|
"""
|
||||||
action - string, the name of the virtual event these keys will be
|
action - string, the name of the virtual event these keys will be
|
||||||
mapped to
|
mapped to
|
||||||
currentKeys - list, a list of all key sequence lists currently mapped
|
currentKeys - list, a list of all key sequence lists currently mapped
|
||||||
to virtual events, for overlap checking
|
to virtual events, for overlap checking
|
||||||
|
_utest - bool, do not wait when running unittest
|
||||||
_htest - bool, change box location when running htest
|
_htest - bool, change box location when running htest
|
||||||
"""
|
"""
|
||||||
Toplevel.__init__(self, parent)
|
Toplevel.__init__(self, parent)
|
||||||
|
self.withdraw() #hide while setting geometry
|
||||||
self.configure(borderwidth=5)
|
self.configure(borderwidth=5)
|
||||||
self.resizable(height=FALSE,width=FALSE)
|
self.resizable(height=FALSE, width=FALSE)
|
||||||
self.title(title)
|
self.title(title)
|
||||||
self.transient(parent)
|
self.transient(parent)
|
||||||
self.grab_set()
|
self.grab_set()
|
||||||
self.protocol("WM_DELETE_WINDOW", self.Cancel)
|
self.protocol("WM_DELETE_WINDOW", self.Cancel)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.action=action
|
self.action=action
|
||||||
self.currentKeySequences=currentKeySequences
|
self.currentKeySequences = currentKeySequences
|
||||||
self.result=''
|
self.result = ''
|
||||||
self.keyString=StringVar(self)
|
self.keyString = StringVar(self)
|
||||||
self.keyString.set('')
|
self.keyString.set('')
|
||||||
self.SetModifiersForPlatform() # set self.modifiers, self.modifier_label
|
self.SetModifiersForPlatform() # set self.modifiers, self.modifier_label
|
||||||
self.modifier_vars = []
|
self.modifier_vars = []
|
||||||
|
@ -37,7 +41,6 @@ class GetKeysDialog(Toplevel):
|
||||||
self.advanced = False
|
self.advanced = False
|
||||||
self.CreateWidgets()
|
self.CreateWidgets()
|
||||||
self.LoadFinalKeyList()
|
self.LoadFinalKeyList()
|
||||||
self.withdraw() #hide while setting geometry
|
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
self.geometry(
|
self.geometry(
|
||||||
"+%d+%d" % (
|
"+%d+%d" % (
|
||||||
|
@ -47,8 +50,9 @@ class GetKeysDialog(Toplevel):
|
||||||
((parent.winfo_height()/2 - self.winfo_reqheight()/2)
|
((parent.winfo_height()/2 - self.winfo_reqheight()/2)
|
||||||
if not _htest else 150)
|
if not _htest else 150)
|
||||||
) ) #centre dialog over parent (or below htest box)
|
) ) #centre dialog over parent (or below htest box)
|
||||||
self.deiconify() #geometry set, unhide
|
if not _utest:
|
||||||
self.wait_window()
|
self.deiconify() #geometry set, unhide
|
||||||
|
self.wait_window()
|
||||||
|
|
||||||
def CreateWidgets(self):
|
def CreateWidgets(self):
|
||||||
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
|
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
|
||||||
|
@ -261,6 +265,7 @@ class GetKeysDialog(Toplevel):
|
||||||
keysOK = True
|
keysOK = True
|
||||||
return keysOK
|
return keysOK
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from idlelib.idle_test.htest import run
|
from idlelib.idle_test.htest import run
|
||||||
run(GetKeysDialog)
|
run(GetKeysDialog)
|
||||||
|
|
|
@ -10,6 +10,7 @@ Refer to comments in EditorWindow autoindent code for details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
import tkinter.messagebox as tkMessageBox
|
import tkinter.messagebox as tkMessageBox
|
||||||
import tkinter.colorchooser as tkColorChooser
|
import tkinter.colorchooser as tkColorChooser
|
||||||
import tkinter.font as tkFont
|
import tkinter.font as tkFont
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import bdb
|
import bdb
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
from idlelib.windows import ListedToplevel
|
from idlelib.windows import ListedToplevel
|
||||||
from idlelib.scrolledlist import ScrolledList
|
from idlelib.scrolledlist import ScrolledList
|
||||||
from idlelib import macosx
|
from idlelib import macosx
|
||||||
|
|
|
@ -7,6 +7,7 @@ import re
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
import tkinter.simpledialog as tkSimpleDialog
|
import tkinter.simpledialog as tkSimpleDialog
|
||||||
import tkinter.messagebox as tkMessageBox
|
import tkinter.messagebox as tkMessageBox
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
@ -26,14 +26,11 @@ show_idlehelp - Create HelpWindow. Called in EditorWindow.help_dialog.
|
||||||
"""
|
"""
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from os.path import abspath, dirname, isfile, join
|
from os.path import abspath, dirname, isfile, join
|
||||||
from tkinter import Toplevel, Frame, Text, Scrollbar, Menu, Menubutton
|
from tkinter import Toplevel, Frame, Text, Menu
|
||||||
|
from tkinter.ttk import Menubutton, Scrollbar
|
||||||
from tkinter import font as tkfont
|
from tkinter import font as tkfont
|
||||||
from idlelib.config import idleConf
|
from idlelib.config import idleConf
|
||||||
|
|
||||||
use_ttk = False # until available to import
|
|
||||||
if use_ttk:
|
|
||||||
from tkinter.ttk import Menubutton
|
|
||||||
|
|
||||||
## About IDLE ##
|
## About IDLE ##
|
||||||
|
|
||||||
|
|
||||||
|
@ -196,15 +193,18 @@ class HelpFrame(Frame):
|
||||||
"Display html text, scrollbar, and toc."
|
"Display html text, scrollbar, and toc."
|
||||||
def __init__(self, parent, filename):
|
def __init__(self, parent, filename):
|
||||||
Frame.__init__(self, parent)
|
Frame.__init__(self, parent)
|
||||||
text = HelpText(self, filename)
|
# keep references to widgets for test access.
|
||||||
|
self.text = text = HelpText(self, filename)
|
||||||
self['background'] = text['background']
|
self['background'] = text['background']
|
||||||
scroll = Scrollbar(self, command=text.yview)
|
self.toc = toc = self.toc_menu(text)
|
||||||
|
self.scroll = scroll = Scrollbar(self, command=text.yview)
|
||||||
text['yscrollcommand'] = scroll.set
|
text['yscrollcommand'] = scroll.set
|
||||||
|
|
||||||
self.rowconfigure(0, weight=1)
|
self.rowconfigure(0, weight=1)
|
||||||
self.columnconfigure(1, weight=1) # text
|
self.columnconfigure(1, weight=1) # text
|
||||||
self.toc_menu(text).grid(column=0, row=0, sticky='nw')
|
toc.grid(row=0, column=0, sticky='nw')
|
||||||
text.grid(column=1, row=0, sticky='nsew')
|
text.grid(row=0, column=1, sticky='nsew')
|
||||||
scroll.grid(column=2, row=0, sticky='ns')
|
scroll.grid(row=0, column=2, sticky='ns')
|
||||||
|
|
||||||
def toc_menu(self, text):
|
def toc_menu(self, text):
|
||||||
"Create table of contents as drop-down menu."
|
"Create table of contents as drop-down menu."
|
||||||
|
@ -265,7 +265,7 @@ def show_idlehelp(parent):
|
||||||
if not isfile(filename):
|
if not isfile(filename):
|
||||||
# try copy_strip, present message
|
# try copy_strip, present message
|
||||||
return
|
return
|
||||||
HelpWindow(parent, filename, 'IDLE Help')
|
return HelpWindow(parent, filename, 'IDLE Help')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from idlelib.idle_test.htest import run
|
from idlelib.idle_test.htest import run
|
||||||
|
|
|
@ -68,6 +68,7 @@ outwin.OutputWindow (indirectly being tested with grep test)
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from idlelib.macosx import _init_tk_type
|
from idlelib.macosx import _init_tk_type
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
|
|
||||||
AboutDialog_spec = {
|
AboutDialog_spec = {
|
||||||
'file': 'help_about',
|
'file': 'help_about',
|
||||||
|
@ -344,7 +345,7 @@ def run(*tests):
|
||||||
frameLabel.pack()
|
frameLabel.pack()
|
||||||
text = tk.Text(frameLabel, wrap='word')
|
text = tk.Text(frameLabel, wrap='word')
|
||||||
text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70)
|
text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70)
|
||||||
scrollbar = tk.Scrollbar(frameLabel, command=text.yview)
|
scrollbar = Scrollbar(frameLabel, command=text.yview)
|
||||||
text.config(yscrollcommand=scrollbar.set)
|
text.config(yscrollcommand=scrollbar.set)
|
||||||
scrollbar.pack(side='right', fill='y', expand=False)
|
scrollbar.pack(side='right', fill='y', expand=False)
|
||||||
text.pack(side='left', fill='both', expand=True)
|
text.pack(side='left', fill='both', expand=True)
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
''' Test autocomplete and autocomple_w
|
||||||
|
|
||||||
|
Coverage of autocomple: 56%
|
||||||
|
'''
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import requires
|
from test.support import requires
|
||||||
from tkinter import Tk, Text
|
from tkinter import Tk, Text
|
||||||
|
|
||||||
import idlelib.autocomplete as ac
|
import idlelib.autocomplete as ac
|
||||||
import idlelib.autocomplete_w as acw
|
import idlelib.autocomplete_w as acw
|
||||||
import idlelib.macosx as mac
|
from idlelib import macosx
|
||||||
from idlelib.idle_test.mock_idle import Func
|
from idlelib.idle_test.mock_idle import Func
|
||||||
from idlelib.idle_test.mock_tk import Event
|
from idlelib.idle_test.mock_tk import Event
|
||||||
|
|
||||||
|
@ -27,7 +31,7 @@ class AutoCompleteTest(unittest.TestCase):
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
requires('gui')
|
requires('gui')
|
||||||
cls.root = Tk()
|
cls.root = Tk()
|
||||||
mac.setupApp(cls.root, None)
|
macosx.setupApp(cls.root, None)
|
||||||
cls.text = Text(cls.root)
|
cls.text = Text(cls.root)
|
||||||
cls.editor = DummyEditwin(cls.root, cls.text)
|
cls.editor = DummyEditwin(cls.root, cls.text)
|
||||||
|
|
||||||
|
|
31
Lib/idlelib/idle_test/test_config_key.py
Normal file
31
Lib/idlelib/idle_test/test_config_key.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
''' Test idlelib.config_key.
|
||||||
|
|
||||||
|
Coverage: 56%
|
||||||
|
'''
|
||||||
|
from idlelib import config_key
|
||||||
|
from test.support import requires
|
||||||
|
requires('gui')
|
||||||
|
import unittest
|
||||||
|
from tkinter import Tk, Text
|
||||||
|
|
||||||
|
|
||||||
|
class GetKeysTest(unittest.TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.root = Tk()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.root.destroy()
|
||||||
|
del cls.root
|
||||||
|
|
||||||
|
|
||||||
|
def test_init(self):
|
||||||
|
dia = config_key.GetKeysDialog(
|
||||||
|
self.root, 'test', '<<Test>>', ['<Key-F12>'], _utest=True)
|
||||||
|
dia.Cancel()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(verbosity=2)
|
29
Lib/idlelib/idle_test/test_debugger.py
Normal file
29
Lib/idlelib/idle_test/test_debugger.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
''' Test idlelib.debugger.
|
||||||
|
|
||||||
|
Coverage: 19%
|
||||||
|
'''
|
||||||
|
from idlelib import debugger
|
||||||
|
from test.support import requires
|
||||||
|
requires('gui')
|
||||||
|
import unittest
|
||||||
|
from tkinter import Tk
|
||||||
|
|
||||||
|
|
||||||
|
class NameSpaceTest(unittest.TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.root = Tk()
|
||||||
|
cls.root.withdraw()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.root.destroy()
|
||||||
|
del cls.root
|
||||||
|
|
||||||
|
def test_init(self):
|
||||||
|
debugger.NamespaceViewer(self.root, 'Test')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(verbosity=2)
|
34
Lib/idlelib/idle_test/test_help.py
Normal file
34
Lib/idlelib/idle_test/test_help.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
'''Test idlelib.help.
|
||||||
|
|
||||||
|
Coverage: 87%
|
||||||
|
'''
|
||||||
|
from idlelib import help
|
||||||
|
from test.support import requires
|
||||||
|
requires('gui')
|
||||||
|
from os.path import abspath, dirname, join
|
||||||
|
from tkinter import Tk
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class HelpFrameTest(unittest.TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
"By itself, this tests that file parsed without exception."
|
||||||
|
cls.root = root = Tk()
|
||||||
|
root.withdraw()
|
||||||
|
helpfile = join(abspath(dirname(dirname(__file__))), 'help.html')
|
||||||
|
cls.frame = help.HelpFrame(root, helpfile)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
del cls.frame
|
||||||
|
cls.root.update_idletasks()
|
||||||
|
cls.root.destroy()
|
||||||
|
del cls.root
|
||||||
|
|
||||||
|
def test_line1(self):
|
||||||
|
text = self.frame.text
|
||||||
|
self.assertEqual(text.get('1.0', '1.end'), ' IDLE ')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(verbosity=2)
|
29
Lib/idlelib/idle_test/test_scrolledlist.py
Normal file
29
Lib/idlelib/idle_test/test_scrolledlist.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
''' Test idlelib.scrolledlist.
|
||||||
|
|
||||||
|
Coverage: 39%
|
||||||
|
'''
|
||||||
|
from idlelib import scrolledlist
|
||||||
|
from test.support import requires
|
||||||
|
requires('gui')
|
||||||
|
import unittest
|
||||||
|
from tkinter import Tk
|
||||||
|
|
||||||
|
|
||||||
|
class ScrolledListTest(unittest.TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.root = Tk()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.root.destroy()
|
||||||
|
del cls.root
|
||||||
|
|
||||||
|
|
||||||
|
def test_init(self):
|
||||||
|
scrolledlist.ScrolledList(self.root)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(verbosity=2)
|
|
@ -7,13 +7,13 @@ information about calls.
|
||||||
|
|
||||||
The coverage is essentially 100%.
|
The coverage is essentially 100%.
|
||||||
'''
|
'''
|
||||||
|
from idlelib import textview as tv
|
||||||
from test.support import requires
|
from test.support import requires
|
||||||
requires('gui')
|
requires('gui')
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
from tkinter import Tk
|
from tkinter import Tk
|
||||||
from idlelib import textview as tv
|
|
||||||
from idlelib.idle_test.mock_idle import Func
|
from idlelib.idle_test.mock_idle import Func
|
||||||
from idlelib.idle_test.mock_tk import Mbox
|
from idlelib.idle_test.mock_tk import Mbox
|
||||||
|
|
||||||
|
|
36
Lib/idlelib/idle_test/test_tree.py
Normal file
36
Lib/idlelib/idle_test/test_tree.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
''' Test idlelib.tree.
|
||||||
|
|
||||||
|
Coverage: 56%
|
||||||
|
'''
|
||||||
|
from idlelib import tree
|
||||||
|
from test.support import requires
|
||||||
|
requires('gui')
|
||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
from tkinter import Tk
|
||||||
|
|
||||||
|
|
||||||
|
class TreeTest(unittest.TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
cls.root = Tk()
|
||||||
|
cls.root.withdraw()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.root.destroy()
|
||||||
|
del cls.root
|
||||||
|
|
||||||
|
def test_init(self):
|
||||||
|
# Start with code slightly adapted from htest.
|
||||||
|
sc = tree.ScrolledCanvas(
|
||||||
|
self.root, bg="white", highlightthickness=0, takefocus=1)
|
||||||
|
sc.frame.pack(expand=1, fill="both", side='left')
|
||||||
|
item = tree.FileTreeItem(tree.ICONDIR)
|
||||||
|
node = tree.TreeNode(sc.canvas, None, item)
|
||||||
|
node.expand()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(verbosity=2)
|
|
@ -1,5 +1,6 @@
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from idlelib import macosx
|
from idlelib import macosx
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
|
|
||||||
class ScrolledList:
|
class ScrolledList:
|
||||||
|
|
||||||
|
@ -124,22 +125,20 @@ class ScrolledList:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _scrolled_list(parent):
|
def _scrolled_list(parent): # htest #
|
||||||
root = Tk()
|
top = Toplevel(parent)
|
||||||
root.title("Test ScrolledList")
|
|
||||||
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
|
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
|
||||||
root.geometry("+%d+%d"%(x, y + 150))
|
top.geometry("+%d+%d"%(x+200, y + 175))
|
||||||
class MyScrolledList(ScrolledList):
|
class MyScrolledList(ScrolledList):
|
||||||
def fill_menu(self): self.menu.add_command(label="right click")
|
def fill_menu(self): self.menu.add_command(label="right click")
|
||||||
def on_select(self, index): print("select", self.get(index))
|
def on_select(self, index): print("select", self.get(index))
|
||||||
def on_double(self, index): print("double", self.get(index))
|
def on_double(self, index): print("double", self.get(index))
|
||||||
|
|
||||||
scrolled_list = MyScrolledList(root)
|
scrolled_list = MyScrolledList(top)
|
||||||
for i in range(30):
|
for i in range(30):
|
||||||
scrolled_list.append("Item %02d" % i)
|
scrolled_list.append("Item %02d" % i)
|
||||||
|
|
||||||
root.mainloop()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# At the moment, test_scrolledlist merely creates instance, like htest.
|
||||||
from idlelib.idle_test.htest import run
|
from idlelib.idle_test.htest import run
|
||||||
run(_scrolled_list)
|
run(_scrolled_list)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
import tkinter.messagebox as tkMessageBox
|
import tkinter.messagebox as tkMessageBox
|
||||||
|
|
||||||
class TextViewer(Toplevel):
|
class TextViewer(Toplevel):
|
||||||
|
@ -50,7 +51,7 @@ class TextViewer(Toplevel):
|
||||||
self.buttonOk = Button(frameButtons, text='Close',
|
self.buttonOk = Button(frameButtons, text='Close',
|
||||||
command=self.Ok, takefocus=FALSE)
|
command=self.Ok, takefocus=FALSE)
|
||||||
self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
|
self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
|
||||||
takefocus=FALSE, highlightthickness=0)
|
takefocus=FALSE)
|
||||||
self.textView = Text(frameText, wrap=WORD, highlightthickness=0,
|
self.textView = Text(frameText, wrap=WORD, highlightthickness=0,
|
||||||
fg=self.fg, bg=self.bg)
|
fg=self.fg, bg=self.bg)
|
||||||
self.scrollbarView.config(command=self.textView.yview)
|
self.scrollbarView.config(command=self.textView.yview)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
|
from tkinter.ttk import Scrollbar
|
||||||
from idlelib import zoomheight
|
from idlelib import zoomheight
|
||||||
from idlelib.config import idleConf
|
from idlelib.config import idleConf
|
||||||
|
|
||||||
|
@ -449,18 +449,17 @@ class ScrolledCanvas:
|
||||||
return "break"
|
return "break"
|
||||||
|
|
||||||
|
|
||||||
def _tree_widget(parent):
|
def _tree_widget(parent): # htest #
|
||||||
root = Tk()
|
top = Toplevel(parent)
|
||||||
root.title("Test TreeWidget")
|
|
||||||
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
|
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
|
||||||
root.geometry("+%d+%d"%(x, y + 150))
|
top.geometry("+%d+%d"%(x+50, y+175))
|
||||||
sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1)
|
sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1)
|
||||||
sc.frame.pack(expand=1, fill="both", side=LEFT)
|
sc.frame.pack(expand=1, fill="both", side=LEFT)
|
||||||
item = FileTreeItem(os.getcwd())
|
item = FileTreeItem(ICONDIR)
|
||||||
node = TreeNode(sc.canvas, None, item)
|
node = TreeNode(sc.canvas, None, item)
|
||||||
node.expand()
|
node.expand()
|
||||||
root.mainloop()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# test_tree is currently a copy of this
|
||||||
from idlelib.idle_test.htest import run
|
from idlelib.idle_test.htest import run
|
||||||
run(_tree_widget)
|
run(_tree_widget)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue