[Avida-cvs] [avida-svn] r727 - branches/developers/avida-edward/source/python/AvidaGui2
gerrishj@myxo.css.msu.edu
gerrishj at myxo.css.msu.edu
Thu Jun 1 13:54:33 PDT 2006
Author: gerrishj
Date: 2006-06-01 16:54:32 -0400 (Thu, 01 Jun 2006)
New Revision: 727
Added:
branches/developers/avida-edward/source/python/AvidaGui2/pyButtonListDialog.py
Removed:
branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui
Modified:
branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui
branches/developers/avida-edward/source/python/AvidaGui2/pyGraphCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
Log:
Saving of graph and petri dish to jpeg files implemented.
Removed stand-alone export dialog, replaced it with a generic checkbox/radio button dialog.
Merged some duplicate PrintFilter functions into pyGraphCtrl
Added: branches/developers/avida-edward/source/python/AvidaGui2/pyButtonListDialog.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyButtonListDialog.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyButtonListDialog.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+
+# Generic dialog box with list of radio buttons or checkboxes
+# Three required parameters: dialog title, list title, and list of items
+# A fourth parameter lets you choose radio buttons (false) or checkboxes (true)
+# Example use:
+# dialog = pyButtonListDialog("Dialog title", "Choose item", ["item1", "item2"])
+# results = dialog.showDialog()
+# results will contain the checked buttons
+
+from qt import *
+
+
+class pyButtonListDialog(QDialog):
+ def __init__(self, title, list_title, items, multi = 0, parent = None,
+ name = None, modal = 0, fl = 0):
+ QDialog.__init__(self,parent,name,modal,fl)
+
+ if title:
+ self.title = title
+ if list_title:
+ self.list_title = list_title
+
+ if not name:
+ self.setName("pyButtonListDialog")
+
+ self.setSizeGripEnabled(1)
+
+ pyButtonListDialogLayout = QVBoxLayout(self,11,6,"pyButtonListDialogLayout")
+
+ self.buttonGroup1 = QButtonGroup(self,"buttonGroup1")
+ self.buttonGroup1.setColumnLayout(0,Qt.Vertical)
+ self.buttonGroup1.layout().setSpacing(6)
+ self.buttonGroup1.layout().setMargin(11)
+ buttonGroup1Layout = QVBoxLayout(self.buttonGroup1.layout())
+ buttonGroup1Layout.setAlignment(Qt.AlignTop)
+
+ self.buttons = []
+ cnt = 0
+ for item in items:
+ if multi:
+ self.buttons.append(QCheckBox(self.buttonGroup1, "button%d" % (cnt)))
+ else:
+ self.buttons.append(QRadioButton(self.buttonGroup1, "button%d" % (cnt)))
+ buttonGroup1Layout.addWidget(self.buttons[-1])
+ self.buttons[-1].setText(self.__tr(item))
+ cnt += 1
+
+ pyButtonListDialogLayout.addWidget(self.buttonGroup1)
+
+ Layout1 = QHBoxLayout(None,0,6,"Layout1")
+
+ self.buttonHelp = QPushButton(self,"buttonHelp")
+ self.buttonHelp.setEnabled(0)
+ self.buttonHelp.setAutoDefault(1)
+ Layout1.addWidget(self.buttonHelp)
+ Horizontal_Spacing2 = QSpacerItem(20, 20, QSizePolicy.Expanding,
+ QSizePolicy.Minimum)
+ Layout1.addItem(Horizontal_Spacing2)
+
+ self.buttonOk = QPushButton(self,"buttonOk")
+ self.buttonOk.setAutoDefault(1)
+ self.buttonOk.setDefault(1)
+ Layout1.addWidget(self.buttonOk)
+
+ self.buttonCancel = QPushButton(self,"buttonCancel")
+ self.buttonCancel.setAutoDefault(1)
+ Layout1.addWidget(self.buttonCancel)
+ pyButtonListDialogLayout.addLayout(Layout1)
+
+ self.languageChange()
+
+ self.resize(QSize(312,131).expandedTo(self.minimumSizeHint()))
+ self.clearWState(Qt.WState_Polished)
+
+ self.connect(self.buttonOk,SIGNAL("clicked()"),self.accept)
+ self.connect(self.buttonCancel,SIGNAL("clicked()"),self.reject)
+
+
+ def languageChange(self):
+ self.setCaption(self.__tr(self.title))
+ self.buttonGroup1.setTitle(self.__tr(self.list_title))
+ self.buttonHelp.setText(self.__tr("&Help"))
+ self.buttonHelp.setAccel(self.__tr("F1"))
+ self.buttonOk.setText(self.__tr("&OK"))
+ self.buttonOk.setAccel(QString.null)
+ self.buttonCancel.setText(self.__tr("&Cancel"))
+ self.buttonCancel.setAccel(QString.null)
+
+
+ def __tr(self,s,c = None):
+ return qApp.translate("pyButtonListDialog",s,c)
+
+ def showDialog(self):
+ "Show the dialog, returning list of items selected"
+ items = []
+ self.exec_loop()
+ res = self.result()
+ if res == 0:
+ return []
+ else:
+ for button in self.buttons:
+ if button.isOn():
+ items.append(str(button.text()))
+ return items
Property changes on: branches/developers/avida-edward/source/python/AvidaGui2/pyButtonListDialog.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -316,6 +316,12 @@
# public slot
+ def fileSaveImages(self):
+ "Export images to a file"
+ self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("saveImagesSig"), ())
+
+ # public slot
+
def fileExit(self):
print "pyEduWorkspaceCtrl.fileExit(): Not implemented yet"
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceView.ui 2006-06-01 20:54:32 UTC (rev 727)
@@ -154,6 +154,7 @@
<action name="fileSaveAsAction"/>
<separator/>
<action name="fileExportAction"/>
+ <action name="fileSaveImagesAction"/>
<separator/>
<action name="m_petri_print_action"/>
<action name="m_graph_print_action"/>
@@ -382,6 +383,20 @@
</action>
<action>
<property name="name">
+ <cstring>fileSaveImagesAction</cstring>
+ </property>
+ <property name="text">
+ <string>Save Images</string>
+ </property>
+ <property name="menuText">
+ <string>Save &Images</string>
+ </property>
+ <property name="accel">
+ <string>Ctrl+I</string>
+ </property>
+ </action>
+ <action>
+ <property name="name">
<cstring>m_petri_print_action</cstring>
</property>
<property name="iconSet">
@@ -767,6 +782,12 @@
<slot>fileExport()</slot>
</connection>
<connection>
+ <sender>fileSaveImagesAction</sender>
+ <signal>activated()</signal>
+ <receiver>pyEduWorkspaceView</receiver>
+ <slot>fileSaveImages()</slot>
+ </connection>
+ <connection>
<sender>m_petri_print_action</sender>
<signal>activated()</signal>
<receiver>pyEduWorkspaceView</receiver>
Deleted: branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyExportCtrl.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -1,30 +0,0 @@
-# Export dialog for exporting stats to Excel
-from qt import *
-from pyExportView import pyExportView
-
-class pyExportCtrl(pyExportView):
- def __init__(self):
- pyExportView.__init__(self)
-
-# def accept(self):
-# self.export()
-# pyExportView.accept(self)
-
- def showDialog(self):
- "Show the dialog, returning list of stats to export"
- items = []
- self.exec_loop()
- res = self.result()
- if res == 0:
- return []
- else:
- # PyQt 3.15 missing QListViewItemIterator
- #for item in QListItemViewIterator(self.listView1):
- i = self.listView1.firstChild()
- if i != None and i.isOn():
- items.append(str(i.text()))
- while i:
- i = i.itemBelow()
- if i != None and i.isOn():
- items.append(str(i.text()))
- return items
Deleted: branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyExportView.ui 2006-06-01 20:54:32 UTC (rev 727)
@@ -1,147 +0,0 @@
-<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
-<class>pyExportView</class>
-<widget class="QDialog">
- <property name="name">
- <cstring>pyExportView</cstring>
- </property>
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>352</width>
- <height>344</height>
- </rect>
- </property>
- <property name="caption">
- <string>Choose Values to Export</string>
- </property>
- <property name="sizeGripEnabled">
- <bool>true</bool>
- </property>
- <widget class="QListView">
- <column>
- <property name="text">
- <string>Export</string>
- </property>
- <property name="clickable">
- <bool>true</bool>
- </property>
- <property name="resizable">
- <bool>true</bool>
- </property>
- </column>
- <property name="name">
- <cstring>listView1</cstring>
- </property>
- <property name="geometry">
- <rect>
- <x>50</x>
- <y>10</y>
- <width>250</width>
- <height>250</height>
- </rect>
- </property>
- </widget>
- <widget class="QLayoutWidget">
- <property name="name">
- <cstring>Layout1</cstring>
- </property>
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>300</y>
- <width>330</width>
- <height>33</height>
- </rect>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <widget class="QPushButton">
- <property name="name">
- <cstring>buttonHelp</cstring>
- </property>
- <property name="text">
- <string>&Help</string>
- </property>
- <property name="accel">
- <string>F1</string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- </widget>
- <spacer>
- <property name="name">
- <cstring>Horizontal Spacing2</cstring>
- </property>
- <property name="orientation">
- <enum>Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- <widget class="QPushButton">
- <property name="name">
- <cstring>buttonOk</cstring>
- </property>
- <property name="text">
- <string>&OK</string>
- </property>
- <property name="accel">
- <string></string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- <widget class="QPushButton">
- <property name="name">
- <cstring>buttonCancel</cstring>
- </property>
- <property name="text">
- <string>&Cancel</string>
- </property>
- <property name="accel">
- <string></string>
- </property>
- <property name="autoDefault">
- <bool>true</bool>
- </property>
- </widget>
- </hbox>
- </widget>
-</widget>
-<connections>
- <connection>
- <sender>buttonOk</sender>
- <signal>clicked()</signal>
- <receiver>pyExportView</receiver>
- <slot>accept()</slot>
- </connection>
- <connection>
- <sender>buttonCancel</sender>
- <signal>clicked()</signal>
- <receiver>pyExportView</receiver>
- <slot>reject()</slot>
- </connection>
-</connections>
-<layoutdefaults spacing="6" margin="11"/>
-</UI>
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyGraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyGraphCtrl.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyGraphCtrl.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -24,3 +24,24 @@
# - Click and drag to create a zoom rectangle;
# - Option-click to zoom-out to full view.
self.m_zoomer.initMousePattern(1)
+
+class PrintFilter(QwtPlotPrintFilter):
+ def __init__(self):
+ QwtPlotPrintFilter.__init__(self)
+ def color(self, c, item, i):
+ if not (self.options() & QwtPlotPrintFilter.PrintCanvasBackground):
+ if item == QwtPlotPrintFilter.MajorGrid:
+ return Qt.darkGray
+ elif item == QwtPlotPrintFilter.MinorGrid:
+ return Qt.gray
+ if item == QwtPlotPrintFilter.Title:
+ return Qt.black
+ elif item == QwtPlotPrintFilter.AxisScale:
+ return Qt.black
+ elif item == QwtPlotPrintFilter.AxisTitle:
+ return Qt.black
+ return Qt.black
+ def font(self, f, item, i):
+ result = QFont(f)
+ result.setPointSize(int(f.pointSize()*1.25))
+ return result
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOneAna_GraphCtrl.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -4,35 +4,13 @@
from Numeric import *
from pyAvidaStatsInterface import pyAvidaStatsInterface
from pyOneAna_GraphView import pyOneAna_GraphView
-from pyExportCtrl import pyExportCtrl
+from pyButtonListDialog import pyButtonListDialog
+from pyGraphCtrl import PrintFilter
from qt import *
from qwt import *
import os.path
import os.path
-
-class PrintFilter(QwtPlotPrintFilter):
- def __init__(self):
- QwtPlotPrintFilter.__init__(self)
- def color(self, c, item, i):
- if not (self.options() & QwtPlotPrintFilter.PrintCanvasBackground):
- if item == QwtPlotPrintFilter.MajorGrid:
- return Qt.darkGray
- elif item == QwtPlotPrintFilter.MinorGrid:
- return Qt.gray
- if item == QwtPlotPrintFilter.Title:
- return Qt.black
- elif item == QwtPlotPrintFilter.AxisScale:
- return Qt.black
- elif item == QwtPlotPrintFilter.AxisTitle:
- return Qt.black
- return Qt.black
- def font(self, f, item, i):
- result = QFont(f)
- result.setPointSize(int(f.pointSize()*1.25))
- return result
-
-
class pyOneAna_GraphCtrl(pyOneAna_GraphView):
def __init__(self,parent = None,name = None,fl = 0):
@@ -213,14 +191,13 @@
def exportSlot(self):
"Export analysis data to a file"
- dialog_caption = "Export analysis as:"
+ dialog_caption = "Export Analysis"
fd = QFileDialog.getSaveFileName("", "CSV (Excel compatible) (*.csv)", None,
"export as", dialog_caption)
filename = str(fd)
if (filename[-4:].lower() != ".csv"):
filename += ".csv"
- dialog = pyExportCtrl()
checks = []
# dictionary indexed by stat name so we can lookup stats to export
stats = {}
@@ -229,12 +206,15 @@
# Note: this relies on labeling dummy stats with None
if stat[0] != "None":
stats[stat[0]] = stat_cnt
- checks.append(QCheckListItem(dialog.listView1, stat[0],
- QCheckListItem.CheckBox))
- # enable last added checkbox
- checks[len(checks) - 1].setOn(True)
+ checks.append(stat[0])
stat_cnt += 1
+ dialog = pyButtonListDialog(dialog_caption, "Choose stats to export",
+ checks, True)
+ # enable checkboxes
+ for button in dialog.buttons:
+ button.setOn(True)
+
res = dialog.showDialog()
if res == []:
return
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_GraphCtrl.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -4,32 +4,11 @@
from Numeric import *
from pyAvidaStatsInterface import pyAvidaStatsInterface
from pyOnePop_GraphView import pyOnePop_GraphView
+from pyGraphCtrl import PrintFilter
from qt import *
from qwt import *
import os.path
-class PrintFilter(QwtPlotPrintFilter):
- def __init__(self):
- QwtPlotPrintFilter.__init__(self)
- def color(self, c, item, i):
- if not (self.options() & QwtPlotPrintFilter.PrintCanvasBackground):
- if item == QwtPlotPrintFilter.MajorGrid:
- return Qt.darkGray
- elif item == QwtPlotPrintFilter.MinorGrid:
- return Qt.gray
- if item == QwtPlotPrintFilter.Title:
- return Qt.black
- elif item == QwtPlotPrintFilter.AxisScale:
- return Qt.black
- elif item == QwtPlotPrintFilter.AxisTitle:
- return Qt.black
- return Qt.black
- def font(self, f, item, i):
- result = QFont(f)
- result.setPointSize(int(f.pointSize()*1.25))
- return result
-
-
class pyOnePop_GraphCtrl(pyOnePop_GraphView):
def __init__(self,parent = None,name = None,fl = 0):
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -9,8 +9,8 @@
from pyReadFreezer import pyReadFreezer
from pyGradientScaleView import pyGradientScaleView
from pyQuitDialogCtrl import pyQuitDialogCtrl
+from pyButtonListDialog import pyButtonListDialog
-
class pyOnePop_PetriDishCtrl(pyOnePop_PetriDishView):
def __init__(self,parent = None,name = None,fl = 0):
@@ -253,22 +253,33 @@
descr(session_mdl)
self.dishDisabled = False
+ def getPetriDishPixmap(self):
+ "Return QPixmap of petri dish and scale"
+ dish_height = self.m_petri_dish_ctrl.m_canvas_view.height()
+ # Hide the scrollbars so they aren't painted
+ self.m_petri_dish_ctrl.m_petri_dish_ctrl_h_scrollBar.hide()
+ self.m_petri_dish_ctrl.m_petri_dish_ctrl_v_scrollBar.hide()
+ dish_pix = QPixmap.grabWidget(self.m_petri_dish_ctrl.m_canvas_view, 0, 0,
+ self.m_petri_dish_ctrl.m_canvas_view.width(),
+ dish_height)
+ self.m_petri_dish_ctrl.m_petri_dish_ctrl_h_scrollBar.show()
+ self.m_petri_dish_ctrl.m_petri_dish_ctrl_v_scrollBar.show()
+ scale_pix = QPixmap.grabWidget(self.m_gradient_scale_ctrl, 0, 0,
+ self.m_gradient_scale_ctrl.width(),
+ self.m_gradient_scale_ctrl.height())
+ p = QPixmap(max(self.m_petri_dish_ctrl.m_canvas_view.width(),
+ self.m_gradient_scale_ctrl.width()),
+ dish_height + self.m_gradient_scale_ctrl.height())
+ painter = QPainter(p)
+ painter.drawPixmap(0, 0, dish_pix)
+ painter.drawPixmap(0, dish_height, scale_pix)
+ painter.end()
+ return p
+
def printPetriDishSlot(self):
+ "Print the petri dish and fitness scale"
printer = QPrinter()
if printer.setup():
- dish_height = self.m_petri_dish_ctrl.m_canvas_view.height()
- # Hide the scrollbars so they aren't printed
- self.m_petri_dish_ctrl.m_petri_dish_ctrl_h_scrollBar.hide()
- self.m_petri_dish_ctrl.m_petri_dish_ctrl_v_scrollBar.hide()
- dish_pix = QPixmap.grabWidget(self.m_petri_dish_ctrl.m_canvas_view, 0, 0,
- self.m_petri_dish_ctrl.m_canvas_view.width(),
- dish_height)
- self.m_petri_dish_ctrl.m_petri_dish_ctrl_h_scrollBar.show()
- self.m_petri_dish_ctrl.m_petri_dish_ctrl_v_scrollBar.show()
- scale_pix = QPixmap.grabWidget(self.m_gradient_scale_ctrl, 0, 0,
- self.m_gradient_scale_ctrl.width(),
- self.m_gradient_scale_ctrl.height())
painter = QPainter(printer)
- painter.drawPixmap(0, 0, dish_pix)
- painter.drawPixmap(0, dish_height + 1, scale_pix)
+ painter.drawPixmap(0, 0, self.getPetriDishPixmap())
painter.end()
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePopulationCtrl.py 2006-06-01 20:54:32 UTC (rev 727)
@@ -5,6 +5,8 @@
from pyAvida import pyAvida
from qt import *
from pyOnePopulationView import pyOnePopulationView
+from pyButtonListDialog import pyButtonListDialog
+from pyGraphCtrl import PrintFilter
import os.path
class pyOnePopulationCtrl(pyOnePopulationView):
@@ -33,7 +35,7 @@
PYSIGNAL("restartPopulationSig"), self.restartPopulationSlot)
def aboutToBeLowered(self):
- """Disconnects "Print..." menu items from One-Pop Graph controller."""
+ """Disconnects menu items from One-Pop Graph controller."""
descr()
self.disconnect(
self.m_session_mdl.m_session_mdtr,
@@ -42,10 +44,13 @@
self.disconnect(
self.m_session_mdl.m_session_mdtr,
PYSIGNAL("printPetriDishSig"),
-# self.m_one_pop_petri_dish_ctrl.m_petri_dish_ctrl.printPetriDishSlot)
self.m_one_pop_petri_dish_ctrl.printPetriDishSlot)
+ self.disconnect(
+ self.m_session_mdl.m_session_mdtr,
+ PYSIGNAL("saveImagesSig"),
+ self.saveImagesSlot)
def aboutToBeRaised(self):
- """Connects "Print..." menu items to One-Pop Graph controller."""
+ """Connects menu items to One-Pop Graph controller."""
descr()
self.connect(
self.m_session_mdl.m_session_mdtr,
@@ -54,8 +59,11 @@
self.connect(
self.m_session_mdl.m_session_mdtr,
PYSIGNAL("printPetriDishSig"),
-# self.m_one_pop_petri_dish_ctrl.m_petri_dish_ctrl.printPetriDishSlot)
self.m_one_pop_petri_dish_ctrl.printPetriDishSlot)
+ self.connect(
+ self.m_session_mdl.m_session_mdtr,
+ PYSIGNAL("saveImagesSig"),
+ self.saveImagesSlot)
def dragEnterEvent( self, e ):
descr(e)
@@ -99,5 +107,35 @@
# self.m_session_mdl.m_session_mdtr.emit(
# PYSIGNAL("doInitializeAvidaPhaseISig"), (self.m_session_mdl.m_tempdir,))
+ def saveImagesSlot(self):
+ "Save petri dish or graph to image file"
+ # Let user select which image to save
+ dlg = pyButtonListDialog("Save Image", "Choose object to save",
+ ["Petri Dish", "Graph"])
+ res = dlg.showDialog()
+ # Let user select file format
+ dialog_caption = "Export Image"
+ fd = QFileDialog.getSaveFileName("", "JPEG (*.jpg);;PNG (*.png)", None,
+ "Save As", dialog_caption)
+ filename = str(fd)
+ if filename == "":
+ return
+ if filename[-4:].lower() == ".jpg":
+ type = "JPEG"
+ elif filename[-4:].lower() == ".png":
+ type = "PNG"
+ else:
+ filename += ".jpg"
+ type = "JPEG"
+
+ # Save the image
+ if res[0] == "Petri Dish":
+ p = self.m_one_pop_petri_dish_ctrl.getPetriDishPixmap()
+ p.save(filename, type, 100)
+ else:
+ p = QPixmap.grabWidget(self.m_one_pop_graph_ctrl.m_graph_ctrl, 0, 0,
+ self.m_one_pop_graph_ctrl.m_graph_ctrl.width(),
+ self.m_one_pop_graph_ctrl.m_graph_ctrl.height())
+ p.save(filename, type, 100)
Modified: branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/to-do_list 2006-05-31 23:30:10 UTC (rev 726)
+++ branches/developers/avida-edward/source/python/AvidaGui2/to-do_list 2006-06-01 20:54:32 UTC (rev 727)
@@ -62,7 +62,6 @@
- replace flip arrow on petri dish with a button with text reading
"configure"
-- printing of petri dish and of color scale
- troubleshoot crash on run end, as set in petri dish control.
- hack with a pause signal upon a certain event completed.
- toggle to see legend instruction names to colors
@@ -82,7 +81,6 @@
- consider different icons in navigation bar and freezer (12/21/05)
- change the text in analyze mode to list the population instead of what
it currently state (12/21/05)
-- investigation of printing petri dish (1/26/06)
Priority Low-
@@ -93,6 +91,9 @@
- Change .csv to .txt extension
- Allow exporting in Petri Dish view
+30-May-06 Printing of petri dish and of color scale
+ - Fill out save dialog with default filename that includes update and other
+ info
************Other*****************
a. Under the sliders with ranges put a few values in grey that tell you the range min and max (non)
More information about the Avida-cvs
mailing list