Menu

[r94]: / plugins / PyCheckerSupport.py  Maximize  Restore  History

Download this file

90 lines (76 with data), 4.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Programmer: Daniel Pozmanter
# E-mail: drpython@bluebottle.com
# Note: You must reply to the verification e-mail to get through.
#
# Copyright 2003-2004 Daniel Pozmanter
#
# Distributed under the terms of the GPL (GNU Public License)
#
# DrPython is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#Plugin
#Python Debugger Support
import sys, os.path
import wx, wx.lib.dialogs
import drPrefsFile
from drPreferences import drPreferences
def MsgBox (window, string):
wx.MessageBox(window, string, 'Debuging', wx.OK)
def OnAbout(DrFrame):
NameAndVersion = "Python Checker Support:\n\nVersion: 0.0.1\n"
AboutString = NameAndVersion + "By Nathan Jones\nBased on code by Daniel Pozmanter\n\nReleased under the GPL."
d = wx.lib.dialogs.ScrolledMessageDialog(DrFrame, AboutString, "About")
d.ShowModal()
d.Destroy()
def OnHelp(DrFrame):
HelpString = "To install set the location of checker.py in the preferences\n"
HelpString = HelpString + "Then run using the menu option"
d = wx.lib.dialogs.ScrolledMessageDialog(DrFrame, HelpString, "Help")
d.ShowModal()
d.Destroy()
def OnPreferences(DrFrame):
dlg = wx.FileDialog(DrFrame, "Select Pychecker", "", "", "Python Source (*.py *.pyw)|*.py;*.pyw", wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
PycheckLocation = dlg.GetPath()
f = file(DrFrame.pluginspreferencesdirectory + "/Pycheck.preferences.dat", 'w')
f.write("<Pycheck.Location>" + PycheckLocation + "</Pycheck.Location>")
f.close()
dlg.Destroy()
def Plugin(DrFrame):
ID_PYTHON_CHECKER = DrFrame.GetNewId()
DrFrame.LoadPluginShortcuts('PyCheckerSupport')
DrFrame.programmenu.AppendSeparator()
DrFrame.programmenu.Append(ID_PYTHON_CHECKER, "Check program with python checker", " Check the current program with python checker")
def OnRunPythonChecker(event):
if DrFrame.txtDocument.GetModify():
answer = wx.MessageBox("The file has been modified.\nIt would be wise to save before running.\nWould you like to save the file?", "DrPython", wx.YES_NO | wx.ICON_QUESTION)
if answer == wx.YES:
DrFrame.OnSave(event)
if os.path.exists(DrFrame.pluginspreferencesdirectory + "/Pycheck.preferences.dat"):
HomeDir = DrFrame.pluginspreferencesdirectory + "/Pycheck.preferences.dat"
f = file(HomeDir, 'r')
text = f.read()
f.close()
Location = drPrefsFile.ExtractPreferenceFromText(text, "Pycheck.Location")
if os.path.exists(Location) != True:
Location = ""
wx.MessageBox("Location of Pychecker has not been set up.\nPlease set it up first.", "DrPython", wx.OK | wx.ICON_EXCLAMATION)
if Location != "":
print '"' + Location + '" "' + DrFrame.txtDocument.filename + '"'
DrFrame.Execute('"' + Location + '" "' +
DrFrame.txtDocument.filename + '"')
else:
wx.MessageBox("Location of Pychecker has not been set up.\nPlease set it up first.", "DrPython", wx.OK | wx.ICON_EXCLAMATION)
DrFrame.Bind(wx.EVT_MENU, OnRunPythonChecker, id=ID_PYTHON_CHECKER)
DrFrame.AddPluginShortcutFunction("PycheckSupport", "OnRunPythonChecker", OnRunPythonChecker)