sourceconst.py :  » IDE » Boa-Constructor » boa-constructor-0.6.1 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » IDE » Boa Constructor 
Boa Constructor » boa constructor 0.6.1 » sourceconst.py
#-----------------------------------------------------------------------------
# Name:        sourceconst.py
# Purpose:     Central place for constants, templates and snippets used by the
#              code generation process
#
# Author:      Riaan Booysen
#
# Created:     2001/19/02
# RCS-ID:      $Id: sourceconst.py,v 1.25 2007/07/02 15:01:07 riaan Exp $
# Copyright:   (c) 2001 - 2007 Riaan Booysen
# Licence:     GPL
#-----------------------------------------------------------------------------

import os

import Preferences, Utils

idnt = Utils.getIndentBlock()

methodIndent = idnt
bodyIndent = idnt*2

def wsfix(s):
    return s.replace('\t', idnt).replace('\n', os.linesep)


boaIdent = '#Boa'
boaClass = 'BoaApp'

init_ctrls = '_init_ctrls'
init_coll = '_init_coll_'
init_utils = '_init_utils'
init_props = '_init_props'
init_events = '_init_events'
init_sizers = '_init_sizers'
code_gen_warning = "generated method, don't edit"

defEnvPython = wsfix('#!/usr/bin/env python\n')
# XXX Frame Companion could return this source in writeImports?
defImport = wsfix('import wx\n\n')
defSig = boaIdent+wsfix(':%(modelIdent)s:%(main)s\n\n')

defCreateClass = wsfix('''def create(parent):
\treturn %(main)s(parent)

''')

srchWindowIdsLC = '\[wx.NewId\(\) for %s in range\((?P<count>\d+)\)\]'
srchWindowIds = '\[(?P<winids>[A-Za-z0-9_, ]*)\] = ' + srchWindowIdsLC
srchWindowIdsCont = '(?P<any>.*)\] = ' + srchWindowIdsLC
defWindowIdsCont = wsfix('] = [wx.NewId() for %(idIdent)s in range(%(idCount)d)]\n')
defWindowIds = wsfix('[%(idNames)s')+defWindowIdsCont

defClass = wsfix('''
class %(main)s(%(defaultName)s):
\tdef '''+init_ctrls+'''(self, prnt):
\t\t%(defaultName)s.__init__(%(params)s)

\tdef __init__(self, parent):
\t\tself.'''+init_ctrls+'''(parent)
''')

defApp = wsfix('''import %(mainModule)s

modules = {'%(mainModule)s' : [1, 'Main frame of Application', 'none://%(mainModule)s.py']}

class BoaApp(wx.App):
\tdef OnInit(self):
\t\tself.main = %(mainModule)s.create(None)
\t\tself.main.Show()
\t\tself.SetTopWindow(self.main)
\t\treturn True

def main():
\tapplication = BoaApp(0)
\tapplication.MainLoop()

if __name__ == '__main__':
\tmain()
''')

defInfoBlock = wsfix('''#-----------------------------------------------------------------------------
# Name:        %(Name)s
# Purpose:     %(Purpose)s
#
# Author:      %(Author)s
#
# Created:     %(Created)s
# RCS-ID:      %(RCS-ID)s
# Copyright:   %(Copyright)s
# Licence:     %(Licence)s
#-----------------------------------------------------------------------------
''')

defSetup_py = wsfix('''
from distutils.core import setup

setup(name = '%(name)s',
      version = '%(version)s',
      scripts = [%(scripts)s],
)
''')

defPackageSrc = wsfix('''# Package initialisation
''')

defPyApp = wsfix('''modules = {}

def main():
\tpass

if __name__ == '__main__':
\tmain()
''')

simpleModuleRunSrc = wsfix('''

if __name__ == '__main__':
\tpass # add a call to run your script here
''')

simpleAppFrameRunSrc = wsfix('''

if __name__ == '__main__':
\tapp = wx.PySimpleApp()
\tframe = create(None)
\tframe.Show()

\tapp.MainLoop()
''')

simpleAppDialogRunSrc = wsfix('''

if __name__ == '__main__':
\tapp = wx.PySimpleApp()
\tdlg = create(None)
\ttry:
\t\tdlg.ShowModal()
\tfinally:
\t\tdlg.Destroy()
\tapp.MainLoop()
''')

simpleAppPopupRunSrc = wsfix('''

if __name__ == '__main__':
\tapp = wx.PySimpleApp()
\tframe = wx.Frame(None, -1, 'Parent')
\tframe.SetAutoLayout(True)
\tframe.Show()
\tpopup = create(frame)
\tpopup.Show(True)
\tapp.MainLoop()
''')
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.