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 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 ProgramInfoPopup(): with imgui.font(largefont): imgui.text("軟體資訊") imgui.separator() imgui.bullet_text("版本: 0.1 alpha") imgui.bullet_text("開發: PUF STUDIO") imgui.bullet_text("Email: [email protected]") imgui.bullet_text("Git Repo: https://github.com/even311379/PdfParserGUI")
def draw(self): 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()
def displayInspector(self, obj): imgui.set_next_window_position(self.position[0], self.position[1]) imgui.set_next_window_size(self.width, self.height) expanded, opened = imgui.begin("Inspector", True) if opened: imgui.begin_group() imgui.bullet_text(obj.name) transform_layer, visible = imgui.collapsing_header( "Transform", True) if transform_layer: HELPER.displayGameObjectTransformSetting(obj, imgui) imgui.end_group() for component in obj.components: HELPER.displayComponentSetting(imgui, component, obj) 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 render_inspector_value ( self, key, value ): if isinstance( value, int )\ or isinstance( value, bool )\ or isinstance( value, float )\ or isinstance( value, str )\ or isinstance( value, tuple )\ or isinstance( value, Fraction ) \ or value is None: imgui.bullet_text( f"{key}: {value}" ) elif isinstance( value, list ): if imgui.tree_node( f"{ key }: { value.__class__.__name__ }({ len( value ) } items)###{ id( value ) }", imgui.TREE_NODE_DEFAULT_OPEN ): i = 0; for obj in value: self.render_inspector_value( str( i ), obj ); i += 1 imgui.tree_pop() else: self.render_inspector( value, key )
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(self.title) imgui.text("Some text with bullets:") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet A") imgui.spacing() imgui.spacing() imgui.text("Another text with bullets:") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet A") 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.new_frame() imgui.set_next_window_position(16, 32, imgui.ONCE) imgui.set_next_window_size(512, 512, imgui.ONCE) imgui.begin("Example: bullet text") imgui.bullet_text("Bullet 1") imgui.bullet_text("Bullet 2") imgui.bullet_text("Bullet 3") 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: 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() 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: 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() imgui.end_frame() imgui.render() self.renderer.render(imgui.get_draw_data())
def render(): global selected_index, selected_file, clones_for_file, padding imgui.set_next_window_position(10, 10) imgui.set_next_window_size(280, 375) imgui.begin( "Clone Classes", False, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_MENU_BAR) if imgui.begin_menu_bar(): if imgui.begin_menu('Sort'): clicked, _ = imgui.menu_item('identifier (ascending)') if clicked: clones.sort(key=lambda x: x.class_identifier) clicked, _ = imgui.menu_item('identifier (descending)') if clicked: clones.sort(key=lambda x: x.class_identifier, reverse=True) clicked, _ = imgui.menu_item('clones (ascending)') if clicked: clones.sort(key=lambda x: x.num_clones) clicked, _ = imgui.menu_item('clones (descending)') if clicked: clones.sort(key=lambda x: x.num_clones, reverse=True) clicked, _ = imgui.menu_item('files (ascending)') if clicked: clones.sort(key=lambda x: len(x.files)) clicked, _ = imgui.menu_item('files (descending)') if clicked: clones.sort(key=lambda x: len(x.files), reverse=True) imgui.end_menu() imgui.end_menu_bar() for index, clone_class in enumerate(clones): if selected_index is clone_class.class_identifier: label = "--> Class {0:03d} ({1} files, {2} clones)".format( clone_class.class_identifier, len(clone_class.files), clone_class.num_clones) else: label = "Class {0:03d} ({1} files, {2} clones)".format( clone_class.class_identifier, len(clone_class.files), clone_class.num_clones) if imgui.button(label, width=260): select_clone(clone_class.class_identifier) imgui.end() imgui.set_next_window_position(10, 390) imgui.set_next_window_size(280, 380) imgui.begin( "Files", False, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_COLLAPSE) for index, file_name in enumerate(unique_file_name): if selected_file is file_name: label = "--> {}".format(os.path.basename(file_name)) else: label = "{}".format(os.path.basename(file_name)) if imgui.button(label, width=260): select_file(file_name) imgui.end() imgui.set_next_window_position(300, 10) imgui.set_next_window_size(890, 760) imgui.begin( "Details", False, imgui.WINDOW_NO_RESIZE | imgui.WINDOW_NO_MOVE | imgui.WINDOW_NO_COLLAPSE | imgui.WINDOW_HORIZONTAL_SCROLLING_BAR | imgui.WINDOW_MENU_BAR) if selected_file is not None and clones_for_file is not None: if imgui.begin_menu_bar(): if imgui.begin_menu('Actions'): clicked, _ = imgui.menu_item('Open in editor') if clicked: os.system("open \"{}\"".format(selected_file)) imgui.end_menu() imgui.end_menu_bar() file_buffer = file_buffers[selected_file] total_cloned_lines = 0 for _, file in clones_for_file: total_cloned_lines += file.num_cloned_lines imgui.begin_group() imgui.text("Information for this file") imgui.bullet_text("This file contains {} lines".format( file_buffer.max_line)) imgui.bullet_text("{} lines are cloned".format(total_cloned_lines)) imgui.bullet_text("That is {0:.2f}% of the total file".format( total_cloned_lines / file_buffer.max_line * 100)) imgui.end_group() imgui.same_line(300) imgui.push_item_width(200) imgui.begin_group() changed, value = imgui.slider_int("Lines of padding", padding, 0, 100) if changed: padding = value imgui.end_group() imgui.pop_item_width() imgui.spacing() imgui.spacing() imgui.spacing() imgui.spacing() for class_identifier, file in clones_for_file: expanded, visible = imgui.collapsing_header( "Clone class {0:03d}".format(class_identifier), None, imgui.TREE_NODE_DEFAULT_OPEN) if expanded: if imgui.button( "View all files for clone class {0:03d}".format( class_identifier)): select_clone(class_identifier) file_buffers[file.file_name].to_imgui(file, padding) if selected_index is not None: imgui.push_item_width(200) imgui.begin_group() changed, value = imgui.slider_int("Lines of padding", padding, 0, 100) if changed: padding = value imgui.end_group() imgui.pop_item_width() clone_class = None for clone in clones: if clone.class_identifier is selected_index: clone_class = clone for i, file in enumerate(clone_class.files): expanded, visible = imgui.collapsing_header( file.file_name, None, imgui.TREE_NODE_DEFAULT_OPEN) if expanded: if imgui.button("View all clones for \"{}\"".format( file.file_name)): select_file(file.file_name) file_buffers[file.file_name].to_imgui(file, padding) imgui.end()
def ParsePdfWidget(): ''' Use subprocess.Popen to run another script in background ''' global WDIR global ODIR global N_Group global AllFileStatus with imgui.font(largefont): imgui.text("Step 1: 設定工作目錄") imgui.bullet_text("設定好推甄資料的目錄。") if WDIR: imgui.separator() with imgui.font(largefont): imgui.text("Step 2: 檢查各別檔案") imgui.push_text_wrap_position(450) imgui.bullet_text("檔案命名有些錯誤,需要額外調整,如: 10054818.pdf 變為10054818_1.pdf") imgui.dummy(50, 0) imgui.same_line() if imgui.button("檢查檔案"): AllFileStatus = GF.CheckAllFiles(WDIR) imgui.push_text_wrap_position(450) imgui.text(AllFileStatus) imgui.separator() with imgui.font(largefont): imgui.text("Step 3: 執行程式-解析成績單內容") imgui.dummy(50, 0) imgui.same_line() if imgui.button("設定輸出目錄"): ODIR = TkFileDialog() if ODIR != "": imgui.text("輸出目錄位置:") imgui.push_text_wrap_position(250) imgui.text(ODIR) imgui.dummy(50, 0) imgui.same_line() if imgui.button("開始解析"): if WDIR == "": imgui.text("請設定檔案目錄") else: subprocess.run(["python","Subprocesses/ParseScoreSheet.py", WDIR, ODIR]) imgui.separator() if os.path.isfile('ManualFiles.log'): with imgui.font(largefont): imgui.text("Step 4: 執行程式-手動檔案分類") imgui.push_item_width(150) changed, N_Group = imgui.slider_int("幾群?", N_Group, min_value = 2, max_value = 20) imgui.text(f"分成{N_Group}群") if imgui.button("開始分群"): subprocess.run(["python","Subprocesses/GroupPdf.py", ODIR, str(N_Group)]) imgui.separator() if os.path.isdir(ODIR+"/Manual"): with imgui.font(largefont): imgui.text("Step 5: 手動處理") imgui.push_text_wrap_position(250) imgui.text(""" 恭喜~~~ 只剩下一咪咪手動的作業就能完工了!! 祝你有美好的一天!! 你現在可以關閉這個程式。 """)
def draw(self): imgui.begin(self.title) imgui.bullet_text("Bullet 1") imgui.bullet_text("Bullet 2") imgui.bullet_text("Bullet 3") imgui.end()
def frame_commands(): io = imgui.get_io() if io.key_ctrl and io.keys_down[glfw.KEY_Q]: sys.exit(0) with imgui.begin_main_menu_bar() as main_menu_bar: if main_menu_bar.opened: with imgui.begin_menu("File", True) as file_menu: if file_menu.opened: clicked_quit, selected_quit = imgui.menu_item( "Quit", "Ctrl+Q") if clicked_quit: sys.exit(0) # turn examples on/off with imgui.begin("Active examples"): for label, enabled in active.copy().items(): _, enabled = imgui.checkbox(label, enabled) active[label] = enabled if active["window"]: with imgui.begin("Hello, Imgui!"): imgui.text("Hello, World!") if active["child"]: with imgui.begin("Example: child region"): with imgui.begin_child("region", 150, -50, border=True): imgui.text("inside region") imgui.text("outside region") if active["tooltip"]: with imgui.begin("Example: tooltip"): imgui.button("Click me!") if imgui.is_item_hovered(): with imgui.begin_tooltip(): imgui.text("This button is clickable.") if active["menu bar"]: try: flags = imgui.WINDOW_MENU_BAR with imgui.begin("Child Window - File Browser", flags=flags): with imgui.begin_menu_bar() as menu_bar: if menu_bar.opened: with imgui.begin_menu('File') as file_menu: if file_menu.opened: clicked, state = imgui.menu_item('Close') if clicked: active["menu bar"] = False raise Exception except Exception: print("exception handled") if active["popup"]: with imgui.begin("Example: simple popup"): if imgui.button("select"): imgui.open_popup("select-popup") imgui.same_line() with imgui.begin_popup("select-popup") as popup: if popup.opened: imgui.text("Select one") imgui.separator() imgui.selectable("One") imgui.selectable("Two") imgui.selectable("Three") if active["popup modal"]: with imgui.begin("Example: simple popup modal"): if imgui.button("Open Modal popup"): imgui.open_popup("select-popup-modal") imgui.same_line() with imgui.begin_popup_modal("select-popup-modal") as popup: if popup.opened: imgui.text("Select an option:") imgui.separator() imgui.selectable("One") imgui.selectable("Two") imgui.selectable("Three") if active["popup context item"]: with imgui.begin("Example: popup context view"): imgui.text("Right-click to set value.") with imgui.begin_popup_context_item("Item Context Menu") as popup: if popup.opened: imgui.selectable("Set to Zero") if active["popup context window"]: with imgui.begin("Example: popup context window"): with imgui.begin_popup_context_window() as popup: if popup.opened: imgui.selectable("Clear") if active["popup context void"]: with imgui.begin_popup_context_void() as popup: if popup.opened: imgui.selectable("Clear") if active["drag drop"]: with imgui.begin("Example: drag and drop"): imgui.button('source') with imgui.begin_drag_drop_source() as src: if src.dragging: imgui.set_drag_drop_payload('itemtype', b'payload') imgui.button('dragged source') imgui.button('dest') with imgui.begin_drag_drop_target() as dst: if dst.hovered: payload = imgui.accept_drag_drop_payload('itemtype') if payload is not None: print('Received:', payload) if active["group"]: with imgui.begin("Example: item groups"): with imgui.begin_group(): imgui.text("First group (buttons):") imgui.button("Button A") imgui.button("Button B") imgui.same_line(spacing=50) with imgui.begin_group(): imgui.text("Second group (text and bullet texts):") imgui.bullet_text("Bullet A") imgui.bullet_text("Bullet B") if active["tab bar"]: with imgui.begin("Example Tab Bar"): with imgui.begin_tab_bar("MyTabBar") as tab_bar: if tab_bar.opened: with imgui.begin_tab_item("Item 1") as item1: if item1.opened: imgui.text("Here is the tab content!") with imgui.begin_tab_item("Item 2") as item2: if item2.opened: imgui.text("Another content...") global opened_state with imgui.begin_tab_item("Item 3", opened=opened_state) as item3: opened_state = item3.opened if item3.selected: imgui.text("Hello Saylor!") if active["list box"]: with imgui.begin("Example: custom listbox"): with imgui.begin_list_box("List", 200, 100) as list_box: if list_box.opened: imgui.selectable("Selected", True) imgui.selectable("Not Selected", False) if active["table"]: with imgui.begin("Example: table"): with imgui.begin_table("data", 2) as table: if table.opened: imgui.table_next_column() imgui.table_header("A") imgui.table_next_column() imgui.table_header("B") imgui.table_next_row() imgui.table_next_column() imgui.text("123") imgui.table_next_column() imgui.text("456") imgui.table_next_row() imgui.table_next_column() imgui.text("789") imgui.table_next_column() imgui.text("111") imgui.table_next_row() imgui.table_next_column() imgui.text("222") imgui.table_next_column() imgui.text("333")