예제 #1
0
def builder(parent, index):
    "Factory function for editor objects from GUI"
    import dialogs
    choices = 'wxNB_TOP|wxNB_BOTTOM|wxNB_LEFT|wxNB_RIGHT'
    options = [("Pages", (0, 20)), ">Add panels", ">Add sizers to panels"]
    defaults = [1, True, False]
    dialog = dialogs.WidgetStyleSelectionDialog(_('wxNotebook'),
                                                _('Orientation'), choices,
                                                options, defaults)
    with misc.disable_stay_on_top(common.adding_window or parent):
        res = dialog.ShowModal()
    style = dialog.get_selection()
    pages, add_panels, add_sizers = dialog.get_options()
    dialog.Destroy()
    if res != wx.ID_OK: return

    name = parent.toplevel_parent.get_next_contained_name('notebook_%d')
    with parent.frozen():
        editor = EditNotebook(name, parent, index, style)
        editor.properties["proportion"].set(1)
        editor.properties["flag"].set("wxEXPAND")
        for n in range(pages):
            # next_pane_name will be used as label and as pane name, if possible
            name = editor.next_pane_name()
            editor.insert_tab(n,
                              name,
                              add_panel=add_panels and name or False,
                              add_sizer=add_sizers)
        if parent.widget: editor.create()
    return editor
예제 #2
0
def builder(parent, index):
    "Factory function for EditSplitterWindow objects"
    import dialogs
    dialog = dialogs.WidgetStyleSelectionDialog(dlg_title, box_title, choices,
                                                ["Create panels"], [True])
    with misc.disable_stay_on_top(common.adding_window or parent):
        res = dialog.ShowModal()
    orientation = dialog.get_selection().split(" ")[0]
    create_panels = dialog.get_options()[0]
    dialog.Destroy()
    if res != wx.ID_OK:
        return

    name = parent.toplevel_parent.get_next_contained_name('window_%d')
    with parent.frozen():
        editor = EditSplitterWindow(name, parent, index, orientation)
        editor.properties["style"].set_to_default()
        if create_panels:
            pane1 = EditPanel(name + '_pane_1', editor, 0)
            pane2 = EditPanel(name + '_pane_2', editor, 1)
        else:
            editor._add_slots()  # XXX focus should be set to first slot

        editor.properties["proportion"].set(1)
        editor.properties["flag"].set("wxEXPAND")

        if parent.widget: editor.create()

        return editor
예제 #3
0
파일: gauge.py 프로젝트: wxGlade/wxGlade
def builder(parent, index):
    "Factory function for editor objects from GUI"
    import dialogs, misc
    dialog = dialogs.WidgetStyleSelectionDialog( _('wxGauge'), _('Orientation'), 'wxGA_HORIZONTAL|wxGA_VERTICAL')
    with misc.disable_stay_on_top(common.adding_window or parent):
        res = dialog.ShowModal()
    style = dialog.get_selection()
    dialog.Destroy()
    if res != wx.ID_OK: return

    name = parent.toplevel_parent.get_next_contained_name('gauge_%d')
    with parent.frozen():
        editor = EditGauge(name, parent, index, style)
        editor.properties["flag"].set("wxEXPAND")
        if parent.widget: editor.create()
    return editor
예제 #4
0
def builder(parent, index):
    "factory function for EditRadioButton objects"
    import dialogs, misc
    name = parent.toplevel_parent.get_next_contained_name('radio_btn_%d')
    dlg = dialogs.WidgetStyleSelectionDialog("RadioButton", None, None, ["?Label"])
    with misc.disable_stay_on_top(common.adding_window or parent):
        res = dlg.ShowModal()
    label, = dlg.get_options()
    dlg.Destroy()
    if res != wx.ID_OK: return

    with parent.frozen():
        editor = EditRadioButton(name, parent, index, label)
        editor.properties["style"].set_to_default()
        editor.check_defaults()
        if parent.widget: editor.create()
    return editor
예제 #5
0
def builder(parent, index, url=None, label=None):
    "factory function for EditHyperlinkCtrl objects"
    name = parent.toplevel_parent.get_next_contained_name('hyperlink_%d')
    if url is None and label is None:
        import dialogs, misc
        dlg = dialogs.WidgetStyleSelectionDialog(_("Hyperlink"), None, None, ["?URL", "?Label"])
        with misc.disable_stay_on_top(common.adding_window or parent):
            res = dlg.ShowModal()
        url, label = dlg.get_options()
        dlg.Destroy()
        if res != wx.ID_OK: return

    with parent.frozen():
        editor = EditHyperlinkCtrl(name, parent, index, label or "")
        editor.properties["style"].set_to_default()
        editor.properties["attribute"].set(True)  # allow to modificate it later on...
        editor.properties["url"].set(url or "")
        editor.check_defaults()
        if parent.widget: editor.create()
    return editor
예제 #6
0
def builder(parent, index):
    "factory function for editor objects from GUI"
    import dialogs, misc
    dialog = dialogs.WidgetStyleSelectionDialog(
        _('wxStaticLine'), _('Orientation'), 'wxLI_HORIZONTAL|wxLI_VERTICAL')
    with misc.disable_stay_on_top(common.adding_window or parent):
        res = dialog.ShowModal()
    style = dialog.get_selection()
    dialog.Destroy()
    if res != wx.ID_OK:
        return

    name = parent.toplevel_parent.get_next_contained_name('static_line_%d')
    with parent.frozen():
        editor = EditStaticLine(name, parent, index, style)
        if parent.IS_SIZER and "orient" in parent.properties and parent.orient:
            if ((parent.orient & wx.VERTICAL and style == "wxLI_HORIZONTAL") or
                (parent.orient & wx.HORIZONTAL and style == "wxLI_VERTICAL")):
                editor.properties["flag"].add("wxEXPAND")
        if parent.widget: editor.create()
    return editor