summaryrefslogtreecommitdiff
path: root/docs/examples/pygtk_chat_client/ChatWindow.py
blob: 51c8dff98b427b2a614eb5ff7b5752fc3deb4612 (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
import gtk
import gobject

class ChatWindow(gtk.Window):
    def __init__(self, channel):
        super(ChatWindow, self).__init__()

        self.sm = channel.sm
        self.channel = channel

        self.set_default_size(300, 300)
        self.set_title('Chat with %s' % channel.target_id)

        vbox = gtk.VBox()
        self.add(vbox)

        sw = gtk.ScrolledWindow()
        vbox.pack_start (sw)

        self.buffer = gtk.TextBuffer()
        tv = gtk.TextView(self.buffer)
        sw.add(tv)

        vbox.show_all()

        self.connect('destroy', lambda s: s.channel.close())

gobject.type_register(ChatWindow)