[Avida-cvs] [avida-svn] r435 - branches/developers/avida-edward/source/python/AvidaGui2

baerb@myxo.css.msu.edu baerb at myxo.css.msu.edu
Tue Jan 10 13:06:02 PST 2006


Author: baerb
Date: 2006-01-10 16:06:02 -0500 (Tue, 10 Jan 2006)
New Revision: 435

Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/pyFreezerCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogView.ui
   branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py
Log:
Continued work on RightClick service menu.  Delete, rename and open work.
Export still not functioning.

Removed a few uncessary print statments.



Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyFreezerCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyFreezerCtrl.py	2006-01-09 20:05:56 UTC (rev 434)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyFreezerCtrl.py	2006-01-10 21:06:02 UTC (rev 435)
@@ -31,7 +31,7 @@
         freezer_item_name = freezer_item_name[9:] 
         self.FreezeOrganismSlot(freezer_item_name)
       else:
-        print "that was not an organism"      
+        pass
     
   def FreezeOrganismSlot(self, freezer_item_name, send_reset_signal = False, send_quit_signal = False):
     tmp_dict = {1:freezer_item_name}
@@ -274,14 +274,17 @@
         file_name = str(item.text(0)) + ".empty"
       elif str(top_level.text(0)).startswith(" Full Petri"):
         file_name = str(item.text(0)) + ".full"
-        file_name = os.path.join(file_name, "petri_dish")
       elif str(top_level.text(0)).startswith(" Organism"):
         file_name = str(item.text(0)) + ".organism"
       file_name = os.path.join(self.m_session_mdl.m_current_freezer, file_name)
 
-      print "BDB " + str(file_name)
       m_right_click_menu = pyRightClickDialogCtrl(item.text(0), file_name)
-      cancel_confirm = m_right_click_menu.showDialog()
+      (file_list_change, open_obj)  = m_right_click_menu.showDialog()
+      if file_list_change == True:
+        self.m_session_mdl.m_session_mdtr.emit(
+          PYSIGNAL("doRefreshFreezerInventorySig"), ())
+      if open_obj == True:
+        self.clicked_itemSlot(item)
 
   class itemDrag(QTextDrag):
     def __init__(self, item_name, parent=None, name=None):
@@ -313,7 +316,7 @@
         freezer_item_name = freezer_item_name[9:] 
         self.FreezeOrganismSlot(freezer_item_name)
       else:
-        print "that was not an organism"      
+        pass 
     
   def FreezeOrganismSlot(self, freezer_item_name, send_reset_signal = False, send_quit_signal = False):
     tmp_dict = {1:freezer_item_name}

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py	2006-01-09 20:05:56 UTC (rev 434)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py	2006-01-10 21:06:02 UTC (rev 435)
@@ -11,9 +11,18 @@
 class pyRightClickDialogCtrl (pyRightClickDialogView):
   def __init__(self, item_name, file_name):
     pyRightClickDialogView.__init__(self)
-    self.connect(self.ConfirmPushButton, SIGNAL("clicked()"), self.DoneDialogSlot)
+    self.file_name = file_name
+    self.NewNameLineEdit.setText(item_name)
+    self.connect(self.ConfirmPushButton, SIGNAL("clicked()"), 
+                 self.DoneDialogSlot)
 
-    print "BDB item_name = " + str(item_name) + " file_name = " + str(file_name)
+    (self.file_dir, self.file_core_name)  = os.path.split(self.file_name)
+    self.file_ext = self.file_core_name[self.file_core_name.rfind('.'):]
+    self.NameTextLabel.setText(item_name)
+    if (self.file_ext == '.organism'):
+      self.TypeTextLabel.setText(self.file_ext.lstrip('.') + ":")
+    else:
+      self.TypeTextLabel.setText(self.file_ext.lstrip('.') + " dish:")
     self.DeleteFlag = 1
     self.RenameFlag = 2
     self.SaveAsFlag = 3
@@ -30,8 +39,53 @@
       self.done(self.OpenFlag)
 
   def showDialog(self):
+    self.change = False
+    self.open_obj = False
     self.show()
-    junk = self.exec_loop()
-    print "BDB junk = " + str(junk)
+    self.exec_loop()
     dialog_result = self.result()
-    print "BDB dialog_results = " + str(dialog_result)
+    new_name_core = str(self.NewNameLineEdit.text())
+    new_name_core = new_name_core.strip()
+
+    # if the user chose to delete file or directory
+
+    if dialog_result == self.DeleteFlag:
+      self.change = True
+      if (self.file_ext == '.full'):
+        tmp_file_list = os.listdir(self.file_name)
+        for file in tmp_file_list:
+          os.remove(os.path.join(self.file_name,file))
+        os.removedirs(self.file_name)
+      else:
+        os.remove(self.file_name)
+
+    # if the user chose to rename the file/directory and they gave an actual
+    # check if that file already exists if it does not rename the file
+
+    elif dialog_result == self.RenameFlag and new_name_core != "":
+      new_name = os.path.join(self.file_dir, new_name_core + self.file_ext)
+      if (os.path.exists(new_name) == False):
+        os.rename(self.file_name, new_name)
+        self.change = True
+
+    elif dialog_result == self.SaveAsFlag:
+      file_dialog = QFileDialog (os.path.join(self.file_dir, '..'), 
+        '.junk1234junk', self, 'Export', False)
+      file_dialog.setCaption('Export ' + self.file_ext.lstrip('.') + " " + 
+        str(self.NameTextLabel.text()) + ' to:')
+      file_dialog.setMode(QFileDialog.DirectoryOnly)
+      # file_dialog.setSelection (self.file_core_name)
+      file_dialog.show()
+      file_dialog.exec_loop()
+      if file_dialog.result() == True:
+        print "BDB dir name = " + str(file_dialog.dir().selectedFile())
+        export_file_name = os.path.join(str(file_dialog.dir().selectedFile()), 
+          self.file_core_name)
+        print "BDB export file name = " + str(export_file_name)
+        # shutil.copytree(self.file_name, str(file_dialog.dir().path()))
+
+    elif dialog_result == self.OpenFlag:
+      self.open_obj = True
+
+    return(self.change, self.open_obj)
+ 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogView.ui
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogView.ui	2006-01-09 20:05:56 UTC (rev 434)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogView.ui	2006-01-10 21:06:02 UTC (rev 435)
@@ -8,8 +8,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>133</width>
-            <height>224</height>
+            <width>262</width>
+            <height>267</height>
         </rect>
     </property>
     <property name="paletteBackgroundColor">
@@ -20,7 +20,7 @@
         </color>
     </property>
     <property name="caption">
-        <string></string>
+        <string>pyRightClickDialogView</string>
     </property>
     <widget class="QButtonGroup">
         <property name="name">
@@ -29,9 +29,9 @@
         <property name="geometry">
             <rect>
                 <x>10</x>
-                <y>10</y>
-                <width>113</width>
-                <height>204</height>
+                <y>12</y>
+                <width>242</width>
+                <height>231</height>
             </rect>
         </property>
         <property name="paletteBackgroundColor">
@@ -51,6 +51,32 @@
             <property name="name">
                 <cstring>unnamed</cstring>
             </property>
+            <widget class="QLayoutWidget">
+                <property name="name">
+                    <cstring>layout2</cstring>
+                </property>
+                <hbox>
+                    <property name="name">
+                        <cstring>unnamed</cstring>
+                    </property>
+                    <widget class="QLabel">
+                        <property name="name">
+                            <cstring>TypeTextLabel</cstring>
+                        </property>
+                        <property name="text">
+                            <string>Type:</string>
+                        </property>
+                    </widget>
+                    <widget class="QLabel">
+                        <property name="name">
+                            <cstring>NameTextLabel</cstring>
+                        </property>
+                        <property name="text">
+                            <string>Name</string>
+                        </property>
+                    </widget>
+                </hbox>
+            </widget>
             <widget class="QRadioButton">
                 <property name="name">
                     <cstring>DeleteRadioButton</cstring>
@@ -66,20 +92,35 @@
                     <string>delete</string>
                 </property>
             </widget>
-            <widget class="QRadioButton">
+            <widget class="QLayoutWidget">
                 <property name="name">
-                    <cstring>RenameRadioButton</cstring>
+                    <cstring>layout1</cstring>
                 </property>
-                <property name="paletteBackgroundColor">
-                    <color>
-                        <red>255</red>
-                        <green>255</green>
-                        <blue>100</blue>
-                    </color>
-                </property>
-                <property name="text">
-                    <string>rename</string>
-                </property>
+                <hbox>
+                    <property name="name">
+                        <cstring>unnamed</cstring>
+                    </property>
+                    <widget class="QRadioButton">
+                        <property name="name">
+                            <cstring>RenameRadioButton</cstring>
+                        </property>
+                        <property name="paletteBackgroundColor">
+                            <color>
+                                <red>255</red>
+                                <green>255</green>
+                                <blue>100</blue>
+                            </color>
+                        </property>
+                        <property name="text">
+                            <string>rename</string>
+                        </property>
+                    </widget>
+                    <widget class="QLineEdit">
+                        <property name="name">
+                            <cstring>NewNameLineEdit</cstring>
+                        </property>
+                    </widget>
+                </hbox>
             </widget>
             <widget class="QRadioButton">
                 <property name="name">
@@ -93,7 +134,7 @@
                     </color>
                 </property>
                 <property name="text">
-                    <string>save as</string>
+                    <string>export</string>
                 </property>
             </widget>
             <widget class="QRadioButton">

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py	2006-01-09 20:05:56 UTC (rev 434)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyWriteToFreezer.py	2006-01-10 21:06:02 UTC (rev 435)
@@ -16,22 +16,19 @@
       out_file_name = (os.path.split(out_file_name)[0])
 
     if out_file_name.endswith(".organism"):
-      print "that was an org"
       is_org = True
 
     elif out_file_name.endswith(".full"):
-      print "that was a full dish man"
       is_dish = True
       self.simplifyPopulation(in_dict)
-      out_file_name = (out_file_name + '/petri_dish')
+      out_file_name = os.path.join(out_file_name, 'petri_dish')
 
     elif out_file_name.endswith(".empty"):
-      print "that was an empty dish man"
       is_dish = True
       is_empty_dish = True
 
     else:
-      print "that was junk man"
+      pass
 
     out_freezer_file = open((out_file_name), "w")
 




More information about the Avida-cvs mailing list