From 6f729c5dd92eaa33276fd2e4ae0c6db44ed41759 Mon Sep 17 00:00:00 2001 From: Antonino Ingargiola Date: Fri, 8 Jun 2007 21:46:55 +0200 Subject: [PATCH] Made Linewidth work on the Plot Properties Dialog. --- plotfile/plotfile2.glade | 9 +++++- plotfile2.py | 75 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/plotfile/plotfile2.glade b/plotfile/plotfile2.glade index 3471c8f..6b77bd3 100644 --- a/plotfile/plotfile2.glade +++ b/plotfile/plotfile2.glade @@ -1702,6 +1702,7 @@ Read the full text in LICENSE.txt in the source dir. False False 1 0 100 1 10 10 + 0 @@ -1756,6 +1757,7 @@ Dashed Dotted False True + 0 @@ -1817,6 +1819,7 @@ Red Yellow False True + 0 @@ -1943,6 +1946,7 @@ Rotated Hexagon (H) Pentagon (p) False True + 0 @@ -1990,7 +1994,7 @@ Pentagon (p) - + True True 1 @@ -2000,6 +2004,7 @@ Pentagon (p) False False 3 0 100 1 10 10 + 0 @@ -2061,6 +2066,7 @@ Red Yellow False True + 0 @@ -2122,6 +2128,7 @@ Red Yellow False True + 0 diff --git a/plotfile2.py b/plotfile2.py index 2ab1cd7..4dc994f 100755 --- a/plotfile2.py +++ b/plotfile2.py @@ -43,6 +43,9 @@ class DataSet: # self.y is a list of series of data self.y = [] if y1 != None: self.add(y1) + + # self.yline is a list of plotted lines from the current DataSet + self.yline = [] # Set the plot style, maker and linestyle attributes # Marker and linestyle are separate variables so we can switch them off @@ -152,7 +155,7 @@ class PlotFileApp(GenericMainPlotWindow): for yi in d.y: if (yi <= 0).any(): return False return True - + def plot(self): if self.debug: print 'plot method' @@ -165,10 +168,12 @@ class PlotFileApp(GenericMainPlotWindow): self.axis.set_xscale('linear') for d in self.data: - print 'data X:', d.x + l = [] for yi in d.y: - print 'data Y:', yi - self.axis.plot(d.x, yi, **d.plot_kwargs) + l += [ self.axis.plot(d.x, yi, **d.plot_kwargs) ] + + if len(d.yline) == 0: + d.yline = l self.axis.set_title(self.title) self.axis.set_xlabel(self.xlabel) @@ -432,8 +437,28 @@ class PlotPropertiesDialog(DialogWindowWithCancel): self.treeView = self.widgetTree.get_widget('treeview') self.create_plotlist() + self.load_widgets() + + self.plot_index = None + + #self.markerTypeModel = self.markerTypeComboB.get_model() - + def load_widgets(self): + self.lineWidthSpinButt = \ + self.widgetTree.get_widget('lineWidthSpinButton') + self.lineStyleComboB = \ + self.widgetTree.get_widget('lineStyleComboBox') + self.lineColorComboB = \ + self.widgetTree.get_widget('lineColorComboBox') + self.markerTypeComboB = \ + self.widgetTree.get_widget('markerTypeComboBox') + self.markerSizeSpinButt = \ + self.widgetTree.get_widget('markerSizeSpinButton') + self.markerEdgeColorComboB = \ + self.widgetTree.get_widget('markerEdgeColComboBox') + self.markerFaceColorComboB = \ + self.widgetTree.get_widget('markerFaceColComboBox') + def create_plotlist(self): # Add a column to the treeView self.addListColumn('Plot List', 0) @@ -461,11 +486,47 @@ class PlotPropertiesDialog(DialogWindowWithCancel): for data in self.callerApp.data: self.plotList.append([data.name]) + ## + # GUI Callbacks + # def on_treeview_cursor_changed(self, *args): - plot_index = self.treeView.get_cursor()[0][0] - print plot_index + self.plot_index = self.treeView.get_cursor()[0][0] + print self.plot_index + data = self.callerApp.data[self.plot_index] + #self.markerTypeComboB. + + def on_lineWidth_value_changed(self, *args): + lw = self.lineWidthSpinButt.get_value() + if self.plot_index is not None: + self.callerApp.data[self.plot_index].plot_kwargs['linewidth'] = lw + self.callerApp.plot() + def on_lineStyle_changed(self, *args): + text = self.lineStyleComboB.get_active_text() + print text + def on_lineColor_changed(self, *args): + text = self.lineColorComboB.get_active_text() + print text + + def on_markerType_changed(self, *args): + text = self.markerTypeComboB.get_active_text() + print text + + def on_markerSize_value_changed(self, *args): + text = self.markerSizeSpinButt.get_value() + print text + + def on_markerEdgeColor_changed(self, *args): + text = self.markerEdgeColorComboB.get_active_text() + print text + + def on_markerFaceColor_changed(self, *args): + text = self.markerFaceColorComboB.get_active_text() + print text + + def on_okButton_clicked(self, widget, *args): + self.window.destroy() class TitleAndAxesWindow(DialogWindowWithCancel): """ -- 2.11.4.GIT