Skip to content

Commit

Permalink
apply component.patch (few tweaks needed to EditorWindow.py), issue #…
Browse files Browse the repository at this point in the history
…25036
  • Loading branch information
roseman committed Sep 13, 2015
1 parent b868daf commit e9ee630
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 169 deletions.
26 changes: 14 additions & 12 deletions ClassBrowser.py
Expand Up @@ -15,21 +15,23 @@
import pyclbr

from idlelib import PyShell
from idlelib.WindowList import ListedToplevel
from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
from idlelib.configHandler import idleConf
from idlelib.component import Component
from idlelib.container import Container

file_open = None # Method...Item and Class...Item use this.
# Normally PyShell.flist.open, but there is no PyShell.flist for htest.

class ClassBrowser:
class ClassBrowser(Component):

def __init__(self, flist, name, path, _htest=False):
# XXX This API should change, if the file doesn't end in ".py"
# XXX the code here is bogus!
"""
_htest - bool, change box when location running htest.
"""
Component.__init__(self, flist)
global file_open
if not _htest:
file_open = PyShell.flist.open
Expand All @@ -38,36 +40,36 @@ def __init__(self, flist, name, path, _htest=False):
self._htest = _htest
self.init(flist)

def close(self, event=None):
self.top.destroy()
def close(self):
# NOTE: container will invoke this, so we don't need to destroy it
self.node.destroy()

def init(self, flist):
self.flist = flist
# reset pyclbr
pyclbr._modules.clear()
# create top
self.top = top = ListedToplevel(flist.root)
top.protocol("WM_DELETE_WINDOW", self.close)
top.bind("<Escape>", self.close)
# NOTE: later we will be passed in container, rather than creating it
self.top = top = Container(flist)
self.top.component = self
top.top.bind("<Escape>", self.close)
if self._htest: # place dialog below parent if running htest
top.geometry("+%d+%d" %
top.top.geometry("+%d+%d" %
(flist.root.winfo_rootx(), flist.root.winfo_rooty() + 200))
self.settitle()
top.focus_set()
top.top.focus_set()
# create scrolled canvas
theme = idleConf.GetOption('main','Theme','name')
background = idleConf.GetHighlight(theme, 'normal')['background']
sc = ScrolledCanvas(top, bg=background, highlightthickness=0, takefocus=1)
sc = ScrolledCanvas(top.w, bg=background, highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both")
item = self.rootnode()
self.node = node = TreeNode(sc.canvas, None, item)
node.update()
node.expand()

def settitle(self):
self.top.wm_title("Class Browser - " + self.name)
self.top.wm_iconname("Class Browser")
self.top.set_title("Class Browser - " + self.name, "Class Browser")

def rootnode(self):
return ModuleBrowserTreeItem(self.file)
Expand Down
43 changes: 22 additions & 21 deletions Debugger.py
@@ -1,9 +1,10 @@
import os
import bdb
from tkinter import *
from idlelib.WindowList import ListedToplevel
from idlelib.ScrolledList import ScrolledList
from idlelib import macosxSupport
from idlelib.component import Component
from idlelib.container import Container


class Idb(bdb.Bdb):
Expand Down Expand Up @@ -47,11 +48,12 @@ def __frame2message(self, frame):
return message


class Debugger:
class Debugger(Component):

vstack = vsource = vlocals = vglobals = None

def __init__(self, pyshell, idb=None):
Component.__init__(self, pyshell.flist)
if idb is None:
idb = Idb(self)
self.pyshell = pyshell
Expand All @@ -69,28 +71,27 @@ def run(self, *args):

def close(self, event=None):
if self.interacting:
self.top.bell()
self.top.top.bell()
return
if self.stackviewer:
self.stackviewer.close(); self.stackviewer = None
# Clean up pyshell if user clicked debugger control close widget.
# (Causes a harmless extra cycle through close_debugger() if user
# toggled debugger from pyshell Debug menu)
self.pyshell.close_debugger()
# Now close the debugger control window....
self.top.destroy()
# NOTE: container will invoke this, so we don't need to destroy it

def make_gui(self):
pyshell = self.pyshell
self.flist = pyshell.flist
self.root = root = pyshell.root
self.top = top = ListedToplevel(root)
self.top.wm_title("Debug Control")
self.top.wm_iconname("Debug")
top.wm_protocol("WM_DELETE_WINDOW", self.close)
self.top.bind("<Escape>", self.close)
# NOTE: later we will be passed in container, rather than creating it
self.top = top = Container(self.flist)
self.top.component = self
self.top.set_title("Debug Control", "Debug")
self.top.top.bind("<Escape>", self.close)
#
self.bframe = bframe = Frame(top)
self.bframe = bframe = Frame(top.w)
self.bframe.pack(anchor="w")
self.buttons = bl = []
#
Expand All @@ -113,39 +114,39 @@ def make_gui(self):
self.cframe.pack(side="left")
#
if not self.vstack:
self.__class__.vstack = BooleanVar(top)
self.__class__.vstack = BooleanVar(top.w)
self.vstack.set(1)
self.bstack = Checkbutton(cframe,
text="Stack", command=self.show_stack, variable=self.vstack)
self.bstack.grid(row=0, column=0)
if not self.vsource:
self.__class__.vsource = BooleanVar(top)
self.__class__.vsource = BooleanVar(top.w)
self.bsource = Checkbutton(cframe,
text="Source", command=self.show_source, variable=self.vsource)
self.bsource.grid(row=0, column=1)
if not self.vlocals:
self.__class__.vlocals = BooleanVar(top)
self.__class__.vlocals = BooleanVar(top.w)
self.vlocals.set(1)
self.blocals = Checkbutton(cframe,
text="Locals", command=self.show_locals, variable=self.vlocals)
self.blocals.grid(row=1, column=0)
if not self.vglobals:
self.__class__.vglobals = BooleanVar(top)
self.__class__.vglobals = BooleanVar(top.w)
self.bglobals = Checkbutton(cframe,
text="Globals", command=self.show_globals, variable=self.vglobals)
self.bglobals.grid(row=1, column=1)
#
self.status = Label(top, anchor="w")
self.status = Label(top.w, anchor="w")
self.status.pack(anchor="w")
self.error = Label(top, anchor="w")
self.error = Label(top.w, anchor="w")
self.error.pack(anchor="w", fill="x")
self.errorbg = self.error.cget("background")
#
self.fstack = Frame(top, height=1)
self.fstack = Frame(top.w, height=1)
self.fstack.pack(expand=1, fill="both")
self.flocals = Frame(top)
self.flocals = Frame(top.w)
self.flocals.pack(expand=1, fill="both")
self.fglobals = Frame(top, height=1)
self.fglobals = Frame(top.w, height=1)
self.fglobals.pack(expand=1, fill="both")
#
if self.vstack.get():
Expand Down Expand Up @@ -190,7 +191,7 @@ def interaction(self, message, frame, info=None):
for b in self.buttons:
b.configure(state="normal")
#
self.top.wakeup()
self.top.move_to_front(self)
self.root.mainloop()
#
for b in self.buttons:
Expand Down

0 comments on commit e9ee630

Please sign in to comment.