def kb_event(self, win, zxchar): #win.prtchar(zxchar) bright = {'1': 1.5, '2': 1.2, '3': 1.0, '4': 0.83, '5': 0.67} contr = {'6': 0.2, '7': 0.33, '8': 0.5, '9': 0.8, '0': 1.2} s = zx2str([zxchar]) if s in 'xX' or zxchar == 12: self.close() return elif s in 'fF': self.delay_s = 0.15 elif s in 'sS': self.delay_s = 3.0 elif s in 'dD': self.floyd_stb = not self.floyd_stb elif s in 'iI': self.invert = not self.invert elif s in 'rR': self.h_v_rot += 1 elif s in 'pP': if self.app_state == AppState.SHOW: self.app_state = AppState.PIC_QUERY_YN if self.ctrlwin: self.ctrlwin.close() self.ctrlwin = TextWindow(self.mgr, 10, 1, 18, 19, border=WindowBorderFrame(), kb_event=self.kb_event_query, cursor_off=True) self.ctrlwin.prttxt(str2zx('save? Y/N', upper_inv=True)) elif s in 'mM': self.movie.clear() self.replay_ix = 0 if self.app_state == AppState.SHOW: self.app_state = AppState.MOVIE_REC if self.ctrlwin: self.ctrlwin.close() self.ctrlwin = TextWindow(self.mgr, 13, 1, 17, 19, border=WindowBorderFrame(), kb_event=self.kb_event_query, cursor_off=True) self.ctrlwin.prttxt(str2zx('recording', upper_inv=True)) elif s in bright: self.brightness = bright[s] elif s in contr: self.contrast = contr[s] # TODO invers, save_pic, help, exit self.ctrlwin_timeout = time.time() + 3 self.check_show_ctrlwin() self.event.reschedule(0.2, 5.0)
def __init__(self,mgr): self.mainwin=TextWindow(mgr,30,22,1,1,border=WindowBorderFrame(),kb_event=self.kb_event, cursor_off=True) self.print_help() #run('cmd',shell=True,stdout=self,stderr=self,stdin=self) #self.proc = Popen(['python','C:\\Users\\Holmatic\\workspace\\serial\\src\\apps\\file_browser.py'],shell=True,stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True) self.proc = None self.revent=mgr.schedule_event(self.periodic,0.5,0.5) self.outThread = None self.errThread = None
def end_movie_rec(self): self.app_state = AppState.MOVIE_QUERY_YN if self.ctrlwin: self.ctrlwin.close() self.ctrlwin = TextWindow(self.mgr, 10, 1, 18, 19, border=WindowBorderFrame(), kb_event=self.kb_event_query, cursor_off=True) self.ctrlwin.prttxt(str2zx('save? Y/N', upper_inv=True))
def check_show_ctrlwin(self): if not self.ctrlwin: self.ctrlwin = TextWindow(self.mgr, 14, 13, 14, 9, border=WindowBorderFrame( str2zx('ZX LIVE CAM')), kb_event=self.kb_event, cursor_off=True) self.ctrlwin.prttxt( str2zx('F fast S slow\n\nD dith I invrt', upper_inv=True)) self.ctrlwin.prttxt(str2zx('\nP pic M movie\n', upper_inv=True)) self.ctrlwin.prttxt( str2zx('\nR rotate\n\n1-5 brightness6-0 contrast\n\nX exit', upper_inv=True)) elif time.time() > self.ctrlwin_timeout: self.ctrlwin.close() self.ctrlwin = None
def __init__(self, mgr): self.mgr = mgr self.mainwin = TextWindow(mgr, 30, 22, 1, 1, border=WindowBorderFrame(), kb_event=self.kb_event, cursor_off=True) self.homecwd = Path.cwd().parent / 'zxroot' self.cwd = self.homecwd self.cwdfiles = [] self.show_offset = 0 self.max_lines = 16 self.f_index_str = '1234567890ABCDEFGHI' self.f_index = str2zx(self.f_index_str) self.actual_lines = 0 self.get_dir() self.show_dir()
def __init__(self, mgr): self.mgr = mgr self.mainwin = TextWindow(mgr, 32, 20, 0, 0) self.inp_win = TextWindow(mgr, 30, 2, 1, 21, border=WindowBorderFrame(), kb_event=self.kb_event, cursor_off=True) self.ed = None self.nick = 'zx-user' self.server = "irc.zxq.de" self.pword = '' self.port = 6667 self.inp_mode = InpMode.MENU self.listener = ListenerThread(self.mainwin) self.choose_site() self.revent = mgr.schedule_event(self.periodic, 2, 2) self.channel = ''
def __init__(self, mgr): self.mainwin = TextWindow(mgr, 30, 22, 1, 1, border=WindowBorderFrame(), kb_event=self.kb_event) #run('cmd',shell=True,stdout=self,stderr=self,stdin=self) #self.proc = Popen(['python','C:\\Users\\Holmatic\\workspace\\serial\\src\\apps\\file_browser.py'],shell=True,stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True) self.proc = Popen('cmd', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True) self.revent = mgr.schedule_event(self.periodic, 0.5, 0.5) print("AppShell starts...") self.outThread = Thread(target=self.out_handler_thread, args=(self.proc.stdout, )) self.errThread = Thread(target=self.out_handler_thread, args=(self.proc.stderr, )) self.outThread.start() self.errThread.start()
def kb_event_query(self, win, zxchar): #win.prtchar(zxchar) s = zx2str([zxchar]) if self.app_state in (AppState.PIC_QUERY_NAME, AppState.MOVIE_QUERY_NAME): if zxchar in (117, 118): # enter,break if zxchar == 118: # enter self.edlin.kb_event(zxchar) if self.app_state == AppState.PIC_QUERY_NAME: if self.edlin.val: # safe pic name = zx2str(self.edlin.val, to_lower=True).strip() #path mwin = self.mgr.show_msg_win(str2zx("save pic ..")) p = zxpi_paths.get_current_work_path() / 'pics' if not p.exists(): p.mkdir(parents=True) n = p / (name + '.zxscr') with n.open('wb') as f: lrg = self.calc_lrg_from_array(self.last_pic) nr, nc = lrg.shape for row in range(nr): #for col in range(nc): f.write(bytes([v for v in lrg[row]])) print("Saved to", str(n)) mwin.close() elif self.app_state == AppState.MOVIE_QUERY_NAME: if self.edlin.val: # save movie name = zx2str(self.edlin.val, to_lower=True).strip() #path pth = zxpi_paths.get_current_work_path() / 'movies' if not pth.exists(): pth.mkdir(parents=True) n = pth / (name + '.zxmovie') mwin = self.mgr.show_msg_win( str2zx("save movie ..")) mv_dat = bytearray() with n.open('wb') as f: for p in self.movie: lrg = self.calc_lrg_from_array(p) nr, nc = lrg.shape for row in range(nr): #for col in range(nc): rowdat = bytearray( [v for v in lrg[row]]) mv_dat += rowdat f.write(rowdat) print("Saved as", str(n)) self.mgr.update(0.1) n = pth / (name + '.p') with n.open('wb') as f: f.write( create_comp_viewer(compress_scr(mv_dat))) mwin.close() if self.edlin: self.edlin.close() self.edlin = None self.app_state = AppState.SHOW self.ctrlwin_timeout = 0 if self.ctrlwin: self.ctrlwin.close() self.ctrlwin = None else: self.edlin.kb_event(zxchar) elif self.app_state in (AppState.MOVIE_REC, ): self.end_movie_rec() else: if s in 'yYzZ': if self.app_state in (AppState.PIC_QUERY_YN, AppState.MOVIE_QUERY_YN): self.app_state = AppState.PIC_QUERY_NAME if self.app_state == AppState.PIC_QUERY_YN else AppState.MOVIE_QUERY_NAME if self.ctrlwin: self.ctrlwin.close() self.ctrlwin = TextWindow(self.mgr, 12, 2, 18, 19, border=WindowBorderFrame(), kb_event=self.kb_event_query, cursor_off=True) self.ctrlwin.prttxt(str2zx('file name:', upper_inv=True)) self.edlin = LinEd(self.ctrlwin, 0, 1, 11, maxchar=255, history=None) else: self.app_state = AppState.SHOW if self.ctrlwin: self.ctrlwin.close() self.ctrlwin = None self.event.reschedule(0.2, 5.0)