示例#1
0
 def key_pressed(self, widget, event):
     # F2 to convert the selected text to devanagari
     if event.keyval == 65471:
         try:
             start, end = self.textbuffer.get_selection_bounds()
             text = start.get_text(end)
             self.textbuffer.delete(start, end)
             devanagari_string = devanagari("hk", text)
             self.textbuffer.insert_at_cursor(devanagari_string)
         except ValueError:
             pass
     # F5 to toggle editing mode
     elif event.keyval == 65474:
         if self.Mode == 'Devanagari':
             self.window.disconnect(self.handler)
             self.Mode = 'Roman'
         else:
             self.handler = self.window.connect("key_release_event", self.key_released)
             self.Mode = 'Devanagari'
示例#2
0
 def key_pressed(self, widget, event):
     # F5
     if event.keyval == 65474:
         start, end = self.textbuffer_src.get_bounds()
         hk_string = self.textbuffer_src.get_text(start, end)
         devanagari_string = devanagari("hk", hk_string)
         self.textbuffer.set_text(devanagari_string)
         self.textview.set_buffer(self.textbuffer)
     # F1 to display transliteration help
     elif event.keyval == 65470:
         self.textbuffer.set_text(help_string)
         self.textview.set_buffer(self.textbuffer)
     # F2 to save the source file
     elif event.keyval == 65471:
         self.save_src_file()
     # F3 to save the destination file
     elif event.keyval == 65472:
         self.save_devanagari_file()            
     # CTRL + s
     elif event.keyval == 115:
         if event.state & gtk.gdk.CONTROL_MASK:
             self.save_src_file()
示例#3
0
 def transcode_the_text(self, widget):
     start, end = self.textbuffer_src.get_bounds()
     hk_string = self.textbuffer_src.get_text(start, end)
     devanagari_string = devanagari("hk", hk_string)
     self.textbuffer.set_text(devanagari_string)
     self.textview.set_buffer(self.textbuffer)