[Avida-cvs] [Avida2-svn] r219 - trunk/source/python/AvidaGui2
baerb@myxo.css.msu.edu
baerb at myxo.css.msu.edu
Wed Jun 22 17:37:12 PDT 2005
Author: baerb
Date: 2005-06-22 20:37:12 -0400 (Wed, 22 Jun 2005)
New Revision: 219
Modified:
trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
trunk/source/python/AvidaGui2/pySessionCtrl.py
Log:
Further fixes to freezing petri dishes.
Added code to track if petri dish files have been saved will be used when quitting
or starting a new petri dish to check if users will be prompted to save or not.
Modified: trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2005-06-22 01:21:27 UTC (rev 218)
+++ trunk/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2005-06-23 00:37:12 UTC (rev 219)
@@ -274,6 +274,7 @@
self.startStatus = False
def startQuitProcessSlot(self):
+ print "*** full_saved = " + str(self.m_one_population_ctrl.m_session_mdl.saved_full_dish)
m_quit_avida_ed = pyQuitDialogCtrl()
quit_return = m_quit_avida_ed.showDialog()
if quit_return == m_quit_avida_ed.QuitFlag:
Modified: trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py 2005-06-22 01:21:27 UTC (rev 218)
+++ trunk/source/python/AvidaGui2/pyPetriConfigureCtrl.py 2005-06-23 00:37:12 UTC (rev 219)
@@ -67,7 +67,6 @@
self.ChangeMutationTextSlot()
self.ChangeWorldSizeTextSlot()
self.populated = False
- self.run_started = False
def ChangeMutationTextSlot(self):
slide_value = float(self.MutationSlider.value())/100.0
@@ -113,11 +112,12 @@
def FillDishSlot(self, dish_name, petri_dict):
- # Stop from filling the petri dish if the dish is disabled
+ # If the petri dish is already filled prompt the user if they want to freeze
+ # the existing dish
if self.DishDisabled:
self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseISig"),())
- # return
+ return
self.full_petri_dict = petri_dict.dictionary
settings_dict = petri_dict.dictionary["SETTINGS"]
self.AncestorComboBox.removeItem (0)
@@ -165,9 +165,10 @@
self.DeathTextLabel3.setEnabled(True)
self.LifeSpanSpinBox.setEnabled(True)
+ def DisablePetriConfigureSlot(self):
- def DisablePetriConfigureSlot(self):
- self.run_started = False
+ # Turn off the controls
+
self.AncestorComboBox.setEnabled(False)
self.StopAtSpinBox.setEnabled(False)
self.StopManuallyRadioButton.setEnabled(False)
@@ -197,6 +198,40 @@
self.m_session_mdl.m_session_mdtr.emit(
PYSIGNAL("doDisablePetriDishSig"), ())
+ def EnablePetriConfigureSlot(self):
+
+ # Turn on the controls
+
+ self.AncestorComboBox.setEnabled(True)
+ self.StopAtSpinBox.setEnabled(True)
+ self.StopManuallyRadioButton.setEnabled(True)
+ self.StopAtRadioButton.setEnabled(True)
+ self.WorldSizeSlider.setEnabled(True)
+ self.RandomSpinBox.setEnabled(True)
+ self.RadomGeneratedRadioButton.setEnabled(True)
+ self.RandomFixedRadioButton.setEnabled(True)
+ self.MutationSlider.setEnabled(True)
+ self.LocalBirthRadioButton.setEnabled(True)
+ self.MassActionRadioButton.setEnabled(True)
+ self.LifeSpanSpinBox.setEnabled(True)
+ self.DieNoButton.setEnabled(True)
+ self.DieYesButton.setEnabled(True)
+ self.MutationPercentTextLabel.setEnabled(True)
+ self.WorldSizeTextLabel.setEnabled(True)
+ self.MutationRateHeadTextLabel.setEnabled(True)
+ self.WorldSizeHeadTextLable.setEnabled(True)
+ self.DeathLabel.setEnabled(True)
+ self.RandomHeadTextLabel.setEnabled(True)
+ self.AncestorHeadTextLabel.setEnabled(True)
+ self.BirthHeadTextLabel.setEnabled(True)
+ self.StopHeadTextLabel.setEnabled(True)
+ self.DeathTextLabel2.setEnabled(True)
+ self.DeathTextLabel3.setEnabled(True)
+ self.DishDisabled = False
+ self.m_session_mdl.m_session_mdtr.emit(
+ PYSIGNAL("doEnablePetriDishSig"), ())
+
+
def CreateFilesFromPetriSlot(self, out_dir = None):
# The input files will be placed in a python generated temporary directory
@@ -253,17 +288,26 @@
# the population dictionary into the temporary dictionary
if (file_name_len > 0):
- os.mkdir(file_name)
+ is_empty_dish = m_pop_up_freezer_file_name.isEmpty()
+ if (not is_empty_dish):
+ os.mkdir(file_name)
- # Copy the average and count files from the teporary output directory
- # to the Freezer directory
+ # Copy the average and count files from the teporary output directory
+ # to the Freezer directory
- shutil.copyfile(os.path.join(self.m_session_mdl.m_tempdir_out, "average.dat"), os.path.join(file_name, "average.dat"))
- shutil.copyfile(os.path.join(self.m_session_mdl.m_tempdir_out, "count.dat"), os.path.join(file_name, "count.dat"))
- file_name = os.path.join(file_name, "petri_dish")
- tmp_dict["POPULATION"] = population_dict
- is_empty_dish = m_pop_up_freezer_file_name.isEmpty()
+ tmp_ave_file = os.path.join(self.m_session_mdl.m_tempdir_out, "average.dat")
+ if (os.path.exists(tmp_ave_file)):
+ shutil.copyfile(tmp_ave_file, os.path.join(file_name, "average.dat"))
+ tmp_count_file = os.path.join(self.m_session_mdl.m_tempdir_out, "count.dat")
+ if (os.path.exists(tmp_count_file)):
+ shutil.copyfile(tmp_count_file, os.path.join(file_name, "count.dat"))
+ file_name = os.path.join(file_name, "petri_dish")
+ tmp_dict["POPULATION"] = population_dict
freezer_file = pyWriteToFreezer(tmp_dict, is_empty_dish, file_name)
+ if (is_empty_dish):
+ self.m_session_mdl.saved_empty_dish = True
+ else:
+ self.m_session_mdl.saved_full_dish = True
self.m_session_mdl.m_session_mdtr.emit(
PYSIGNAL("doRefreshFreezerInventorySig"), ())
Modified: trunk/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- trunk/source/python/AvidaGui2/pySessionCtrl.py 2005-06-22 01:21:27 UTC (rev 218)
+++ trunk/source/python/AvidaGui2/pySessionCtrl.py 2005-06-23 00:37:12 UTC (rev 219)
@@ -59,6 +59,8 @@
# Create "model" for storing state data.
class pyMdl: pass
self.m_session_mdl = pyMdl()
+ self.m_session_mdl.saved_empty_dish = False
+ self.m_session_mdl.saved_full_dish = False
self.m_session_mdl.m_current_workspace = "default.workspace"
self.m_session_mdl.m_current_freezer = os.path.join(self.m_session_mdl.m_current_workspace, "freezer")
@@ -152,10 +154,10 @@
del old_avida
if self.m_avida and hasattr(self.m_avida, "m_avida_thread_mdtr"):
print "pySessionCtrl.setAvidaSlot(): connecting self.m_avida ..."
-# self.connect(
-# self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
-# self.avidaUpdatedSlot)
self.connect(
+ self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
+ self.avidaUpdatedSlot)
+ self.connect(
self.m_session_mdl.m_session_mdtr, PYSIGNAL("doStartAvidaSig"),
self.m_avida.m_avida_thread_mdtr, PYSIGNAL("doStartAvidaSig"))
self.connect(
@@ -196,7 +198,13 @@
self.m_should_update = False
self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doPauseAvidaSig"), ())
+ def avidaUpdatedSlot(self):
+ # When there is a new update assume that the session has an unsaved
+ # state
+
+ self.m_session_mdl.saved_full_dish = False
+
def unitTest(self, recurse = False):
return pyUnitTestSuiteRecurser("pySessionCtrl", globals(), recurse).construct().runTest().lastResult()
More information about the Avida-cvs
mailing list