Skip to content

Commit

Permalink
vspreview/main.py: allow custom function generating text
Browse files Browse the repository at this point in the history
e.g.
last.std.SetFrameProps(vsp_text=lambda f: '%s' % f.props).set_output()

Signed-off-by: akarin <i@akarin.info>
  • Loading branch information
AkarinVS committed Nov 2, 2022
1 parent 3d7212a commit 06b408c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion vspreview/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ class MainWindow(AbstractMainWindow):
}
# status bar
STATUS_FRAME_PROP = lambda prop: 'Type: %s' % (prop['_PictType'].decode('utf-8') if '_PictType' in prop else '?')
STATUS_TEXT_FUNC_NAME = 'vsp_text'

BENCHMARK_FRAME_DATA_SHARING_FIX = True
DEBUG_PLAY_FPS = False
Expand Down Expand Up @@ -647,7 +648,15 @@ def switch_frame(self, pos: Union[Frame, Time], *, render_frame: bool = True) ->
if render_frame:
self.current_output.graphics_scene_item.setImage(self.render_frame(frame))

self.statusbar.frame_props_label.setText(MainWindow.STATUS_FRAME_PROP(self.current_output.cur_frame[0].props))
text = ''
if MainWindow.STATUS_TEXT_FUNC_NAME in self.current_output.cur_frame[0].props:
frame = self.current_output.cur_frame[0]
func = frame.props[MainWindow.STATUS_TEXT_FUNC_NAME]
if callable(func):
text = func(f=frame)
if text == '':
text = MainWindow.STATUS_FRAME_PROP(self.current_output.cur_frame[0].props)
self.statusbar.frame_props_label.setText(text)

def switch_output(self, value: Union[int, Output]) -> None:
if len(self.outputs) == 0:
Expand Down

0 comments on commit 06b408c

Please sign in to comment.