Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2..../idlelib
File: Debugger.py
import os
[0] Fix | Delete
import bdb
[1] Fix | Delete
from Tkinter import *
[2] Fix | Delete
from idlelib.WindowList import ListedToplevel
[3] Fix | Delete
from idlelib.ScrolledList import ScrolledList
[4] Fix | Delete
from idlelib import macosxSupport
[5] Fix | Delete
[6] Fix | Delete
[7] Fix | Delete
class Idb(bdb.Bdb):
[8] Fix | Delete
[9] Fix | Delete
def __init__(self, gui):
[10] Fix | Delete
self.gui = gui
[11] Fix | Delete
bdb.Bdb.__init__(self)
[12] Fix | Delete
[13] Fix | Delete
def user_line(self, frame):
[14] Fix | Delete
if self.in_rpc_code(frame):
[15] Fix | Delete
self.set_step()
[16] Fix | Delete
return
[17] Fix | Delete
message = self.__frame2message(frame)
[18] Fix | Delete
try:
[19] Fix | Delete
self.gui.interaction(message, frame)
[20] Fix | Delete
except TclError: # When closing debugger window with [x] in 3.x
[21] Fix | Delete
pass
[22] Fix | Delete
[23] Fix | Delete
def user_exception(self, frame, info):
[24] Fix | Delete
if self.in_rpc_code(frame):
[25] Fix | Delete
self.set_step()
[26] Fix | Delete
return
[27] Fix | Delete
message = self.__frame2message(frame)
[28] Fix | Delete
self.gui.interaction(message, frame, info)
[29] Fix | Delete
[30] Fix | Delete
def in_rpc_code(self, frame):
[31] Fix | Delete
if frame.f_code.co_filename.count('rpc.py'):
[32] Fix | Delete
return True
[33] Fix | Delete
else:
[34] Fix | Delete
prev_frame = frame.f_back
[35] Fix | Delete
if prev_frame.f_code.co_filename.count('Debugger.py'):
[36] Fix | Delete
# (that test will catch both Debugger.py and RemoteDebugger.py)
[37] Fix | Delete
return False
[38] Fix | Delete
return self.in_rpc_code(prev_frame)
[39] Fix | Delete
[40] Fix | Delete
def __frame2message(self, frame):
[41] Fix | Delete
code = frame.f_code
[42] Fix | Delete
filename = code.co_filename
[43] Fix | Delete
lineno = frame.f_lineno
[44] Fix | Delete
basename = os.path.basename(filename)
[45] Fix | Delete
message = "%s:%s" % (basename, lineno)
[46] Fix | Delete
if code.co_name != "?":
[47] Fix | Delete
message = "%s: %s()" % (message, code.co_name)
[48] Fix | Delete
return message
[49] Fix | Delete
[50] Fix | Delete
[51] Fix | Delete
class Debugger:
[52] Fix | Delete
[53] Fix | Delete
vstack = vsource = vlocals = vglobals = None
[54] Fix | Delete
[55] Fix | Delete
def __init__(self, pyshell, idb=None):
[56] Fix | Delete
if idb is None:
[57] Fix | Delete
idb = Idb(self)
[58] Fix | Delete
self.pyshell = pyshell
[59] Fix | Delete
self.idb = idb
[60] Fix | Delete
self.frame = None
[61] Fix | Delete
self.make_gui()
[62] Fix | Delete
self.interacting = 0
[63] Fix | Delete
self.nesting_level = 0
[64] Fix | Delete
[65] Fix | Delete
def run(self, *args):
[66] Fix | Delete
# Deal with the scenario where we've already got a program running
[67] Fix | Delete
# in the debugger and we want to start another. If that is the case,
[68] Fix | Delete
# our second 'run' was invoked from an event dispatched not from
[69] Fix | Delete
# the main event loop, but from the nested event loop in 'interaction'
[70] Fix | Delete
# below. So our stack looks something like this:
[71] Fix | Delete
# outer main event loop
[72] Fix | Delete
# run()
[73] Fix | Delete
# <running program with traces>
[74] Fix | Delete
# callback to debugger's interaction()
[75] Fix | Delete
# nested event loop
[76] Fix | Delete
# run() for second command
[77] Fix | Delete
#
[78] Fix | Delete
# This kind of nesting of event loops causes all kinds of problems
[79] Fix | Delete
# (see e.g. issue #24455) especially when dealing with running as a
[80] Fix | Delete
# subprocess, where there's all kinds of extra stuff happening in
[81] Fix | Delete
# there - insert a traceback.print_stack() to check it out.
[82] Fix | Delete
#
[83] Fix | Delete
# By this point, we've already called restart_subprocess() in
[84] Fix | Delete
# ScriptBinding. However, we also need to unwind the stack back to
[85] Fix | Delete
# that outer event loop. To accomplish this, we:
[86] Fix | Delete
# - return immediately from the nested run()
[87] Fix | Delete
# - abort_loop ensures the nested event loop will terminate
[88] Fix | Delete
# - the debugger's interaction routine completes normally
[89] Fix | Delete
# - the restart_subprocess() will have taken care of stopping
[90] Fix | Delete
# the running program, which will also let the outer run complete
[91] Fix | Delete
#
[92] Fix | Delete
# That leaves us back at the outer main event loop, at which point our
[93] Fix | Delete
# after event can fire, and we'll come back to this routine with a
[94] Fix | Delete
# clean stack.
[95] Fix | Delete
if self.nesting_level > 0:
[96] Fix | Delete
self.abort_loop()
[97] Fix | Delete
self.root.after(100, lambda: self.run(*args))
[98] Fix | Delete
return
[99] Fix | Delete
try:
[100] Fix | Delete
self.interacting = 1
[101] Fix | Delete
return self.idb.run(*args)
[102] Fix | Delete
finally:
[103] Fix | Delete
self.interacting = 0
[104] Fix | Delete
[105] Fix | Delete
def close(self, event=None):
[106] Fix | Delete
try:
[107] Fix | Delete
self.quit()
[108] Fix | Delete
except Exception:
[109] Fix | Delete
pass
[110] Fix | Delete
if self.interacting:
[111] Fix | Delete
self.top.bell()
[112] Fix | Delete
return
[113] Fix | Delete
if self.stackviewer:
[114] Fix | Delete
self.stackviewer.close(); self.stackviewer = None
[115] Fix | Delete
# Clean up pyshell if user clicked debugger control close widget.
[116] Fix | Delete
# (Causes a harmless extra cycle through close_debugger() if user
[117] Fix | Delete
# toggled debugger from pyshell Debug menu)
[118] Fix | Delete
self.pyshell.close_debugger()
[119] Fix | Delete
# Now close the debugger control window....
[120] Fix | Delete
self.top.destroy()
[121] Fix | Delete
[122] Fix | Delete
def make_gui(self):
[123] Fix | Delete
pyshell = self.pyshell
[124] Fix | Delete
self.flist = pyshell.flist
[125] Fix | Delete
self.root = root = pyshell.root
[126] Fix | Delete
self.top = top = ListedToplevel(root)
[127] Fix | Delete
self.top.wm_title("Debug Control")
[128] Fix | Delete
self.top.wm_iconname("Debug")
[129] Fix | Delete
top.wm_protocol("WM_DELETE_WINDOW", self.close)
[130] Fix | Delete
self.top.bind("<Escape>", self.close)
[131] Fix | Delete
#
[132] Fix | Delete
self.bframe = bframe = Frame(top)
[133] Fix | Delete
self.bframe.pack(anchor="w")
[134] Fix | Delete
self.buttons = bl = []
[135] Fix | Delete
#
[136] Fix | Delete
self.bcont = b = Button(bframe, text="Go", command=self.cont)
[137] Fix | Delete
bl.append(b)
[138] Fix | Delete
self.bstep = b = Button(bframe, text="Step", command=self.step)
[139] Fix | Delete
bl.append(b)
[140] Fix | Delete
self.bnext = b = Button(bframe, text="Over", command=self.next)
[141] Fix | Delete
bl.append(b)
[142] Fix | Delete
self.bret = b = Button(bframe, text="Out", command=self.ret)
[143] Fix | Delete
bl.append(b)
[144] Fix | Delete
self.bret = b = Button(bframe, text="Quit", command=self.quit)
[145] Fix | Delete
bl.append(b)
[146] Fix | Delete
#
[147] Fix | Delete
for b in bl:
[148] Fix | Delete
b.configure(state="disabled")
[149] Fix | Delete
b.pack(side="left")
[150] Fix | Delete
#
[151] Fix | Delete
self.cframe = cframe = Frame(bframe)
[152] Fix | Delete
self.cframe.pack(side="left")
[153] Fix | Delete
#
[154] Fix | Delete
if not self.vstack:
[155] Fix | Delete
self.__class__.vstack = BooleanVar(top)
[156] Fix | Delete
self.vstack.set(1)
[157] Fix | Delete
self.bstack = Checkbutton(cframe,
[158] Fix | Delete
text="Stack", command=self.show_stack, variable=self.vstack)
[159] Fix | Delete
self.bstack.grid(row=0, column=0)
[160] Fix | Delete
if not self.vsource:
[161] Fix | Delete
self.__class__.vsource = BooleanVar(top)
[162] Fix | Delete
self.bsource = Checkbutton(cframe,
[163] Fix | Delete
text="Source", command=self.show_source, variable=self.vsource)
[164] Fix | Delete
self.bsource.grid(row=0, column=1)
[165] Fix | Delete
if not self.vlocals:
[166] Fix | Delete
self.__class__.vlocals = BooleanVar(top)
[167] Fix | Delete
self.vlocals.set(1)
[168] Fix | Delete
self.blocals = Checkbutton(cframe,
[169] Fix | Delete
text="Locals", command=self.show_locals, variable=self.vlocals)
[170] Fix | Delete
self.blocals.grid(row=1, column=0)
[171] Fix | Delete
if not self.vglobals:
[172] Fix | Delete
self.__class__.vglobals = BooleanVar(top)
[173] Fix | Delete
self.bglobals = Checkbutton(cframe,
[174] Fix | Delete
text="Globals", command=self.show_globals, variable=self.vglobals)
[175] Fix | Delete
self.bglobals.grid(row=1, column=1)
[176] Fix | Delete
#
[177] Fix | Delete
self.status = Label(top, anchor="w")
[178] Fix | Delete
self.status.pack(anchor="w")
[179] Fix | Delete
self.error = Label(top, anchor="w")
[180] Fix | Delete
self.error.pack(anchor="w", fill="x")
[181] Fix | Delete
self.errorbg = self.error.cget("background")
[182] Fix | Delete
#
[183] Fix | Delete
self.fstack = Frame(top, height=1)
[184] Fix | Delete
self.fstack.pack(expand=1, fill="both")
[185] Fix | Delete
self.flocals = Frame(top)
[186] Fix | Delete
self.flocals.pack(expand=1, fill="both")
[187] Fix | Delete
self.fglobals = Frame(top, height=1)
[188] Fix | Delete
self.fglobals.pack(expand=1, fill="both")
[189] Fix | Delete
#
[190] Fix | Delete
if self.vstack.get():
[191] Fix | Delete
self.show_stack()
[192] Fix | Delete
if self.vlocals.get():
[193] Fix | Delete
self.show_locals()
[194] Fix | Delete
if self.vglobals.get():
[195] Fix | Delete
self.show_globals()
[196] Fix | Delete
[197] Fix | Delete
def interaction(self, message, frame, info=None):
[198] Fix | Delete
self.frame = frame
[199] Fix | Delete
self.status.configure(text=message)
[200] Fix | Delete
#
[201] Fix | Delete
if info:
[202] Fix | Delete
type, value, tb = info
[203] Fix | Delete
try:
[204] Fix | Delete
m1 = type.__name__
[205] Fix | Delete
except AttributeError:
[206] Fix | Delete
m1 = "%s" % str(type)
[207] Fix | Delete
if value is not None:
[208] Fix | Delete
try:
[209] Fix | Delete
m1 = "%s: %s" % (m1, str(value))
[210] Fix | Delete
except:
[211] Fix | Delete
pass
[212] Fix | Delete
bg = "yellow"
[213] Fix | Delete
else:
[214] Fix | Delete
m1 = ""
[215] Fix | Delete
tb = None
[216] Fix | Delete
bg = self.errorbg
[217] Fix | Delete
self.error.configure(text=m1, background=bg)
[218] Fix | Delete
#
[219] Fix | Delete
sv = self.stackviewer
[220] Fix | Delete
if sv:
[221] Fix | Delete
stack, i = self.idb.get_stack(self.frame, tb)
[222] Fix | Delete
sv.load_stack(stack, i)
[223] Fix | Delete
#
[224] Fix | Delete
self.show_variables(1)
[225] Fix | Delete
#
[226] Fix | Delete
if self.vsource.get():
[227] Fix | Delete
self.sync_source_line()
[228] Fix | Delete
#
[229] Fix | Delete
for b in self.buttons:
[230] Fix | Delete
b.configure(state="normal")
[231] Fix | Delete
#
[232] Fix | Delete
self.top.wakeup()
[233] Fix | Delete
# Nested main loop: Tkinter's main loop is not reentrant, so use
[234] Fix | Delete
# Tcl's vwait facility, which reenters the event loop until an
[235] Fix | Delete
# event handler sets the variable we're waiting on
[236] Fix | Delete
self.nesting_level += 1
[237] Fix | Delete
self.root.tk.call('vwait', '::idledebugwait')
[238] Fix | Delete
self.nesting_level -= 1
[239] Fix | Delete
#
[240] Fix | Delete
for b in self.buttons:
[241] Fix | Delete
b.configure(state="disabled")
[242] Fix | Delete
self.status.configure(text="")
[243] Fix | Delete
self.error.configure(text="", background=self.errorbg)
[244] Fix | Delete
self.frame = None
[245] Fix | Delete
[246] Fix | Delete
def sync_source_line(self):
[247] Fix | Delete
frame = self.frame
[248] Fix | Delete
if not frame:
[249] Fix | Delete
return
[250] Fix | Delete
filename, lineno = self.__frame2fileline(frame)
[251] Fix | Delete
if filename[:1] + filename[-1:] != "<>" and os.path.exists(filename):
[252] Fix | Delete
self.flist.gotofileline(filename, lineno)
[253] Fix | Delete
[254] Fix | Delete
def __frame2fileline(self, frame):
[255] Fix | Delete
code = frame.f_code
[256] Fix | Delete
filename = code.co_filename
[257] Fix | Delete
lineno = frame.f_lineno
[258] Fix | Delete
return filename, lineno
[259] Fix | Delete
[260] Fix | Delete
def cont(self):
[261] Fix | Delete
self.idb.set_continue()
[262] Fix | Delete
self.abort_loop()
[263] Fix | Delete
[264] Fix | Delete
def step(self):
[265] Fix | Delete
self.idb.set_step()
[266] Fix | Delete
self.abort_loop()
[267] Fix | Delete
[268] Fix | Delete
def next(self):
[269] Fix | Delete
self.idb.set_next(self.frame)
[270] Fix | Delete
self.abort_loop()
[271] Fix | Delete
[272] Fix | Delete
def ret(self):
[273] Fix | Delete
self.idb.set_return(self.frame)
[274] Fix | Delete
self.abort_loop()
[275] Fix | Delete
[276] Fix | Delete
def quit(self):
[277] Fix | Delete
self.idb.set_quit()
[278] Fix | Delete
self.abort_loop()
[279] Fix | Delete
[280] Fix | Delete
def abort_loop(self):
[281] Fix | Delete
self.root.tk.call('set', '::idledebugwait', '1')
[282] Fix | Delete
[283] Fix | Delete
stackviewer = None
[284] Fix | Delete
[285] Fix | Delete
def show_stack(self):
[286] Fix | Delete
if not self.stackviewer and self.vstack.get():
[287] Fix | Delete
self.stackviewer = sv = StackViewer(self.fstack, self.flist, self)
[288] Fix | Delete
if self.frame:
[289] Fix | Delete
stack, i = self.idb.get_stack(self.frame, None)
[290] Fix | Delete
sv.load_stack(stack, i)
[291] Fix | Delete
else:
[292] Fix | Delete
sv = self.stackviewer
[293] Fix | Delete
if sv and not self.vstack.get():
[294] Fix | Delete
self.stackviewer = None
[295] Fix | Delete
sv.close()
[296] Fix | Delete
self.fstack['height'] = 1
[297] Fix | Delete
[298] Fix | Delete
def show_source(self):
[299] Fix | Delete
if self.vsource.get():
[300] Fix | Delete
self.sync_source_line()
[301] Fix | Delete
[302] Fix | Delete
def show_frame(self, stackitem):
[303] Fix | Delete
self.frame = stackitem[0] # lineno is stackitem[1]
[304] Fix | Delete
self.show_variables()
[305] Fix | Delete
[306] Fix | Delete
localsviewer = None
[307] Fix | Delete
globalsviewer = None
[308] Fix | Delete
[309] Fix | Delete
def show_locals(self):
[310] Fix | Delete
lv = self.localsviewer
[311] Fix | Delete
if self.vlocals.get():
[312] Fix | Delete
if not lv:
[313] Fix | Delete
self.localsviewer = NamespaceViewer(self.flocals, "Locals")
[314] Fix | Delete
else:
[315] Fix | Delete
if lv:
[316] Fix | Delete
self.localsviewer = None
[317] Fix | Delete
lv.close()
[318] Fix | Delete
self.flocals['height'] = 1
[319] Fix | Delete
self.show_variables()
[320] Fix | Delete
[321] Fix | Delete
def show_globals(self):
[322] Fix | Delete
gv = self.globalsviewer
[323] Fix | Delete
if self.vglobals.get():
[324] Fix | Delete
if not gv:
[325] Fix | Delete
self.globalsviewer = NamespaceViewer(self.fglobals, "Globals")
[326] Fix | Delete
else:
[327] Fix | Delete
if gv:
[328] Fix | Delete
self.globalsviewer = None
[329] Fix | Delete
gv.close()
[330] Fix | Delete
self.fglobals['height'] = 1
[331] Fix | Delete
self.show_variables()
[332] Fix | Delete
[333] Fix | Delete
def show_variables(self, force=0):
[334] Fix | Delete
lv = self.localsviewer
[335] Fix | Delete
gv = self.globalsviewer
[336] Fix | Delete
frame = self.frame
[337] Fix | Delete
if not frame:
[338] Fix | Delete
ldict = gdict = None
[339] Fix | Delete
else:
[340] Fix | Delete
ldict = frame.f_locals
[341] Fix | Delete
gdict = frame.f_globals
[342] Fix | Delete
if lv and gv and ldict is gdict:
[343] Fix | Delete
ldict = None
[344] Fix | Delete
if lv:
[345] Fix | Delete
lv.load_dict(ldict, force, self.pyshell.interp.rpcclt)
[346] Fix | Delete
if gv:
[347] Fix | Delete
gv.load_dict(gdict, force, self.pyshell.interp.rpcclt)
[348] Fix | Delete
[349] Fix | Delete
def set_breakpoint_here(self, filename, lineno):
[350] Fix | Delete
self.idb.set_break(filename, lineno)
[351] Fix | Delete
[352] Fix | Delete
def clear_breakpoint_here(self, filename, lineno):
[353] Fix | Delete
self.idb.clear_break(filename, lineno)
[354] Fix | Delete
[355] Fix | Delete
def clear_file_breaks(self, filename):
[356] Fix | Delete
self.idb.clear_all_file_breaks(filename)
[357] Fix | Delete
[358] Fix | Delete
def load_breakpoints(self):
[359] Fix | Delete
"Load PyShellEditorWindow breakpoints into subprocess debugger"
[360] Fix | Delete
pyshell_edit_windows = self.pyshell.flist.inversedict.keys()
[361] Fix | Delete
for editwin in pyshell_edit_windows:
[362] Fix | Delete
filename = editwin.io.filename
[363] Fix | Delete
try:
[364] Fix | Delete
for lineno in editwin.breakpoints:
[365] Fix | Delete
self.set_breakpoint_here(filename, lineno)
[366] Fix | Delete
except AttributeError:
[367] Fix | Delete
continue
[368] Fix | Delete
[369] Fix | Delete
class StackViewer(ScrolledList):
[370] Fix | Delete
[371] Fix | Delete
def __init__(self, master, flist, gui):
[372] Fix | Delete
if macosxSupport.isAquaTk():
[373] Fix | Delete
# At least on with the stock AquaTk version on OSX 10.4 you'll
[374] Fix | Delete
# get a shaking GUI that eventually kills IDLE if the width
[375] Fix | Delete
# argument is specified.
[376] Fix | Delete
ScrolledList.__init__(self, master)
[377] Fix | Delete
else:
[378] Fix | Delete
ScrolledList.__init__(self, master, width=80)
[379] Fix | Delete
self.flist = flist
[380] Fix | Delete
self.gui = gui
[381] Fix | Delete
self.stack = []
[382] Fix | Delete
[383] Fix | Delete
def load_stack(self, stack, index=None):
[384] Fix | Delete
self.stack = stack
[385] Fix | Delete
self.clear()
[386] Fix | Delete
for i in range(len(stack)):
[387] Fix | Delete
frame, lineno = stack[i]
[388] Fix | Delete
try:
[389] Fix | Delete
modname = frame.f_globals["__name__"]
[390] Fix | Delete
except:
[391] Fix | Delete
modname = "?"
[392] Fix | Delete
code = frame.f_code
[393] Fix | Delete
filename = code.co_filename
[394] Fix | Delete
funcname = code.co_name
[395] Fix | Delete
import linecache
[396] Fix | Delete
sourceline = linecache.getline(filename, lineno)
[397] Fix | Delete
import string
[398] Fix | Delete
sourceline = string.strip(sourceline)
[399] Fix | Delete
if funcname in ("?", "", None):
[400] Fix | Delete
item = "%s, line %d: %s" % (modname, lineno, sourceline)
[401] Fix | Delete
else:
[402] Fix | Delete
item = "%s.%s(), line %d: %s" % (modname, funcname,
[403] Fix | Delete
lineno, sourceline)
[404] Fix | Delete
if i == index:
[405] Fix | Delete
item = "> " + item
[406] Fix | Delete
self.append(item)
[407] Fix | Delete
if index is not None:
[408] Fix | Delete
self.select(index)
[409] Fix | Delete
[410] Fix | Delete
def popup_event(self, event):
[411] Fix | Delete
"override base method"
[412] Fix | Delete
if self.stack:
[413] Fix | Delete
return ScrolledList.popup_event(self, event)
[414] Fix | Delete
[415] Fix | Delete
def fill_menu(self):
[416] Fix | Delete
"override base method"
[417] Fix | Delete
menu = self.menu
[418] Fix | Delete
menu.add_command(label="Go to source line",
[419] Fix | Delete
command=self.goto_source_line)
[420] Fix | Delete
menu.add_command(label="Show stack frame",
[421] Fix | Delete
command=self.show_stack_frame)
[422] Fix | Delete
[423] Fix | Delete
def on_select(self, index):
[424] Fix | Delete
"override base method"
[425] Fix | Delete
if 0 <= index < len(self.stack):
[426] Fix | Delete
self.gui.show_frame(self.stack[index])
[427] Fix | Delete
[428] Fix | Delete
def on_double(self, index):
[429] Fix | Delete
"override base method"
[430] Fix | Delete
self.show_source(index)
[431] Fix | Delete
[432] Fix | Delete
def goto_source_line(self):
[433] Fix | Delete
index = self.listbox.index("active")
[434] Fix | Delete
self.show_source(index)
[435] Fix | Delete
[436] Fix | Delete
def show_stack_frame(self):
[437] Fix | Delete
index = self.listbox.index("active")
[438] Fix | Delete
if 0 <= index < len(self.stack):
[439] Fix | Delete
self.gui.show_frame(self.stack[index])
[440] Fix | Delete
[441] Fix | Delete
def show_source(self, index):
[442] Fix | Delete
if not (0 <= index < len(self.stack)):
[443] Fix | Delete
return
[444] Fix | Delete
frame, lineno = self.stack[index]
[445] Fix | Delete
code = frame.f_code
[446] Fix | Delete
filename = code.co_filename
[447] Fix | Delete
if os.path.isfile(filename):
[448] Fix | Delete
edit = self.flist.open(filename)
[449] Fix | Delete
if edit:
[450] Fix | Delete
edit.gotoline(lineno)
[451] Fix | Delete
[452] Fix | Delete
[453] Fix | Delete
class NamespaceViewer:
[454] Fix | Delete
[455] Fix | Delete
def __init__(self, master, title, dict=None):
[456] Fix | Delete
width = 0
[457] Fix | Delete
height = 40
[458] Fix | Delete
if dict:
[459] Fix | Delete
height = 20*len(dict) # XXX 20 == observed height of Entry widget
[460] Fix | Delete
self.master = master
[461] Fix | Delete
self.title = title
[462] Fix | Delete
import repr
[463] Fix | Delete
self.repr = repr.Repr()
[464] Fix | Delete
self.repr.maxstring = 60
[465] Fix | Delete
self.repr.maxother = 60
[466] Fix | Delete
self.frame = frame = Frame(master)
[467] Fix | Delete
self.frame.pack(expand=1, fill="both")
[468] Fix | Delete
self.label = Label(frame, text=title, borderwidth=2, relief="groove")
[469] Fix | Delete
self.label.pack(fill="x")
[470] Fix | Delete
self.vbar = vbar = Scrollbar(frame, name="vbar")
[471] Fix | Delete
vbar.pack(side="right", fill="y")
[472] Fix | Delete
self.canvas = canvas = Canvas(frame,
[473] Fix | Delete
height=min(300, max(40, height)),
[474] Fix | Delete
scrollregion=(0, 0, width, height))
[475] Fix | Delete
canvas.pack(side="left", fill="both", expand=1)
[476] Fix | Delete
vbar["command"] = canvas.yview
[477] Fix | Delete
canvas["yscrollcommand"] = vbar.set
[478] Fix | Delete
self.subframe = subframe = Frame(canvas)
[479] Fix | Delete
self.sfid = canvas.create_window(0, 0, window=subframe, anchor="nw")
[480] Fix | Delete
self.load_dict(dict)
[481] Fix | Delete
[482] Fix | Delete
dict = -1
[483] Fix | Delete
[484] Fix | Delete
def load_dict(self, dict, force=0, rpc_client=None):
[485] Fix | Delete
if dict is self.dict and not force:
[486] Fix | Delete
return
[487] Fix | Delete
subframe = self.subframe
[488] Fix | Delete
frame = self.frame
[489] Fix | Delete
for c in subframe.children.values():
[490] Fix | Delete
c.destroy()
[491] Fix | Delete
self.dict = None
[492] Fix | Delete
if not dict:
[493] Fix | Delete
l = Label(subframe, text="None")
[494] Fix | Delete
l.grid(row=0, column=0)
[495] Fix | Delete
else:
[496] Fix | Delete
names = dict.keys()
[497] Fix | Delete
names.sort()
[498] Fix | Delete
row = 0
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function