Ejemplo n.º 1
0
    def draw(self):
        imgui.new_frame()

        pos_x = 10
        pos_y = 10
        sz = 20

        draw_list = imgui.get_window_draw_list()

        for i in range(0, imgui.COLOR_COUNT):
            name = imgui.get_style_color_name(i)
            draw_list.add_rect_filled(pos_x, pos_y, pos_x + sz, pos_y + sz,
                                      imgui.get_color_u32_idx(i))
            imgui.dummy(sz, sz)
            imgui.same_line()

        rgba_color = imgui.get_color_u32_rgba(1, 1, 0, 1)
        draw_list.add_rect_filled(pos_x, pos_y, pos_x + sz, pos_y + sz,
                                  rgba_color)

        imgui.end_frame()

        imgui.render()

        self.renderer.render(imgui.get_draw_data())
Ejemplo n.º 2
0
    def _show_custom_ui(self):
        if self.shader_error is None:
            return

        imgui.dummy(1, 5)
        imgui.text_colored("Shader error. (?)", 1.0, 0.0, 0.0)
        if imgui.is_item_hovered():
            imgui.set_tooltip(self.shader_error)
Ejemplo n.º 3
0
def ProgessBar(CV, MV, BarSize = 200):
    if CV >= MV:
        CV = MV
    imgui.dummy(10, 20)
    draw_list = imgui.get_window_draw_list()
    sp = imgui.get_item_rect_min()
    ep = imgui.get_item_rect_max()
    draw_list.add_rect(sp[0]+60,ep[1], sp[0]+60 + BarSize ,sp[1], imgui.get_color_u32_rgba(0.098, 0.098, 0.439, 1))
    draw_list.add_rect_filled(sp[0]+60,ep[1], sp[0]+60 + CV/MV * BarSize ,sp[1], imgui.get_color_u32_rgba(0.098, 0.098, 0.439, 1))
    draw_list.add_text(sp[0]+60 + BarSize + 10, sp[1] + 2, imgui.get_color_u32_rgba(1,0.5,0.5,1), f'{round(CV/MV* 100, 2)} %')    
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
def _imgui_pick_file_menu(base_path, wildcard="*"):
    MAX_FILE_DISPLAY_LENGTH = 60

    try:
        entries = []
        for name in os.listdir(base_path):
            entries.append(
                (not os.path.isdir(os.path.join(base_path, name)), name))

        imgui.text("New:")
        imgui.same_line()
        imgui.push_item_width(-1)
        changed, value = imgui.input_text("", "", 255,
                                          imgui.INPUT_TEXT_ENTER_RETURNS_TRUE)
        if changed:
            return os.path.join(base_path, value)
        imgui.separator()
        for w in WILDCARDS:
            if imgui.button(w):
                return os.path.join(base_path, w)
            imgui.same_line()
        imgui.dummy(0, 0)
        imgui.separator()

        if len(entries) == 0:
            imgui.dummy(200, 0)

        for not_is_dir, name in sorted(entries):
            display_name = name
            if len(display_name) > MAX_FILE_DISPLAY_LENGTH:
                display_name = display_name[:MAX_FILE_DISPLAY_LENGTH //
                                            2] + "..." + display_name[
                                                -MAX_FILE_DISPLAY_LENGTH // 2:]

            if not not_is_dir:
                if imgui.begin_menu(display_name):
                    selected_path = _imgui_pick_file_menu(
                        os.path.join(base_path, name), wildcard)
                    imgui.end_menu()
                    if selected_path is not None:
                        return os.path.join(base_path, selected_path)
            else:
                if not fnmatch.fnmatch(name, wildcard):
                    continue
                clicked, state = imgui.menu_item(display_name, None, False)
                if clicked:
                    return os.path.join(base_path, name)

        imgui.separator()
        imgui.text("Pick: %s" % wildcard)
    except:
        imgui.text("Unable to open dir")
Ejemplo n.º 6
0
    def _show_custom_ui(self):
        imgui.dummy(0, 10)
        imgui.text("Sourced %d blocks" % self.blocks)

        sinks = self.pulse.sinks
        current_sink_index = self.pulse.current_sink_index
        current_sink_name = sinks.get(current_sink_index, "<unknown>")
        #print("Unkown sink %s out of %s" % (repr(current_sink_index), sinks))

        imgui.push_item_width(250)
        if imgui.begin_combo("", current_sink_name):
            for index, sink_name in sinks.items():
                is_selected = index == current_sink_index
                opened, selected = imgui.selectable(sink_name, is_selected)
                if opened:
                    self.pulse.current_sink_index = index
                if is_selected:
                    imgui.set_item_default_focus()
            imgui.end_combo()
Ejemplo n.º 7
0
    def _show_custom_ui(self):
        imgui.dummy(1, 5)
        imgui.text("lambda x:")
        imgui.push_item_width(208)
        changed, text = imgui.input_text("", self.get("lambda"), 255,
                                         imgui.INPUT_TEXT_ENTER_RETURNS_TRUE)
        if changed:
            self.get_input("lambda").value = text

        if self.compile_error is not None:
            imgui.text_colored("Compilation error. (?)", 1.0, 0.0, 0.0)
            if imgui.is_item_hovered():
                imgui.set_tooltip(self.compile_error)
        elif self.run_error is not None:
            imgui.text_colored("Runtime error. (?)", 1.0, 0.0, 0.0)
            if imgui.is_item_hovered():
                imgui.set_tooltip(self.run_error)
        else:
            imgui.text("Lambda compiled.")
Ejemplo n.º 8
0
    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())
Ejemplo n.º 9
0
def FileWindow():
    '''
    string wdir, path to project folder
    '''
    global WDIR
    global LoadedFile
    global InstIndex
    global PersonIndex
    global ReloadPDF
      
    if not WDIR:
        imgui.dummy(50, 0)
        imgui.same_line()
        if imgui.button("選擇推甄資料目錄"):
            WDIR = TkFileDialog()
            
    else:
        imgui.text("現行推甄資料目錄:")
        imgui.push_text_wrap_position(150)
        imgui.text(WDIR)
        imgui.dummy(80,0)
        imgui.same_line()
        if imgui.button("變更"):
            WDIR = TkFileDialog()
        imgui.separator()
        if GF.CheckWDIR(WDIR):
            imgui.text('目前系所:')
            IList = os.listdir(WDIR)
            _, InstIndex = imgui.combo("", InstIndex, IList)
            imgui.text('學生編號:')
            PersonList = os.listdir(WDIR+'/'+IList[InstIndex])
            _, PersonIndex = imgui.listbox("", PersonIndex, PersonList, 15)
            imgui.text(f"目前檔案: {PersonList[PersonIndex]}")
            if imgui.button("查看檔案"):
                os.startfile(f'{WDIR}/{IList[InstIndex]}/{PersonList[PersonIndex]}/{PersonList[PersonIndex]}.pdf')                
                    
        else:
            with imgui.font(largefont):
                imgui.text('目錄錯誤,請重選!')
Ejemplo n.º 10
0
 def _show_custom_ui(self):
     if self.status:
         imgui.dummy(1, 5)
         imgui.text_colored("Error. (?)", 1.0, 0.0, 0.0)
         if imgui.is_item_hovered():
             imgui.set_tooltip(self.status)
Ejemplo n.º 11
0
                                                          max_value=n_frames,
                                                          format='%d')
            if imgui.button(
                    'Pause Animation' if play_animation else 'Play Animation'):
                play_animation = not play_animation
            imgui.end()

            # Control panel
            panel_width = max(width // 4, 300)
            imgui.set_next_window_position(width - panel_width, 0)
            imgui.set_next_window_size(panel_width, height - timeline_height)
            imgui.set_next_window_bg_alpha(0.8)
            imgui.begin('controlpanel', False,
                        imgui.WINDOW_NO_TITLE_BAR | imgui.WINDOW_NO_RESIZE)
            imgui.text('Control Panel')
            imgui.dummy(0, 10)
            imgui.text('active fg element')
            clicked, active_fg_element = imgui.listbox('', active_fg_element,
                                                       fg_element_labels)
            if imgui.button('Export GIF'):
                export_gif()
            if imgui.button('Export MOV'):
                export_mov()
            clicked, spray_trail = imgui.checkbox('spray_trail', spray_trail)
            clicked, ricochet = imgui.checkbox('ricochet', ricochet)
            imgui.end()

        glClearColor(1.0, 1.0, 1.0, 1.0)
        glClear(GL_COLOR_BUFFER_BIT)

        glUseProgram(shader)
Ejemplo n.º 12
0
 def _show_custom_ui(self):
     if self.filter_status is not None:
         imgui.dummy(1, 5)
         imgui.text_colored("Filter error. (?)", 1.0, 0.0, 0.0)
         if imgui.is_item_hovered():
             imgui.set_tooltip(self.filter_status)
Ejemplo n.º 13
0
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("""
            恭喜~~~
            只剩下一咪咪手動的作業就能完工了!!

            祝你有美好的一天!!
            你現在可以關閉這個程式。
            """)