author | Radek Brich <radek.brich@devl.cz> |
Mon, 09 Dec 2013 11:39:28 +0100 | |
changeset 91 | fba99a54ec49 |
parent 76 | 3a41b351b122 |
permissions | -rw-r--r-- |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
1 |
from gi.repository import GObject |
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
2 |
from gi.repository import Gtk |
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
3 |
from gi.repository import Pango |
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
4 |
|
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
from cgi import escape |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
|
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
8 |
class DataView(Gtk.ScrolledWindow): |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
def __init__(self): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
super(DataView, self).__init__() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
sw = self |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
13 |
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
14 |
sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) |
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
15 |
self.treeview = Gtk.TreeView(Gtk.ListStore(str)) |
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
16 |
self.treeview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
self.treeview.set_property("rubber-banding", True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
sw.add(self.treeview) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
19 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
def load_data(self, names, rows): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
x = [str] * (len(names) + 1) |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
23 |
liststore = Gtk.ListStore(*x) |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
for c in self.treeview.get_columns(): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
self.treeview.remove_column(c) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
27 |
|
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
28 |
tvcolumn = Gtk.TreeViewColumn() |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
cell = DataViewCellRenderer() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
cell.set_property('head', True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
tvcolumn.pack_start(cell, True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
tvcolumn.set_property('resizable', True) |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
33 |
#tvcolumn.set_property('sizing', Gtk.TREE_VIEW_COLUMN_FIXED) |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
tvcolumn.set_attributes(cell, text=0) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
tvcolumn.set_min_width(2) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
self.treeview.append_column(tvcolumn) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
38 |
i = 0 |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
39 |
for c in names: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
i += 1 |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
41 |
typename = c[1] |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
42 |
title = '<b>%s</b>' % escape(c[0]) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
43 |
if typename: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
44 |
title += '\n<span size="small">%s</span>' % typename |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
45 |
|
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
46 |
tvcolumn = Gtk.TreeViewColumn() |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
47 |
cell = DataViewCellRenderer() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
48 |
|
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
49 |
lab = Gtk.Label() |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
50 |
lab.set_use_underline(False) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
51 |
lab.set_markup(title) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
52 |
lab.show() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
53 |
tvcolumn.set_widget(lab) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
54 |
tvcolumn.set_property('resizable', True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
55 |
tvcolumn.pack_start(cell, True) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
56 |
tvcolumn.set_attributes(cell, text=i) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
57 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
58 |
self.treeview.append_column(tvcolumn) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
59 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
60 |
self.treeview.set_model(liststore) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
61 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
62 |
i = 0 |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
63 |
for row in rows: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
64 |
i += 1 |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
65 |
liststore.append([i]+list(row)) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
66 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
67 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
68 |
|
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
69 |
class DataViewCellRenderer(Gtk.CellRenderer): |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
70 |
__gtype_name__ = 'DataViewCellRenderer' |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
71 |
__gproperties__ = { |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
72 |
'text': (GObject.TYPE_STRING, None, None, '', GObject.PARAM_READWRITE), |
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
73 |
'head': (GObject.TYPE_BOOLEAN, None, None, False, GObject.PARAM_READWRITE)} |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
74 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
75 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
76 |
def __init__(self): |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
77 |
Gtk.CellRenderer.__init__(self) |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
78 |
self._props = {'text' : '', 'head' : False} |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
79 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
80 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
81 |
def do_set_property(self, pspec, value): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
82 |
if not pspec.name in self._props: |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
83 |
raise AttributeError('Unknown property: %s' % pspec.name) |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
84 |
self._props[pspec.name] = value |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
85 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
86 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
87 |
def do_get_property(self, pspec): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
88 |
return self._props[pspec.name] |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
89 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
90 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
91 |
def on_get_size(self, widget, cell_area): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
92 |
if cell_area == None: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
93 |
pangoctx = widget.get_pango_context() |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
94 |
layout = Pango.Layout(pangoctx) |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
95 |
layout.set_width(-1) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
96 |
layout.set_text(self.get_property('text') or 'NULL') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
97 |
w,h = layout.get_pixel_size() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
98 |
return (0, 0, w+5, 20) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
99 |
x = cell_area.x |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
100 |
y = cell_area.x |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
101 |
w = cell_area.width |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
102 |
h = cell_area.height |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
103 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
104 |
return (x,y,w,h) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
105 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
106 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
107 |
def on_render(self, window, widget, background_area, cell_area, expose_area, flags): |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
108 |
x = background_area.x |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
109 |
y = background_area.y |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
110 |
w = background_area.width |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
111 |
h = background_area.height |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
112 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
113 |
ctx = window.cairo_create() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
114 |
ctx.set_line_width(0.4) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
115 |
ctx.set_source_rgb(0, 0, 0) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
116 |
ctx.move_to(x+w-1.5, y-0.5) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
117 |
ctx.line_to(x+w-1.5, y+h-0.5) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
118 |
ctx.line_to(x-0.5, y+h-0.5) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
119 |
ctx.stroke() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
120 |
ctx.set_source_rgb(1, 1, 1) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
121 |
ctx.move_to(x+w-0.5, y-0.5) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
122 |
ctx.line_to(x+w-0.5, y+h-0.5) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
123 |
ctx.stroke() |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
124 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
125 |
pangoctx = widget.get_pango_context() |
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
126 |
layout = Pango.Layout(pangoctx) |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
127 |
text = self.get_property('text') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
128 |
head = self.get_property('head') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
129 |
|
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
130 |
if head: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
131 |
layout.set_markup('<b>%s</b>' % text) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
132 |
else: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
133 |
if text is None: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
134 |
layout.set_markup('<span foreground="gray">NULL</span>') |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
135 |
else: |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
136 |
layout.set_text(text) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
137 |
|
76
3a41b351b122
Port pgconsole to Python3 + GTK3.
Radek Brich <radek.brich@devl.cz>
parents:
10
diff
changeset
|
138 |
widget.style.paint_layout(window, Gtk.STATE_NORMAL, True, |
10
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
139 |
cell_area, widget, '', |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
140 |
cell_area.x, cell_area.y, |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
141 |
layout) |
f3a1b9792cc9
Added pgconsole. It is my older project, a GUI query console. It uses GTK+ and asynchronous queries.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
142 |