Exemple #1
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')
        cls.refresh()
        cls.trigger('quit')


result = app.run()
print(result)
if result.interrupted():
    print('Ctrl-C pressed.')
else:
    result.unwrap()
Exemple #2
0
#!/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()
Exemple #3
0
class BottomLeftWindow(CursedWindow):
    X, Y = 0, 24
    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)
        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 BottomRightWindow(CursedWindow):
    X, Y = 24, 24
    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)
        cls.write('1,1', x=1, y=1)
        cls.write('2,2', x=2, y=2)
        cls.write('N,N', x=None, y=3)


app.run().unwrap()