Index: prepareQMX.GUI.py
===================================================================
--- prepareQMX.GUI.py	(revision 15)
+++ prepareQMX.GUI.py	(revision 16)
@@ -10,12 +10,13 @@
 #---------------------------------------------------------------------------------------------------
 from Tkinter import *
 from copy import deepcopy
+import tkFileDialog
 import StringIO, os
 
 #---------------------------------------------------------------------------------------------------
 from qmxEMBED import embedDefinitions
 from qmxJOB import jobDefinitions
-from qmxSTR import strDefinitions
+from qmxSTR import strClusterDefinitions, strSystemDefinitions
 from qmxCALC import calcDefinitions, QmxCalcDefinition
 
 from qmxWRITE import writeData
@@ -24,27 +25,24 @@
 #---------------------------------------------------------------------------------------------------
 #---------------------------------------------------------------------------------------------------
 class MyLabelFrame(LabelFrame):
-    def __init__(self, mainWnd, master, title, def_list, extras):
+    def __init__(self, mainWnd, master, title, name, def_list, fields):
         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
+            definition_new.system = name
             self.definitions.append(definition_new)
 
-        fields=['import', 'class', 'class.options']
-        if extras is not None:
-            for key in extras:
-                fields.append(key)
+        if fields is None:
+            fields = ['']
 
         self.entries=[]
         for key in fields:
             text=StringVar()
             text.set('')
-            self.entries.append((key, text, Entry(self, textvariable=text, width=15)))
+            self.entries.append((key, text, Entry(self, textvariable=text, width=25)))
             
     def grid(self, **arguments):
         LabelFrame.grid(self, arguments, sticky=(N+W+E))
@@ -54,18 +52,18 @@
     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)
+            Label(self, text=key, width=15, anchor=W).grid(row=irow,  column=2)
+            textfield.grid(row=irow, column=3)
             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=Listbox(self, yscrollcommand=scrollbar.set, height=5, width=15, selectmode=SINGLE, exportselection=0)
+        self.listbox.grid(row=0, column=0, rowspan=irow, sticky=NS)
         self.listbox.bind('<ButtonRelease-1>', self.select)
 
         scrollbar.config(command=self.listbox.yview)
-        scrollbar.grid(row=0, column=4, rowspan=irow, sticky=NS)
+        scrollbar.grid(row=0, column=1, rowspan=irow, sticky=NS)
        
         for item in self.definitions:
             self.listbox.insert(END, item.name)
@@ -93,80 +91,65 @@
     def __init__(self, master):
         Frame.__init__(self, master)
         
-        #--- Structures ---
-        bigFrame = LabelFrame(self, text='Structures')
-        irow=0; icol=0
-        def_list=embedDefinitions
-        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)
-
-        icol+=1;
-        for label in ['System', 'Cluster']:
-            def_list=strDefinitions
-            frame=MyLabelFrame(self, bigFrame, label, def_list, None)
-            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=[QmxCalcDefinition()]
-        frame=MyLabelFrame(self, bigFrame, 'Qmx', def_list, None)
-        frame.doLayout()
-        frame.grid(row=irow, column=icol)
-        self.frames.append(frame)
-
-        icol+=1
-        for label in ['Low-Level', 'High-Level']:
-            def_list=calcDefinitions
-            frame=MyLabelFrame(self, bigFrame, label, def_list, None)
-            frame.doLayout()
-            frame.grid(row=irow, column=icol)
-            self.frames.append(frame)
-            icol+=1
-        bigFrame.grid(row=1, columnspan=3)
+        fields=['import', 'class', 'class.options']
         
-        #--- General ---
-        bigFrame = LabelFrame(self, text='General')
-        extras=['method', 'method.options']
-        frame=MyLabelFrame(self, bigFrame, 'Job', jobDefinitions, 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)
+        irow=0
+        for calcLabel, strLabel, strDefinitions in (
+                ("high-level",  "cluster", strClusterDefinitions), 
+                ("low-level",  "system", strSystemDefinitions)):
+            #column
+            icolLocal=0;
+            #build outFrame
+            outFrame = LabelFrame(self, text=calcLabel+" method - "+strLabel)
+            outFrame.grid(row=irow, columnspan=3,  sticky=W, pady=5)
+            irow+=1
+            
+            for title, def_list in ((calcLabel, calcDefinitions),  (strLabel, strDefinitions)):
+                # build frame
+                myFrame=MyLabelFrame(self, outFrame, title, title, def_list, fields)
+                myFrame.doLayout()
+                myFrame.grid(row=0, column=icolLocal, padx=5, pady=5)
+                # add frame for analyssis
+                self.frames.append(myFrame)
+                # move column
+                icolLocal += 1
+            
+        outFrame = LabelFrame(self, text="General")
+        outFrame.grid(row=irow, columnspan=3, pady=5); irow+=1
+        for title, name, def_list, extra_list,  irowLocal, icolLocal,  irspan in (
+            ("Optimization Method",  "job", jobDefinitions, fields + ['method', 'method.options'], 0, 0, 2), 
+            ("Embedding Method", "embed", embedDefinitions, fields + ['set_calculator'], 0, 1, 1), 
+            ("Hybrid Method", "hybrid", [QmxCalcDefinition()], fields, 1, 1, 1)):
+            # build frame
+            myFrame=MyLabelFrame(self, outFrame, title, name, def_list, extra_list)
+            myFrame.doLayout()
+            myFrame.grid(row=irowLocal, column=icolLocal,  rowspan=irspan, padx=5, pady=5)
+            # add frame for analyssis
+            self.frames.append(myFrame)
+            
+        outFrame=LabelFrame(self, text="PREVIEW")
+        scrollbar=Scrollbar(outFrame, orient=VERTICAL)
         scrollbar.set(0.0, 1.0)
-        self.text=Text(frame, yscrollcommand=scrollbar.set, width=60, heigh=10, state=DISABLED)
+        self.text=Text(outFrame, yscrollcommand=scrollbar.set, width=80, 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)
+        outFrame.grid(row=irow, column=0, sticky=W, pady=5);
 
-        frame = Frame(self)
-
-        #image = PhotoImage(file="exit.gif")
-        buttonExit=Button(frame, text="Quit!", command=self.quit)
-        #buttonExit.image = image
+        myFrame = Frame(self)
+        buttonExit=Button(myFrame, text="Quit!", command=self.quit)
         buttonExit.grid(row=1, column = 1, rowspan=3, sticky= W+E+N+S)
         
-        buttonSave=Button(frame, text='save settings', state=DISABLED)
+        buttonSave=Button(myFrame, text='save settings', state=DISABLED)
         buttonSave.grid(row=1, column = 2, sticky=(EW))
 
-        buttonScript=Button(frame, text='Write qmx.in input file', command=self.writeScript)
+        buttonScript=Button(myFrame, text='Write SCRIPT file', command=self.writeScript)
         buttonScript.grid(row=2, column = 2, sticky=EW)
 
-        buttonPython=Button(frame, text='Write qmx.py script file', command=self.writePython)
+        buttonPython=Button(myFrame, text='Write PYTHON file', command=self.writePython)
         buttonPython.grid(row=3, column = 2, sticky=EW)
 
-        frame.grid(row=2, column=2, sticky=SE)
+        myFrame.grid(row=irow, column=2, sticky=SE)
 
         #--- MainWindow ---
         self.grid(sticky=(W+N+S+E))
@@ -176,7 +159,10 @@
         quit()
     
     def writePython(self):
-        file = open("qmx.py","w")
+        fileName = tkFileDialog.asksaveasfile(mode='w')
+        if fileName is None:
+            return
+        file = open(fileName,"w")
         definitions=[]
         for frame in self.frames:
             definition = frame.getSelection()
@@ -189,7 +175,10 @@
         
         
     def writeScript(self):
-        file = open("qmx.in","w")
+        fileName = tkFileDialog.asksaveasfile(mode='w')
+        if fileName is None:
+            return
+        file = open(fileName,"w")
         for frame in self.frames:
             definition = frame.getSelection()
             if definition is None:
