コード例 #1
0
 def __init__basic_setup(self):
   conversation = gtk.TreeStore(object, object, str)
   self.conv_tree = ConvTree(self, conversation)
   self.conv_area.add(self.conv_tree)
コード例 #2
0
class GUI(object):

  def __init__(self):
    self.__init_gui()
    gtk.main()

  def __init_gui(self):
    self.__init__aliases()
    self.__init__basic_setup()
    self.__init__connections()

  def __init__aliases(self):
    self.builder = gtk.Builder()
    self.builder.add_from_file(GnomeConfig.main_gui)
    self.gui = self.builder.get_object('main_window')
    self.conv_area = self.builder.get_object('conv_area')

    # The expanded fields
    self.default_text = self.builder.get_object('default_text')
    self.female_text  = self.builder.get_object('female_text')

    # The checkboxes
    self.skippable_check    = self.builder.get_object('skippable_check')
    self.question_check    = self.builder.get_object('question_check')
    self.persistence_check = self.builder.get_object('persistence_check')
    self.display_check     = self.builder.get_object('display_check')


  def __init__basic_setup(self):
    conversation = gtk.TreeStore(object, object, str)
    self.conv_tree = ConvTree(self, conversation)
    self.conv_area.add(self.conv_tree)

  def __init__connections(self):
    SIGNAL_CONNECTIONS_DIC = {
      "on_destroy": self.destroy,
      "on_load": self.on_load,
      "button-press-event": self.button_press
                              }
    self.builder.connect_signals(SIGNAL_CONNECTIONS_DIC)
    
    # Add listeners   
    self.gui.connect("key-press-event", self.button_press)
    self.conv_tree.connect("cursor-changed", self.cursor_changed, None)

  def line_selected(self):
    tree_store, tree_iter = self.conv_tree.get_selection().get_selected()
    model = self.conv_tree.get_model()

    if tree_iter:
      return model.get_path(tree_iter) 
    else:
      return None

  def button_press(self, widget, ev):
    try:
      selected = self.line_selected()
      if ev.keyval == 65361L and selected:
        self.conv_tree.collapse_row(selected)
      
      elif ev.keyval == 65363L and selected:
        self.conv_tree.expand_to_path(selected)