# Helper script when freezing Pmw applications. It concatenates all
# Pmw megawidget files into a single file, 'Pmw.py', in the current
# directory. The script must be called with one argument, being the
# path to the 'lib' directory of the required version of Pmw.
# To freeze a Pmw application, you will also need to copy the
# following files to the application directory before freezing:
# The order of these files is significant. Files which reference
# other files must appear later. Files may be deleted if they are not
'Dialog', 'TimeFuncs', 'Balloon', 'ButtonBox', 'EntryField',
'Group', 'LabeledWidget', 'MainMenuBar', 'MenuBar', 'MessageBar',
'MessageDialog', 'NoteBook', 'OptionMenu', 'PanedWidget', 'PromptDialog',
'RadioSelect', 'ScrolledCanvas', 'ScrolledField', 'ScrolledFrame',
'ScrolledListBox', 'ScrolledText', 'HistoryText', 'SelectionDialog',
'TextDialog', 'TimeCounter', 'AboutDialog', 'ComboBox', 'ComboBoxDialog',
'Counter', 'CounterDialog',
# Set this to 0 if you do not use any of the Pmw.Color functions:
# Set this to 0 if you do not use any of the Pmw.Blt functions:
if not os
.path
.isabs(path
):
path
= os
.path
.join(os
.getcwd(), path
)
if not os
.path
.islink(path
):
dir = os
.path
.dirname(path
)
path
= os
.path
.join(dir, os
.readlink(path
))
# Read the file and modify it so that it can be bundled with the
file = 'Pmw' + file + '.py'
text
= open(os
.path
.join(srcdir
, file)).read()
text
= regsub
.gsub('import Pmw\>', '', text
)
text
= regsub
.gsub('INITOPT = Pmw.INITOPT', '', text
)
text
= regsub
.gsub('\<Pmw\.', '', text
)
text
= '\n' + ('#' * 70) + '\n' + '### File: ' + file + '\n' + text
# Work out which version is being bundled.
file = os
.path
.normpath(file)
dir = os
.path
.dirname(file)
dir = os
.path
.dirname(dir)
dir = os
.path
.basename(dir)
version
= string
.replace(dir[4:], '_', '.')
# Code to import the Color module.
# Code to import the Blt module.
# Code used when not linking with PmwBlt.py.
# Code to define the functions normally supplied by the dynamic loader.
raise ValueError, 'Dynamic versioning not available'
def setalphaversions(*alpha_versions):
raise ValueError, 'Dynamic versioning not available'
def installedversions(alpha = 0):
sys
.argv
.remove('-noblt')
if '-nocolor' in sys
.argv
:
sys
.argv
.remove('-nocolor')
print 'usage: bundlepmw.py [-noblt] [-nocolor] /path/to/Pmw/Pmw_X_X_X/lib'
if os
.path
.exists('Pmw.py'):
print 'Pmw.py already exists. Remove it and try again.'
outfile
= open('Pmw.py', 'w')
outfile
.write(extraCode
% version
)
# Specially handle PmwBase.py file:
text
= regsub
.gsub('import PmwLogicalFont', '', text
)
text
= regsub
.gsub('PmwLogicalFont._font_initialise', '_font_initialise', text
)
outfile
.write(ignoreBltCode
)
files
.append('LogicalFont')
print ' Pmw.py has been created.'
print ' Before running freeze, also copy the following file(s):'
print ' ' + os
.path
.join(srcdir
, 'PmwBlt.py')
print ' ' + os
.path
.join(srcdir
, 'PmwColor.py')