コード例 #1
0
ファイル: model.py プロジェクト: gfannes/subsoil
    def _show(self, ctx):
        # Show/adjust the weights
        if (not self.mlp.layers):
            bimpy.text("Warning: you need at least one layer")
            return

        # Select layer
        names = ["{ix} {str}".format(ix=ix, str=str(layer)) for ix,layer in enumerate(self.mlp.layers)]
        if (bimpy.combo("Layer", self.ui.layer_ix, names)):
            self.ui.neuron_ix.value = 0
        layer_ix = self.ui.layer_ix.value
        if (layer_ix < len(self.mlp.layers)):
            layer = self.mlp.layers[layer_ix]
            # Select neuron
            names = ["{ix}".format(ix=ix) for ix,neuron in enumerate(layer.neurons)]
            bimpy.combo("Neuron", self.ui.neuron_ix, names)
            neuron_ix = self.ui.neuron_ix.value
            if (neuron_ix < len(layer.neurons)):
                neuron = layer.neurons[neuron_ix]
                weights = [bimpy.Float(self.weights[neuron.weight_offset+ix]) for ix,_ in enumerate(neuron.input_ixs)]
                for ix,weight in enumerate(weights):
                    bimpy.slider_float("Weight {ix}".format(ix=ix), weight, *util.mm)
                    self.weights[neuron.weight_offset+ix] = weight.value

        if (self.mlp.layers[-1].nr_neurons != 1):
            bimpy.text("Warning: last layer should have only one output")
            return

        if (not self.setup()):
            return
コード例 #2
0
ファイル: io.py プロジェクト: gfannes/subsoil
    def show(self, ctx):
        # Add a layer to the MLP
        bimpy.push_item_width(80)
        bimpy.input_int("nr neurons", self.ui.nr_neurons)
        bimpy.same_line()
        bimpy.combo("transfer", self.ui.transfer, self.ui.transfer_names)
        if (self.ui.nr_neurons.value > 0):
            bimpy.same_line()
            if (bimpy.button("add layer")):
                transfer = self.ui.transfer_names[self.ui.transfer.value]
                self.model.add_layer(transfer, self.ui.nr_neurons.value)
        bimpy.pop_item_width()

        self.model.show(ctx)

        show_io_plot(self.ui.input, self.model)
コード例 #3
0
ファイル: app.py プロジェクト: gfannes/subsoil
 def show(self, ctx):
     if (bimpy.collapsing_header("Subapp selection ({str})".format(str=str(self)))):
         if bimpy.combo("Selected app", self.ix, self.names):
             self.update()
             print("App changed to {str}".format(str=str(self)))
     if (bimpy.collapsing_header("App processing")):
         if (self.app is None):
             bimpy.text("This subapp is not supported.")
             return
         self.app.show(ctx)
コード例 #4
0
ファイル: main.py プロジェクト: vladsterz/build_tools_manager
def main():
    selected_compiler = bimpy.Int()
    ctx = bimpy.Context()
    ctx.init(WIDTH, HEIGHT, "Virtual enviroment manager")

    environments = getAvailableEnviroments()
    compilers_list = list(data.compilers.keys())

    show_new_env_menu = False

    while (not ctx.should_close()):
        with ctx:
            bimpy.set_next_window_pos(bimpy.Vec2(0, 0), bimpy.Condition.Once)
            bimpy.set_next_window_size(bimpy.Vec2(WIDTH, HEIGHT),
                                       bimpy.Condition.Once)
            bimpy.begin("Enviroments",bimpy.Bool(True), \
                bimpy.WindowFlags.NoCollapse and bimpy.WindowFlags.NoResize)
            bimpy.text(sys.version)
            bimpy.columns(2)
            for enviroment in environments:
                if bimpy.button(enviroment):
                    compiler = list(data.compilers.values())[
                        selected_compiler.
                        value] if selected_compiler.value != 0 else ""
                    subprocess.call(
                        ['start', environments[enviroment], compiler],
                        shell=True)
                bimpy.next_column()
                if bimpy.button("O##" + enviroment):
                    subprocess.Popen(r'explorer /select,' +
                                     os.path.dirname(environments[enviroment]))
                    #os.startfile(os.path.realpath(os.path.dirname(environments[enviroment])))
                bimpy.next_column()
            bimpy.columns(1)
            if bimpy.combo("Compiler", selected_compiler, compilers_list):
                pass

            # if bimpy.button("Add new enviroment"):
            #     new_env_ctx = BimpyContext(WIDTH, HEIGHT, "New enviroment menu")
            #     while(not new_env_ctx.ctx.should_close()):
            #         with new_env_ctx.ctx:
            #             bimpy.begin("dsad")
            #             bimpy.text("d")
            #             bimpy.end()

            # if bimpy.button("Create new enviroment"):

            bimpy.end()
コード例 #5
0
ファイル: widgets.py プロジェクト: zakx/bimpy
            bimpy.next_column()
            bimpy.text("Some text")
            bimpy.next_column()
            bimpy.text("Some text")
            bimpy.next_column()
            bimpy.text("Some text")
            bimpy.separator()
            bimpy.columns(1)

            if bimpy.button("Some button"):
                a = 0
                print("!!!")

            bimpy.progress_bar(a)

            bimpy.combo("Combo!", selectedItem, mylist)

            bimpy.push_item_width(-10.0)
            bimpy.plot_lines("Some plot", vals, graph_size=bimpy.Vec2(0, 300))
            bimpy.pop_item_width()

            a += 0.01
        bimpy.end()

        if bimpy.begin("Hello2!",
                       flags=(bimpy.WindowFlags.AlwaysAutoResize
                              | bimpy.WindowFlags.NoTitleBar)):
            bimpy.text("Some text")

            if bimpy.button("Some button"):
                print("!!!")
コード例 #6
0
        if bimpy.button(" < Prev (z) ") or bimpy.is_key_released(ord('Z')):
            b_i.value -= 1
        bimpy.same_line()
        bimpy.checkbox("Autoplay (c to stop)", is_autoplay)
        if bimpy.is_key_down(ord('C')):
            is_autoplay.value = False
        bimpy.same_line()
        if bimpy.button(" Next > (x) ") or bimpy.is_key_released(
                ord('X')) or is_autoplay.value:
            b_i.value += 1

        if display_frame != b_i.value:
            simulate_to_frame(b_i.value)

        bimpy.combo('Label used for annotation', current_label_idx, all_labels)

        img_display_w = bimpy.get_window_content_region_width()
        img_display_h = img_display_w * video_h / video_w

        # Get the zero coordinate of the actual image rendering
        img_display_zero = bimpy.get_cursor_pos() + bimpy.get_window_pos()
        bimpy.image(img_view, bimpy.Vec2(img_display_w, img_display_h))

        # Logic for deleting rects. Click an active rect to make inactive, click to delete.
        delete_rect = None
        for key, r in rect_db[display_frame].items():
            color = 0xFF00FF00 if is_rect_active(r) else 0xFFFFFF00
            x1, y1, x2, y2 = ui_get_screen_rect(r.x1, r.y1, r.x2, r.y2)
            if bimpy.is_mouse_hovering_rect(bimpy.Vec2(x1, y1),
                                            bimpy.Vec2(x2, y2), 0):
コード例 #7
0
def show_demo_window():
    bp.begin_root(menu=True)

    #  Menu Bar
    if bp.begin_menu_bar():
        if bp.begin_menu("Menu"):
            bp.end_menu()

        if bp.begin_menu("Examples"):
            bp.end_menu()

        if bp.begin_menu("Tools"):
            bp.end_menu()

        bp.end_menu_bar()

    global clicked
    if bp.button("Button"):
        clicked += 1
    if clicked & 1:
        bp.same_line()
        bp.text("Thanks for clicking me!")

    bp.checkbox("checkbox", check)

    bp.radio_button("radio a", e, 0)
    bp.same_line()
    bp.radio_button("radio b", e, 1)
    bp.same_line()
    bp.radio_button("radio c", e, 2)

    #  Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style.
    for i in range(7):
        if i > 0:
            bp.same_line()
        bp.push_id_int(i)
        bp.push_style_color(bp.Colors.Button, bp.Vec4(i / 7.0, 0.6, 0.6, 1.0))
        bp.push_style_color(bp.Colors.ButtonHovered,
                            bp.Vec4(i / 7.0, 0.7, 0.7, 1.0))
        bp.push_style_color(bp.Colors.ButtonActive,
                            bp.Vec4(i / 7.0, 0.8, 0.8, 1.0))
        bp.button("Click")
        bp.pop_style_color(3)
        bp.pop_id()

    #  Use AlignTextToFramePadding() to align text baseline to the baseline of framed elements (otherwise a Text+SameLine+Button sequence will have the text a little too high by default)
    bp.align_text_to_frame_padding()
    bp.text("Hold to repeat:")
    bp.same_line()

    #  Arrow buttons with Repeater
    spacing = bp.get_style().item_inner_spacing.x
    bp.push_button_repeat(True)

    global counter
    if bp.arrow_button("##left", bp.Direction.Left):
        counter -= 1

    bp.same_line(0.0, spacing)
    if bp.arrow_button("##right", bp.Direction.Right):
        counter += 1

    bp.pop_button_repeat()
    bp.same_line()
    bp.text("%d" % counter)

    bp.text("Hover over me")
    if bp.is_item_hovered():
        bp.set_tooltip("I am a tooltip")

    bp.same_line()
    bp.text("- or me")
    if bp.is_item_hovered():
        bp.begin_tooltip()
        bp.text("I am a fancy tooltip")
        arr = [0.6, 0.1, 1.0, 0.5, 0.92, 0.1, 0.2]
        bp.plot_lines("Curve", arr)
        bp.end_tooltip()

    bp.separator()

    bp.label_text("label", "Value")

    #  Using the _simplified_ one-liner Combo() api here
    #  See "Combo" section for examples of how to use the more complete BeginCombo()/EndCombo() api.
    items = [
        "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII",
        "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO"
    ]
    bp.combo("combo", item_current, items)
    bp.same_line()
    help_marker(
        "Refer to the \"Combo\" section below for an explanation of the full BeginCombo/EndCombo API, and demonstration of various flags.\n"
    )

    #  To wire InputText() with std::string or any other custom string type,
    #  see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file.
    bp.input_text("input text", str0, 128)
    bp.same_line()
    help_marker(
        "USER:\nHold SHIFT or use mouse to select text.\n"
        "CTRL+Left/Right to word jump.\n"
        "CTRL+A or double-click to select all.\n"
        "CTRL+X,CTRL+C,CTRL+V clipboard.\n"
        "CTRL+Z,CTRL+Y undo/redo.\n"
        "ESCAPE to revert.\n\nPROGRAMMER:\nYou can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated in imgui_demo.cpp)."
    )

    bp.end()
コード例 #8
0
 def render_widget(self):
     if bimpy.combo(self.bimpy_name, self._bimpy_value,
                    self.allowed_values_list):
         self._value = self.allowed_values[self.allowed_values_list[
             self._bimpy_value.value]]