def render_timeline(self): imgui.begin("timeline") tstamp = self.frame['tstamp'] if imgui.button("<"): self.playing = False if self.i > 0: self.loadframe(self.i - 1) imgui.same_line() if self.playing: if (self.i == self.scanner.num_frames()-1) or imgui.button("stop"): self.playing = False elif time.time() >= self.ts[self.i+1] - self.t0: self.nextframe() elif imgui.button("play"): self.playing = True self.t0 = tstamp - time.time() imgui.same_line() if imgui.button(">"): self.playing = False self.nextframe() tsfrac = tstamp - int(tstamp) tstring = time.strftime("%H:%M:%S.", time.localtime( tstamp)) + "%02d" % (tsfrac*100) imgui.same_line() imgui.text(tstring) w = imgui.get_window_width() if self.show_frontview: imgui.image(self.fronttexid, w, w/2) # 2:1 aspect for front view else: # 4:3 aspect imgui.image(self.frametexid, w, 3*w/4) if self.acts is not None: imgui.plot_lines("activations", self.acts) nCtrlAngles = (len(self.controlstate[self.i]) - 12) // 3 cc = self.controlstate[self.i][-nCtrlAngles:] imgui.plot_lines( "control costs", np.clip(cc, 0, 100)) # make a histogram of expected cone locations if self.acts is not None: hist = np.zeros(len(self.acts)*2, np.float32) np.add.at(hist, self.frame['c0'], 1) np.add.at(hist, self.frame['c1'], -1) hist = np.cumsum(hist) hist = hist[:len(self.acts)] + hist[-len(self.acts):] imgui.plot_lines("expected cone locations", hist) changed, i = imgui.slider_int( "frame", self.i, 0, self.scanner.num_frames()-1) if changed: self.playing = False self.loadframe(i) imgui.end()
def draw(self): imgui.begin("Example: drag float") changed, self.value = imgui.drag_float( "Default", self.value, ) changed, self.value = imgui.drag_float("Less precise", self.value, format="%.1f") imgui.text("Changed: %s, Value: %s" % (changed, self.value)) imgui.end()
def draw(self): imgui.begin("Scope") self.begin_input(self.input) imgui.button('input') self.end_input() imgui.same_line(spacing=16) imgui.plot_lines("Sin(t)", np.array(self.values).astype(np.float32), graph_size=imgui.get_content_region_available()) imgui.end()
def main(): pygame.init() size = 800, 600 pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE) imgui.create_context() impl = PygameRenderer() io = imgui.get_io() io.display_size = size while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() impl.process_event(event) imgui.new_frame() 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.same_line() imgui.text_colored("Eggs", 0.2, 1., 0.) #imgui.same_line() imgui.bullet_text("bullet_text") # 不换行 #imgui.same_line() imgui.end() # note: cannot use screen.fill((1, 1, 1)) because pygame's screen # does not support fill() on OpenGL sufraces gl.glClearColor(1, 1, 1, 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() impl.render(imgui.get_draw_data()) pygame.display.flip()
def draw(self): style = imgui.get_style() imgui.begin("Colors") imgui.columns(4) for color in range(0, imgui.COLOR_COUNT): imgui.text("Color: {}".format(color)) imgui.color_button("color#{}".format(color), *style.colors[color]) imgui.next_column() imgui.end()
def draw(self): imgui.begin("Example: tooltip") imgui.button("Click me!") if imgui.is_item_hovered(): imgui.begin_tooltip() imgui.text("This button is clickable.") imgui.text("This button has full window tooltip.") texture_id = imgui.get_io().fonts.texture_id imgui.image(texture_id, 512, 64, border_color=(1, 0, 0, 1)) imgui.end_tooltip() imgui.end()
def draw(self): imgui.begin("Example: dummy elements") imgui.text("Some text with bullets:") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet B") imgui.dummy(0, 50) imgui.bullet_text("Text after dummy") imgui.end()
def draw(self): imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.float_val = imgui.input_float('Type coefficient:', self.float_val) imgui.text('You wrote: %f' % self.float_val) imgui.end() arcade.draw_text(str(self.float_val), 512, 128, arcade.color.WHITE_SMOKE, 64)
def draw(self): import ast module = ast.parse(""" |def add(a: float, b: float) -> float: | return a + b |""".replace(' |', '')) imgui.begin("Module", True) fun = module.body[0] self.function(fun) imgui.end()
def draw(self): imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.test_input = imgui.input_int("Integer Input Test", self.test_input) imgui.end() arcade.draw_text(str(self.test_input), 512, 128, arcade.color.WHITE_SMOKE, 64)
def render_ui(self): # Test window imgui.new_frame() imgui.begin("Custom window", True) imgui.text("Bar") imgui.text_colored("Eggs", 0.2, 1., 0.) imgui.end() # Render imgui.render() self.imgui.render(imgui.get_draw_data())
def draw(self): imgui.begin("Poly Line Overlay") draw_list = imgui.get_overlay_draw_list() draw_list.add_polyline([(20, 35), (90, 35), (55, 80)], imgui.get_color_u32_rgba(1, 1, 0, 1), closed=False, thickness=3) draw_list.add_polyline([(110, 35), (180, 35), (145, 80)], imgui.get_color_u32_rgba(1, 0, 0, 1), closed=True, thickness=3) 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 draw(self): imgui.begin("Test Window") imgui.text("This is the test window.") changed, self.double_val = imgui.input_double('Type multiplier:', self.double_val) imgui.text('You wrote: %d' % self.double_val) imgui.end() arcade.draw_text(str(self.double_val), 512, 128, arcade.color.WHITE_SMOKE, 64)
def render_ui(self): imgui.new_frame() imgui.begin("camera") is_change_y, self.u_campos.y = imgui.slider_float( "y", self.u_campos.y, -3.14159 * 4.0, 3.14159 * 4.0) if is_change_y: self.uniform("u_campos", self.u_campos) imgui.end() imgui.render() self.imgui.render(imgui.get_draw_data())
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): flags = imgui.WINDOW_MENU_BAR imgui.begin("Child Window - File Browser", flags=flags) if imgui.begin_menu_bar(): if imgui.begin_menu('File'): imgui.menu_item('Close') imgui.end_menu() imgui.end_menu_bar() imgui.end()
def draw(self): imgui.begin("Example: item indenting") imgui.text("Some text with bullets:") imgui.bullet_text("Bullet A") imgui.indent() imgui.bullet_text("Bullet B (first indented)") imgui.bullet_text("Bullet C (indent continues)") imgui.unindent() imgui.bullet_text("Bullet D (indent cleared)") imgui.end()
def draw(self): imgui.begin("Spark") self.begin_input(self.input) imgui.button('input') self.end_input() if imgui.button("Run"): self.reset() imgui.end() self.emitter.draw()
def main(): pygame.init() clock = pygame.time.Clock() size = 640, 480 pygame.display.set_mode(size, pygame.HWSURFACE | 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): clicked_quit, selected_quit = imgui.menu_item( "Quit", 'Cmd+Q', False, True ) if clicked_quit: pygame.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() # note: cannot use screen.fill((1, 1, 1)) because pygame's screen # does not support fill() on OpenGL sufraces gl.glClearColor(1, 1, 1, 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() pygame.display.flip() clock.tick(60)
def draw(self): imgui.begin(self.title) imgui.text("Some text with bullets") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet A") imgui.separator() imgui.text("Another text with bullets") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet A") imgui.end()
def draw(self): imgui.begin('My Wallet') imgui.text('total balance: %.2f' % self.wallet.balance()) for symbol, info in self.wallet.assets.items(): imgui.text('%.2f%%' % self.wallet.allocation_pct(symbol)) imgui.same_line() imgui.text(symbol) imgui.same_line() imgui.text(str(info['mean_price'])) imgui.same_line() imgui.text(str(info['amount'])) imgui.same_line() imgui.text(str(info['balance'])) imgui.end()
def on_frame(): 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()
def draw_imgui(scene: Scene): if Settings.GuiEnabled: # Menu Bar if imgui.begin_main_menu_bar(): if imgui.begin_menu("File"): imgui.menu_item("Open") if imgui.menu_item("Exit")[0]: glfw.terminate() imgui.end_menu() if imgui.begin_menu("View"): if imgui.menu_item("Grid", shortcut='G', selected=Settings.GridEnabled)[0]: Settings.GridEnabled = not Settings.GridEnabled if imgui.menu_item("GUI", shortcut='TAB', selected=Settings.GuiEnabled)[0]: Settings.GuiEnabled = not Settings.GuiEnabled if imgui.menu_item("Stats", shortcut='P', selected=Settings.StatsEnabled)[0]: Settings.StatsEnabled = not Settings.StatsEnabled imgui.end_menu() if Settings.StatsEnabled: imgui.same_line(imgui.get_window_width() - 150) imgui.text("FPS: " + "%.2f" % Global.fps + " " + "%.2f" % Global.frametime + "ms") imgui.end_main_menu_bar() # imgui.show_demo_window() # Scene imgui.begin("Scene") draw_node_item(scene.nodelist[0], scene) imgui.end() imgui.begin("Properties") imgui.text("Model") imgui.end() else: pass
def draw(self): 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()
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())
def draw(self): width = 20 height = 100 imgui.begin(self.title) changed, self.value = imgui.v_slider_int("vertical slider int", width, height, self.value, min_value=0, max_value=100, format="%d") imgui.text("Changed: %s, Values: %s" % (changed, self.value)) imgui.end()
def main(): window = impl_glfw_init() impl = GlfwRenderer(window) box1 = box2 = box3 = True while not glfw.window_should_close(window): glfw.poll_events() impl.process_inputs() imgui.new_frame() 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.begin("Scope Test") box1 = imgui.checkbox("Checkbox", box1)[1] with imgui.scope(2): imgui.new_line() imgui.text("Same name, different scope:") box2 = imgui.checkbox("Checkbox", box2)[1] imgui.new_line() imgui.text("Same name, same scope:") imgui.text("(This will not work right)") box3 = imgui.checkbox("Checkbox", box3)[1] imgui.end() gl.glClearColor(1., 1., 1., 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() glfw.swap_buffers(window) impl.shutdown() imgui.shutdown() glfw.terminate()
def on_mod(self, im): ''' 进行具体的应用逻辑绘制处理:im为imgui环境对象;返回值告知程序是否继续. 此方法应该被子类重载,完成具体的功能逻辑 ''' # 判断是否有ctrl+Q按下,结束app if im.is_key_down('ctrl+Q'): return False if not self._on_menu(): return False style = imgui.get_style() imgui.begin("Color window") imgui.columns(4) for color in range(0, imgui.COLOR_COUNT): imgui.text("Color: {} {}".format( color, imgui.get_style_color_name(color))) imgui.color_button("color#{}".format(color), *style.colors[color]) imgui.next_column() imgui.end() # 获取当前主窗口尺寸 win_width, win_height = im.main_win.get_size() # 定义菜单条高度 bar_height = 24 # 计算横向比例分隔 widths, hpos = split(win_width, (5, 15, 30)) # 计算左侧竖向比例分隔 heights, vpos = split(win_height - bar_height, (10, 30)) # 左侧列表 self.do_show_text('样本列表', hpos[0], bar_height, widths[0], win_height - bar_height, 'list') # 左上窗口 self.do_show_text('差异处', hpos[1], bar_height + vpos[0], widths[1], heights[0], 'tmp_text') # 左下窗口 self.do_show_text('新结果', hpos[1], bar_height + vpos[1], widths[1], heights[1], '测试123456') # 重新计算右侧竖向比例分隔 heights, vpos = split(win_height - bar_height, (30, 30)) # 右上窗口 self.do_show_text('原文本', hpos[2], bar_height + vpos[0], widths[2], heights[0], '测试1234') # 右下窗口 self.do_show_text('预处理', hpos[2], bar_height + vpos[1], widths[2], heights[1], '测试1234') #imgui.show_demo_window() return True
def main(): pygame.init() size = 800, 600 pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL) pygame.display.set_caption("GBDev tool window") 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("Menu", True): open_gbtd, selected_none = imgui.menu_item("Open GBTD", None, False, True) open_gbtk, selected_none = imgui.menu_item("Open GBTK", None, False, True) export_json, selected_none = imgui.menu_item("Export Default Json", None, False, True) clicked_quit, selected_quit = imgui.menu_item("Quit", 'Cmd+Q', False, True) if clicked_quit: exit(1) if open_gbtd: os.system("wine tools/GBTD/GBTD.EXE &") if open_gbtk: os.system("wine tools/GBTK.exe &") if export_json: tools.json2c.default_use() imgui.end_menu() imgui.end_main_menu_bar() imgui.begin("Data", True) img_path = "data/img" onlyfiles = [f for f in listdir(img_path) if isfile(join(img_path, f))] #print(onlyfiles) for file in onlyfiles: imgui_image_menu(img_path+"/"+file) imgui.end() imgui.begin("Images", True) imgs_id = [] for img_filename in onlyfiles: if img_filename.split(".")[-1] == "png": imgs_id.append((img_path+"/"+img_filename, img_manager.load_image(img_path+"/"+img_filename))) for img in imgs_id: img_size = img_manager.get_image_size(img[0]) if img[1] is not 0 and img_size is not (): imgui.image(img[1], img_size[0]*2, img_size[1]*2, (0,1), (1,0)) imgui.same_line() imgui.end() # note: cannot use screen.fill((1, 1, 1)) because pygame's screen # does not support fill() on OpenGL sufraces gl.glClearColor(1, 1, 1, 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() pygame.display.flip()
import imgui def my_render_function(): print 'foo' io = imgui.get_io() io.display_size = 1920.0, 1280.0 io.render_draw_lists_fn = my_render_function io.fonts.add_font_default() io.fonts.get_tex_data_as_rgba32() ## Application main loop while True: io = imgui.get_io(); io.delta_time = 1.0/60.0; print 'Render' imgui.new_frame() imgui.begin("My window") imgui.text("Hello, world.") imgui.end() imgui.render() print '...done' #io.mouse_pos = mouse_pos; #io.mouse_down[0] = mouse_button_0; # io.KeysDown[i] = ... # #
def onDrawGuiCallback(self, *args, **kw): if self.window_visable: try: if imgui.begin('AutoLoot {0} - {1}##Entity_mainwindow'.format(autoloot.__version__, autoloot.__author__), (600,350)): # button bar if imgui.checkbox('Enable Auto-Loot', self.enabled_auto_loot): self.enabled_auto_loot = not self.enabled_auto_loot if imgui.collapsingHeader('Available Loot ({0} items)'.format(len(self.bot.items))): imgui.columns(4) for item in self.bot.items: if not item: continue imgui.text(item.roleName) imgui.nextColumn() if item.__module__ == 'DroppedItem': try: imgui.text('Lootable' if item._checkPickItem(self.bot.p) else 'Not Lootable') except AttributeError: imgui.text('Not _checkPickItem') else: imgui.text('Openable?') imgui.nextColumn() imgui.text('{0}'.format(self.bot.p.position.distTo(item.position))) imgui.nextColumn() if imgui.button('Go To {0}##NavToEntity'.format(item.__module__)): nav.moveToEntityPathFind(item) imgui.nextColumn() imgui.separator() imgui.columns(1) if imgui.collapsingHeader('Debug All Entities'): for entity_name, entities in sorted(self.bot.entities.iteritems()): for entity in entities: imgui.columns(5) imgui.separator() imgui.text('{0}'.format(entity_name)) imgui.nextColumn() imgui.text('{0}'.format(entity.id)) imgui.nextColumn() if entity_name == 'DroppedItem' and hasattr(entity, '_checkPickItem') and entity._checkPickItem(self.bot.p): imgui.text('{0}'.format('Lootable')) elif not entity_name == 'DroppedItem': imgui.text('No Data Available') else: imgui.text('Not your Loot!') imgui.nextColumn() if entity and hasattr(entity, 'position') and self.bot.p and hasattr(self.bot.p, 'position'): imgui.text('{0}'.format(self.bot.p.position.distTo(entity.position))) else: imgui.text('No Position Information') imgui.nextColumn() if imgui.button('NavToEntity##NavToEntity'): nav.moveToEntityPathFind(entity) imgui.nextColumn() imgui.columns(1) imgui.end() except Exception: import traceback for line in traceback.format_exc().splitlines(): roplus.log(line) self.window_visable = False