def button_open(entry):
			d = gtk.FileChooserDialog(title='Open Hidden Markov Model',
			                          action=gtk.FILE_CHOOSER_ACTION_OPEN,
			                          buttons=(gtk.STOCK_CANCEL, \
			                                   gtk.RESPONSE_CANCEL, \
			                                   gtk.STOCK_OPEN, \
			                                   gtk.RESPONSE_OK),
			                          parent=self)
			d.set_select_multiple(False)
			d.set_default_response(gtk.RESPONSE_OK)

			filter = gtk.FileFilter()
			filter.set_name('Hidden Markov Model')
			#filter.add_mime_type('text/*')
			for ext1 in ('.txt', '.hmm'):
				for ext2 in ('', '.gz', '.bz2'):
					filter.add_pattern('*' + ext1 + ext2)
			d.add_filter(filter)

			filter = gtk.FileFilter()
			filter.set_name('All files')
			filter.add_mime_type('*/*')
			filter.add_pattern('*')
			d.add_filter(filter)

			response = d.run()
			if response != gtk.RESPONSE_OK:
				d.destroy()
				return
			file_name = d.get_filename()

			self.hmm = HiddenMarkovModel.load(open(file_name, 'rb'))
			d.destroy()
		def button_save_as(entry):
			d = gtk.FileChooserDialog(title=None,
			                          action=gtk.FILE_CHOOSER_ACTION_SAVE,
			                          buttons=(gtk.STOCK_CANCEL, \
			                                   gtk.RESPONSE_CANCEL, \
			                                   gtk.STOCK_SAVE, \
			                                   gtk.RESPONSE_OK),
			                          parent=self)
			d.set_select_multiple(False)
			d.set_default_response(gtk.RESPONSE_OK)

			response = d.run()
			if response != gtk.RESPONSE_OK:
				d.destroy()
				return
			file_name = d.get_filename()

			self.hmm.dump(fp=open(file_name, 'wb'), indent=2)
			d.destroy()
def load_default_hmm():
	return HiddenMarkovModel.load(open(join(dirname(abspath(__file__)),
			pardir, pardir, 'default_model.hmm'), 'rb'))