示例#1
0
 def set_tools(self, tools):
     self.tools = tools
     if not self._tb: return # nothing left to do
     while self._tb.DeleteToolByPos(0):
         pass # clear the toolbar
     # now add all the tools
     for tool in self.tools:
         if misc.streq(tool.id, '---'): # the tool is a separator
             self._tb.AddSeparator()
         else:
             if tool.bitmap1:
                 bmp1 = None
                 if not (tool.bitmap1.startswith('var:') or
                         tool.bitmap1.startswith('code:')):
                     bmp1 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap1)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp1 or not bmp1.Ok(): bmp1 = wx.EmptyBitmap(1, 1)
             else:
                 bmp1 = wx.NullBitmap
             if tool.bitmap2:
                 bmp2 = None
                 if not (tool.bitmap2.startswith('var:') or
                         tool.bitmap2.startswith('code:')):
                     bmp2 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap2)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp2 or not bmp2.Ok(): bmp2 = wx.EmptyBitmap(1, 1)
             else:
                 bmp2 = wx.NullBitmap
             # signature of AddTool for 2.3.2.1:
             # wxToolBarToolBase *AddTool(
             #    int id, const wxBitmap& bitmap,
             #    const wxBitmap& pushedBitmap, bool toggle = FALSE,
             #    wxObject *clientData = NULL,
             #    const wxString& shortHelpString = wxEmptyString,
             #    const wxString& longHelpString = wxEmptyString)
             if not misc.check_wx_version(2, 3, 3):
                 # use the old signature, some of the entries are ignored
                 self._tb.AddTool(wx.NewId(), bmp1, bmp2, tool.type == 1,
                                  shortHelpString=\
                                  misc.wxstr(tool.short_help),
                                  longHelpString=misc.wxstr(tool.long_help))
             else:
                 kinds = [wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO]
                 try:
                     kind = kinds[int(tool.type)]
                 except (ValueError, IndexError):
                     kind = wx.ITEM_NORMAL
                 self._tb.AddLabelTool(wx.NewId(), misc.wxstr(tool.label),
                                       bmp1, bmp2, kind,
                                       misc.wxstr(tool.short_help),
                                       misc.wxstr(tool.long_help))
     # this is required to refresh the toolbar properly
     self._refresh_widget()
示例#2
0
文件: toolbar.py 项目: italomaia/spe
 def set_tools(self, tools):
     self.tools = tools
     if not self._tb: return  # nothing left to do
     while self._tb.DeleteToolByPos(0):
         pass  # clear the toolbar
     # now add all the tools
     for tool in self.tools:
         if misc.streq(tool.id, '---'):  # the tool is a separator
             self._tb.AddSeparator()
         else:
             if tool.bitmap1:
                 bmp1 = None
                 if not (tool.bitmap1.startswith('var:')
                         or tool.bitmap1.startswith('code:')):
                     bmp1 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap1)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp1 or not bmp1.Ok(): bmp1 = wx.EmptyBitmap(1, 1)
             else:
                 bmp1 = wx.NullBitmap
             if tool.bitmap2:
                 bmp2 = None
                 if not (tool.bitmap2.startswith('var:')
                         or tool.bitmap2.startswith('code:')):
                     bmp2 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap2)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp2 or not bmp2.Ok(): bmp2 = wx.EmptyBitmap(1, 1)
             else:
                 bmp2 = wx.NullBitmap
             # signature of AddTool for 2.3.2.1:
             # wxToolBarToolBase *AddTool(
             #    int id, const wxBitmap& bitmap,
             #    const wxBitmap& pushedBitmap, bool toggle = FALSE,
             #    wxObject *clientData = NULL,
             #    const wxString& shortHelpString = wxEmptyString,
             #    const wxString& longHelpString = wxEmptyString)
             if not misc.check_wx_version(2, 3, 3):
                 # use the old signature, some of the entries are ignored
                 self._tb.AddTool(wx.NewId(), bmp1, bmp2, tool.type == 1,
                                  shortHelpString=\
                                  misc.wxstr(tool.short_help),
                                  longHelpString=misc.wxstr(tool.long_help))
             else:
                 kinds = [wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO]
                 try:
                     kind = kinds[int(tool.type)]
                 except (ValueError, IndexError):
                     kind = wx.ITEM_NORMAL
                 self._tb.AddLabelTool(wx.NewId(), misc.wxstr(tool.label),
                                       bmp1, bmp2, kind,
                                       misc.wxstr(tool.short_help),
                                       misc.wxstr(tool.long_help))
     # this is required to refresh the toolbar properly
     self._refresh_widget()
示例#3
0
文件: codegen.py 项目: italomaia/spe
 def get_properties_code(self, dialog):
     prop = dialog.properties
     pygen = common.code_writers['python']
     cn = pygen.cn
     out = []
     title = prop.get('title')
     if title: out.append('self.SetTitle(%s)\n' % pygen.quote_str(title))
     icon = prop.get('icon')
     if icon:
         if icon.startswith('var:'):
             if not dialog.preview:
                 out.append('_icon = ' + cn('wxEmptyIcon') + '()\n')
                 out.append(('_icon.CopyFromBitmap(' + cn('wxBitmap') +
                             '(%s, ' + cn('wxBITMAP_TYPE_ANY') + '))\n') % \
                            icon[4:].strip())
                 out.append('self.SetIcon(_icon)\n')
         elif icon.startswith('code:'):
             if not dialog.preview:
                 out.append('_icon = ' + cn('wxEmptyIcon') + '()\n')
                 out.append(('_icon.CopyFromBitmap(%s)\n') % \
                            icon[5:].strip())
                 out.append('self.SetIcon(_icon)\n')
         else:
             if dialog.preview:
                 import misc
                 icon = misc.get_relative_path(icon, True)
             out.append('_icon = ' + cn('wxEmptyIcon') + '()\n')
             out.append(('_icon.CopyFromBitmap(' + cn('wxBitmap') +
                         '(%s, ' + cn('wxBITMAP_TYPE_ANY') + '))\n') % \
                        pygen.quote_str(icon, False, False))
             out.append('self.SetIcon(_icon)\n')
     out.extend(pygen.generate_common_properties(dialog))
     return out
示例#4
0
 def _get_bitmap(bitmap):
     bmp_preview_path = os.path.join(common.wxglade_path, "icons",
                                     "icon.xpm")
     if not bitmap:
         return cn('wxNullBitmap')
     elif bitmap.startswith('var:'):
         if obj.preview:
             return "%s('%s', %s)" % (cn('wxBitmap'), bmp_preview_path,
                                      cn('wxBITMAP_TYPE_XPM') )
         else:
             return (cn('wxBitmap') + '(%s,' + cn('wxBITMAP_TYPE_ANY') +
                     ')') % (bitmap[4:].strip())
     elif bitmap.startswith('code:'):
         if obj.preview:
             return "%s('%s', %s)" % (cn('wxBitmap'), bmp_preview_path,
                                      cn('wxBITMAP_TYPE_XPM') )
         else:
             return '(%s)' % bitmap[5:].strip()
     else:
         if obj.preview:
             import misc
             bitmap = misc.get_relative_path(bitmap, True)
         return cn('wxBitmap') + \
                ('(%s, ' + cn('wxBITMAP_TYPE_ANY') + ')') % \
                pygen.quote_str(bitmap, False, False)
示例#5
0
    def get_preview_obj_bitmap(self, bitmap=None):
        """\
        Create a wxBitmap instance from the given statement.

        If not statement is given, the instance variable named "bitmap" is used.

        @param bitmap: Bitmap definition
        @type bitmap: str | None

        @see: L{get_preview_obj_artprovider()}
        @see: L{get_preview_obj_emptybitmap()}

        @rtype: wx.Bitmap | wx.EmptyBitmap
        """
        if bitmap is None:
            bitmap = getattr(self, 'bitmap', None)

        if not bitmap:
            return wx.EmptyBitmap(1, 1)

        if bitmap.startswith('var:') or bitmap.startswith('code:'):
            return wx.EmptyBitmap(16, 16)
        elif bitmap.startswith('empty:'):
            return self.get_preview_obj_emptybitmap(bitmap)
        elif bitmap.startswith('art:'):
            return self.get_preview_obj_artprovider(bitmap)
        else:
            bitmap = misc.get_relative_path(bitmap)
            return wx.Bitmap(bitmap, wx.BITMAP_TYPE_ANY)
示例#6
0
 def get_properties_code(self, dialog):
     prop = dialog.properties
     pygen = common.code_writers['python']
     cn = pygen.cn
     out = []
     title = prop.get('title')
     if title: out.append('self.SetTitle(%s)\n' % pygen.quote_str(title))
     icon = prop.get('icon')
     if icon: 
         if icon.startswith('var:'):
             if not dialog.preview:
                 out.append('_icon = ' + cn('wxEmptyIcon') + '()\n')
                 out.append(('_icon.CopyFromBitmap(' + cn('wxBitmap') +
                             '(%s, ' + cn('wxBITMAP_TYPE_ANY') + '))\n') % \
                            icon[4:].strip())
                 out.append('self.SetIcon(_icon)\n')
         elif icon.startswith('code:'):
             if not dialog.preview:
                 out.append('_icon = ' + cn('wxEmptyIcon') + '()\n')
                 out.append(('_icon.CopyFromBitmap(%s)\n') % \
                            icon[5:].strip())
                 out.append('self.SetIcon(_icon)\n')
         else:
             if dialog.preview:
                 import misc
                 icon = misc.get_relative_path(icon, True)
             out.append('_icon = ' + cn('wxEmptyIcon') + '()\n')
             out.append(('_icon.CopyFromBitmap(' + cn('wxBitmap') +
                         '(%s, ' + cn('wxBITMAP_TYPE_ANY') + '))\n') % \
                        pygen.quote_str(icon, False, False))
             out.append('self.SetIcon(_icon)\n')
     out.extend(pygen.generate_common_properties(dialog))
     return out
示例#7
0
 def _get_bitmap(bitmap):
     bmp_preview_path = os.path.join(common.wxglade_path, "icons",
                                     "icon.xpm")
     if not bitmap:
         return cn('wxNullBitmap')
     elif bitmap.startswith('var:'):
         if obj.preview:
             return "%s('%s', %s)" % (cn('wxBitmap'), bmp_preview_path,
                                      cn('wxBITMAP_TYPE_XPM'))
         else:
             return (cn('wxBitmap') + '(%s,' + cn('wxBITMAP_TYPE_ANY') +
                     ')') % (bitmap[4:].strip())
     elif bitmap.startswith('code:'):
         if obj.preview:
             return "%s('%s', %s)" % (cn('wxBitmap'), bmp_preview_path,
                                      cn('wxBITMAP_TYPE_XPM'))
         else:
             return '(%s)' % bitmap[5:].strip()
     else:
         if obj.preview:
             import misc
             bitmap = misc.get_relative_path(bitmap, True)
         return cn('wxBitmap') + \
                ('(%s, ' + cn('wxBITMAP_TYPE_ANY') + ')') % \
                pygen.quote_str(bitmap, False, False)
示例#8
0
 def load_bitmap(self, which=None, empty=[None]):
     if which is None: which = self.bitmap
     if which and \
            not (which.startswith('var:') or which.startswith('code:')):
         which = misc.get_relative_path(which)
         return wx.Bitmap(which, wx.BITMAP_TYPE_ANY)
     else:
         if empty[0] is None:
             empty[0] = wx.EmptyBitmap(1, 1)         
         return empty[0]
示例#9
0
 def load_bitmap(self, which=None, empty=[None]):
     if which is None: which = self.bitmap
     if which and \
            not (which.startswith('var:') or which.startswith('code:')):
         which = misc.get_relative_path(which)
         return wx.Bitmap(which, wx.BITMAP_TYPE_ANY)
     else:
         if empty[0] is None:
             empty[0] = wx.EmptyBitmap(1, 1)         
         return empty[0]
示例#10
0
 def load_bitmap(self, empty=[None]):
     if self.bitmap and \
            not (self.bitmap.startswith('var:') or
                 self.bitmap.startswith('code:')):
         path = misc.get_relative_path(self.bitmap)
         print "LOADING FROM:", path
         return wx.Bitmap(path, wx.BITMAP_TYPE_ANY)
     else:
         if empty[0] is None:
             empty[0] = wx.EmptyBitmap(1, 1)
         return empty[0]
示例#11
0
 def load_bitmap(self, empty=[None]):
     if self.bitmap and \
            not (self.bitmap.startswith('var:') or
                 self.bitmap.startswith('code:')):
         path = misc.get_relative_path(self.bitmap)
         print "LOADING FROM:", path
         return wx.Bitmap(path, wx.BITMAP_TYPE_ANY)
     else:
         if empty[0] is None:
             empty[0] = wx.EmptyBitmap(1, 1)
         return empty[0]
示例#12
0
文件: toolbar.py 项目: dsqiu/qzystudy
 def set_tools(self, tools):
     self.tools = tools
     if not self._tb: return # nothing left to do
     while self._tb.DeleteToolByPos(0):
         pass # clear the toolbar
     # now add all the tools
     for tool in self.tools:
         if misc.streq(tool.id, '---'): # the tool is a separator
             self._tb.AddSeparator()
         else:
             if tool.bitmap1:
                 bmp1 = None
                 if not (tool.bitmap1.startswith('var:') or
                         tool.bitmap1.startswith('code:')):
                     bmp1 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap1)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp1 or not bmp1.Ok(): bmp1 = wx.EmptyBitmap(1, 1)
             else:
                 bmp1 = wx.NullBitmap
             if tool.bitmap2:
                 bmp2 = None
                 if not (tool.bitmap2.startswith('var:') or
                         tool.bitmap2.startswith('code:')):
                     bmp2 = wx.Bitmap(
                         misc.get_relative_path(misc.wxstr(tool.bitmap2)),
                         wx.BITMAP_TYPE_ANY)
                 if not bmp2 or not bmp2.Ok(): bmp2 = wx.EmptyBitmap(1, 1)
             else:
                 bmp2 = wx.NullBitmap
             kinds = [wx.ITEM_NORMAL, wx.ITEM_CHECK, wx.ITEM_RADIO]
             try:
                 kind = kinds[int(tool.type)]
             except (ValueError, IndexError):
                 kind = wx.ITEM_NORMAL
             self._tb.AddLabelTool(wx.NewId(), misc.wxstr(tool.label),
                                   bmp1, bmp2, kind,
                                   misc.wxstr(tool.short_help),
                                   misc.wxstr(tool.long_help))
     # this is required to refresh the toolbar properly
     self._refresh_widget()
示例#13
0
    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.wxglade_path, "icons",
                                        "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, []
示例#14
0
    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.wxglade_path, "icons",
                                        "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, []
示例#15
0
    def generate_code_bitmap(self, bitmap, preview=False):
        """\
        Returns a code fragment that generates an wxBitmap object

        @param bitmap: Bitmap definition
        @type bitmap: str

        @param preview: True to generate code for the preview
        @type preview:  bool

        @rtype: str

        @see: L{tmpl_inline_bitmap}
        @see: L{get_inline_stmt_emptybitmap()}
        @see: L{get_inline_stmt_artprovider()}
        """
        assert self.tmpl_inline_bitmap

        if not bitmap:
            return self.codegen.cn('wxNullBitmap')

        if preview and ( bitmap.startswith('var:') or bitmap.startswith('code:') ):
            preview_icon = os.path.join(config.icons_path, "icon.xpm")
            return self.tmpl_inline_bitmap % { 'name': self.codegen.cn('wxBitmap'),
                                               'bitmap': self.codegen.quote_path(preview_icon),
                                               'bitmap_type': self.codegen.cn('wxBITMAP_TYPE_XPM') }

        if bitmap.startswith('var:'):
            return self.tmpl_inline_bitmap % { 'name': self.codegen.cn('wxBitmap'),
                                               'bitmap': bitmap[4:].strip(),
                                               'bitmap_type': self.codegen.cn('wxBITMAP_TYPE_ANY') }

        if bitmap.startswith('empty:'):
            return self.get_inline_stmt_emptybitmap(bitmap)

        if bitmap.startswith('art:'):
            return self.get_inline_stmt_artprovider(bitmap)

        if bitmap.startswith('code:'):
            return '%s' % self.codegen.cn(bitmap[5:].strip())

        if preview:
            bitmap = misc.get_relative_path(bitmap, True)

        return self.tmpl_inline_bitmap % { 'name': self.codegen.cn('wxBitmap'),
                                           'bitmap': self.codegen.quote_path(bitmap),
                                           'bitmap_type': self.codegen.cn('wxBITMAP_TYPE_ANY') }
示例#16
0
    def on_drop_files(self, screen_xy, ctrl, filenames):
        # as this dialog is shown modal with the main window as parent,
        # this method is called from the main window drop target
        if ctrl is not self.bitmap1 and ctrl is not self.bitmap2: return False

        if not wx.GetKeyState(wx.WXK_ALT) and not wx.GetKeyState(
                wx.WXK_CONTROL):
            # insert relative filename, if available and the filename is under the project directory
            filenames = [
                misc.get_relative_path(filename) for filename in filenames
            ]

        if os.path.sep == "\\":
            filenames = [filename.replace("\\", "/") for filename in filenames]
        if len(filenames) == 1:
            ctrl.SetValue(filenames[0])
        else:
            other_ctrl = self.bitmap2 if ctrl is self.bitmap1 else self.bitmap1
            other_ctrl.SetValue(filenames[1])
示例#17
0
文件: dialog.py 项目: dsqiu/qzystudy
 def set_icon(self, value):
     self.icon = value.strip()
     if self.widget:
         if self.icon and not (self.icon.startswith('var:') or
                               self.icon.startswith('code:')):
             icon = misc.get_relative_path(self.icon)
             bmp = wx.Bitmap(icon, wx.BITMAP_TYPE_ANY)
             if not bmp.Ok():
                 self.set_icon("")
             else:
                 icon = wx.EmptyIcon()
                 icon.CopyFromBitmap(bmp)
                 self.widget.SetIcon(icon) 
         else:
             import os
             icon = wx.EmptyIcon()
             xpm = os.path.join(common.icons_path, 'dialog.xpm')
             icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm))
             self.widget.SetIcon(icon)
示例#18
0
文件: dialog.py 项目: italomaia/spe
 def set_icon(self, value):
     self.icon = value.strip()
     if self.widget:
         if self.icon and not (self.icon.startswith('var:')
                               or self.icon.startswith('code:')):
             icon = misc.get_relative_path(self.icon)
             bmp = wx.Bitmap(icon, wx.BITMAP_TYPE_ANY)
             if not bmp.Ok():
                 self.set_icon("")
             else:
                 icon = wx.EmptyIcon()
                 icon.CopyFromBitmap(bmp)
                 self.widget.SetIcon(icon)
         else:
             import os
             icon = wx.EmptyIcon()
             xpm = os.path.join(common.wxglade_path, 'icons', 'dialog.xpm')
             icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm))
             self.widget.SetIcon(icon)
示例#19
0
    def get_code(self, obj):
        pygen = common.code_writers['python']
        cn = pygen.cn
        prop = obj.properties
        id_name, id = pygen.generate_code_id(obj) 
        bmp_file = prop.get('bitmap', '')
        bmp_preview_path = os.path.join(common.wxglade_path, "icons",
                                        "icon.xpm")
        if not obj.parent.is_toplevel: parent = 'self.%s' % obj.parent.name
        else: parent = 'self'
        style = prop.get("style")
        if style: style = ", style=%s" % pygen.cn_f(style)
        else: style = ''
        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,' + cn('wxBITMAP_TYPE_ANY)')) % \
                      bmp_file[4:].strip()
        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)
        init = []
        if id_name: init.append(id_name)
        klass = obj.klass
        if klass == obj.base: klass = cn(klass)
        init.append('self.%s = %s(%s, %s, %s%s)\n' % 
                    (obj.name, klass, parent, id, bmp,style))
        props_buf = pygen.generate_common_properties(obj)

        disabled_bmp = prop.get('disabled_bitmap')
        if disabled_bmp:
            if disabled_bmp.startswith('var:'):
                if not obj.preview:
                    var = disabled_bmp[4:].strip()
                    props_buf.append(
                        ('self.%s.SetBitmapDisabled(' +
                         cn('wxBitmap') +'(%s,' + cn('wxBITMAP_TYPE_ANY') +
                         '))\n') % (obj.name, var))
            elif disabled_bmp.startswith('code:'):
                if not obj.preview:
                    var = disabled_bmp[5:].strip()
                    props_buf.append(
                        ('self.%s.SetBitmapDisabled(' +
                        '(%s))\n') % \
                        (obj.name, var))
            else:
                props_buf.append(('self.%s.SetBitmapDisabled(' +
                                  cn('wxBitmap') + '(%s, ' +
                                  cn('wxBITMAP_TYPE_ANY') + '))\n') % \
                                 (obj.name,
                                  pygen.quote_str(disabled_bmp, False, False)))
                
        if not prop.has_key('size'):
            props_buf.append('self.%s.SetSize(self.%s.GetBestSize())\n' % \
                             (obj.name, obj.name))
        if prop.get('default', False):
            props_buf.append('self.%s.SetDefault()\n' % obj.name)
        return init, props_buf, []