"php beautifier wx gui" by avion
Rating:









(0 votes)
| Name: | php beautifier wx gui |
|---|---|
| Uploaded By: | avion |
| Date Created: | June 29, 2009 4:54 p.m. |
| Date Modified: | July 1, 2009 3:21 a.m. |
| Description: | Nice gui frontend to pear php beautifier (works even as stand alone script) Since scriptshare has temporary issues with long scripts, you should get whole script at : http://codepad.org/jwysIsmz (here is cat out, it's missing some 20 lines) |
| Num Views: | 1496 |
| Num Downloads: | 403 |
Contents
""" PHP Beautifier gui frontend
works as plugin to programmers notepad and stand alone """
__description__ = "Nice gui frontend to pear php beautifier"
__version__ = "1.0"
__author__ = "Goran Medakovic - avion || jet-plane"
__copyright__ = "(C) 2009 GNU GPL 3."
__requirements__ = "wxPython extension, php, php_beautifier"
__usage__ = "php_beautifier_gui.py filename > beautified.php"
import ConfigParser, wx
from subprocess import Popen, PIPE
try:
import scintilla
import pn
from pypn.decorators import script
except:
#dummy decorator
def script(name,group):
def decorator(f):
return f
return decorator
@script("PHP Code beautifier Gui", "PHP")
def Php_Beautifier():
class PhPB(wx.App):
def OnInit(self):
frame = Dialog(None)
frame.Show()
self.SetTopWindow(frame)
return True
class Dialog(wx.Frame):
def __init__(self, *args, **kwds):
self.cfg = ConfigParser.ConfigParser()
self.config = {}
self.LoadSettings()
wx.Frame.__init__(self, *args, **kwds)
self.chk_ident_space = wx.CheckBox(self, -1, "Ident With Spaces")
self.spin_ident_space = wx.SpinCtrl(self, -1, "4", min=0, max=100)
self.chk_ident_tabs = wx.CheckBox(self, -1, "Ident With Tabs")
self.spin_ident_tabs = wx.SpinCtrl(self, -1, "1", min=0, max=100)
self.chk_header = wx.CheckBox(self, -1, "Header Information")
self.cmb_header = wx.ComboBox(self, -1, choices=["LGPL", "PHP", "BSD", "Apache", "Pear"], style=wx.CB_DROPDOWN|wx.CB_DROPDOWN|wx.CB_READONLY)
self.chk_newline_class = wx.CheckBox(self, -1, "Newline Class")
self.chk_newline_func = wx.CheckBox(self, -1, "Newline Function")
self.chk_newline_bef = wx.CheckBox(self, -1, "New Lines Before")
self.txt_newline_bef = wx.TextCtrl(self, -1, self.config['newline_bef_txt'])
self.chk_newline_aft = wx.CheckBox(self, -1, "New Lines After")
self.txt_newline_aft = wx.TextCtrl(self, -1, self.config['newline_aft_txt'])
self.chk_array_nest = wx.CheckBox(self, -1, "Arrays Nested")
self.chk_lower = wx.CheckBox(self, -1, "Lowercase")
self.chk_list_fc = wx.CheckBox(self, -1, "List functions/classes")
self.cmb_list_fc = wx.ComboBox(self, -1, choices=["List Functions", "List Classes", "List Functions and Classes"], style=wx.CB_DROPDOWN|wx.CB_DROPDOWN|wx.CB_READONLY)
self.chk_style = wx.CheckBox(self, -1, "Style")
self.cmb_style = wx.ComboBox(self, -1, choices=["K&R", "Allman", "Whitesmiths", "GNU"], style=wx.CB_DROPDOWN|wx.CB_DROPDOWN|wx.CB_READONLY)
self.btn_ok = wx.Button(self, wx.ID_APPLY, "")
self.btn_canc = wx.Button(self, wx.ID_EXIT, "")
self.__set_properties()
self.__do_layout()
def __set_properties(self):
self.SetTitle("Php beautifier")
self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
headertooltips = "Adds header information to a file. These can be Php, BSD, Apache, LGPL or Pear license info."
listfc = "Create a list of functions and classes in the script By default, this Filter puts the list at the beggining of the script. If you want it in another position, put a comment like that // Class and Function List The script lookup for the string 'Class and Function List' in a comment and replace the entire comment with the list."
newlinesbefore = "Add new lines before specific keywords. Keywords are separated by a single colon.\nExample: if:switch:T_CLASS"
newlinesafter = "Add new lines after specific keywords. Keywords are separated by a single colon.\nExample: T_COMMENT:function"
self.SetSize(wx.DLG_SZE(self, (255, 220)))
self.cmb_header.SetToolTipString(headertooltips)
self.cmb_list_fc.SetToolTipString(listfc)
self.cmb_style.SetToolTipString("Style of formating")
self.chk_lower.SetToolTipString("Lowercase all control structures (if/then/for..)")
self.chk_ident_space.SetToolTipString("Indent the code with the set number of spaces.")
self.chk_ident_tabs.SetToolTipString("Indent the code with the set number of tabs.")
self.chk_header.SetToolTipString(headertooltips)
self.chk_newline_class.SetToolTipString("Add a new line after class before opening brace.")
self.chk_newline_func.SetToolTipString("Add a new line after function before opening brace.")
self.chk_newline_bef.SetToolTipString(newlinesbefore)
self.txt_newline_bef.SetToolTipString(newlinesbefore)
self.chk_newline_aft.SetToolTipString(newlinesafter)
self.txt_newline_aft.SetToolTipString(newlinesafter)
self.chk_array_nest.SetToolTipString("Indent the array structures.")
self.chk_list_fc.SetToolTipString(listfc)
self.chk_style.SetToolTipString("Style of formating")
# Load saved (default) values
self.cmb_style.SetSelection(self.config['style_sel'])
self.cmb_list_fc.SetSelection(self.config['list_fc_sel'])
self.cmb_header.SetSelection(self.config['header_sel'])
self.chk_ident_space.SetValue(self.config['ident_space'])
---cut-out---