How to use the imgui.button function in imgui

To help you get started, we’ve selected a few imgui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github christopherdumas / atomicdatabase / AtomicDatabase / gui_windows.py View on Github external
elif metadata["type"] == 3:
                imgui.text("Leave -1s to allow an arbitrary string.")
                changed, metadata["num_limits"] = imgui.input_float2('Float Limits##'+attr, *metadata["num_limits"])
            elif metadata["type"] == 1:
                imgui.text("Leave blank to allow an arbitrary string.")
                changed, strings = imgui.input_text(
                    "Allowed Strings##" + attr,
                    ','.join(metadata["allowed_strings"]),
                    256,
                    imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
                )
                metadata["allowed_strings"] = list(filter(lambda x: len(x), strings.split(",")))
            elif metadata["type"] == 0:
                imgui.text("All entities allowed")
            imgui.unindent()
        if imgui.button("Add New Attribute Metadata"):
            imgui.open_popup("new-attribute-meta")

        new_name = draw_ok_cancel_popup("new-attribute-meta", "Attribute Name:")
        if new_name:
            new_name = new_name.lower().replace(" ", "_").replace("-", "_")
            DB.attribute_metadata[new_name] = {
                "description": "",
                "type": 5,
                "num_limits": (0,0),
                "is_list": False,
                "allowed_strings": []
            }
            attr_expanded[new_name] = False
        imgui.end()
github nx-python / nx / nx / utils / terminal / menu.py View on Github external
# Create a button "Import this"
        if imgui.button("Import this", width=self.BTN_WIDTH, height=self.BTN_HEIGHT):
            # Execute code when button is pressed
            self.input = "dpaste:>>1441C4D"
        # push style
        imgui.pop_style_color(1)

        imgui.same_line()

        """
        for loop      
        """
        # Give a style to the button
        imgui.push_style_color(imgui.COLOR_BUTTON, *self.KEY_COLOR_LGRAY)
        # Create a button "For loop this"
        if imgui.button("For loop", width=self.BTN_WIDTH, height=self.BTN_HEIGHT):
            # Execute code when button is pressed
            self.input = "dpaste:>>2BTR5CV"
        # push style
        imgui.pop_style_color(1)

        for i in range(2):
            imgui.same_line()
            self.placeholder()

        imgui.end_group()
github pthom / imgui_datascience / imgui_datascience / imgui_image_lister.py View on Github external
def _show_image(self):
        if self.current_image in self.images_info:
            imgui.begin_group()
            if imgui.button("X"):
                self.images_info.pop(self.current_image)
                self.current_image = ""
            else:
                image_info = self.images_info[self.current_image]
                if image_info.additional_legend != "":
                    imgui.same_line()
                    imgui.text(image_info.additional_legend)
                img = image_info.image
                image_size = imgui.Vec2(img.shape[1], img.shape[0])
                image_size = image_size_fit_in_gui(image_size, self._max_image_size(), can_make_bigger=True)
                imgui_cv.image_explorer(img, title=self.current_image,
                                        width=int(round(image_size.x)), height=int(round(image_size.y)),
                                        image_adjustments=image_info.image_adjustments)
            imgui.end_group()
github christopherdumas / atomicdatabase / AtomicDatabase / gui_windows.py View on Github external
popup_registry[ide] = ""
        imgui.text(message)
        changed, popup_registry[ide] = imgui.input_text(
            "##" + ide,
            popup_registry[ide],
            26,
            imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
        )
        if changed or imgui.button("OK"):
            imgui.close_current_popup()
            val = popup_registry[ide]
            popup_registry[ide] = ""
            imgui.end_popup()
            return val
        imgui.same_line()
        if imgui.button("Cancel"):
            imgui.close_current_popup()
            popup_registry[ide] = ""
            imgui.end_popup()
            return False
        imgui.end_popup()
github christopherdumas / atomicdatabase / AtomicDatabase / gui_windows.py View on Github external
def draw_ok_cancel_popup(ide, message="Type a Thing:"):
    if imgui.begin_popup(ide):
        if not ide in popup_registry:
            popup_registry[ide] = ""
        imgui.text(message)
        changed, popup_registry[ide] = imgui.input_text(
            "##" + ide,
            popup_registry[ide],
            26,
            imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
        )
        if changed or imgui.button("OK"):
            imgui.close_current_popup()
            val = popup_registry[ide]
            popup_registry[ide] = ""
            imgui.end_popup()
            return val
        imgui.same_line()
        if imgui.button("Cancel"):
            imgui.close_current_popup()
            popup_registry[ide] = ""
            imgui.end_popup()
            return False
        imgui.end_popup()
github nx-python / PyNX / main.py View on Github external
t.main()
        imgui.pop_style_color(1)

        imgui.end_group()

        
        imgui.end()

        if ERROR:
            imgui.set_next_window_size(width, height)
            imgui.set_next_window_position(0, 0)
            imgui.begin("ERROR", 
                flags=imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_SAVED_SETTINGS
            )
            imgui.text(str(ERROR))
            if imgui.button("OK", width=200, height=60):
                ERROR = ""
            imgui.end()

        imgui.render()
        renderer.render()

    renderer.shutdown()
github nx-python / PyNX / main.py View on Github external
dirs = sorted(dirs)
        files = sorted(files)

        for e in dirs:
            imgui.push_style_color(imgui.COLOR_BUTTON, *FOLDER_COLOR)
            if imgui.button(e + "/", width=200, height=60):
                os.chdir(e)
            imgui.pop_style_color(1)

        for e in files:
            if e.endswith(".py"):
                imgui.push_style_color(imgui.COLOR_BUTTON, *PYFILE_COLOR)
            else:
                imgui.push_style_color(imgui.COLOR_BUTTON, *FILE_COLOR)

            if imgui.button(e, width=200, height=60) and e.endswith(".py"):
                run_python_module(e)
            
            imgui.pop_style_color(1)
        
        imgui.end_group()
        # end of file picker

        imgui.same_line(spacing=50)
        imgui.begin_group()
        imgui.text("Utils:")

        imgui.push_style_color(imgui.COLOR_BUTTON, *APP_COLOR)
        if imgui.button("Interactive Python", width=200, height=60):
            t = Terminal()
            t.main()
        imgui.pop_style_color(1)