blob: 80b8bcb0e9785d97b5debd57e70752ee78c3b343 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# encoding: utf-8
"""
Example application for integrating serving a Urwid application remotely.
Run this application with::
twistd -ny twisted_serve_ssh.tac
Then in another terminal run::
ssh -p 6022 user@localhost
(The password is 'pw' without the quotes.)
Note: To use this in real life, you must use some real checker.
"""
from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
import urwid
from twisted_serve_ssh import UrwidMind, UrwidUi, create_application
class HelloUi(UrwidUi):
def create_urwid_toplevel(self):
txt = urwid.Edit('Hello World?\n ')
txt2 = urwid.Edit('Hello World?\n ')
fill = urwid.Filler(urwid.Pile([txt, txt2]), 'top')
return fill
class HelloMind(UrwidMind):
ui_factory = HelloUi
cred_checkers = [InMemoryUsernamePasswordDatabaseDontUse(user='pw')]
application = create_application('TXUrwid Demo', HelloMind, 6022)
# vim: ft=python
|