Initial commit of basic Python front-end to J-Ben.
[jben2_gui.git] / tab_worddict.py
blobb905633969741abbf116ed50e19ee149e99b8a6f
1 #!/usr/bin/env python
3 # Project: J-Ben, Python front-end
4 # File: tab_worddict.py
5 # Author: Paul Goins
6 # Created on: 20 Nov 2008
8 import gtk
10 class TabWordDict:
11 def __init__(self):
12 self.contents = gtk.VBox(spacing = 5)
13 self.contents.set_border_width(5)
15 # Top box: "Enter word or expression:" [________] [ Search ]
16 self.querylabel = gtk.Label(_("Enter word or expression:"))
17 self.queryentry = gtk.Entry()
19 self.searchbutton = gtk.Button(_("_Search"))
20 btnbox = gtk.HButtonBox()
21 btnbox.set_spacing(5)
22 btnbox.set_layout(gtk.BUTTONBOX_START)
23 btnbox.pack_start(self.searchbutton)
25 topbox = gtk.HBox(spacing = 5)
26 topbox.pack_start(self.querylabel, expand = False)
27 topbox.pack_start(self.queryentry)
28 topbox.pack_start(btnbox, expand = False)
29 self.contents.pack_start(topbox, expand = False)
31 # Middle box: a GTKTextView wrapped in a GTKScrolledWindow
32 self.output = gtk.TextView()
33 self.output.set_editable(False)
34 self.output.set_wrap_mode(gtk.WRAP_WORD_CHAR)
35 self.search()
36 outputwindow = gtk.ScrolledWindow()
37 outputwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
38 outputwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
39 outputwindow.add(self.output)
40 self.contents.pack_start(outputwindow)
42 # Bottom box: [__Back__] [Forward_] [_Random_] [# ] "of # vocab"
43 self.backbutton = gtk.Button(stock = gtk.STOCK_GO_BACK)
44 self.nextbutton = gtk.Button(stock = gtk.STOCK_GO_FORWARD)
45 self.randombutton = gtk.Button(_("_Random"))
46 self.indexentry = gtk.Entry()
47 self.indexentry.set_width_chars(5)
48 self.indexentry.set_max_length(5)
49 self.indexlabel = gtk.Label(_("of 0 vocab"))
51 btnbox2 = gtk.HButtonBox()
52 btnbox2.set_spacing(5)
53 btnbox2.set_layout(gtk.BUTTONBOX_START)
54 btnbox2.pack_start(self.backbutton)
55 btnbox2.pack_start(self.nextbutton)
56 btnbox2.pack_start(self.randombutton)
58 bottombox = gtk.HBox(spacing = 5)
59 bottombox.pack_start(btnbox2, expand = False)
60 bottombox.pack_end(self.indexlabel, expand = False)
61 bottombox.pack_end(self.indexentry, expand = False)
62 self.contents.pack_start(bottombox, expand = False)
64 def search(self):
65 # For now, searching is disabled.
66 self.output.get_buffer().set_text(_("No search has been entered."))