2006-04-05 23:27:14 +02:00
|
|
|
#!/usr/bin/env python -v
|
|
|
|
|
|
|
|
class KeywordGeneratorFrontend:
|
|
|
|
'this class handles the gui'
|
|
|
|
|
|
|
|
import kg_calc
|
|
|
|
import sys,string
|
|
|
|
|
|
|
|
def __init__(self, gtkext):
|
|
|
|
# gtk is given, it has to be known in the whole class
|
|
|
|
self.gtk = gtkext
|
|
|
|
# define which gladefile to use for frontend
|
|
|
|
gladefile = "kg-frontend/kg-frontend.glade"
|
|
|
|
self.gui = self.gtk.glade.XML(gladefile)
|
|
|
|
# set button handlers
|
|
|
|
actions = { "on_bu_ok_clicked": self.clicked_ok,
|
2006-04-07 00:02:32 +02:00
|
|
|
"on_bu_filechoose_clicked": self.choose_file,
|
|
|
|
"on_bu_exit_clicked": self.exit,
|
2006-04-05 23:27:14 +02:00
|
|
|
"on_window1_destroy": self.exit }
|
|
|
|
# connect the actions to the events
|
|
|
|
self.gui.signal_autoconnect (actions)
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
#### implementation of actions
|
|
|
|
|
|
|
|
def clicked_ok(self, widget):
|
|
|
|
'read input fields and print them'
|
|
|
|
#self.gui.get_widget("tf_output").set_text("saved to file")
|
|
|
|
entry1 = self.gui.get_widget("entry1").get_text()
|
|
|
|
entry2 = self.gui.get_widget("entry2").get_text()
|
|
|
|
entry3 = self.gui.get_widget("entry3").get_text()
|
|
|
|
kg = self.kg_calc.KeywordGenerator()
|
|
|
|
self.keywords = kg.generate_keywords(entry1,entry2,entry3)
|
|
|
|
self.outputfield = self.gui.get_widget("tf_output")
|
|
|
|
self.textbuffer = self.outputfield.get_buffer()
|
|
|
|
self.textbuffer.set_text(self.keywords)
|
|
|
|
|
2006-04-07 00:02:32 +02:00
|
|
|
def choose_file(self, widget):
|
|
|
|
import filechooser
|
|
|
|
fcd = filechooser.FileChooserDialog()
|
|
|
|
filename = fcd.getfilename()
|
|
|
|
if filename:
|
|
|
|
print "hier haste den dateinamen, mach damit was du willst :)"
|
|
|
|
print filename
|
|
|
|
else:
|
|
|
|
self.outputfield = self.gui.get_widget("tf_output")
|
|
|
|
self.textbuffer = self.outputfield.get_buffer()
|
|
|
|
self.textbuffer.set_text("Du hast leider keine Datei ausgewaehlt")
|
|
|
|
|
2006-04-05 23:27:14 +02:00
|
|
|
def exit(self, widget):
|
|
|
|
print "schiss digga"
|
|
|
|
self.sys.exit(1)
|
|
|
|
|
|
|
|
|