diff -ur kon_ut.old/snd_ut.py kon_ut.now/snd_ut.py --- kon_ut.old/snd_ut.py 2020-09-23 20:58:44.000000000 +0900 +++ kon_ut.now/snd_ut.py 2022-05-02 18:46:14.487021370 +0900 @@ -49,6 +49,23 @@ wait_msg.stop() return b +def load_bytes_part( name, from_byte=None, to_byte=None ): + if from_byte is None and to_byte is None: + return load_bytes( name ) + + if from_byte is None: + from_byte = 0 + + if to_byte is None: + st = os.lstat( name ) + to_byte = st.st_size + + b = bytes( [] ) + with open( name, 'rb' ) as f: + if from_byte > 0: + f.seek( from_byte ) + b = f.read( to_byte - from_byte ) + return b def save_bytes(name, b): wait_msg = wait_msg_new( 'save ' + name ) @@ -168,7 +185,7 @@ e = empty.new() e.raw_bytes = None - def get_bytes(start_sec=0, end_sec=-1): + def get_bytes_cache(start_sec=0, end_sec=-1): if e.raw_bytes == None: make( name, 'raw', 'load' ) e.raw_bytes = load_bytes( name + '.raw' ) @@ -180,6 +197,14 @@ end = inf.byte_sec( end_sec ) if end_sec >= 0 else len( e.raw_bytes ) return e.raw_bytes[ start : end ] + def get_bytes( start_sec=0, end_sec=-1, cache=True ): + if cache: + return get_bytes_cache( start_sec, end_sec ) + + from_byte = inf.byte_sec( start_sec ) + to_byte = inf.byte_sec( end_sec ) if end_sec >= 0 else None + return load_bytes_part( name + '.raw', from_byte, to_byte ) + def get_arr(start_sec=0, end_sec=-1): b = get_bytes( start_sec, end_sec ) return bytes_to_arr( b ) diff -ur kon_ut.old/wx_ut.py kon_ut.now/wx_ut.py --- kon_ut.old/wx_ut.py 2020-10-01 20:03:50.000000000 +0900 +++ kon_ut.now/wx_ut.py 2022-05-02 18:46:17.824626208 +0900 @@ -1,5 +1,6 @@ #!/usr/bin/env python +import os import wx import empty @@ -333,19 +334,36 @@ e.app = self e.frame = wx_new( wx.Frame, title, parent=None ) bind( e.frame, quit_hdl, wx.EVT_CLOSE ) + set_icon() init( e ) e.frame.Layout() e.frame.Fit() + e.frame.FitInside() e.app.SetTopWindow( e.frame ) + ( w, h ) = e.frame.GetSize() + e.frame.SetMinSize( ( w, h + 10 ) ) # title bar height ? + if e.on_init: e.on_init( e ) else: e.frame.Show() return 1 + def set_icon( path='hoge.png' ): + if not e.frame: + return + + if not os.path.exists( path ): + return + + bm = wx.Bitmap( path ) + icon = wx.EmptyIcon() + icon.CopyFromBitmap( bm ) + e.frame.SetIcon( icon ) + def poll_start(poll_func, sec, hz, gc): th = None if poll_func: