[Avida-cvs] [Avida2-svn] r54 - trunk/source/python/AvidaGui2

baerb at myxo.css.msu.edu baerb at myxo.css.msu.edu
Tue Mar 15 12:19:52 PST 2005


Author: baerb
Date: 2005-03-15 15:19:52 -0500 (Tue, 15 Mar 2005)
New Revision: 54

Modified:
   trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
   trunk/source/python/AvidaGui2/pyPetriConfigureView.py
   trunk/source/python/AvidaGui2/pyPetriConfigureView.ui
Log:
Changed interface code.

Added code to allow writing to the Freezer (not complete)



Modified: trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-03-15 20:16:28 UTC (rev 53)
+++ trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2005-03-15 20:19:52 UTC (rev 54)
@@ -3,44 +3,83 @@
 from AvidaCore import cConfig
 from qt import *
 from pyPetriConfigureView import pyPetriConfigureView
+from pyWriteGenesis import pyWriteGenesis
 
 
 class pyPetriConfigureCtrl(pyPetriConfigureView):
 
   def __init__(self,parent = None,name = None,fl = 0):
     pyPetriConfigureView.__init__(self,parent,name,fl)
-    self.connect(self.MutationSlider, SIGNAL("valueChanged(int)"), 
-      self.ChangeMutationText)
-    self.connect(self.WorldSizeSlider, SIGNAL("valueChanged(int)"), 
-      self.ChangeWorldSizeText)
 
   def construct(self, session_mdl):
     self.m_session_mdl = session_mdl
     self.m_session_petri_view = pyPetriConfigureView()
+    self.connect(self.MutationSlider, SIGNAL("valueChanged(int)"), 
+      self.ChangeMutationTextSlot)
+    self.connect(self.WorldSizeSlider, SIGNAL("valueChanged(int)"), 
+      self.ChangeWorldSizeTextSlot)
+    self.connect(self.DieYesButton, SIGNAL("clicked()"), 
+      self.ChangeDeathTextSlot)
+    self.connect(self.DieNoButton, SIGNAL("clicked()"), 
+      self.ChangeDeathTextSlot)
+    self.connect(self.RadomGeneratedRadioButton, SIGNAL("clicked()"), 
+      self.ChangeRandomSpinBoxSlot)
+    self.connect(self.RandomFixedRadioButton, SIGNAL("clicked()"), 
+      self.ChangeRandomSpinBoxSlot)
+    self.connect(self.StopManuallyRadioButton, SIGNAL("clicked()"), 
+      self.ChangeStopSpinBoxSlot)
+    self.connect(self.StopAtRadioButton, SIGNAL("clicked()"), 
+      self.ChangeStopSpinBoxSlot)
+    self.connect(self.SavePetriPushButton, SIGNAL("clicked()"), 
+      PYSIGNAL("freezeDishPhaseISig"))
+    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("freezeDishPhaseIISig"), 
+      self.FreezePetriSlot)
     self.connect(self.m_session_mdl.m_session_mdtr,
       PYSIGNAL("doDefrostDishSig"), self.FillDishSlot)
-    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("setAvidaSig"),
+    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doInitializeAvidaPhaseISig"),
       self.DisablePetriConfigureSlot)
+    self.connect(self.m_session_mdl.m_session_mdtr, PYSIGNAL("doInitializeAvidaPhaseISig"),
+      self.CreateFilesFromPetriSlot)
     self.populated = False
-    self.run_started = False
+    self.run_started = False    
 
-  def ChangeMutationText(self):
+  def ChangeMutationTextSlot(self):
     slide_value_txt = str(float(self.MutationSlider.value())/10.0) + "%"
     self.MutationPercentTextLabel.setText(slide_value_txt)
 
-  def ChangeWorldSizeText(self):
+  def ChangeWorldSizeTextSlot(self):
     slide_value = str(self.WorldSizeSlider.value())
     slide_value_txt = slide_value + " x " + slide_value + " cells"
     self.WorldSizeTextLabel.setText(slide_value_txt)
 
+  def ChangeDeathTextSlot(self):
+    if self.DieYesButton.isChecked() == False:
+      self.DeathTextLabel2.setEnabled(False)
+      self.DeathTextLabel3.setEnabled(False)
+      self.LifeSpanSpinBox.setEnabled(False)
+    else:
+      self.DeathTextLabel2.setEnabled(True)
+      self.DeathTextLabel3.setEnabled(True)
+      self.LifeSpanSpinBox.setEnabled(True)
+
+  def ChangeRandomSpinBoxSlot(self):
+    if self.RadomGeneratedRadioButton.isChecked() == True:
+      self.RandomSpinBox.setEnabled(False)
+    else:
+      self.RandomSpinBox.setEnabled(True)
+  
+  def ChangeStopSpinBoxSlot(self):
+    if self.StopManuallyRadioButton.isChecked() == True:
+      self.StopAtSpinBox.setEnabled(False)
+    else:
+      self.StopAtSpinBox.setEnabled(True)
+  
   def FillDishSlot(self, petri_info):
-    print "called FillDish"
-    print petri_info.file_name
     settings_info =  petri_info.dictionary["SETTINGS"]
     self.AncestorComboBox.removeItem (0)
     start_creature = settings_info["START_CREATURE"]
-    self.AncestorComboBox.insertItem(start_creature[0])
-    max_updates = int(settings_info["MAX_UPDATES"][0])
+    self.AncestorComboBox.insertItem(start_creature)
+    max_updates = int(settings_info["MAX_UPDATES"])
     self.StopAtSpinBox.setValue(max_updates)
     if max_updates < 0:
        self.StopManuallyRadioButton.setChecked(True)
@@ -48,8 +87,8 @@
     else:
        self.StopManuallyRadioButton.setChecked(False)
        self.StopAtRadioButton.setChecked(True)
-    self.WorldSizeSlider.setValue(int(settings_info["WORLD-X"][0]))
-    seed = int(settings_info["RANDOM_SEED"][0])
+    self.WorldSizeSlider.setValue(int(settings_info["WORLD-X"]))
+    seed = int(settings_info["RANDOM_SEED"])
     self.RandomSpinBox.setValue(seed)
     if seed == 0:
        self.RadomGeneratedRadioButton.setChecked(True)
@@ -57,21 +96,28 @@
     else:
        self.RadomGeneratedRadioButton.setChecked(False)
        self.RandomFixedRadioButton.setChecked(True)
-    copy_mutation_percent = float(settings_info["COPY_MUT_PROB"][0]) * 100;
+    copy_mutation_percent = float(settings_info["COPY_MUT_PROB"]) * 100;
     self.MutationSlider.setValue(int(copy_mutation_percent * 10))
-    if int(settings_info["BIRTH_METHOD"][0]) in [0, 1, 2, 3]:
+    if int(settings_info["BIRTH_METHOD"]) in [0, 1, 2, 3]:
        self.LocalBirthRadioButton.setChecked(True)
        self.MassActionRadioButton.setChecked(False)
     else:
        self.LocalBirthRadioButton.setChecked(False)
        self.MassActionRadioButton.setChecked(True)
-    self.LifeSpanSpinBox.setValue(int(settings_info["AGE_LIMIT"][0]))
-    if int(settings_info["DEATH_METHOD"][0]) == 0:
+    self.LifeSpanSpinBox.setValue(int(settings_info["AGE_LIMIT"]))
+    if int(settings_info["DEATH_METHOD"]) == 0:
        self.DieNoButton.setChecked(True)
        self.DieYesButton.setChecked(False)
+       self.DeathTextLabel2.setEnabled(False)
+       self.DeathTextLabel3.setEnabled(False)
+       self.LifeSpanSpinBox.setEnabled(False)
     else:
        self.DieNoButton.setChecked(False)
        self.DieYesButton.setChecked(True)
+       self.DeathTextLabel2.setEnabled(True)
+       self.DeathTextLabel3.setEnabled(True)
+       self.LifeSpanSpinBox.setEnabled(True)
+       
 
   def DisablePetriConfigureSlot(self):
     print "called DisablePetriConfigureSlot"
@@ -101,3 +147,44 @@
     self.StopHeadTextLabel.setEnabled(False)
     self.DeathTextLabel2.setEnabled(False)
     self.DeathTextLabel3.setEnabled(False)
+
+  def CreateFilesFromPetriSlot(self, out_dir = None):
+    tmp_dict = self.Form2Dictionary()
+    write_object = pyWriteGenesis(tmp_dict, "freezer/", "test/")
+    self.m_session_mdl.m_session_mdtr.emit(
+      PYSIGNAL("doInitializeAvidaPhaseIISig"), ("test/genesis.avida",))
+      
+  def Form2Dictionary(self):
+    tmp_dict = {}
+    settings_info = {}
+    
+    settings_info["START_CREATURE"] = str(self.AncestorComboBox.text(0))
+    if (self.StopAtRadioButton.isChecked() == True):
+      settings_info["MAX_UPDATES"] = self.StopAtSpinBox.value()
+    else:
+      settings_info["MAX_UPDATES"] = -1
+    settings_info["WORLD-X"] = self.WorldSizeSlider.value()
+    settings_info["WORLD-Y"] = self.WorldSizeSlider.value()
+    if self.RandomFixedRadioButton.isChecked == True:
+      settings_info["RANDOM_SEED"] = self.RandomSpinBox.value()
+    else:
+      settings_info["RANDOM_SEED"] = 0
+    settings_info["COPY_MUT_PROB"] = float(self.MutationSlider.value())/1000.0
+    if self.LocalBirthRadioButton.isChecked() == True:
+      settings_info["BIRTH_METHOD"] = 0
+    else:
+      settings_info["BIRTH_METHOD"] = 0
+    settings_info["AGE_LIMIT"] = self.LifeSpanSpinBox.value()
+    if self.DieNoButton.isChecked() == True:
+      settings_info["DEATH_METHOD"] = 0
+    else:
+      settings_info["DEATH_METHOD"] = 2
+    tmp_dict["SETTINGS"] = settings_info
+    return tmp_dict
+    
+  def FreezePetriSlot(self, freeze_dir = None, population_dict = None):
+    print "called FreezePetriSlot"
+    tmp_dict = self.Form2Dictionary()
+    tmp_dict["POPULATION"] = population_dict
+    print tmp_dict
+    
\ No newline at end of file

Modified: trunk/source/python/AvidaGui2/pyPetriConfigureView.py
===================================================================
--- trunk/source/python/AvidaGui2/pyPetriConfigureView.py	2005-03-15 20:16:28 UTC (rev 53)
+++ trunk/source/python/AvidaGui2/pyPetriConfigureView.py	2005-03-15 20:19:52 UTC (rev 54)
@@ -2,7 +2,7 @@
 
 # Form implementation generated from reading ui file 'pyPetriConfigureView.ui'
 #
-# Created: Tue Mar 8 10:54:37 2005
+# Created: Mon Mar 14 14:51:31 2005
 #      by: The PyQt User Interface Compiler (pyuic) 3.14
 #
 # WARNING! All changes made in this file will be lost!
@@ -116,6 +116,7 @@
         layout92 = QVBoxLayout(None,0,6,"layout92")
 
         self.DeathTextLabel2 = QLabel(self,"DeathTextLabel2")
+        self.DeathTextLabel2.setEnabled(0)
         DeathTextLabel2_font = QFont(self.DeathTextLabel2.font())
         self.DeathTextLabel2.setFont(DeathTextLabel2_font)
         layout92.addWidget(self.DeathTextLabel2)
@@ -123,12 +124,14 @@
         layout91 = QHBoxLayout(None,0,6,"layout91")
 
         self.LifeSpanSpinBox = QSpinBox(self,"LifeSpanSpinBox")
+        self.LifeSpanSpinBox.setEnabled(0)
         self.LifeSpanSpinBox.setMaxValue(99999)
         self.LifeSpanSpinBox.setMinValue(1)
         self.LifeSpanSpinBox.setValue(10)
         layout91.addWidget(self.LifeSpanSpinBox)
 
         self.DeathTextLabel3 = QLabel(self,"DeathTextLabel3")
+        self.DeathTextLabel3.setEnabled(0)
         DeathTextLabel3_font = QFont(self.DeathTextLabel3.font())
         self.DeathTextLabel3.setFont(DeathTextLabel3_font)
         layout91.addWidget(self.DeathTextLabel3)
@@ -161,6 +164,7 @@
         layout85.addWidget(self.RandomFixedRadioButton)
 
         self.RandomSpinBox = QSpinBox(self,"RandomSpinBox")
+        self.RandomSpinBox.setEnabled(0)
         RandomSpinBox_font = QFont(self.RandomSpinBox.font())
         self.RandomSpinBox.setFont(RandomSpinBox_font)
         self.RandomSpinBox.setMaxValue(32767)
@@ -252,6 +256,7 @@
         layout81.addWidget(self.StopAtRadioButton)
 
         self.StopAtSpinBox = QSpinBox(self.StopButtonGroup,"StopAtSpinBox")
+        self.StopAtSpinBox.setEnabled(0)
         StopAtSpinBox_font = QFont(self.StopAtSpinBox.font())
         self.StopAtSpinBox.setFont(StopAtSpinBox_font)
         self.StopAtSpinBox.setMaxValue(10000000)
@@ -263,9 +268,14 @@
         layout83.addWidget(self.StopButtonGroup)
         pyPetriConfigureViewLayout.addLayout(layout83)
 
+        self.SavePetriPushButton = QPushButton(self,"SavePetriPushButton")
+        SavePetriPushButton_font = QFont(self.SavePetriPushButton.font())
+        self.SavePetriPushButton.setFont(SavePetriPushButton_font)
+        pyPetriConfigureViewLayout.addWidget(self.SavePetriPushButton)
+
         self.languageChange()
 
-        self.resize(QSize(309,414).expandedTo(self.minimumSizeHint()))
+        self.resize(QSize(309,451).expandedTo(self.minimumSizeHint()))
         self.clearWState(Qt.WState_Polished)
 
         self.connect(self.RadomGeneratedRadioButton,SIGNAL("clicked()"),self.RandomFixedRadioButton.toggle)
@@ -294,7 +304,7 @@
         self.RandomFixedRadioButton.setText(self.__tr("Set at"))
         self.AncestorHeadTextLabel.setText(self.__tr("Ancestral Organism(s)"))
         self.AncestorComboBox.clear()
-        self.AncestorComboBox.insertItem(self.__tr("<default>"))
+        self.AncestorComboBox.insertItem(self.__tr("default.organism"))
         self.AncestorComboBox.setCurrentItem(0)
         self.BirthHeadTextLabel.setText(self.__tr("Where should new organism be placed?"))
         self.BirthButtonGroup.setTitle(QString.null)
@@ -305,6 +315,7 @@
         self.StopManuallyRadioButton.setText(self.__tr("Manually"))
         self.StopAtRadioButton.setText(QString.null)
         self.StopAtSpinBox.setSuffix(self.__tr(" updates"))
+        self.SavePetriPushButton.setText(self.__tr("Freeze Petri Dish"))
 
 
     def __tr(self,s,c = None):

Modified: trunk/source/python/AvidaGui2/pyPetriConfigureView.ui
===================================================================
--- trunk/source/python/AvidaGui2/pyPetriConfigureView.ui	2005-03-15 20:16:28 UTC (rev 53)
+++ trunk/source/python/AvidaGui2/pyPetriConfigureView.ui	2005-03-15 20:19:52 UTC (rev 54)
@@ -9,7 +9,7 @@
             <x>0</x>
             <y>0</y>
             <width>309</width>
-            <height>414</height>
+            <height>451</height>
         </rect>
     </property>
     <property name="font">
@@ -311,6 +311,9 @@
                                     <property name="name">
                                         <cstring>DeathTextLabel2</cstring>
                                     </property>
+                                    <property name="enabled">
+                                        <bool>false</bool>
+                                    </property>
                                     <property name="font">
                                         <font>
                                         </font>
@@ -331,6 +334,9 @@
                                             <property name="name">
                                                 <cstring>LifeSpanSpinBox</cstring>
                                             </property>
+                                            <property name="enabled">
+                                                <bool>false</bool>
+                                            </property>
                                             <property name="maxValue">
                                                 <number>99999</number>
                                             </property>
@@ -348,6 +354,9 @@
                                             <property name="name">
                                                 <cstring>DeathTextLabel3</cstring>
                                             </property>
+                                            <property name="enabled">
+                                                <bool>false</bool>
+                                            </property>
                                             <property name="font">
                                                 <font>
                                                 </font>
@@ -430,6 +439,9 @@
                             <property name="name">
                                 <cstring>RandomSpinBox</cstring>
                             </property>
+                            <property name="enabled">
+                                <bool>false</bool>
+                            </property>
                             <property name="font">
                                 <font>
                                 </font>
@@ -492,7 +504,7 @@
                 <widget class="QComboBox">
                     <item>
                         <property name="text">
-                            <string>&lt;default&gt;</string>
+                            <string>default.organism</string>
                         </property>
                     </item>
                     <property name="name">
@@ -668,6 +680,9 @@
                                     <property name="name">
                                         <cstring>StopAtSpinBox</cstring>
                                     </property>
+                                    <property name="enabled">
+                                        <bool>false</bool>
+                                    </property>
                                     <property name="font">
                                         <font>
                                         </font>
@@ -694,6 +709,18 @@
                 </widget>
             </vbox>
         </widget>
+        <widget class="QPushButton">
+            <property name="name">
+                <cstring>SavePetriPushButton</cstring>
+            </property>
+            <property name="font">
+                <font>
+                </font>
+            </property>
+            <property name="text">
+                <string>Freeze Petri Dish</string>
+            </property>
+        </widget>
     </vbox>
 </widget>
 <connections>




More information about the Avida-cvs mailing list