class Window(object):
    def __init__(self, interactive=False, windowIndex=0):
        """
        Interactive=True means that "plot" displays the figure immediately
        Interactive=False means that "plot" load the data, but show will display all figures at once
        """
        self.reset()
        self.interactive = interactive
        self.windowIndex = windowIndex
        
    def reset(self):
        self.lines = []
        self.glplot = None
        
    def plot(self, *args, **kwargs):
        line = Line(*args, **kwargs)
        if line.options["color"] is None:
            line.set_color(LINECOLORS[len(self.lines) % len(LINECOLORS)])
        self.lines.append(line)
        
    def show(self):
        data = [l.data for l in self.lines]
        fulldata = np.vstack(data)
        options = [l.options for l in self.lines]
        databounds = get_databounds(data)
    
        if not(self.interactive):
            app = QtGui.QApplication(sys.argv)
           
        if self.glplot is None:
            self.glplot = GLPlot(self.interactive, self.windowIndex)
            
        self.glplot.glWidget.load_data(fulldata, databounds, options)
        self.glplot.show()
        
        if not(self.interactive):
            sys.exit(app.exec_())
        
    def close(self):
        self.glplot.hide()
        self.reset()
 def show(self):
     data = [l.data for l in self.lines]
     fulldata = np.vstack(data)
     options = [l.options for l in self.lines]
     databounds = get_databounds(data)
 
     if not(self.interactive):
         app = QtGui.QApplication(sys.argv)
        
     if self.glplot is None:
         self.glplot = GLPlot(self.interactive, self.windowIndex)
         
     self.glplot.glWidget.load_data(fulldata, databounds, options)
     self.glplot.show()
     
     if not(self.interactive):
         sys.exit(app.exec_())