#!/usr/bin/env python from cursed import CursedApp, CursedWindow app = CursedApp() class ScrollingWindow(CursedWindow): WIDTH = 'max' HEIGHT = 23 SCROLL = True i = 0 @classmethod def update(cls): c = cls.getch() if c == 27: cls.trigger('quit') return cls.addstr('{}'.format(cls.i)) cls.nextline() cls.i += 1 cls.refresh() class FooterWindow(CursedWindow): WIDTH = 'max' HEIGHT = 1 Y = 23 @classmethod def init(cls): cls.addstr('Press ESCAPE to exit')
#!/usr/bin/env python from cursed import CursedApp, CursedWindow app = CursedApp() class MainWindow(CursedWindow): WIDTH = 8 HEIGHT = 4 BORDERED = True @classmethod def update(cls): k = cls.getch() if k is None: return cls.addstr('{:6}'.format(k), x=0, y=0) cls.addstr('0x{:04x}'.format(k), x=0, y=1) cls.refresh() result = app.run() print(result) if result.interrupted(): print('Ctrl-C pressed.') else: result.unwrap()
#!/usr/bin/env python from cursed import CursedWindow, CursedApp app = CursedApp() class LeftWindow(CursedWindow): X, Y = 0, 0 WIDTH = 24 HEIGHT = 24 BORDERED = True @classmethod def update(cls): cls.write('N,N', x=None, y=None) cls.write('0,0', x=0, y=0) cls.write('1,1', x=1, y=1) cls.write('2,2', x=2, y=2) cls.write('N,N', x=None, y=3) class RightWindow(CursedWindow): X, Y = 24, 0 WIDTH, HEIGHT = 24, 24 BORDERED = True @classmethod def update(cls): cls.write('N,N', x=None, y=None) cls.write('0,0', x=0, y=0)