/usr/lib/python2.7/dist-packages/wxglade/widgets/static_bitmap/codegen.py is in python-wxglade 0.6.8-2.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | # codegen.py: code generator functions for wxStaticBitmap objects
# $Id: codegen.py,v 1.26 2007/03/27 07:01:53 agriggio Exp $
#
# Copyright (c) 2002-2007 Alberto Griggio <agriggio@users.sourceforge.net>
# License: MIT (see license.txt)
# THIS PROGRAM COMES WITH NO WARRANTY
import common, os
class PythonCodeGenerator:
def get_code(self, obj):
pygen = common.code_writers['python']
cn = pygen.cn
prop = obj.properties
attribute = pygen.test_attribute(obj)
id_name, id = pygen.generate_code_id(obj)
bmp_file = prop.get('bitmap', '')
bmp_preview_path = os.path.join(common.icons_path, "icon.xpm")
if not bmp_file:
bmp = cn('wxNullBitmap')
elif bmp_file.startswith('var:'):
if obj.preview:
bmp = "%s('%s',%s)" % (cn('wxBitmap'), bmp_preview_path,
cn('wxBITMAP_TYPE_XPM') )
else:
bmp = cn('wxBitmap') + '(%s, %s)' % (bmp_file[4:].strip(),
cn('wxBITMAP_TYPE_ANY'))
elif bmp_file.startswith('code:'):
if obj.preview:
bmp = "%s('%s',%s)" % (cn('wxBitmap'), bmp_preview_path,
cn('wxBITMAP_TYPE_XPM') )
else:
bmp = '(%s)' % bmp_file[5:].strip()
else:
if obj.preview:
import misc
bmp_file = misc.get_relative_path(bmp_file, True)
bmp = (cn('wxBitmap') + '(%s, ' + cn('wxBITMAP_TYPE_ANY') +
')') % pygen.quote_str(bmp_file, False, False)
if not obj.parent.is_toplevel: parent = 'self.%s' % obj.parent.name
else: parent = 'self'
init = []
if id_name: init.append(id_name)
if attribute: prefix = 'self.'
else: prefix = ''
style = prop.get('style')
if style:
style = ', style=%s' % pygen.cn_f(style)
else:
style = ''
klass = obj.klass
if klass == obj.base: klass = pygen.cn(klass)
init.append('%s%s = %s(%s, %s, %s%s)\n' %
(prefix, obj.name, klass, parent, id, bmp, style))
props_buf = pygen.generate_common_properties(obj)
if not attribute:
# the object doesn't have to be stored as an attribute of the
# custom class, but it is just considered part of the layout
return [], [], init + props_buf
return init, props_buf, []
# end of class PythonCodeGenerator
class CppCodeGenerator:
def get_code(self, obj):
cppgen = common.code_writers['C++']
prop = obj.properties
attribute = cppgen.test_attribute(obj)
id_name, id = cppgen.generate_code_id(obj)
if id_name: ids = [ id_name ]
else: ids = []
bmp_file = prop.get('bitmap', '')
if not obj.parent.is_toplevel: parent = '%s' % obj.parent.name
else: parent = 'this'
if not bmp_file:
bmp = 'wxNullBitmap'
elif bmp_file.startswith('var:'):
bmp = 'wxBitmap(%s,wxBITMAP_TYPE_ANY)' % bmp_file[4:].strip()
elif bmp_file.startswith('code:'):
bmp = '(%s)' % bmp_file[5:].strip()
else:
bmp = 'wxBitmap(%s, wxBITMAP_TYPE_ANY)' % \
cppgen.quote_str(bmp_file, False, False)
if not obj.parent.is_toplevel: parent = '%s' % obj.parent.name
else: parent = 'this'
if attribute: prefix = ''
else: prefix = '%s* ' % obj.klass
style = prop.get('style')
if style:
style = ', wxDefaultPosition, wxDefaultSize, ' + style
else:
style = ''
init = [ '%s%s = new %s(%s, %s, %s%s);\n' %
(prefix, obj.name, obj.klass, parent, id, bmp, style) ]
props_buf = cppgen.generate_common_properties(obj)
if not attribute:
return [], ids, [], init + props_buf
return init, ids, props_buf, []
# end of class CppCodeGenerator
def xrc_code_generator(obj):
xrcgen = common.code_writers['XRC']
class XrcCodeGenerator(xrcgen.DefaultXrcObject):
def write(self, *args, **kwds):
try: del self.properties['attribute']
except KeyError: pass
xrcgen.DefaultXrcObject.write(self, *args, **kwds)
return XrcCodeGenerator(obj)
def initialize():
common.class_names['EditStaticBitmap'] = 'wxStaticBitmap'
pygen = common.code_writers.get('python')
if pygen:
pygen.add_widget_handler('wxStaticBitmap', PythonCodeGenerator())
cppgen = common.code_writers.get('C++')
if cppgen:
cppgen.add_widget_handler('wxStaticBitmap', CppCodeGenerator())
xrcgen = common.code_writers.get('XRC')
if xrcgen:
xrcgen.add_widget_handler('wxStaticBitmap', xrc_code_generator)
|