Ejemplo n.º 1
0
def builder(parent, sizer, pos):
    "factory function for EditToolBar objects"
    import window_dialog as wd
    klass = 'wxToolBar' if common.app_tree.app.language.lower(
    ) == 'xrc' else 'MyToolBar'

    # if e.g. on a frame, suggest the user to add the tool bar to this
    toplevel_widget = None
    if misc.focused_widget is not None and misc.focused_widget.node.parent:
        toplevel_widget = common.app_tree._find_toplevel(
            misc.focused_widget.node).widget
        if not "toolbar" in toplevel_widget.properties:
            toplevel_widget = None
    if toplevel_widget is not None:
        dialog = wd.StandaloneOrChildDialog(klass,
                                            "Select toolbar type and class",
                                            toplevel_widget, "toolbar")
    else:
        dialog = wd.WindowDialog(klass, None,
                                 'Select standalone toolbar class', True)

    klass = dialog.show()
    dialog.Destroy()
    if klass is None: return
    if klass is True:
        # add to toplevel widget
        toplevel_widget.properties["toolbar"].set(True, notify=True)
        return
    name = dialog.get_next_name("toolbar")
    with parent and parent.frozen() or misc.dummy_contextmanager():
        tb = EditToolBar(name, klass, parent)
        tb.node = Node(tb)
        common.app_tree.add(tb.node)
        if parent and parent.widget: tb.create()
Ejemplo n.º 2
0
def builder(parent, pos):
    "factory function for EditMenuBar objects"
    import window_dialog as wd
    klass = 'wxMenuBar' if common.root.language.lower(
    ) == 'xrc' else 'MyMenuBar'

    # if e.g. on a frame, suggest the user to add the menu bar to this
    toplevel_widget = None
    if misc.focused_widget is not None and not misc.focused_widget.IS_ROOT:
        toplevel_widget = misc.focused_widget.toplevel_parent
        if not "menubar" in toplevel_widget.properties:
            toplevel_widget = None
    if toplevel_widget is not None:
        dialog = wd.StandaloneOrChildDialog(klass,
                                            "Select menubar type and class",
                                            toplevel_widget, "menubar")
    else:
        dialog = wd.WindowDialog(klass, None,
                                 'Select standalone menubar class', True)

    klass = dialog.show()
    dialog.Destroy()
    if klass is None: return None
    if klass is True:
        # add to toplevel widget
        toplevel_widget.properties["menubar"].set(True, notify=True)
        return toplevel_widget._menubar
    name = dialog.get_next_name("menubar")
    with (not parent.IS_ROOT
          and parent.frozen()) or misc.dummy_contextmanager():
        editor = EditMenuBar(name, klass, parent)
        editor.create()
        editor.widget.Show()
    return editor
Ejemplo n.º 3
0
def _paste(parent, sizer, pos, clipboard_data):
    "parse XML and insert widget"
    option, span, flag, border, xml_unicode = clipboard2widget( clipboard_data )
    if not xml_unicode: return False
    import xml_parse
    try:
        wx.BeginBusyCursor()
        # widget representation is still unicode, but parser need UTF8
        xml_utf8 = xml_unicode.encode('utf8')
        parser = xml_parse.ClipboardXmlWidgetBuilder(parent, sizer, pos, option, span, flag, border)
        with parent and parent.frozen() or misc.dummy_contextmanager():
            parser.parse_string(xml_utf8)
        common.app_tree.saved = False
        return True  # Widget hierarchy pasted.
    except xml_parse.XmlParsingError:
        if config.debugging: raise
        return False
    finally:
        wx.EndBusyCursor()
Ejemplo n.º 4
0
def _paste(parent, pos, clipboard_data):
    "parse XML and insert widget"
    option, span, flag, border, xml_unicode = clipboard2widget( clipboard_data )
    if not xml_unicode: return False
    import xml_parse
    try:
        wx.BeginBusyCursor()
        # widget representation is still unicode, but parser need UTF8
        xml_utf8 = xml_unicode.encode('utf8')
        parser = xml_parse.ClipboardXmlWidgetBuilder(parent, pos, option, span, flag, border)
        with parent and parent.frozen() or misc.dummy_contextmanager():
            parser.parse_string(xml_utf8)
            if parent and hasattr(parent, "on_child_pasted"):
                parent.on_child_pasted()  # trigger e.g. re-sizing of the children
        misc.rebuild_tree( parser.top_obj )
        return True  # Widget hierarchy pasted.
    except xml_parse.XmlParsingError:
        if config.debugging: raise
        return False
    finally:
        wx.EndBusyCursor()
Ejemplo n.º 5
0
def _paste(parent, index, clipboard_data, rebuild_tree=True):
    "parse XML and insert widget"
    option, span, flag, border, xml_unicode = clipboard2widget( clipboard_data )
    if not xml_unicode: return None
    import xml_parse
    try:
        wx.BeginBusyCursor()
        # widget representation is still unicode, but parser need UTF8
        xml_utf8 = xml_unicode.encode('utf8')
        parser = xml_parse.ClipboardXmlWidgetBuilder(parent, index, option, span, flag, border)
        with parent and parent.frozen() or misc.dummy_contextmanager():
            parser.parse_string(xml_utf8)
            if parent and hasattr(parent, "on_child_pasted"):
                parent.on_child_pasted()  # trigger e.g. re-sizing of the children
        freeze = parser._object_counter>80  # for more objects, we freeze the Tree during re-build
        if rebuild_tree: misc.rebuild_tree( parser.top_obj, freeze=freeze )
        return parser.top_obj  # Widget hierarchy pasted.
    except xml_parse.XmlParsingError:
        if config.debugging: raise
        return None
    finally:
        wx.EndBusyCursor()