(self, show=True)
| 70 | |
| 71 | @imgui_utils.scoped_by_object_id |
| 72 | def __call__(self, show=True): |
| 73 | viz = self.viz |
| 74 | recent_pkls = [pkl for pkl in self.recent_pkls if pkl != self.user_pkl] |
| 75 | if show: |
| 76 | imgui.text('Pickle') |
| 77 | imgui.same_line(viz.label_w) |
| 78 | idx = self.user_pkl.rfind('/') |
| 79 | changed, self.user_pkl = imgui_utils.input_text('##pkl', self.user_pkl[idx+1:], 1024, |
| 80 | flags=(imgui.INPUT_TEXT_AUTO_SELECT_ALL | imgui.INPUT_TEXT_ENTER_RETURNS_TRUE), |
| 81 | width=(-1), |
| 82 | help_text='<PATH> | <URL> | <RUN_DIR> | <RUN_ID> | <RUN_ID>/<KIMG>.pkl') |
| 83 | if changed: |
| 84 | self.load(self.user_pkl, ignore_errors=True) |
| 85 | if imgui.is_item_hovered() and not imgui.is_item_active() and self.user_pkl != '': |
| 86 | imgui.set_tooltip(self.user_pkl) |
| 87 | # imgui.same_line() |
| 88 | imgui.text(' ') |
| 89 | imgui.same_line(viz.label_w) |
| 90 | if imgui_utils.button('Recent...', width=viz.button_w, enabled=(len(recent_pkls) != 0)): |
| 91 | imgui.open_popup('recent_pkls_popup') |
| 92 | imgui.same_line() |
| 93 | if imgui_utils.button('Browse...', enabled=len(self.search_dirs) > 0, width=viz.button_w): |
| 94 | imgui.open_popup('browse_pkls_popup') |
| 95 | self.browse_cache.clear() |
| 96 | self.browse_refocus = True |
| 97 | |
| 98 | if imgui.begin_popup('recent_pkls_popup'): |
| 99 | for pkl in recent_pkls: |
| 100 | clicked, _state = imgui.menu_item(pkl) |
| 101 | if clicked: |
| 102 | self.load(pkl, ignore_errors=True) |
| 103 | imgui.end_popup() |
| 104 | |
| 105 | if imgui.begin_popup('browse_pkls_popup'): |
| 106 | def recurse(parents): |
| 107 | key = tuple(parents) |
| 108 | items = self.browse_cache.get(key, None) |
| 109 | if items is None: |
| 110 | items = self.list_runs_and_pkls(parents) |
| 111 | self.browse_cache[key] = items |
| 112 | for item in items: |
| 113 | if item.type == 'run' and imgui.begin_menu(item.name): |
| 114 | recurse([item.path]) |
| 115 | imgui.end_menu() |
| 116 | if item.type == 'pkl': |
| 117 | clicked, _state = imgui.menu_item(item.name) |
| 118 | if clicked: |
| 119 | self.load(item.path, ignore_errors=True) |
| 120 | if len(items) == 0: |
| 121 | with imgui_utils.grayed_out(): |
| 122 | imgui.menu_item('No results found') |
| 123 | recurse(self.search_dirs) |
| 124 | if self.browse_refocus: |
| 125 | imgui.set_scroll_here() |
| 126 | viz.skip_frame() # Focus will change on next frame. |
| 127 | self.browse_refocus = False |
| 128 | imgui.end_popup() |
| 129 |
nothing calls this directly
no test coverage detected