Index: README.txt
===================================================================
--- README.txt	(revision 8)
+++ README.txt	(revision 9)
@@ -1,5 +1,5 @@
 ==========
 Python ASE
 ==========
-
+ 
 Webpage: http://wiki.fysik.dtu.dk/ase
Index: prepareQMX.py
===================================================================
--- prepareQMX.py	(revision 8)
+++ prepareQMX.py	(revision 9)
@@ -31,9 +31,12 @@
     line = getline(section, "program", lines)
     if line is None:
         line=""
-    if True or line.lower() == "turbomole":
+    if line.lower() == "turbomole":
         data.str_import = "from ase.io.turbomole import read_turbomole"
         data.str_class = "read_turbomole"
+    elif line.lower() == "vasp":
+        data.str_import = "from ase.io.vasp import read_vasp"
+        data.str_class = "read_vasp"
         
     data.str_structure = getline(section, "structure", lines)
     return data
Index: prepareQMX.GUI.py
===================================================================
--- prepareQMX.GUI.py	(revision 8)
+++ prepareQMX.GUI.py	(revision 9)
@@ -1,35 +1,310 @@
 #!/usr/bin/env python
 from Tkinter import *
+from copy import deepcopy
+import StringIO
 
+#-------------------------------------------------------------------------------
+#--- GENERAL -------------------------------------------------------------------
+#-------------------------------------------------------------------------------
+class Definition(object):
+    def getValue(self, key):
+        if self.keywords.__contains__(key):
+            return self.keywords[key]
+        return ''
+        
+#-------------------------------------------------------------------------------
+#--- STR DEFINITIONS -----------------------------------------------------------
+#-------------------------------------------------------------------------------
+class VASPStrDefinition(Definition):
+    def __init__(self):
+        self.name='VASP'
+        self.keywords = {}
+        self.keywords['import']='ase.io.vasp'
+        self.keywords['class']='read_vasp'
+        self.keywords['class.options']="'POSCAR'"
+    
+#-------------------------------------------------------------------------------
+class TURBOMOLEStrDefintion(Definition):
+    def __init__(self):
+        self.name='TURBOMOLE'
+        self.keywords = {}
+        self.keywords['import']='ase.io.turbomole'
+        self.keywords['class']='read_turbomole'
+        self.keywords['class.options']="'coord'"
 
-class ScrolledList(Frame):
-    def __init__(self, options, parent=None):
-        Frame.__init__(self, parent)
-        self.pack(expand=YES, fill=BOTH)                  
-        self.makeWidgets(options)
+#-------------------------------------------------------------------------------
+class EmbedStrDefinition(Definition):
+    def __init__(self):
+        self.name='Embed'
+        self.system='Embed'
+        self.keywords = {}
+        self.keywords['import']='ase.embed'
+        self.keywords['class']='Embed'
+        self.keywords['class.options']='system, cluster'
+        self.keywords['method']='embed'
+        self.keywords['calculator']='qmx'
+
+#-------------------------------------------------------------------------------
+#--- PRG DEFINITIONS -----------------------------------------------------------
+#-------------------------------------------------------------------------------
+class VASPPrgDefinition(Definition):
+    def __init__(self):
+        self.name='VASP'
+        self.keywords = {}
+        self.keywords['import']='ase.calculators.vasp'
+        self.keywords['class']='Vasp'
+        self.keywords['class.options']='write_input=False'
+
+#-------------------------------------------------------------------------------
+class QmxPrgDefinition(Definition):
+    def __init__(self):
+        self.name='QMX'
+        self.keywords = {}
+        self.keywords['import']='ase.calculators.qmx'
+        self.keywords['class']='Qmx'
+        self.keywords['class.options']='high_level, low_level'
+
+#-------------------------------------------------------------------------------
+class TURBOMOLEPrgDefinition(Definition):
+    def __init__(self):
+        self.name='TURBOMOLE'
+        self.keywords = {}
+        self.keywords['import']='ase.calculators.turbomole'
+        self.keywords['class']='Turbomole'
+
+#-------------------------------------------------------------------------------
+#--- JOB DEFINITIONS -----------------------------------------------------------
+#-------------------------------------------------------------------------------
+class QNJobDefintion(Definition):
+    def __init__(self):
+        self.name='QuasiNewton'
+        self.keywords = {}
+        self.keywords['import']='ase.optimize'
+        self.keywords['class']= 'QuasiNewton'
+        self.keywords['method']='run'
+
+#-------------------------------------------------------------------------------
+#-------------------------------------------------------------------------------
+#-------------------------------------------------------------------------------
+
+class MyLabelFrame(LabelFrame):
+    def __init__(self, mainWnd, master, title, def_list, extra=[]):
+        LabelFrame.__init__(self, master, text=title)
+        self.mainWnd = mainWnd
+        self.definitions=[]
+        self.title = title
+
+        for definition in def_list:
+            definition_new = deepcopy(definition)
+            definition_new.system = title
+            self.definitions.append(definition_new)
+
+        fields=['import', 'class', 'class.options']
+        for key in extra:
+            fields.append(key)
+
+        self.entries=[]
+        for key in fields:
+            text=StringVar()
+            text.set('')
+            self.entries.append((key, text, Entry(self, textvariable=text, width=15)))
+            
+    def grid(self, **arguments):
+        LabelFrame.grid(self, arguments, sticky=(N+W+E))
+        self.listbox.selection_set(first=0)
+        self.select(None)
         
-    def handleList(self, event):
-        index = self.listbox.curselection()            
-        label = self.listbox.get(index)                
-        self.runCommand(label)                         
+    def doLayout(self):
+        irow=0
+        for (key, text, textfield) in self.entries:
+            Label(self, text=key, width=15, anchor=W).grid(row=irow)
+            textfield.grid(row=irow, column=1)
+            textfield.bind("<KeyRelease>", self.update)
+            irow+=1
+        
+        scrollbar=Scrollbar(self, orient=VERTICAL)
+        self.listbox=Listbox(self, yscrollcommand=scrollbar.set, height=0, width=15, selectmode=SINGLE)
+        self.listbox.grid(row=0, column=2, rowspan=irow, columnspan=2, sticky=NS)
+        self.listbox.bind('<ButtonRelease-1>', self.select)
 
-    def makeWidgets(self, options):                    
-        sbar = Scrollbar(self)
-        list = Listbox(self, relief=SUNKEN)
-        sbar.config(command=list.yview)                
-        list.config(yscrollcommand=sbar.set)              
-        sbar.pack(side=RIGHT, fill=Y)                     
-        list.pack(side=LEFT, expand=YES, fill=BOTH)    
-        pos = 0
-        for label in options:                          
-            list.insert(pos, label)                    
-            pos = pos + 1
+        scrollbar.config(command=self.listbox.yview)
+        scrollbar.grid(row=0, column=4, rowspan=irow, sticky=NS)
+       
+        for item in self.definitions:
+            self.listbox.insert(END, item.name)
+        
+    def select(self, event):
+        selection=self.listbox.curselection()
+        if len(selection) == 1:
+            self.curr_definition=deepcopy(self.definitions[int(selection[0])])
+            for (key, text, textfield) in self.entries:
+                text.set(self.curr_definition.getValue(key))
+        self.mainWnd.preview()
+    
+    def getSelection(self):
+        return self.curr_definition
+        
+    def update(self, event):
+        for (key, text, textfield) in self.entries:
+            self.curr_definition.keywords[key]=text.get()
+        self.mainWnd.preview()
 
-        list.bind('<Double-1>', self.handleList)       
-        self.listbox = list
-    def runCommand(self, selection):                   
-        print 'You selected:', selection
+class MainWindow(Frame):
+    frames=[]
+    text=None
+    def __init__(self, master):
+        Frame.__init__(self, master)
+        
+        #--- Structures ---
+        bigFrame = LabelFrame(self, text='Structures')
+        irow=0; icol=0
+        def_list=[EmbedStrDefinition()]
+        extras=['method', 'method.options', 'calculator']
+        frame=MyLabelFrame(self, bigFrame, 'Embed', def_list, extras)
+        frame.doLayout()
+        frame.grid(row=irow, column=icol)
+        self.frames.append(frame)
 
-if __name__ == '__main__':
-    options = map((lambda x: 'Lumberjack-' + str(x)), range(20))
-    ScrolledList(options).mainloop()
+        icol+=1;
+        def_list=[VASPStrDefinition(), TURBOMOLEStrDefintion()]
+        for label in ['Cluster', 'System']:
+            extras = ['cell']
+            frame=MyLabelFrame(self, bigFrame, label, def_list, extras)
+            frame.doLayout()
+            frame.grid(row=irow, column=icol)
+            self.frames.append(frame)
+            icol+=1
+        bigFrame.grid(row=0, columnspan=3)
+
+        #--- Methods ---
+        bigFrame = LabelFrame(self, text='Methods')
+        irow=0; icol=0
+        def_list=[QmxPrgDefinition()]
+        frame=MyLabelFrame(self, bigFrame, 'Qmx', def_list)
+        frame.doLayout()
+        frame.grid(row=irow, column=icol)
+        self.frames.append(frame)
+
+        icol+=1
+        def_list=[VASPPrgDefinition(), TURBOMOLEPrgDefinition()]
+        for label in ['High-Level', 'Low-Level']:
+            def_list=[VASPPrgDefinition(), TURBOMOLEPrgDefinition()]
+            frame=MyLabelFrame(self, bigFrame, label, def_list)
+            frame.doLayout()
+            frame.grid(row=irow, column=icol)
+            self.frames.append(frame)
+            icol+=1
+        bigFrame.grid(row=1, columnspan=3)
+        
+        #--- General ---
+        bigFrame = LabelFrame(self, text='General')
+        extras=['method', 'method.options']
+        frame=MyLabelFrame(self, bigFrame, 'Job', [QNJobDefintion()], extras)
+        frame.doLayout()
+        frame.grid()
+        self.frames.append(frame)
+        bigFrame.grid(row=2, sticky=NW)
+
+        frame=LabelFrame(self, text="PREVIEW")
+        scrollbar=Scrollbar(frame, orient=VERTICAL)
+        scrollbar.set(0.0, 1.0)
+        self.text=Text(frame, yscrollcommand=scrollbar.set, width=60, heigh=10, state=DISABLED)
+        self.text.grid(sticky=(N+W+S+E))
+        scrollbar.config(command=self.text.yview)
+        scrollbar.grid(row=0, column=1, sticky=NS)        
+        frame.grid(row=2, column=1)
+
+        frame = Frame(self)
+        buttonSave=Button(frame, text='save settings', state=DISABLED)
+        buttonSave.grid(row=1, sticky=(EW))
+
+        buttonPrint=Button(frame, text='Write qmx.py input file', command=self.writeButton)
+        buttonPrint.grid(row=2, sticky=EW)
+
+        frame.grid(row=2, column=2, sticky=SE)
+
+        #--- MainWindow ---
+        self.grid(sticky=(W+N+S+E))
+        self.preview()
+    
+    def writeButton(self):
+        file = open("data","w")
+        self.writeData(file)
+        file.close()
+
+    def writeData(self, stream):
+        keys=['import']
+        definitions=[]
+
+        for frame in self.frames:
+            definition = frame.getSelection()
+            if definition is not None:
+                definitions.append(definition)
+
+        arrImports=[]
+        for definition in definitions:
+            strClass=definition.getValue('class')
+            strImport=definition.getValue('import')
+            
+            if (strClass is not '' and strImport is not ''):
+                s='from '+strImport+' import '+strClass+'\n'
+                if not s in arrImports:
+                    stream.write(s)
+                    arrImports.append(s)
+
+        stream.write("\n")
+        for name in ['High-Level', 'Low-Level', 'Qmx']:
+            for definition in definitions:
+                if definition.system != name:
+                    continue
+                strSystem=definition.system.lower().replace("-", "_")
+                strClass=definition.getValue('class')
+                strOptions=definition.getValue('class.options')
+
+                if (strClass is not ''):
+                    stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
+
+        stream.write("\n")
+        for name in ['System', 'Cluster', 'Embed']:
+            for definition in definitions:
+                if definition.system != name:
+                    continue
+                strSystem=definition.system.lower()
+                strClass=definition.getValue('class')
+                strOptions=definition.getValue('class.options')
+
+                if (strClass is not ''):
+                    stream.write(strSystem+'='+strClass+'('+strOptions+')\n')
+                    
+                if name is 'Embed':
+                    strMethod=definition.getValue('method')
+                    strOptions=definition.getValue('method.options')
+                    stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
+
+                    strOptions=definition.getValue('calculator')
+                    stream.write(strSystem+'.set_calculator('+strOptions+')\n')
+            
+        stream.write("\n")
+        for definition in definitions:
+            if (definition.system == 'Job'):
+                strSystem=definition.system.lower()
+                strMethod=definition.getValue('method')
+                strOptions=definition.getValue('method.options')
+                stream.write(strSystem+'.'+strMethod+'('+strOptions+')\n')
+                
+    def preview(self):
+        stream = StringIO.StringIO()
+        self.writeData(stream)
+        s = stream.getvalue()
+        
+        if self.text is not None:
+            pos, end = self.text.yview()
+            self.text.config(state=NORMAL)
+            self.text.delete(1.0, END)
+            self.text.insert(END, s)
+            self.text.config(state=DISABLED)
+            self.text.yview(MOVETO, pos)
+
+print
+mainWnd=MainWindow(Tk())
+mainWnd.mainloop()
