diff -r 3b7a38af5c42 -r cb4124e3e75b plotter/qgpib_plotter.py --- a/plotter/qgpib_plotter.py Sun Feb 03 23:39:27 2008 +0100 +++ b/plotter/qgpib_plotter.py Mon Feb 04 19:02:42 2008 +0100 @@ -2,6 +2,7 @@ import os, sys import time +import glob from PyQt4 import QtGui, QtCore, uic from PyQt4.QtCore import SIGNAL, Qt @@ -22,6 +23,8 @@ from qpreferences import AbstractPreferences from qpreferenceseditor import PreferencesEditor +from tools import str_num_cmp + class Preferences(AbstractPreferences): ORGANISATION="Logilab" APPLICATION="qgpib_plotter" @@ -86,7 +89,6 @@ if bg and bg.isValid(): self.plotterWidget.qview.setBackgroundBrush(QtGui.QBrush(bg)) pen_colors = [self._prefs["color%d"%i] for i in range(8)] - print self.plotterWidget.pen_colors = pen_colors def replotCurrent(self): @@ -150,6 +152,11 @@ def openTriggered(self, checked=False): filenames = QtGui.QFileDialog.getOpenFileNames(self, "Open a HPGL file to display", '.', 'HPGL files (*.plt)\nAll files (*)') + self.openFiles(filenames) + if not self.plotsView.currentIndex().isValid(): + self.plotsView.setCurrentIndex(self.plotsView.model().index(0, 0)) + + def openFiles(self, filenames): for filename in filenames: filename = str(filename) if os.path.exists(filename): @@ -160,10 +167,7 @@ lst.append(name) self._plots[name] = data self.plotsView.model().setStringList(lst) - - if not self.plotsView.currentIndex().isValid(): - self.plotsView.setCurrentIndex(self.plotsView.model().index(0, 0)) - + def plotReceived(self, num): self._receiving = False self.setReceivingLed() @@ -180,6 +184,7 @@ def saveTriggered(self, checked=False): print "save" + def saveAsTriggered(self, checked=False): index = self.plotsView.selectionModel().currentIndex() if index.isValid(): @@ -306,9 +311,6 @@ return self._plots[num] finally: self._plotsmutex.unlock() - - - def main(): import optparse @@ -330,6 +332,9 @@ a = QtGui.QApplication(argv) w = QtHPGLPlotter() + files = [f for f in argv[1:] if os.path.isfile(f)] + files.sort(cmp=str_num_cmp) + w.openFiles(files) w.show() a.exec_()