Edit an experience entry by double-clicking on the tree
[crapvine.git] / number_as_text_attribute_box.py
blobdc4806d5eccd75498724387ec0170898300dc433
1 ## This file is part of Crapvine.
2 ##
3 ## Copyright (C) 2007 Andrew Sayman <lorien420@myrealbox.com>
4 ##
5 ## Crapvine is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## Crapvine is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import gtk
19 import gtk.glade
20 import gobject
21 import configuration
23 class NumberAsTextAttributeBox:
24 __glade_xml_file = configuration.get_number_as_text_attribute_box_xml_file_path()
25 def __init__(self, menu_name, display_name, overlord, character):
26 self.xml = gtk.glade.XML(self.__glade_xml_file, 'numberastextattribute')
27 self.vbox = self.xml.get_widget('numberastextattribute')
28 self.entry = self.xml.get_widget('numberAsTextAttributeEntry')
29 self.label = self.xml.get_widget('lblNumberAsTextAttributeName')
30 self.menu_name = menu_name
31 self.display_name = display_name
32 self.overlord = overlord
33 self.character = character
35 self.label.set_label(self.display_name.capitalize())
36 self.entry.set_value(float(self.character[self.display_name]))
38 self.xml.signal_autoconnect({
39 'on_value_changed': self.on_text_changed,
40 'demand_menu' : self.demand_menu,
41 'on_increment' : self.on_increment,
42 'on_decrement' : self.on_decrement
45 def on_text_changed(self, entry):
46 self.character[self.display_name] = entry.get_text()
48 def demand_menu(self, unused=None, unused2=None, unused3=None):
49 print 'Demanding menu for text %s' % (self.menu_name)
50 self.overlord.target = self
51 self.overlord.show_menu(self.menu_name)
53 def add_menu_item(self, menu_item):
54 self.entry.set_text(menu_item.name)
56 def on_increment(self, widget=None):
57 pass
58 def on_decrement(self, widget=None):
59 pass
61 def get_vbox(self):
62 return self.vbox