Example #1
0
 def _set_menu_bar(self):
     if self.menubar:
         # create a MenuBar
         from menubar import EditMenuBar
         self._menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar',
                                     self)
         if self.widget: self._menubar.create()
     else:
         # remove
         if self._menubar is None: return
         self._menubar = self._menubar.remove()
Example #2
0
 def _set_menu_bar(self):
     if self.menubar:
         # create a MenuBar
         from menubar import EditMenuBar
         self._menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar', self)
         self._menubar.node = Node(self._menubar)
         common.app_tree.add(self._menubar.node, self.node)
         if self.widget: self._menubar.create()
     else:
         # remove
         if self._menubar is None: return
         self._menubar = self._menubar.remove()
Example #3
0
    def set_menubar(self, value):
        if value:
            from menubar import EditMenuBar
            self.menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar',
                                       self, common.property_panel)
            self.menubar.node = Tree.Node(self.menubar)
            common.app_tree.add(self.menubar.node, self.node)

            if self.widget:
                self.menubar.show_widget(True)
                self.menubar.show_properties()
        else:
            self.menubar = self.menubar.remove()
            self.show_properties(None)
Example #4
0
 def set_menubar(self, value):
     if value:
         from menubar import EditMenuBar
         self.menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar',
                                    self, common.property_panel)
         self.menubar.node = Tree.Node(self.menubar)
         common.app_tree.add(self.menubar.node, self.node)
         
         if self.widget:
             self.menubar.show_widget(True)
             self.menubar.show_properties()
     else:
         self.menubar = self.menubar.remove()
         self.show_properties(None)
Example #5
0
class EditFrame(TopLevelBase, EditStylesMixin, BitmapMixin):
    WX_CLASS = "wxFrame"
    _PROPERTIES = [
        "Widget", "title", "icon", "centered", "sizehints", "menubar",
        "toolbar", "statusbar", "style"
    ]
    PROPERTIES = TopLevelBase.PROPERTIES + _PROPERTIES + TopLevelBase.EXTRA_PROPERTIES
    _PROPERTY_HELP = {'icon': 'Icon for this window.'}
    _PROPERTY_LABELS = {
        "sizehints": 'Set Size Hints',
        "menubar": 'Has MenuBar',
        "toolbar": 'Has ToolBar',
        "statusbar": 'Has StatusBar'
    }
    ATT_CHILDREN = ["_menubar", "_statusbar", "_toolbar"]

    def __init__(self,
                 name,
                 parent,
                 title,
                 style=wx.DEFAULT_FRAME_STYLE,
                 klass='wxFrame'):  #XXX style is not used
        TopLevelBase.__init__(self, name, klass, parent, title=title)
        self.base = 'wxFrame'
        EditStylesMixin.__init__(self)
        self.properties["style"].set(style)

        # initialise instance properties
        self.icon = np.BitmapPropertyD("")
        self.centered = np.CheckBoxProperty(False, default_value=False)
        self.sizehints = np.CheckBoxProperty(False, default_value=False)
        self.menubar = np.CheckBoxProperty(False, default_value=False)
        self.toolbar = np.CheckBoxProperty(False, default_value=False)
        if "statusbar" in self.PROPERTIES:
            self.statusbar = np.CheckBoxProperty(False, default_value=False)
            self._statusbar = None
        else:
            self.statusbar = None
        self._menubar = self._toolbar = None  # these properties will hold the EditMenubar instances etc.

    def create_widget(self):
        if self.parent:
            parent = self.parent.widget
        else:
            #parent = common.palette
            parent = None
        style = self.style
        if common.pin_design_window: style |= wx.STAY_ON_TOP
        self.widget = wx.Frame(parent, self.id, self.title, style=style)
        self._set_widget_icon()

    def finish_widget_creation(self):
        # add menu, status and tool bar
        TopLevelBase.finish_widget_creation(self)
        if not self.properties['size'].is_active():
            self.widget.SetSize((400, 300))
        if wx.Platform == '__WXMSW__':
            self.widget.CenterOnScreen()
        if self.menubar and self._menubar.widget:
            self.widget.SetMenuBar(self._menubar.widget)
        if self.statusbar and self._statusbar.widget:
            self.widget.SetStatusBar(self._statusbar.widget)
        if self.toolbar and self._toolbar.widget:
            self.widget.SetToolBar(self._toolbar.widget)

    def remove(self, *args):
        # remove menu, status and tool bar
        if self.menubar:
            self._menubar = self._menubar.remove(gtk_do_nothing=True)
        if self.statusbar:
            self._statusbar = self._statusbar.remove(do_nothing=True)
        if self.toolbar:
            self._toolbar = self._toolbar.remove(do_nothing=True)
        TopLevelBase.remove(self, *args)

    def _set_widget_icon(self):
        if self.icon:
            bitmap = self.get_preview_obj_bitmap(self.icon.strip())
        else:
            xpm = os.path.join(config.icons_path, 'frame.xpm')
            bitmap = misc.get_xpm_bitmap(xpm)

        icon = compat.wx_EmptyIcon()
        icon.CopyFromBitmap(bitmap)
        self.widget.SetIcon(icon)

    def _set_menu_bar(self):
        if self.menubar:
            # create a MenuBar
            from menubar import EditMenuBar
            self._menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar',
                                        self)
            if self.widget: self._menubar.create()
        else:
            # remove
            if self._menubar is None: return
            self._menubar = self._menubar.remove()

    def _set_status_bar(self):
        if self.statusbar:
            # create a StatusBar
            from statusbar import EditStatusBar
            self._statusbar = EditStatusBar(self.name + '_statusbar',
                                            'wxStatusBar', self)
            if self.widget: self._statusbar.create()
        else:
            # remove
            if self._statusbar is None: return
            self._statusbar = self._statusbar.remove()
        if self.widget:
            # this is needed at least on win32
            wx.PostEvent(
                self.widget,
                wx.SizeEvent(self.widget.GetSize(), self.widget.GetId()))

    def _set_tool_bar(self):
        if self.toolbar:
            # create a ToolBar
            from toolbar import EditToolBar
            EditToolBar(self.name + '_toolbar', 'wxToolBar', self)
            if self.widget: self._toolbar.create()
        else:
            # remove
            if self._toolbar is None: return
            self._toolbar = self._toolbar.remove()

    def properties_changed(self, modified):
        if not modified or "icon" in modified and self.widget:
            self._set_widget_icon()

        if not modified or "menubar" in modified: self._set_menu_bar()
        if not modified or "statusbar" in modified: self._set_status_bar()
        if not modified or "toolbar" in modified: self._set_tool_bar()

        if modified:
            intersection = {"menubar", "statusbar",
                            "toolbar"}.intersection(modified)
            if intersection and self.properties[
                    intersection.pop()].previous_value is not None:
                # previous value is not None -> triggered by user
                misc.rebuild_tree(widget=self, recursive=False, focus=False)

        TopLevelBase.properties_changed(self, modified)
        EditStylesMixin.properties_changed(self, modified)
Example #6
0
class EditFrame(TopLevelBase, EditStylesMixin, BitmapMixin):
    _PROPERTIES = [
        "Widget", "title", "icon", "centered", "sizehints", "menubar",
        "toolbar", "statusbar", "style"
    ]
    PROPERTIES = TopLevelBase.PROPERTIES + _PROPERTIES
    _PROPERTY_HELP = {'icon': BitmapMixin.bitmap_tooltip_text}
    _PROPERTY_LABELS = {
        "sizehints": 'Set Size Hints',
        "menubar": 'Has MenuBar',
        "toolbar": 'Has ToolBar',
        "statusbar": 'Has StatusBar'
    }

    def __init__(self,
                 name,
                 parent,
                 id,
                 title,
                 style=wx.DEFAULT_FRAME_STYLE,
                 klass='wxFrame'):  #XXX style is not used
        TopLevelBase.__init__(self, name, klass, parent, id, title=title)
        self.properties["base"].set('wxFrame')
        EditStylesMixin.__init__(self)

        # initialise instance properties
        self.icon = np.FileNamePropertyD("", default_value="")
        self.centered = np.CheckBoxProperty(False, default_value=False)
        self.sizehints = np.CheckBoxProperty(False)
        self.menubar = np.CheckBoxProperty(False)
        self.toolbar = np.CheckBoxProperty(False)
        if "statusbar" in self.PROPERTIES:
            self.statusbar = np.CheckBoxProperty(False)
            self._statusbar = None
        else:
            self.statusbar = None
        self._menubar = self._toolbar = None  # these properties will hold the EditMenubar instances etc.

    def create_widget(self):
        if self.parent:
            parent = self.parent.widget
        else:
            #parent = common.palette
            parent = None
        self.widget = wx.Frame(parent, self.id, self.title)
        self._set_widget_icon()

    def finish_widget_creation(self):
        # add menu, status and tool bar
        TopLevelBase.finish_widget_creation(self)
        if not self.properties['size'].is_active():
            self.widget.SetSize((400, 300))
        if wx.Platform == '__WXMSW__':
            self.widget.CenterOnScreen()
        if self.menubar and self._menubar.widget:
            self.widget.SetMenuBar(self._menubar.widget)
        if self.statusbar and self._statusbar.widget:
            self.widget.SetStatusBar(self._statusbar.widget)
        if self.toolbar and self._toolbar.widget:
            self.widget.SetToolBar(self._toolbar.widget)

    def remove(self, *args):
        # remove menu, status and tool bar
        if self.menubar:
            self._menubar = self._menubar.remove(gtk_do_nothing=True)
        if self._statusbar:
            self._statusbar = self._statusbar.remove(do_nothing=True)
        if self.toolbar:
            self._toolbar = self._toolbar.remove(do_nothing=True)
        TopLevelBase.remove(self, *args)

    def _set_widget_icon(self):
        if self.icon:
            bitmap = self.get_preview_obj_bitmap(self.icon.strip())
        else:
            xpm = os.path.join(config.icons_path, 'frame.xpm')
            bitmap = misc.get_xpm_bitmap(xpm)

        icon = wx.EmptyIcon()
        icon.CopyFromBitmap(bitmap)
        self.widget.SetIcon(icon)

    def _set_menu_bar(self):
        if self.menubar:
            # create a MenuBar
            from menubar import EditMenuBar
            self._menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar',
                                        self)
            self._menubar.node = Node(self._menubar)
            common.app_tree.add(self._menubar.node, self.node)
            if self.widget: self._menubar.create()
        else:
            # remove
            if self._menubar is None: return
            self._menubar = self._menubar.remove()

    def _set_status_bar(self):
        if self.statusbar:
            # create a StatusBar
            from statusbar import EditStatusBar
            self._statusbar = EditStatusBar(self.name + '_statusbar',
                                            'wxStatusBar', self)
            if self.widget: self._statusbar.create()
        else:
            # remove
            if self._statusbar is None: return
            self._statusbar = self._statusbar.remove()
        if self.widget:
            # this is needed at least on win32
            wx.PostEvent(
                self.widget,
                wx.SizeEvent(self.widget.GetSize(), self.widget.GetId()))

    def _set_tool_bar(self):
        if self.toolbar:
            # create a ToolBar
            from toolbar import EditToolBar
            self._toolbar = EditToolBar(self.name + '_toolbar', 'wxToolBar',
                                        self)
            self._toolbar.node = Node(self._toolbar)
            common.app_tree.add(self._toolbar.node, self.node)

            if self.widget: self._toolbar.create()
        else:
            # remove
            if self._toolbar is None: return
            self._toolbar = self._toolbar.remove()

    def properties_changed(self, modified):
        if not modified or "icon" in modified and self.widget:
            self._set_widget_icon()

        if not modified or "menubar" in modified: self._set_menu_bar()
        if not modified or "statusbar" in modified: self._set_status_bar()
        if not modified or "toolbar" in modified: self._set_tool_bar()

        TopLevelBase.properties_changed(self, modified)
        EditStylesMixin.properties_changed(self, modified)
Example #7
0
class EditFrame(TopLevelBase):
    def __init__(self, name, parent, id, title, property_window,
                 style=wx.DEFAULT_FRAME_STYLE, show=True, klass='wxFrame'):
        TopLevelBase.__init__(self, name, klass, parent, id,
                              property_window, show=show, title=title)
        self.base = 'wxFrame'
        self.style = style
        self.statusbar = None
        self.icon = ''
        self.access_functions['statusbar'] = (self.get_statusbar,
                                              self.set_statusbar)
        self.menubar = None
        self.access_functions['menubar'] = (self.get_menubar, self.set_menubar)
        self.toolbar = None
        self.access_functions['toolbar'] = (self.get_toolbar, self.set_toolbar)

        self.access_functions['style'] = (self.get_style, self.set_style)

        self.access_functions['icon'] = (self.get_icon, self.set_icon)
        prop = self.properties
        style_labels = ['#section#' + _('Style'), 'wxDEFAULT_FRAME_STYLE',
                        'wxICONIZE', 'wxCAPTION',
                        'wxMINIMIZE', 'wxMINIMIZE_BOX', 'wxMAXIMIZE',
                        'wxMAXIMIZE_BOX', 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU',
                        'wxSIMPLE_BORDER', 'wxRESIZE_BORDER',
                        'wxFRAME_TOOL_WINDOW', 'wxFRAME_NO_TASKBAR',
                        'wxFRAME_FLOAT_ON_PARENT',
                        'wxNO_BORDER',
                        'wxNO_FULL_REPAINT_ON_RESIZE',
                        'wxFULL_REPAINT_ON_RESIZE',
                        'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN']
        self.style_pos = [wx.DEFAULT_FRAME_STYLE,
                          wx.ICONIZE, wx.CAPTION, wx.MINIMIZE,
                          wx.MINIMIZE_BOX, wx.MAXIMIZE, wx.MAXIMIZE_BOX,
                          wx.STAY_ON_TOP, wx.SYSTEM_MENU, wx.SIMPLE_BORDER,
                          wx.RESIZE_BORDER, wx.FRAME_TOOL_WINDOW,
                          wx.FRAME_NO_TASKBAR, wx.FRAME_FLOAT_ON_PARENT,
                          wx.NO_BORDER,
                          wx.NO_FULL_REPAINT_ON_RESIZE,
                          wx.FULL_REPAINT_ON_RESIZE,
                          wx.TAB_TRAVERSAL, wx.CLIP_CHILDREN]
        if misc.check_wx_version(2, 5):
            style_labels.insert(5, 'wxCLOSE_BOX')
            self.style_pos.insert(4, wx.CLOSE_BOX)
        prop['style'] = CheckListProperty(self, 'style', None, style_labels)
        # menubar property
        prop['menubar'] = CheckBoxProperty(self, 'menubar', None,
                                           _('Has MenuBar'))
        # statusbar property
        prop['statusbar'] = CheckBoxProperty(self, 'statusbar', None,
                                             _('Has StatusBar'))
        # toolbar property
        prop['toolbar'] = CheckBoxProperty(self, 'toolbar', None,
                                           _('Has ToolBar'))
        # icon property
        prop['icon'] = FileDialogProperty(self, 'icon', None,
                                          style=wx.OPEN|wx.FILE_MUST_EXIST,
                                          can_disable=True, label=_("icon"))
        # centered property
        self.centered = False
        self.access_functions['centered'] = (self.get_centered,
                                             self.set_centered)
        prop['centered'] = CheckBoxProperty(self, 'centered', None,
                                            label=_("centered"))
        # size hints property
        self.sizehints = False
        self.access_functions['sizehints'] = (self.get_sizehints,
                                              self.set_sizehints)
        prop['sizehints'] = CheckBoxProperty(self, 'sizehints', None,
                                             label=_('Set Size Hints'))

    def create_widget(self):
        if self.parent: w = self.parent.widget
        else: w = common.palette
        self.widget = wx.Frame(w, self.id, self.get_title())
        self.set_icon(self.icon)

    def finish_widget_creation(self):
        TopLevelBase.finish_widget_creation(self)
        if not self.properties['size'].is_active():
            #if self.sizer: self.sizer.fit_parent()
            #else:
            self.widget.SetSize((400, 300))
        if wx.Platform == '__WXMSW__':
            self.widget.CenterOnScreen()
        if self.menubar and self.menubar.widget:
            self.widget.SetMenuBar(self.menubar.widget)
        if self.statusbar and self.statusbar.widget:
            self.widget.SetStatusBar(self.statusbar.widget)
        if self.toolbar and self.toolbar.widget:
            self.widget.SetToolBar(self.toolbar.widget)

    def create_properties(self):
        TopLevelBase.create_properties(self)
        prop = self.properties
        panel = wx.ScrolledWindow(self.notebook, -1, style=wx.TAB_TRAVERSAL)
        prop['title'].display(panel)
        prop['icon'].display(panel)
        prop['centered'].display(panel)
        prop['sizehints'].display(panel)
        prop['menubar'].display(panel)
        prop['toolbar'].display(panel)
        try:
            sbprop = prop['statusbar']
            sbprop.display(panel)
        except KeyError:
            sbprop = None
        prop['style'].display(panel)
        
        szr = wx.BoxSizer(wx.VERTICAL)
        szr.Add(prop['title'].panel, 0, wx.EXPAND)
        szr.Add(prop['icon'].panel, 0, wx.EXPAND)
        szr.Add(prop['centered'].panel, 0, wx.EXPAND)
        szr.Add(prop['sizehints'].panel, 0, wx.EXPAND)
        szr.Add(prop['menubar'].panel, 0, wx.EXPAND)
        szr.Add(prop['toolbar'].panel, 0, wx.EXPAND)
        if sbprop:
            szr.Add(sbprop.panel, 0, wx.EXPAND)
        szr.Add(prop['style'].panel, 0, wx.EXPAND)
        panel.SetAutoLayout(True)
        panel.SetSizer(szr)
        szr.Fit(panel)
        self.notebook.AddPage(panel, 'Widget')
        w, h = panel.GetClientSizeTuple()
        panel.SetScrollbars(5, 5, int(math.ceil(w/5.0)), int(math.ceil(h/5.0)))

    def get_menubar(self):
        return self.menubar is not None

    def set_menubar(self, value):
        if value:
            from menubar import EditMenuBar
            self.menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar',
                                       self, common.property_panel)
            self.menubar.node = Tree.Node(self.menubar)
            common.app_tree.add(self.menubar.node, self.node)
            
            if self.widget:
                self.menubar.show_widget(True)
                self.menubar.show_properties()
        else:
            self.menubar = self.menubar.remove()
            self.show_properties(None)

    def get_statusbar(self):
        return self.statusbar is not None

    def set_statusbar(self, value):
        if value:
            self.statusbar = EditStatusBar(self, common.property_panel)
            if self.widget:
                self.statusbar.show_widget(True)
                self.statusbar.show_properties()
        else:
            self.statusbar = self.statusbar.remove()
            self.show_properties(None)
        if self.widget:
            # this is needed at least on win32
            wx.PostEvent(self.widget, wx.SizeEvent(self.widget.GetSize(),
                                                   self.widget.GetId()))
        
    def get_toolbar(self):
        return self.toolbar is not None

    def set_toolbar(self, value):
        if value:
            from toolbar import EditToolBar
            self.toolbar = EditToolBar(self.name + '_toolbar', 'wxToolBar',
                                       self, common.property_panel)
            self.toolbar.node = Tree.Node(self.toolbar)
            common.app_tree.add(self.toolbar.node, self.node)
            
            if self.widget:
                self.toolbar.show_widget(True)
                self.toolbar.show_properties()
        else:
            self.toolbar = self.toolbar.remove()
            self.show_properties(None)

    def get_style(self):
        retval = [0] * len(self.style_pos)
        try:
            if self.style == wx.DEFAULT_FRAME_STYLE: retval[0] = 1
            else:
                for i in range(len(self.style_pos)):
                    if self.style & self.style_pos[i]: retval[i] = 1
                retval[0] = 0
        except AttributeError:
            pass
        return retval

    def set_style(self, value):
        value = self.properties['style'].prepare_value(value)
        style = 0
        for v in range(len(value)):
            if value[v]:
                style |= self.style_pos[v]
        self.style = style
        if self.widget: self.widget.SetWindowStyleFlag(style)

    def remove(self, *args):
        if self.menubar:
            self.menubar = self.menubar.remove(gtk_do_nothing=True)
        if self.statusbar:
            self.statusbar = self.statusbar.remove(do_nothing=True)
        if self.toolbar:
            self.toolbar = self.toolbar.remove(do_nothing=True)
        TopLevelBase.remove(self, *args)
    
    def get_icon(self):
        # is a string that holds the filename (for example: icon.png)
        return self.icon 

    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:')):
                # setting icon
                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:
                # removing icon
                icon = wx.EmptyIcon()
                import os
                xpm = os.path.join(common.wxglade_path, 'icons', 'frame.xpm')
                icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm))
                self.widget.SetIcon(icon)

    def get_centered(self):
        return self.centered

    def set_centered(self, value):
        try: self.centered = bool(int(value))
        except ValueError: pass

    def get_sizehints(self):
        return self.sizehints

    def set_sizehints(self, value):
        try: self.sizehints = bool(int(value))
        except ValueError: pass
Example #8
0
class EditFrame(TopLevelBase):
    def __init__(self,
                 name,
                 parent,
                 id,
                 title,
                 property_window,
                 style=wx.DEFAULT_FRAME_STYLE,
                 show=True,
                 klass='wxFrame'):
        TopLevelBase.__init__(self,
                              name,
                              klass,
                              parent,
                              id,
                              property_window,
                              show=show,
                              title=title)
        self.base = 'wxFrame'
        self.style = style
        self.statusbar = None
        self.icon = ''
        self.access_functions['statusbar'] = (self.get_statusbar,
                                              self.set_statusbar)
        self.menubar = None
        self.access_functions['menubar'] = (self.get_menubar, self.set_menubar)
        self.toolbar = None
        self.access_functions['toolbar'] = (self.get_toolbar, self.set_toolbar)

        self.access_functions['style'] = (self.get_style, self.set_style)

        self.access_functions['icon'] = (self.get_icon, self.set_icon)
        prop = self.properties
        style_labels = [
            '#section#' + _('Style'), 'wxDEFAULT_FRAME_STYLE', 'wxICONIZE',
            'wxCAPTION', 'wxMINIMIZE', 'wxMINIMIZE_BOX', 'wxMAXIMIZE',
            'wxMAXIMIZE_BOX', 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU',
            'wxSIMPLE_BORDER', 'wxRESIZE_BORDER', 'wxFRAME_TOOL_WINDOW',
            'wxFRAME_NO_TASKBAR', 'wxFRAME_FLOAT_ON_PARENT', 'wxNO_BORDER',
            'wxNO_FULL_REPAINT_ON_RESIZE', 'wxFULL_REPAINT_ON_RESIZE',
            'wxTAB_TRAVERSAL', 'wxCLIP_CHILDREN'
        ]
        self.style_pos = [
            wx.DEFAULT_FRAME_STYLE, wx.ICONIZE, wx.CAPTION, wx.MINIMIZE,
            wx.MINIMIZE_BOX, wx.MAXIMIZE, wx.MAXIMIZE_BOX, wx.STAY_ON_TOP,
            wx.SYSTEM_MENU, wx.SIMPLE_BORDER, wx.RESIZE_BORDER,
            wx.FRAME_TOOL_WINDOW, wx.FRAME_NO_TASKBAR,
            wx.FRAME_FLOAT_ON_PARENT, wx.NO_BORDER,
            wx.NO_FULL_REPAINT_ON_RESIZE, wx.FULL_REPAINT_ON_RESIZE,
            wx.TAB_TRAVERSAL, wx.CLIP_CHILDREN
        ]
        if misc.check_wx_version(2, 5):
            style_labels.insert(5, 'wxCLOSE_BOX')
            self.style_pos.insert(4, wx.CLOSE_BOX)
        prop['style'] = CheckListProperty(self, 'style', None, style_labels)
        # menubar property
        prop['menubar'] = CheckBoxProperty(self, 'menubar', None,
                                           _('Has MenuBar'))
        # statusbar property
        prop['statusbar'] = CheckBoxProperty(self, 'statusbar', None,
                                             _('Has StatusBar'))
        # toolbar property
        prop['toolbar'] = CheckBoxProperty(self, 'toolbar', None,
                                           _('Has ToolBar'))
        # icon property
        prop['icon'] = FileDialogProperty(self,
                                          'icon',
                                          None,
                                          style=wx.OPEN | wx.FILE_MUST_EXIST,
                                          can_disable=True,
                                          label=_("icon"))
        # centered property
        self.centered = False
        self.access_functions['centered'] = (self.get_centered,
                                             self.set_centered)
        prop['centered'] = CheckBoxProperty(self,
                                            'centered',
                                            None,
                                            label=_("centered"))
        # size hints property
        self.sizehints = False
        self.access_functions['sizehints'] = (self.get_sizehints,
                                              self.set_sizehints)
        prop['sizehints'] = CheckBoxProperty(self,
                                             'sizehints',
                                             None,
                                             label=_('Set Size Hints'))

    def create_widget(self):
        if self.parent: w = self.parent.widget
        else: w = common.palette
        self.widget = wx.Frame(w, self.id, self.get_title())
        self.set_icon(self.icon)

    def finish_widget_creation(self):
        TopLevelBase.finish_widget_creation(self)
        if not self.properties['size'].is_active():
            #if self.sizer: self.sizer.fit_parent()
            #else:
            self.widget.SetSize((400, 300))
        if wx.Platform == '__WXMSW__':
            self.widget.CenterOnScreen()
        if self.menubar and self.menubar.widget:
            self.widget.SetMenuBar(self.menubar.widget)
        if self.statusbar and self.statusbar.widget:
            self.widget.SetStatusBar(self.statusbar.widget)
        if self.toolbar and self.toolbar.widget:
            self.widget.SetToolBar(self.toolbar.widget)

    def create_properties(self):
        TopLevelBase.create_properties(self)
        prop = self.properties
        panel = wx.ScrolledWindow(self.notebook, -1, style=wx.TAB_TRAVERSAL)
        prop['title'].display(panel)
        prop['icon'].display(panel)
        prop['centered'].display(panel)
        prop['sizehints'].display(panel)
        prop['menubar'].display(panel)
        prop['toolbar'].display(panel)
        try:
            sbprop = prop['statusbar']
            sbprop.display(panel)
        except KeyError:
            sbprop = None
        prop['style'].display(panel)

        szr = wx.BoxSizer(wx.VERTICAL)
        szr.Add(prop['title'].panel, 0, wx.EXPAND)
        szr.Add(prop['icon'].panel, 0, wx.EXPAND)
        szr.Add(prop['centered'].panel, 0, wx.EXPAND)
        szr.Add(prop['sizehints'].panel, 0, wx.EXPAND)
        szr.Add(prop['menubar'].panel, 0, wx.EXPAND)
        szr.Add(prop['toolbar'].panel, 0, wx.EXPAND)
        if sbprop:
            szr.Add(sbprop.panel, 0, wx.EXPAND)
        szr.Add(prop['style'].panel, 0, wx.EXPAND)
        panel.SetAutoLayout(True)
        panel.SetSizer(szr)
        szr.Fit(panel)
        self.notebook.AddPage(panel, 'Widget')
        w, h = panel.GetClientSizeTuple()
        panel.SetScrollbars(5, 5, int(math.ceil(w / 5.0)),
                            int(math.ceil(h / 5.0)))

    def get_menubar(self):
        return self.menubar is not None

    def set_menubar(self, value):
        if value:
            from menubar import EditMenuBar
            self.menubar = EditMenuBar(self.name + '_menubar', 'wxMenuBar',
                                       self, common.property_panel)
            self.menubar.node = Tree.Node(self.menubar)
            common.app_tree.add(self.menubar.node, self.node)

            if self.widget:
                self.menubar.show_widget(True)
                self.menubar.show_properties()
        else:
            self.menubar = self.menubar.remove()
            self.show_properties(None)

    def get_statusbar(self):
        return self.statusbar is not None

    def set_statusbar(self, value):
        if value:
            self.statusbar = EditStatusBar(self, common.property_panel)
            if self.widget:
                self.statusbar.show_widget(True)
                self.statusbar.show_properties()
        else:
            self.statusbar = self.statusbar.remove()
            self.show_properties(None)
        if self.widget:
            # this is needed at least on win32
            wx.PostEvent(
                self.widget,
                wx.SizeEvent(self.widget.GetSize(), self.widget.GetId()))

    def get_toolbar(self):
        return self.toolbar is not None

    def set_toolbar(self, value):
        if value:
            from toolbar import EditToolBar
            self.toolbar = EditToolBar(self.name + '_toolbar', 'wxToolBar',
                                       self, common.property_panel)
            self.toolbar.node = Tree.Node(self.toolbar)
            common.app_tree.add(self.toolbar.node, self.node)

            if self.widget:
                self.toolbar.show_widget(True)
                self.toolbar.show_properties()
        else:
            self.toolbar = self.toolbar.remove()
            self.show_properties(None)

    def get_style(self):
        retval = [0] * len(self.style_pos)
        try:
            if self.style == wx.DEFAULT_FRAME_STYLE: retval[0] = 1
            else:
                for i in range(len(self.style_pos)):
                    if self.style & self.style_pos[i]: retval[i] = 1
                retval[0] = 0
        except AttributeError:
            pass
        return retval

    def set_style(self, value):
        value = self.properties['style'].prepare_value(value)
        style = 0
        for v in range(len(value)):
            if value[v]:
                style |= self.style_pos[v]
        self.style = style
        if self.widget: self.widget.SetWindowStyleFlag(style)

    def remove(self, *args):
        if self.menubar:
            self.menubar = self.menubar.remove(gtk_do_nothing=True)
        if self.statusbar:
            self.statusbar = self.statusbar.remove(do_nothing=True)
        if self.toolbar:
            self.toolbar = self.toolbar.remove(do_nothing=True)
        TopLevelBase.remove(self, *args)

    def get_icon(self):
        # is a string that holds the filename (for example: icon.png)
        return self.icon

    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:')):
                # setting icon
                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:
                # removing icon
                icon = wx.EmptyIcon()
                import os
                xpm = os.path.join(common.wxglade_path, 'icons', 'frame.xpm')
                icon.CopyFromBitmap(misc.get_xpm_bitmap(xpm))
                self.widget.SetIcon(icon)

    def get_centered(self):
        return self.centered

    def set_centered(self, value):
        try:
            self.centered = bool(int(value))
        except ValueError:
            pass

    def get_sizehints(self):
        return self.sizehints

    def set_sizehints(self, value):
        try:
            self.sizehints = bool(int(value))
        except ValueError:
            pass