1 """Graphical interface for the Jazz Parser.
2
3 Very much not finished yet, but would be nice to finish in the future.
4 Just makes taking input and choosing parameters easier.
5
6 """
7 """
8 ============================== License ========================================
9 Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding
10
11 This file is part of The Jazz Parser.
12
13 The Jazz Parser is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 The Jazz Parser is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with The Jazz Parser. If not, see <http://www.gnu.org/licenses/>.
25
26 ============================ End license ======================================
27
28 """
29 __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"
30
31
32
33 import pygtk
34 pygtk.require('2.0')
35
36 import gtk, pango, sys, gobject
37 from jazzparser.data.input import INPUT_TYPES, BULK_INPUT_TYPES, get_input_type
38 from jazzparser.utils.options import file_option, new_file_option, \
39 zero_to_one_float, choose_from_dict, choose_from_list
40
42 """
43 Main top-level interface window.
44
45 """
47 gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL, *args, **kwargs)
48
49 self.set_border_width(5)
50 self.set_title("Jazz Parser")
51
52
53 self._vbox = gtk.VBox(spacing=5)
54 self.add(self._vbox)
55
56 self._input_frame = gtk.Frame(label="Input")
57 self._input_box = gtk.VBox(spacing=4)
58 self._input_box.set_border_width(5)
59 self._input_frame.add(self._input_box)
60 self._vbox.add(self._input_frame)
61
62 input_type_box = gtk.HBox(spacing=3)
63 input_type_label = gtk.Label("Input type:")
64 input_type_box.add(input_type_label)
65 input_type_selector = gtk.combo_box_new_text()
66 for (itype_name,itype) in INPUT_TYPES+BULK_INPUT_TYPES:
67 input_type_selector.append_text(itype_name)
68 input_type_box.add(input_type_selector)
69 self._input_type_selector = input_type_selector
70 self._input_box.add(input_type_box)
71
72 input_file_box = gtk.HBox(spacing=3)
73 self._filename_label = gtk.Label("No file selected")
74 input_file_box.add(self._filename_label)
75 file_button = gtk.Button("Choose file")
76 input_file_box.add(file_button)
77 file_button.connect("clicked", self.select_input_file)
78 self._input_box.add(input_file_box)
79
80 input_options_box = gtk.HBox(spacing=3)
81
82 input_options_button = gtk.Button("Input options")
83 input_options_box.add(input_options_button)
84 input_options_button.connect("clicked", self.edit_input_options)
85 self._input_box.add(input_options_box)
86
87 self._tagger_frame = gtk.Frame(label="Supertagger")
88 self._tagger_hbox = gtk.HBox()
89 self._tagger_frame.add(self._tagger_hbox)
90 self._vbox.add(self._tagger_frame)
91
92 self._parser_frame = gtk.Frame(label="Parser")
93 self._parser_hbox = gtk.HBox()
94 self._parser_frame.add(self._parser_hbox)
95 self._vbox.add(self._parser_frame)
96
97
98
99 self.connect("destroy", self.destroy)
100
114
126
130
133
135 """
136 Generic editing window for module options.
137
138 """
139 - def __init__(self, options, parent, title="Edit options", *args, **kwargs):
140 gtk.Window.__init__(self, *args, **kwargs)
141 self.set_title(title)
142 self.set_modal(True)
143 self.set_transient_for(parent)
144 self.set_border_width(5)
145 self.main_window = parent
146
147
148 if len(options) == 0:
149 self.add(gtk.Label("No options for this input type"))
150 else:
151 vbox = gtk.VBox(spacing=3)
152 for option in options:
153 hbox = gtk.HBox(spacing=5)
154
155 if option.filter == int:
156
157 hbox.add(gtk.Label(option.name))
158 hbox.add(gtk.SpinButton(
159 gtk.Adjustment(value=0, lower=0, upper=9999,
160 step_incr=1),
161 0, 0))
162 elif option.filter == file_option:
163
164 raise NotImplementedError
165 elif option.filter == new_file_option:
166
167 raise NotImplementedError
168 elif option.filter == float:
169
170 raise NotImplementedError
171 elif option.filter == zero_to_one_float:
172
173 raise NotImplementedError
174 elif option.filter == choose_from_dict:
175
176 raise NotImplementedError
177 elif option.filter == choose_from_list:
178
179 raise NotImplementedError
180 else:
181
182 hbox.add(gtk.Label(option.name))
183 hbox.add(gtk.Entry())
184 vbox.add(hbox)
185
186 self.add(vbox)
187
188 self.connect("destroy", self.destroy)
189 self.show_all()
190
194
196 dlg = gtk.MessageDialog(parent=parent,
197 type=gtk.MESSAGE_ERROR,
198 message_format=message,
199 buttons=gtk.BUTTONS_OK)
200 dlg.run()
201 dlg.destroy()
202