annotate finch/libgnt/pygnt/test.py @ 22557:25d34ee59435

Belarusian Latin translation updated again (Ihar Hrachyshka) Closes #5333
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 29 Mar 2008 19:14:17 +0000
parents fefe61275687
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22013
fefe61275687 A small patch from shreevatsa: "Some of the Python scripts start with
Richard Laager <rlaager@wiktel.com>
parents: 19707
diff changeset
1 #!/usr/bin/env python
18679
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
2 import gobject
15932
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 import gnt
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4
18679
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
5 class MyObject(gobject.GObject):
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
6 __gproperties__ = {
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
7 'mytype': (gobject.TYPE_INT, 'mytype', 'the type of the object',
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
8 0, 10000, 0, gobject.PARAM_READWRITE),
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
9 'string': (gobject.TYPE_STRING, 'string property', 'the string',
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
10 None, gobject.PARAM_READWRITE),
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
11 'gobject': (gobject.TYPE_OBJECT, 'object property', 'the object',
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
12 gobject.PARAM_READWRITE),
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
13 }
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
14
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
15 def __init__(self, type = 'string', value = None):
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
16 self.__gobject_init__()
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
17 self.set_property(type, value)
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
18
19707
44b070f6a3f8 Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18679
diff changeset
19 def __del__(self):
44b070f6a3f8 Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18679
diff changeset
20 pass
44b070f6a3f8 Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18679
diff changeset
21
18679
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
22 def do_set_property(self, pspec, value):
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
23 if pspec.name == 'string':
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
24 self.string = value
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
25 self.type = gobject.TYPE_STRING
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
26 elif pspec.name == 'gobject':
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
27 self.gobject = value
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
28 self.type = gobject.TYPE_OBJECT
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
29 else:
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
30 raise AttributeError, 'unknown property %s' % pspec.name
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
31 def do_get_property(self, pspec):
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
32 if pspec.name == 'string':
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
33 return self.string
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
34 elif pspec.name == 'gobject':
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
35 return self.gobject
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
36 elif pspec.name == 'mytype':
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
37 return self.type
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
38 else:
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
39 raise AttributeError, 'unknown property %s' % pspec.name
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
40 gobject.type_register(MyObject)
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
41
18556
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
42 def button_activate(button, tree):
18679
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
43 list = tree.get_selection_text_list()
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
44 ent = tree.get_selection_data()
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
45 if ent.type == gobject.TYPE_STRING:
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
46 str = ""
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
47 for i in list:
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
48 str = str + i
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
49 entry.set_text("clicked!!!" + str)
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
50 elif ent.type == gobject.TYPE_OBJECT:
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
51 ent.gobject.set_text("mwhahaha!!!")
15932
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 gnt.gnt_init()
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 win = gnt.Window()
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 entry = gnt.Entry("")
18679
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
58 obj = MyObject()
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
59 obj.set_property('gobject', entry)
15932
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 win.add_widget(entry)
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 win.set_title("Entry")
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 button = gnt.Button("Click!")
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 win.add_widget(button)
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66
18556
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
67 tree = gnt.Tree()
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
68 tree.set_property("columns", 1)
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
69 win.add_widget(tree)
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
70
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
71 # so random non-string values can be used as the key for a row in a GntTree!
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
72 last = None
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
73 for i in range(1, 100):
18679
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
74 key = MyObject('string', str(i))
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
75 tree.add_row_after(key, [str(i)], None, last)
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
76 last = key
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
77
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
78 tree.add_row_after(MyObject('gobject', entry), ["asd"], None, None)
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
79 tree.add_row_after(MyObject('string', "b"), ["123"], MyObject('gobject', entry), None)
18556
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
80
5e1412f4e67a Do some work to make pygnt more useful. The dbus-gnt script works fairly
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15932
diff changeset
81 button.connect("activate", button_activate, tree)
15932
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82
18679
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
83 tv = gnt.TextView()
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
84
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
85 win.add_widget(tv)
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
86 tv.append_text_with_flags("What up!!", gnt.TEXT_FLAG_BOLD)
6b16fca71f8b Add some more functions for GntTree. One point to note is that the key
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18556
diff changeset
87
15932
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 win.show()
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 gnt.gnt_main()
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 gnt.gnt_quit()
8fd5ab3f9716 python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93