123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 |
- import time
- import os
- import math
- import numpy as np
- from numpy.polynomial.polynomial import polyval
- import h5py
- import traceback
- import csv
- import warnings
- from scipy.optimize import curve_fit
- from scipy.stats import chisquare
- from scipy.stats import chi2_contingency
- from scipy.special import erfc, erf
- import datetime
- import pyqtgraph as pg
- from PyQt4 import QtGui, QtCore, QtSvg
- import matplotlib
- matplotlib.use("Qt4Agg")
- #matplotlib.use("Agg")
- import matplotlib.pyplot as plt
- import logging
- try:
- #for KCG
- from ..base import kcgwidget as kcgw
- from ..base.backend import board
- from ..base.backend.board import available_boards
- from ..base.backend.DataSet import DataSet
- from ..base.backend.TimeScan import TimeScan
- from .. import config
- from ..config import colours, coloursTrans
- from ..base.backend.CalibrationHandle import theCalibration
- from ..base.globals import glob as global_objects
- from .CorrelationCorrection import CorrelationCorrection
- from ..base import storage
-
- except:
- import traceback
- traceback.print_exc()
- #for Analysis GUI
- import config
- from config import colours, coloursTrans
- import kcgwidget as kcgw
- from CalibrationHandle import theCalibration
- from constants import KARA
- from TimeScan import TimeScan
- from DataSet import DataSet
- from CorrelationCorrection import CorrelationCorrection
- LINEAR = 0
- GAUSS = 1
- GAUSSB = 2
- EGAUSSC= 3
- EGAUSS = 4
- EGAUSSB= 5
- SKEW = 6
- SINUS = 7
- __widget_id__ = None
- import shutil
- def sinus(x,a,b,c,d):
- return a*np.sin(b*x*(2*np.pi)+d)+c
- class CorrelationWidget(kcgw.KCGWidgets):
- """
- """
- def __init__(self, unique_id, parent, timeScan=None, delays=None, workingChannels=[0,1,2,3,4,5,6,7]):
- super(CorrelationWidget, self).__init__()
-
- self.id = unique_id
- self.par = parent
- # ------[ Variable declaration ]------------
- self.parent=parent
- self.timeScan = timeScan # Data to plot
- self.dataSet = None
- self.delays = delays
- self.updater = None
- self.workingChannels = workingChannels
- self.bunch = 0
- self.plotList = []
- tmp = CorrelationCorrection("",0,0,0, workingChannels=workingChannels)
- self.calibId = None
- if timeScan is not None:
- self.calibId = self.timeScan.calibId
- self.originalnotplotted = True
- self.running = False
-
- self.outText = self.createLabel('')
- self.outText.setStyleSheet("font: 12pt Courier")
- # -------[ Create structure ]----------
- self.outerLayout = QtGui.QVBoxLayout() # Outermost layout of this window
- self.setLayout(self.outerLayout)
- self.settingsLayout = QtGui.QGridLayout()
- lineindex = 0
-
- self.ts_label = QtGui.QLabel('selected Timescan: ')
- self.settingsLayout.addWidget(self.ts_label, lineindex, 0,1,2)
- lineindex +=1
- self.ds_label = QtGui.QLabel('selected DataSet: ')
- self.settingsLayout.addWidget(self.ds_label, lineindex, 0,1,2)
- lineindex +=1
- self.cf_label = QtGui.QLabel('selected CalibrationFile: ')
- self.settingsLayout.addWidget(self.cf_label, lineindex, 0,1,2)
- lineindex +=1
- if tmp.checkForCuda():
- self.text_label = QtGui.QLabel('working local on:')
- self.settingsLayout.addWidget(self.text_label, lineindex-3, 2,1,2)
- self.text_label = QtGui.QLabel(os.path.abspath(tmp.dirToReconstruction))
- self.settingsLayout.addWidget(self.text_label, lineindex-2, 2,1,2)
- else:
- self.text_label = QtGui.QLabel('working remote on:')
- self.settingsLayout.addWidget(self.text_label, lineindex-3, 2,1,2)
- self.text_label = QtGui.QLabel(tmp.host)
- self.settingsLayout.addWidget(self.text_label, lineindex-2, 2,1,2)
- self.text_label = QtGui.QLabel(tmp.remotePath)
- self.settingsLayout.addWidget(self.text_label, lineindex-1, 2,1,2)
- self.oTS_btn = QtGui.QPushButton("Open Timescan")
- self.oTS_btn.setStyleSheet("padding: 15px;")
- self.oTS_btn.clicked.connect(self.openTimeScan)
- self.settingsLayout.addWidget(self.oTS_btn, lineindex, 0,1,2)
- self.oMF_btn = QtGui.QPushButton("Open Measurement")
- self.oMF_btn.setStyleSheet("padding: 15px;")
- self.oMF_btn.clicked.connect(self.openMeasurement)
- self.settingsLayout.addWidget(self.oMF_btn, lineindex, 2,1,1)
- self.settingsLayout.addWidget(self.outText, lineindex, 3,2,1)
- lineindex +=1
- self.okay_btn = QtGui.QPushButton("Run")
- self.okay_btn.setStyleSheet("padding: 15px;")
- self.okay_btn.clicked.connect(self.on_okay)
- self.settingsLayout.addWidget(self.okay_btn, lineindex, 0)
- self.okay_btn = QtGui.QPushButton("Save")
- self.okay_btn.setStyleSheet("padding: 15px;")
- self.okay_btn.clicked.connect(self.on_save)
- self.settingsLayout.addWidget(self.okay_btn, lineindex, 1)
-
- self.cancel_btn = QtGui.QPushButton("Cancel")
- self.cancel_btn.setStyleSheet("padding: 15px;")
- self.cancel_btn.clicked.connect(self.on_cancel)
- self.settingsLayout.addWidget(self.cancel_btn, lineindex, 2)
- lineindex += 1
- self.multiBunchSelector = self.createSpinbox(0,184, start_value=0, interval=1, connect=self.plot)
- self.multiBunchSelectorLabel = self.createLabel('Bunch Selection:')
- self.settingsLayout.addWidget(self.multiBunchSelectorLabel, lineindex, 0)
- self.settingsLayout.addWidget(self.multiBunchSelector, lineindex, 1)
- self.multiBunchSelector.hide()
- self.multiBunchSelectorLabel.hide()
- #######################
- self.plotLayout = QtGui.QHBoxLayout()
- self.plotWidget1 = QtGui.QWidget()
- self.plotlayout1= QtGui.QGridLayout() # Main Layout to hold the most elements in this window
- self.all_plot_widget = pg.PlotWidget(title="Timescan")
-
- self.plotlayout1.addWidget(self.all_plot_widget, 0, 0)
- #self.plotlayout1.addWidget(self.outText, 2, 0,1,1)
- self.plotWidget1.setLayout(self.plotlayout1)
- self.plotWidget2 = QtGui.QWidget()
- self.plotlayout2 = QtGui.QGridLayout() # Main Layout to hold the most elements in this window
- self.result_m_plot = pg.PlotWidget(title="Mean")
- self.result_s_plot = pg.PlotWidget(title="Width")
- self.result_a_plot = pg.PlotWidget(title="Amplitude")
- self.syncedPlots = [self.result_m_plot, self.result_s_plot, self.result_a_plot] # put as many plots as you wish
- def onSigRangeChanged(r):
- for g in self.syncedPlots:
- if g !=r :
- g.blockSignals(True)
- g.setRange(xRange=r.getAxis('bottom').range)
- g.blockSignals(False)
- for g in self.syncedPlots:
- g.sigRangeChanged.connect(onSigRangeChanged)
-
- def setAxis(axis, lable, unit="", setSpace=False):
- labelStyle = {'color': '#000', 'font-size': '12pt'}
- axis.setLabel(lable, units=unit, **labelStyle)
-
- font=QtGui.QFont()
- font.setPixelSize(15)
- axis.tickFont = font
- axis.setStyle(tickTextOffset = 20)
- if unit != "":
- axis.enableAutoSIPrefix()
- if setSpace:
- axis.setWidth(int(80))
- setAxis(self.all_plot_widget.plotItem.getAxis('bottom'), 't', 's')
- setAxis(self.all_plot_widget.plotItem.getAxis('left'), '', '', True)
-
- self.plotlayout2.addWidget(self.result_m_plot, 0, 0)
- self.plotlayout2.addWidget(self.result_s_plot, 1, 0)
- self.plotlayout2.addWidget(self.result_a_plot, 2, 0)
- self.plotWidget2.setLayout(self.plotlayout2)
- self.plotLayout.addWidget(self.plotWidget1)
- self.plotLayout.addWidget(self.plotWidget2)
- # -- Create Parameter Adjust
-
- self.outerLayout.addLayout(self.settingsLayout)
- self.outerLayout.addLayout(self.plotLayout)
- self.setWindowTitle("Correlation Test")
- self.plot()
- self.updateLabels()
- try:
- board.get_board_config(available_boards[0]).observe(self, self.updateDelay, 'lastDataSet')
- except:
- traceback.print_exc()
- pass
- def openTimeScan(self):
- filename = str(QtGui.QFileDialog.getOpenFileName(self, "Select Time Scan"))
- if filename != "" and '.scan' in filename:
- self.timeScan = TimeScan(filename)
- self.calibId = self.timeScan.calibId
- self.updater = None
- self.running = False
- self.originalnotplotted = True
- self.plot()
- self.updateLabels()
-
- def openMeasurement(self):
- filename = str(QtGui.QFileDialog.getOpenFileName(self, "Select Measurementfile"))
- if filename != "" and '.out' in filename:
- self.dataSet = DataSet(filename)
- self.delays = self.dataSet.getCalibratedDelay()
- self.updater = None
- self.running = False
- #self.originalnotplotted = True
- self.plot()
- self.updateLabels()
- def updateLabels(self):
- try:
- self.ts_label.setText('selected Timescan: ' + (self.timeScan.fileName if self.timeScan is not None else 'None'))
- name = 'None'
- if self.dataSet is not None:
- if self.dataSet.fileName is None:
- name = 'last'
- else:
- name = self.dataSet.fileName
- self.ds_label.setText('selected DataSet: ' + name)
- self.cf_label.setText('selected CalibrationFile: ' + (self.calibId if self.calibId is not None else 'None'))
- except Exception as e:
- traceback.print_exc()
- def on_okay(self, param):
- if self.timeScan is None or self.delays is None:
- return
- self.thread = storage.ThreadStorage()
- if self.thread.running:
- logging.info("already running")
- return
- #self.processbarWidget = WaitingWidget(self)
- self.popup = kcgw.PopupDialog("Please Wait\nSimulation ongoing",
- title='Running', okonly=True)
- self.popup.show()
- #self.popup.deleteLater()
- #self.popup.get_return_value()
- scanx, scany, scane = self.timeScan.getScanOverTime(0, True, True)
- #self.updater = CorrelationCorrection(os.path.dirname(self.timeScan.fileName), scanx, scany, self.delays, workingChannels=self.workingChannels)
- self.updater = CorrelationCorrection(os.path.dirname(self.timeScan.fileName), self.scanxAll, self.scanyAll, self.delays, workingChannels=self.workingChannels)
- self.thread.register(self.updater)
- self.thread.connect('stopSignal', self._threadStop)
- self.thread.start('run')
- self.running = True
- """
- if not self.running:
- scanx, scany, scane = self.timeScan.getScanOverTime(0, True, True)
- self.updater = CorrelationCorrection(os.path.dirname(self.timeScan.fileName), scanx, scany, self.delays)
- self.updater.run(True)
- self.plot()
-
- """
- def on_save(self, param):
- print('save')
- if self.thread.running:
- print('thread still running')
- return
- if self.running:
- #print('save')
- self.updater.save(os.path.join(os.path.dirname(self.dataSet.fileName), 'correlation.hdf'))
- self.running = False
- pass
- def on_cancel(self, param):
- if self.thread.running:
- self.thread.stop()
- #print('on_cancel')
- self.parent.updater=None
- #self.close()
- pass
- def _threadStop(self):
- self.thread.stop()
- #print('_threadStop')
- self.popup.close()
- if self.processbarWidget is not None:
- self.processbarWidget.close()
- self.plot()
- def updateTimeScan(self, timeScan):
- self.timeScan = timeScan
- self.calibId = self.timeScan.calibId
- self.updater = None
- self.running = False
- self.originalnotplotted = True
- self.plot()
- self.updateLabels()
- def updateDelay(self, dataSet):
- #print('updateDelay')
- self.dataSet = dataSet
- self.delays = dataSet.getCalibratedDelay()
- self.updater = None
- self.running = False
- #self.originalnotplotted = True
- self.plot()
- self.updateLabels()
- #print('updateDelay done', self.delays)
- def plot(self):
- """
- Plot Data
- :return: -
- """
- if self.bunch != self.multiBunchSelector.value():
- self.originalnotplotted = True
- self.bunch = self.multiBunchSelector.value()
- try:
- if self.originalnotplotted:
- self.processbarWidget = WaitingWidget(self)
- self.scanxAll = []
- self.scanyAll = []
- if self.timeScan is not None:
- if self.timeScan.multibunch:
- self.multiBunchSelector.show()
- self.multiBunchSelectorLabel.show()
- else:
- self.multiBunchSelector.hide()
- self.multiBunchSelectorLabel.hide()
-
- #print('plot timeScan')
- self.all_plot_widget.plotItem.clear()
-
- for i in self.workingChannels:
-
- scanx, scany, scane = self.timeScan.getScanOverTime(i, True, True, bunch=self.multiBunchSelector.value())
- sorter = np.argsort(scanx)
- scanx = scanx[sorter]
- scany = scany[sorter]
- self.scanxAll.extend(scanx)
- self.scanyAll.extend(scany)
- N=3
- scanyAvg = np.convolve(scany, np.ones((N,))/N, mode='valid')
- self.all_plot_widget.plotItem.plot(scanx, scany, pen=None, symbolPen=pg.mkPen(colours[i]), symbolSize=4, pxMode=True, symbolBrush=pg.mkBrush(colours[i]), downsample=200)
- #self.all_plot_widget.plotItem.plot(scanx[1:-1], scanyAvg, pen=pg.mkPen(colours[i]), downsample=200)
- self.scanxAll = np.array(self.scanxAll)
- self.scanyAll = np.array(self.scanyAll)
- sorter = np.argsort(self.scanxAll)
- self.scanxAll = self.scanxAll[sorter]
- self.scanyAll = self.scanyAll[sorter]
- try:
- popt, perr, fitFun, pcov, label, x = self.doFit(self.scanxAll, self.scanyAll, EGAUSS)
- self.all_plot_widget.plotItem.plot(self.scanxAll, fitFun(self.scanxAll, *popt), pen=pg.mkPen(colours[3]), downsample=200)
- except Exception as e:
- pass
-
-
- self.processbarWidget.close()
- self.processbarWidget = None
- self.originalnotplotted = False
- if self.delays is not None:
- #print('plot delays')
- if self.scanyAll == []:
- self.scanyAll.extend([0,1])
- self.scanxAll.extend([0,1])
- i=1
- font = QtGui.QFont()
- font.setPixelSize(14)
- if self.plotList != []:
- for item in self.plotList:
- self.all_plot_widget.plotItem.removeItem(item)
- self.plotList = []
- for x in self.delays:
- if i-1 not in self.workingChannels:
- i += 1
- continue
- self.plotList.append(self.all_plot_widget.plotItem.plot([x,x], [np.min(self.scanyAll)*0.8, np.max(self.scanyAll)*1.2], pen=pg.mkPen(colours[0]), downsample=200))
- text = pg.TextItem(str(i), anchor=(0.5,1), color=(0,0,0))
- text.setFont(font)
- text.setPos(x,np.max(self.scanyAll)*1.22)
- self.all_plot_widget.addItem(text)
- self.plotList.append(text)
- i += 1
- if self.updater is not None:
- self.result_m_plot.plotItem.clear()
- self.result_s_plot.plotItem.clear()
- self.result_a_plot.plotItem.clear()
- self.result_m_plot.plotItem.plot(self.updater.mo, pen=pg.mkPen(colours[0]))
- #self.result_m_plot.plotItem.plot(self.updater.m , pen=pg.mkPen(colours[3]))
- self.result_m_plot.plotItem.plot(self.updater.mc, pen=pg.mkPen(colours[1]))
-
- self.result_s_plot.plotItem.plot(self.updater.so, pen=pg.mkPen(colours[0]))
- #self.result_s_plot.plotItem.plot(self.updater.s , pen=pg.mkPen(colours[3]))
- self.result_s_plot.plotItem.plot(self.updater.sc, pen=pg.mkPen(colours[1]))
- self.result_a_plot.plotItem.plot(self.updater.ao, pen=pg.mkPen(colours[0]))
- #self.result_a_plot.plotItem.plot(self.updater.a , pen=pg.mkPen(colours[3]))
- self.result_a_plot.plotItem.plot(self.updater.ac, pen=pg.mkPen(colours[1]))
- try:
- pov0 = self.updater.povUnCorr
- pov1 = self.updater.povCorr
- pov2 = self.updater.povOrg
- text = " : Org | Corr | Ideal \n"
- text += "A-M: {: .5f} | {: .5f} | {: .5f} \n".format(pov0[0,1], pov1[0,1], pov2[0,1])
- text += "A-S: {: .5f} | {: .5f} | {: .5f} \n".format(pov0[0,2], pov1[0,2], pov2[0,2])
- text += "M-S: {: .5f} | {: .5f} | {: .5f} ".format(pov0[1,2], pov1[1,2], pov2[1,2])
- self.outText.setText(text)
-
- except Exception as e:
- pass
- self.show()
- self.setFocus()
- except Exception as e:
- traceback.print_exc()
-
- ##################################################################################
- def doFit(self, x,y, type, p0=None, baseline=0, findMin=False):
- #np.seterr(all='warn')
- #warnings.filterwarnings('error')
- def linear(x,a,b):
- return a + b*x
- def gauss(x, sigma, mu, A, b):
- return A*np.exp(-0.5*((x-mu)/sigma)**2) + b
- def expgauss(x, s, m, a ,l, b):
- return a*l/2*np.exp(l/2*(2*m + l*s**2 - 2*x)) * erfc((m +l*s**2 -x)/(np.sqrt(2)*s)) + b
- def expgauss2(x, s, m, a, t, b):
- return a*s/t*np.sqrt(np.pi/2) * np.exp(0.5 * (s/t)**2 - (x-m)/t) * erfc(1/np.sqrt(2)*(s/t - (x-m)/s)) + b
-
- def sinus(x,a,b,c,d):
- return a*np.sin(b*x*(2*np.pi)+d)+c
- def skewnorm(x, s, m, a, l, b):
- def p(x):
- return 1/np.sqrt(2*np.pi) * np.exp(- x**2/2)
- def g(x):
- return 0.5*(1+erf(x/np.sqrt(2)))
- return a*2/s*p((x-m)/s)*g(l*(x-m)/s) + b
-
- if findMin:
- startx = x[np.where(y==np.min(y))]
- else:
- startx = x[np.where(y==np.max(y))]
- y = y[np.argsort(x)]
- x = x[np.argsort(x)]
- if type == EGAUSS:
- fitFun = expgauss
- p0 = (23e-12, startx, 7e-8, 0.02e12, 2040)
- if findMin:
- p0 = (23e-12, startx, -7e-8, 0.02e12, 2040)
- label = [' s ', ' m ', ' a ', ' l ', ' b ']
- elif type == EGAUSSB:
- fitFun = expgauss2
- p0 = [19e-12, startx, 1200, 40e-12, 2040]
- if findMin:
- p0 = [19e-12, startx, -1200, 40e-12, 2040]
- label = [' s ', ' m ', ' a ', ' l ', ' b ']
- elif type == SKEW:
- fitFun = skewnorm
- p0 = [80e-12, startx, 6e-8, 3, 2040] # 220e-12
- if findMin:
- p0 = [80e-12, startx, -6e-8, 3, 2040] # 220e-12
- label = [' s ', ' m ', ' a ', ' l ', ' b ']
- else:
- print('Fit type unknown ', type)
- return 0,0, lambda x: x , 0
- if baseline != 0:
- print('baseline', baseline)
- fitFunOrg = fitFun
- fitFun = lambda x, s, m, a, l: fitFunOrg(x,s,m,a,l, baseline)
- p0 = p0[:-1]
- if p0 is not None:
- popt, pcov = curve_fit(fitFun, x, y, p0=p0)
- else:
- popt, pcov = curve_fit(fitFun, x, y)
- #popt = p0
- perr = np.sqrt(np.absolute(np.diag(pcov)))
- if baseline != 0:
- fitFun = fitFunOrg
- popt = np.append(popt, baseline)
- return popt, perr, fitFun, pcov, label, x
- ##################################################################################
- def closeEvent(self, event):
- """
- Event handler for closing this window
- """
- try:
- board.get_board_config(available_boards[0]).unobserve(self, 'lastDataSet')
- except:
- pass
- if self.processbarWidget is not None:
- self.processbarWidget.close()
- if self.parent is not None:
- self.parent.updater = None
-
- global __widget_id__
- __widget_id__ = None
-
- del self.par.widgets[self.id]
- print('closed')
- def addCorrelationWidget():
- global __widget_id__
- if __widget_id__:
- global_objects.get_global('area').widgets[__widget_id__].setFocus()
- else:
- nid = kcgw.idg.genid()
- __widget_id__ = nid
- w = CorrelationWidget(nid, global_objects.get_global('area'), workingChannels=config.working_channels)
- global_objects.get_global('area').newWidget(w, "Correlation Widget", nid, widget_type=4, minSize=True)
- return global_objects.get_global('area').widgets[__widget_id__]
- kcgw.register_widget(QtGui.QIcon(config.icon_path("correlation.svg")), "Correlation Widget", addCorrelationWidget, "Ctrl+Shift+C")
- # 8888888b. 888 888 888 d8b 888 888
- # 888 Y88b 888 888 o 888 Y8P 888 888
- # 888 888 888 888 d8b 888 888 888
- # 888 d88P 888d888 .d88b. .d8888b .d88b. .d8888b 88888b. 8888b. 888d888 888 d888b 888 888 .d88888 .d88b. .d88b. 888888
- # 8888888P" 888P" d88""88b d88P" d8P Y8b 88K 888 "88b "88b 888P" 888d88888b888 888 d88" 888 d88P"88b d8P Y8b 888
- # 888 888 888 888 888 88888888 "Y8888b. 888 888 .d888888 888 88888P Y88888 888 888 888 888 888 88888888 888
- # 888 888 Y88..88P Y88b. Y8b. X88 888 d88P 888 888 888 8888P Y8888 888 Y88b 888 Y88b 888 Y8b. Y88b.
- # 888 888 "Y88P" "Y8888P "Y8888 88888P' 88888P" "Y888888 888 888P Y888 888 "Y88888 "Y88888 "Y8888 "Y888
- # 888
- # Y8b d88P
- # "Y88P"
- class ProcesbarWidget(kcgw.KCGWidgets):
- """
- The Timescan result plot subwindow.
- """
- def __init__(self, parent, twobars=False):
- super(ProcesbarWidget, self).__init__()
- self.setWindowTitle("please wait")
-
- # ------[ Variable declaration ]------------
- self.parent = parent
- self.twobars = twobars
-
- # -------[ Create structure ]----------
- self.outerLayout = QtGui.QVBoxLayout() # Outermost layout of this window
- self.setLayout(self.outerLayout)
- self.progressbar = QtGui.QProgressBar()
- #self.layout.addWidget(self.progressbar, lineindex,0,1,4)
- self.progressbar.setRange(0,1000)
- self.outerLayout.addWidget(self.createLabel(' \n ....Running.... \n '))
- self.outerLayout.addWidget(self.progressbar)
- if twobars:
- self.progressbar2 = QtGui.QProgressBar()
- #self.layout.addWidget(self.progressbar, lineindex,0,1,4)
- self.progressbar2.setRange(0,1000)
- self.outerLayout.addWidget(self.progressbar2)
- self.show()
- def update(self, value, value2=0):
- self.progressbar.setValue(value)
- if self.twobars:
- self.progressbar2.setValue(value2)
- QtGui.qApp.processEvents()
- ##################################################################################
- def closeEvent(self, event):
- """
- Event handler for closing this window
- """
- self.parent.processbarWidget = None
- pass
- class WaitingWidget(kcgw.KCGWidgets):
- """
- The Timescan result plot subwindow.
- """
- def __init__(self, parent):
- super(WaitingWidget, self).__init__()
- self.setWindowTitle("please wait")
-
- # ------[ Variable declaration ]------------
- self.parent = parent
-
- # -------[ Create structure ]----------
- self.outerLayout = QtGui.QVBoxLayout() # Outermost layout of this window
- self.setLayout(self.outerLayout)
- self.outerLayout.addWidget(self.createLabel(' \n ....Loading.... \n '))
- self.show()
- QtGui.qApp.processEvents()
- ##################################################################################
- def closeEvent(self, event):
- """
- Event handler for closing this window
- """
- self.parent.processbarWidget = None
- pass
|