def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: checkboxes for flags", flags=self.flags) clicked, self.flags = imgui.checkbox_flags( "No resize", self.flags, imgui.WINDOW_NO_RESIZE ) clicked, self.flags = imgui.checkbox_flags( "No move", self.flags, imgui.WINDOW_NO_MOVE ) clicked, self.flags = imgui.checkbox_flags( "No collapse", self.flags, imgui.WINDOW_NO_COLLAPSE ) # note: it also allows to use multiple flags at once clicked, self.flags = imgui.checkbox_flags( "No resize & no move", self.flags, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE ) imgui.text("Current flags value: {0:b}".format(self.flags)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: checkboxes") # note: first element of return two-tuple notifies if there was a click # event in currently processed frame and second element is actual # checkbox state. _, self.checkbox1_enabled = imgui.checkbox("Checkbox 1", self.checkbox1_enabled) _, self.checkbox2_enabled = imgui.checkbox("Checkbox 2", self.checkbox2_enabled) imgui.text("Checkbox 1 state value: {}".format(self.checkbox1_enabled)) imgui.text("Checkbox 2 state value: {}".format(self.checkbox2_enabled)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def update(self): self.window_size = pygame.display.get_surface().get_size() if self.use_base_window: imgui.set_next_window_position(0, 0) imgui.set_next_window_size(self.window_size[0], self.window_size[1]) imgui.begin("main", False, self.base_window_flags) if self.use_menu_bar and imgui.begin_menu_bar(): self.draw_menu() imgui.end_menu_bar() self.draw_base_window() imgui.end() else: if self.use_menu_bar and imgui.begin_main_menu_bar(): self.draw_menu() imgui.end_main_menu_bar() self.draw_windows() if self.show_style_window: self.show_style_window = imgui.begin("Style Editor", True)[1] imgui.show_style_editor() imgui.end() if self.show_demo_window: self.show_demo_window = imgui.show_demo_window(True)
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(256, 256, imgui.ONCE) imgui.begin("Circle") draw_list = imgui.get_window_draw_list() draw_list.add_circle(100, 60, 30, imgui.get_color_u32_rgba(1, 1, 0, 1), thickness=3) imgui.end() imgui.set_next_window_position(270, 32, imgui.ONCE) imgui.set_next_window_size(256, 256, imgui.ONCE) imgui.begin("Filled Circle") draw_list = imgui.get_window_draw_list() draw_list.add_circle_filled(100, 60, 30, imgui.get_color_u32_rgba(1, 1, 0, 1)) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) if imgui.begin_main_menu_bar(): # first menu dropdown if imgui.begin_menu('File', True): imgui.menu_item('New', 'Ctrl+N', False, True) imgui.menu_item('Open ...', 'Ctrl+O', False, True) # submenu if imgui.begin_menu('Open Recent', True): imgui.menu_item('doc.txt', None, False, True) imgui.end_menu() imgui.end_menu() imgui.end_main_menu_bar() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def draw_console(): global _console_text_temp if console.SHOW_CONSOLE: imgui.set_next_window_bg_alpha(0.35) imgui.set_next_window_position(0, 0) imgui.set_next_window_size(screen_utils.WIDTH, 110) imgui.begin( "ConsoleWindow", False, imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_SAVED_SETTINGS) imgui.begin_child("ConsoleOutput", 0, -25, False) for text, color in console.text_buffer: if color is None: color = (0.25, 0.75, 1) imgui.text_colored(text, color[0], color[1], color[2], 0.8) imgui.text("") imgui.set_scroll_y(imgui.get_scroll_max_y()) imgui.end_child() buf_size = 256 if len(_console_text_temp) > 0 and not _console_text_temp[0] == "/": buf_size = 64 enter, text = imgui.input_text("Input", _console_text_temp, buf_size, imgui.INPUT_TEXT_ENTER_RETURNS_TRUE) if enter: if str.startswith(text, "/"): text = str.replace(text, "/", "", 1) console.handle_input(text) else: client_net.send_message(text) text = "" _console_text_temp = text imgui.end()
def render_callback(self, time: float, frametime: float): if imgui.begin_main_menu_bar(): if imgui.begin_menu("File", True): clicked_quit, selected_quit = imgui.menu_item( "Quit", 'Cmd+Q', False, True ) if clicked_quit: exit(1) imgui.end_menu() changed, value = imgui.input_text("", self.input_text, 30) if changed: imgui.set_next_window_position(imgui.get_item_rect_min().x, imgui.get_item_rect_max().y) imgui.set_next_window_size(imgui.get_item_rect_size().x, 0) if imgui.begin("##popup", False, imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE): for index, row in symbol_list.iterrows(): if value.upper() in row[0]: opened, selected = imgui.selectable(row[0] + " - " + row[2]) if imgui.is_item_clicked(): input_text = row[0] selected_symbol = row[0] imgui.end() if imgui.button("download"): yfc.download(self.selected_symbol, symbol_data_file()) imgui.end_main_menu_bar() pass
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) if imgui.begin_main_menu_bar(): if imgui.begin_menu("File", True): clicked_quit, selected_quit = imgui.menu_item( "Quit", 'Cmd+Q', False, True) if clicked_quit: exit(1) imgui.end_menu() imgui.end_main_menu_bar() imgui.show_test_window() imgui.begin("Custom window", True) imgui.text("Bar") imgui.text_colored("Eggs", 0.2, 1., 0.) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def draw_timeseries_window(self, width, height): imgui.set_next_window_size(width / 10, height) imgui.set_next_window_position(0, 0) imgui.begin("Time Series", flags=default_flags) graph_size = [width / 11, height / 7.5] self.summary.draw_plots(self.simulator.time, graph_size) imgui.end()
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: item groups") imgui.begin_group() imgui.text("First group (buttons):") imgui.button("Button A") imgui.button("Button B") imgui.end_group() imgui.same_line(spacing=50) imgui.begin_group() imgui.text("Second group (text and bullet texts):") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet B") imgui.end_group() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: color edit with alpha") # note: first element of return two-tuple notifies if the color was changed # in currently processed frame and second element is current value # of color and alpha _, self.color = imgui.color_edit4("Alpha", *self.color, show_alpha=True) _, self.color = imgui.color_edit4("No alpha", *self.color, show_alpha=False) imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def __enter__(self): glClearColor(0, 1, 0, 0) while not glfw.window_should_close(self.window): cur_time = glfw.get_time() elapsed = cur_time - self.prev_time self.prev_time = cur_time glfw.poll_events() self.impl.process_inputs() self._process(elapsed) imgui.new_frame() imgui.set_next_window_position(0, 0) imgui.set_next_window_size(280, 180) imgui.begin("Uniforms", False, imgui.WINDOW_NO_RESIZE) imgui.push_item_width(-45) for cont in self.program.controls: cont.update() imgui.end() glClear(GL_COLOR_BUFFER_BIT) self._draw() imgui.render() self.impl.render(imgui.get_draw_data()) glfw.swap_buffers(self.window)
def window(title: str, widget: Widget, position: Tuple[int, int] = None, size: Tuple[int, int] = None, flags: int = 0) -> Widget: """ Create a window with a given `widget` inside. Contents are drawn only if the window is opened. * **Window title must be unique.** Contents of windows with an identical title will appear inside a single window. * **Windows must not be nested.** Nested windows may lead to visibility feedback loops, which manifests as flicker on some docking operations. """ while True: if position is not None: imgui.set_next_window_position(*position) if size is not None: imgui.set_next_window_size(*size) else: imgui.set_next_window_size(400, 300, imgui.FIRST_USE_EVER) expanded, opened = imgui.begin(title, flags=flags) try: if expanded and opened: next(widget) except StopIteration as e: return e.value finally: imgui.end() yield
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: drag and drop") imgui.button('source') if imgui.begin_drag_drop_source(): imgui.set_drag_drop_payload('itemtype', b'payload') imgui.button('dragged source') imgui.end_drag_drop_source() imgui.button('dest') if imgui.begin_drag_drop_target(): payload = imgui.accept_drag_drop_payload('itemtype') if payload is not None: print('Received:', payload) imgui.end_drag_drop_target() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def show_togglable_window(window_param, window_function_code): global _ALL_TOGGLABLE_STATUS if window_param.window_title not in _ALL_TOGGLABLE_STATUS: _ALL_TOGGLABLE_STATUS[ window_param.window_title] = window_param.initialShow this_window_open_status = _ALL_TOGGLABLE_STATUS[window_param.window_title] if this_window_open_status: toggle_button_legend = "Hide " + window_param.window_title else: toggle_button_legend = "Show " + window_param.window_title if imgui.button(make_unique_label(toggle_button_legend)): this_window_open_status = not this_window_open_status if this_window_open_status: imgui.set_next_window_size(window_param.size[0], window_param.size[1]) if window_param.include_begin_code: imgui.begin(window_param.window_title) window_function_code() if window_param.include_begin_code: imgui.end()
def render_new_drawing_popup(window): "Settings for creating a new drawing." if window._new_drawing: imgui.open_popup("New drawing") w, h = window.get_size() imgui.set_next_window_size(200, 120) imgui.set_next_window_position(w // 2 - 100, h // 2 - 60) if imgui.begin_popup_modal("New drawing")[0]: imgui.text("Creating a new drawing.") imgui.separator() changed, new_size = imgui.drag_int3("Shape", *window._new_drawing["shape"], min_value=1, max_value=2048) if changed: window._new_drawing["shape"] = new_size if imgui.button("OK"): window.really_create_drawing() imgui.close_current_popup() imgui.same_line() if imgui.button("Cancel"): window._new_drawing = None imgui.close_current_popup() imgui.end_popup()
def render_unsaved_exit(window): "Popup to prevent exiting the application with unsaved work." if window.exit_unsaved_drawings: imgui.open_popup("Really exit?") imgui.set_next_window_size(500, 200) if imgui.begin_popup_modal("Really exit?")[0]: imgui.text("You have unsaved work in these drawing(s):") imgui.begin_child("unsaved", border=True, height=imgui.get_content_region_available()[1] - 26) for drawing in window.exit_unsaved_drawings: imgui.text(drawing.filename) if imgui.is_item_hovered(): pass # TODO popup thumbnail of the picture? imgui.end_child() if imgui.button("Yes, exit anyway"): imgui.close_current_popup() pyglet.app.exit() imgui.same_line() if imgui.button("Yes, but save first"): for drawing in window.exit_unsaved_drawings: window.save_drawing(drawing) pyglet.app.exit() imgui.same_line() if imgui.button("No, cancel"): window.exit_unsaved_drawings = None imgui.close_current_popup() imgui.end_popup()
def menu_bar(self): if imgui.begin_main_menu_bar(): if imgui.begin_menu("File", True): clicked_quit, selected_quit = imgui.menu_item( "Quit", 'Cmd+Q', False, True) if clicked_quit: self.cleanup() exit(0) imgui.end_menu() changed, value = imgui.input_text("", self.input_text, 30) if changed: imgui.set_next_window_position(imgui.get_item_rect_min().x, imgui.get_item_rect_max().y) imgui.set_next_window_size(imgui.get_item_rect_size().x, 0) if imgui.begin( "##popup", False, imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE): for index, row in self.symbol_list.iterrows(): if value.upper() in row[0]: _, _ = imgui.selectable(row[0] + " - " + row[2]) if imgui.is_item_clicked(): self.input_text = row[0] self.load_symbol(str(row[0]).lower()) imgui.end() imgui.end_main_menu_bar()
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: simple popup modal") if imgui.button("Open Modal popup"): imgui.open_popup("select-popup") imgui.same_line() if imgui.begin_popup_modal("select-popup")[0]: imgui.text("Select an option:") imgui.separator() imgui.selectable("One") imgui.selectable("Two") imgui.selectable("Three") imgui.end_popup() imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def show_main_menu(): global text, ip_text style: GuiStyle = imgui.get_style() style.window_border_size = 0 style.colors[imgui.COLOR_BUTTON] = Vec4(0.26, 0.59, 0.5, 0.4) style.colors[imgui.COLOR_BUTTON_ACTIVE] = Vec4(0.06, 0.53, 0.4, 1.0) style.colors[imgui.COLOR_BUTTON_HOVERED] = Vec4(0.26, 0.59, 0.5, 1.0) imgui.set_next_window_bg_alpha(0) imgui.set_next_window_position(300, 220) imgui.set_next_window_size(180, 200) imgui.begin("tremor0", False, imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_ALWAYS_USE_WINDOW_PADDING) _, username = imgui.input_text("Name", text, 16) _, ip = imgui.input_text("Host", ip_text, 32) ip_text = ip text = username imgui.end() imgui.set_next_window_bg_alpha(0) imgui.set_next_window_size(100, 100) imgui.set_next_window_position(200, 200) imgui.begin("tremor1", False, imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_ALWAYS_USE_WINDOW_PADDING) imgui.text_colored("Tremor", 0.9, 0.6, 1.0) play_clicked = imgui.button("Play", 82, 25) exit_clicked = imgui.button("Exit", 82, 25) if exit_clicked: graphics_subsystem.request_close() if play_clicked: print(username) client_net.connect_to_server((ip, 27070), username) imgui.end()
def main(): renderer = NXRenderer() currentDir = os.getcwd() while True: renderer.handleinputs() imgui.new_frame() width, height = renderer.io.display_size imgui.set_next_window_size(width, height) imgui.set_next_window_position(0, 0) imgui.begin("", flags=imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_SAVED_SETTINGS) imgui.text("Welcome to PyNX!") imgui.text("Touch is supported") imgui.text("Current dir: " + os.getcwd()) if os.getcwd() != "sdmc:/": imgui.push_style_color(imgui.COLOR_BUTTON, *FOLDER_COLOR) if imgui.button("../", width=200, height=60): os.chdir("..") imgui.pop_style_color(1) dirs = [] files = [] for e in os.listdir(): if os.path.isdir(e): dirs.append(e) else: files.append(e) 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() imgui.render() renderer.render() renderer.shutdown()
def update(self, data): if data.any(): if self.photo is None: # start new thing self.photo = data.photo self.l_button = data.buttons[:, 0] self.r_button = data.buttons[:, 1] self.l_force = data.forces[:, 0] self.r_force = data.forces[:, 1] elif max(self.photo.shape) < 1000: self.photo = np.hstack((self.photo, data.photo)) self.l_button = np.hstack((self.l_button, data.buttons[:, 0])) self.r_button = np.hstack((self.r_button, data.buttons[:, 1])) self.l_force = np.hstack((self.l_force, data.forces[:, 0])) self.r_force = np.hstack((self.r_force, data.forces[:, 1])) else: shp = -data.photo.shape[0] self.photo = np.roll(self.photo, shp) self.l_button = np.roll(self.l_button, shp) self.r_button = np.roll(self.r_button, shp) self.l_force = np.roll(self.l_force, shp) self.r_force = np.roll(self.r_force, shp) self.photo[shp:] = data.photo self.l_button[shp:] = data.buttons[:, 0] self.r_button[shp:] = data.buttons[:, 1] self.l_force[shp:] = data.forces[:, 0] self.r_force[shp:] = data.forces[:, 1] imgui.set_next_window_size(270, 600) imgui.begin('plot', False, self.flags) imgui.plot_lines('Photo', self.photo.astype('f') / 2**10, scale_min=0, scale_max=1, graph_size=(180, 100)) imgui.plot_lines('l_force', self.l_force.astype('f') / 2**12, scale_min=0, scale_max=1, graph_size=(180, 100)) imgui.plot_lines('r_force', self.r_force.astype('f') / 2**12, scale_min=0, scale_max=1, graph_size=(180, 100)) style = imgui.get_style() imgui.plot_lines('l_button', smooth(self.l_button.astype('f')) * 6, scale_min=-1.1, scale_max=1.1, graph_size=(180, 100)) imgui.plot_lines('r_button', smooth(self.r_button.astype('f')) * 6, scale_min=-1.1, scale_max=1.1, graph_size=(180, 100)) imgui.end()
def _render_gui(self): w, h = self.get_size() imgui.new_frame() if self.stroke_tool and self.stroke_tool.show_rect: if self.stroke_tool.rect: rect = self.stroke_tool.rect p0 = self._to_window_coords(*rect.topleft) p1 = self._to_window_coords(*rect.bottomright) ui.render_selection_rectangle(self, p0, p1) with imgui.font(self._font): ui.render_menu(self) if self.drawing: imgui.set_next_window_size(115, h - 20) imgui.set_next_window_position(w - 115, 20) imgui.begin("Sidebar", False, flags=(imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE)) ui.render_tools(self.tools, self.icons) imgui.separator() ui.render_palette(self.drawing) imgui.separator() ui.render_layers(self.view) imgui.end() ui.render_unsaved_exit(self) ui.render_unsaved_close_drawing(self) render_plugins_ui(self.drawing) ui.render_new_drawing_popup(self) if self._error: imgui.open_popup("Error") if imgui.begin_popup_modal("Error")[0]: imgui.text(self._error) if imgui.button("Doh!"): self._error = None imgui.close_current_popup() imgui.end_popup() imgui.render() imgui.end_frame() data = imgui.get_draw_data() self.imgui_renderer.render(data)
def draw(self): imgui.set_next_window_position(self.window.width - 288, 32, imgui.ONCE) imgui.set_next_window_size(256, 256, imgui.ONCE) imgui.begin("Sparks") if imgui.button("Run"): self.reset() imgui.end() self.emitter.draw()
def draw_platform_window(self, width, height): imgui.set_next_window_size(width / 6, height / 4) imgui.set_next_window_position(width * 5 / 6, 0) imgui.begin("Information", flags=default_flags) imgui.text(f"Platform:\n\t{self.platform}") imgui.text(f"Device: \n\t{self.device}") imgui.text(f"Snapshot:\n\t{self.snapshots[self.current_snapshot]}") imgui.text(f"Day:\n\t{self.simulator.time}") imgui.end()
def show(self, value, read_only): clicked, self.show_texture = imgui.checkbox("Show", self.show_texture) if not self.show_texture: return texture = value.value if texture is None: self.texture_aspect = None else: h, w, _ = texture.shape self.texture_aspect = w / h cursor_pos = imgui.get_cursor_screen_pos() imgui.set_next_window_size(500, 500, imgui.ONCE) imgui.set_next_window_size_constraints((0.0, 0.0), (float("inf"), float("inf")), self.window_size_callback) imgui.set_next_window_position(*imgui.get_io().mouse_pos, imgui.ONCE, pivot_x=0.5, pivot_y=0.5) expanded, opened = imgui.begin( "Texture of %s###%s%s" % (self.node.spec.name, id(self.node), id(self)), True, imgui.WINDOW_NO_SCROLLBAR) if not opened: self.show_texture = False if expanded: if texture is None: imgui.text("No texture associated") else: # [::-1] reverses list texture_size = texture.shape[:2][::-1] texture_aspect = texture_size[0] / texture_size[1] window_size = imgui.get_content_region_available() imgui.image(texture._handle, window_size[0], window_size[0] / texture_aspect) if imgui.is_item_hovered() and imgui.is_mouse_clicked(1): # little hack to have first context menu entry under cursor io = imgui.get_io() pos = io.mouse_pos io.mouse_pos = pos[0] - 20, pos[1] - 20 imgui.open_popup("context") io.mouse_pos = pos if imgui.begin_popup("context"): if imgui.menu_item("save")[0]: util.image.save_screenshot(texture.get()) imgui.menu_item("texture handle: %s" % texture._handle, None, False, False) imgui.menu_item("texture dtype: %s" % str(texture.dtype), None, False, False) imgui.menu_item("texture shape: %s" % str(texture.shape), None, False, False) imgui.end_popup() imgui.end()
def update(self, curSceneGOs): imgui.set_next_window_position(self.position[0], self.position[1]) imgui.set_next_window_size(self.width, self.height) imgui.begin("Hierarchy") for obj in curSceneGOs: self.displayGameObjectOnHierarchy(obj) imgui.end() if self.curControlObject != None and isinstance( self.curControlObject, GameObject): self.inspector.displayInspector(self.curControlObject)
def run(gui_loop_function, params=Params()): if params.windowed_full_screen: os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % ( params.windowed_full_screen_x_margin / 2, params.window_title_height) pygame.init() pygame.display.set_caption(params.win_title) win_size = params.win_size if params.windowed_full_screen: info = pygame.display.Info() screen_size = (info.current_w - params.windowed_full_screen_x_margin, info.current_h) win_size = (screen_size[0], screen_size[1] - params.window_title_height - params.windows_taskbar_height) pygame.display.set_mode( win_size, pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE) imgui_ext._load_fonts() io = imgui.get_io() io.display_size = win_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 params.provide_default_window: imgui.set_next_window_position(0, 0) imgui.set_next_window_size(win_size[0], win_size[1]) imgui.begin("Default window") gui_loop_function() if params.provide_default_window: imgui.end() ImGuiImageLister._heartbeat() # note: cannot use screen.fill((1, 1, 1)) because pygame's screen # does not support fill() on OpenGL surfaces gl.glClearColor(1, 1, 1, 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() pygame.display.flip() imgui_cv._clear_all_cv_textures() imgui_ext.__clear_all_unique_labels()
def begin_maximized_window(name, glfw_window, menu_bar=False): imgui.set_next_window_position(0, 0) imgui.set_next_window_size(*glfw.get_window_size(glfw_window)) imgui.push_style_var(imgui.STYLE_WINDOW_ROUNDING, 0) imgui.push_style_var(imgui.STYLE_WINDOW_BORDERSIZE, 0) window_flags = imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_COLLAPSE | \ imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | \ imgui.WINDOW_NO_BRING_TO_FRONT_ON_FOCUS | imgui.WINDOW_NO_NAV_FOCUS | \ imgui.WINDOW_NO_DOCKING if menu_bar: window_flags |= imgui.WINDOW_MENU_BAR imgui.begin(name, True, window_flags) imgui.pop_style_var(2)
def draw(self): imgui.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: empty window") imgui.end() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())