#! /usr/bin/env python # Copyright (c) 2001, MetaSlash Inc. All rights reserved. """ Interface wrapper for IDLE to use PyChecker. """ import string import glob from Tkconstants import * import Tkinter from WindowList import ListedToplevel try: from pychecker import checker except ImportError: checker = None def initWindow(parent, name, closeCB): dialog = ListedToplevel(parent) dialog.wm_title(name) dialog.wm_iconname(name) dialog.wm_protocol('WM_DELETE_WINDOW', closeCB) dialog.bind('', closeCB) return dialog def getWarnings(filelist): cfg = checker.Config.Config() return checker.getWarnings(filelist, cfg) class PyCheckerWindow: def __init__(self, w): self.dialog = dialog = initWindow(w, 'PyChecker', self.close) label = Tkinter.Label(dialog, name='fileLabel', text='Filename(s):') label.grid(row=0, col=0, sticky=N+S+W) self.filenames = Tkinter.Entry(dialog, name='filenames', width=60) self.filenames.grid(row=0, col=1) runButton = Tkinter.Button(dialog, name='run', text='Run', command=self.run) runButton.grid(row=0, col=2) self.dialog.bind('', self.run) self.output = Tkinter.Text(dialog, name='output') self.output.grid(row=2, col=0, columnspan=3) def close(self, event=None): self.dialog.destroy() def run(self, event=None): files = self.filenames.get() filelist = glob.glob(files) warnings = getWarnings(filelist) text = "" for warn in warnings: text = text + "\n%s:%d: %s" % (warn.file, warn.line, warn.err) if not text: text = "No warnings found." self.output.delete('0.0', 'end') self.output.insert('0.0', text) def run(shell): if checker is None: import tkMessageBox tkMessageBox.showerror("PyChecker not available", "Sorry, PyChecker is not installed.", master=shell.text) else: PyCheckerWindow(shell.text)

AltStyle によって変換されたページ (->オリジナル) /