2 # -*- coding: utf-8 -*-
4 # Project: J-Ben, Python front-end
5 # File: tab_worddict.py
7 # Created on: 20 Nov 2008
11 class TabWordDict(gtk
.VBox
):
13 gtk
.VBox
.__init
__(self
, spacing
= 5)
14 self
.set_border_width(5)
16 # Top box: "Enter word or expression:" [________] [ Search ]
17 self
.querylabel
= gtk
.Label(_("Enter word or expression:"))
18 self
.queryentry
= gtk
.Entry()
20 self
.searchbutton
= gtk
.Button(_("_Search"))
21 self
.searchbutton
.connect("clicked", self
.on_search_clicked
)
22 btnbox
= gtk
.HButtonBox()
24 btnbox
.set_layout(gtk
.BUTTONBOX_START
)
25 btnbox
.pack_start(self
.searchbutton
)
27 topbox
= gtk
.HBox(spacing
= 5)
28 topbox
.pack_start(self
.querylabel
, expand
= False)
29 topbox
.pack_start(self
.queryentry
)
30 topbox
.pack_start(btnbox
, expand
= False)
31 self
.pack_start(topbox
, expand
= False)
33 # Middle box: a GTKTextView wrapped in a GTKScrolledWindow
34 self
.output
= gtk
.TextView()
35 self
.output
.set_editable(False)
36 self
.output
.set_wrap_mode(gtk
.WRAP_WORD_CHAR
)
37 self
.on_search_clicked(None)
38 outputwindow
= gtk
.ScrolledWindow()
39 outputwindow
.set_shadow_type(gtk
.SHADOW_ETCHED_IN
)
40 outputwindow
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_AUTOMATIC
)
41 outputwindow
.add(self
.output
)
42 self
.pack_start(outputwindow
)
44 # Bottom box: [__Back__] [Forward_] [_Random_] [# ] "of # vocab"
45 self
.backbutton
= gtk
.Button(stock
= gtk
.STOCK_GO_BACK
)
46 self
.backbutton
.connect("clicked", self
.on_back_clicked
)
47 self
.forwardbutton
= gtk
.Button(stock
= gtk
.STOCK_GO_FORWARD
)
48 self
.forwardbutton
.connect("clicked", self
.on_forward_clicked
)
49 self
.randombutton
= gtk
.Button(_("_Random"))
50 self
.randombutton
.connect("clicked", self
.on_random_clicked
)
51 self
.indexentry
= gtk
.Entry()
52 self
.indexentry
.set_width_chars(5)
53 self
.indexentry
.set_max_length(5)
54 self
.indexlabel
= gtk
.Label(_("of 0 vocab"))
56 btnbox2
= gtk
.HButtonBox()
57 btnbox2
.set_spacing(5)
58 btnbox2
.set_layout(gtk
.BUTTONBOX_START
)
59 btnbox2
.pack_start(self
.backbutton
)
60 btnbox2
.pack_start(self
.forwardbutton
)
61 btnbox2
.pack_start(self
.randombutton
)
63 bottombox
= gtk
.HBox(spacing
= 5)
64 bottombox
.pack_start(btnbox2
, expand
= False)
65 bottombox
.pack_end(self
.indexlabel
, expand
= False)
66 bottombox
.pack_end(self
.indexentry
, expand
= False)
67 self
.pack_start(bottombox
, expand
= False)
69 def on_search_clicked(self
, widget
):
70 # For now, searching is disabled.
71 print "TabWordDict.on_search_clicked"
72 self
.output
.get_buffer().set_text(_("No search has been entered."))
74 def on_back_clicked(self
, widget
):
75 print "TabWordDict.on_back_clicked"
78 def on_forward_clicked(self
, widget
):
79 print "TabWordDict.on_forward_clicked"
82 def on_random_clicked(self
, widget
):
83 print "TabWordDict.on_random_clicked"