How to use the imgui.get_io 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 swistakm / pyimgui / doc / examples / pygame_.py View on Github external
def main():
    pygame.init()

    size = 800, 600

    pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL)

    io = imgui.get_io()
    io.fonts.add_font_default()
    io.display_size = size

    renderer = PygameRenderer()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            renderer.process_event(event)

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):
github christopherdumas / atomicdatabase / AtomicDatabase / __main__.py View on Github external
def run():
    global DB, database_name, TICK_INTERVAL, show_meta_attr, show_rules_db, show_eav_db, show_table_db
    font_extra = imgui.get_io().fonts.add_font_from_file_ttf(
        "Fonts/Roboto-Light.ttf", 20
    )
    font_extra2 = imgui.get_io().fonts.add_font_from_file_ttf(
        "Fonts/RobotoMono-Light.ttf", 20
    )
    window, gl_context = impl_pysdl2_init()
    renderer = SDL2Renderer(window)

    running = True
    event = SDL_Event()

    show_save_as = False
    show_load_db = False

    TICK_INTERVAL = 30
    next_time = SDL_GetTicks() + TICK_INTERVAL;

    io = imgui.get_io()
    while running:
github christopherdumas / atomicdatabase / AtomicDatabase / gui_windows.py View on Github external
'Value##data-value-string',
                data_value,
                256,
                imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
            )
        elif data_type == 2:
            changed, data_value = imgui.input_int(
                'Value##data-value-int',
                data_value
            )
        elif data_type == 3:
            changed, data_value = imgui.input_float(
                'Value##data-value-float',
                data_value
            )
        if imgui.button("OK") or imgui.get_io().keys_down[SDL_SCANCODE_RETURN]:
            try:
                if data_type == 0:
                    data_value = DB.entities[data_value]
                if constant:
                    DB.global_binds[data_attr] = data_value
                else:
                    DB.add((DB.entities[data_entity], data_attr, data_value))
                query_error = ""
                data_entity = 0
                data_attr = ""
                data_type = 1
                data_value = ""
                imgui.close_current_popup()
            except ValueError as e:
                query_error = "Data Error: " + str(e)
        imgui.same_line()
github swistakm / pyimgui / imgui / integrations / opengl.py View on Github external
def __init__(self):
        if not imgui.get_current_context():
            raise RuntimeError(
                "No valid ImGui context. Use imgui.create_context() first and/or "
                "imgui.set_current_context()."
            )
        self.io = imgui.get_io()

        self._font_texture = None

        self.io.delta_time = 1.0 / 60.0

        self._create_device_objects()
        self.refresh_font_texture()
github pthom / imgui_datascience / imgui_datascience / imgui_cv.py View on Github external
texture_id = _image_to_texture(
        image_and_ajustments,
        always_refresh = always_refresh,
        linked_user_image_address=linked_user_image_address
        )
    if title == "":
        imgui.image_button(texture_id, viewport_size.width, viewport_size.height, frame_padding=0)
        is_mouse_hovering = imgui.is_item_hovered()
    else:
        imgui.begin_group()
        imgui.image_button(texture_id, viewport_size.width, viewport_size.height, frame_padding=0)
        is_mouse_hovering = imgui.is_item_hovered()
        imgui.text(title)
        imgui.end_group()

    if is_mouse_hovering and imgui.get_io().mouse_down[0]:
        last_time = statics.zoom_click_times[zoom_key]
        now = timer()
        if now - last_time > 0.3:
            statics.zoomed_status[zoom_key] = not statics.zoomed_status[zoom_key]
            statics.zoom_click_times[zoom_key] = now

    return mouse_position_last_image()
github pthom / imgui_datascience / imgui_datascience / imgui_image_lister.py View on Github external
def actual_window_startup_size(self):
        if self.max_size:
            display_size = imgui.get_io().display_size
            return imgui.Vec2(display_size.x - 40, display_size.y - 20)
        else:
            return self.window_size
github swistakm / pyimgui / imgui / impl / _sdl2.py View on Github external
def process_inputs(self):
        io = imgui.get_io()

        s_w = ctypes.pointer(ctypes.c_int(0))
        s_h = ctypes.pointer(ctypes.c_int(0))
        SDL_GetWindowSize(self.window, s_w, s_h)
        w = s_w.contents.value
        h = s_h.contents.value

        io.display_size = w, h
        io.display_fb_scale = 1, 1

        current_time = SDL_GetTicks() / 1000.0

        if self._gui_time:
            self.io.delta_time = current_time - self._gui_time
        else:
            self.io.delta_time = 1. / 60.
github swistakm / pyimgui / doc / source / gen_example.py View on Github external
# -*- coding: utf-8 -*-
from inspect import cleandoc
import os

import glfw
import OpenGL.GL as gl
from PIL import Image

import imgui
from imgui.impl import GlfwImpl


io = imgui.get_io()


new_frame = imgui.new_frame

mouse_pos = (-1, -1)
mouse_down = 0


def _clear_mouse():
    global mouse_pos
    global mouse_down

    mouse_pos = (-1, -1)
    mouse_down = 0
github pthom / imgui_datascience / imgui_datascience / imgui_ext.py View on Github external
def _load_one_font(font_size, font_file="source-sans-pro.regular.ttf"):
    io = imgui.get_io()
    font_full_path = ""
    font_dirs = [this_script_dir, "./", "./fonts/"]
    for font_dir in font_dirs:
        if os.path.exists(font_dir + "/" + font_file):
            font_full_path = font_dir + "/" + font_file

    if len(font_full_path) == 0:
        raise RuntimeError("Could not find font file")
    font = io.fonts.add_font_from_file_ttf(font_full_path, font_size)
    return font
github swistakm / pyimgui / imgui / integrations / cocos2d.py View on Github external
def __init__(self):
        super(ImguiLayer, self).__init__()

        self.renderer = None
        self.io = imgui.get_io()

        self._map_keys()