def __init__(self, parent=None, vlayout=None, worldConfigObject=None): self.parent = parent self.monitorConf = Monitor.DEFAULT_CONFIG_DICT self._environmentSelectionChanged(sorted(MMLF_ENVIRONMENTS.keys())[0]) self._agentSelectionChanged(sorted(MMLF_AGENTS.keys())[0]) # Environment Configuration environmentLabel = QtGui.QLabel("Environment") self.environmentComboBox = QtGui.QComboBox(self.parent) self.environmentComboBox.addItems(sorted(MMLF_ENVIRONMENTS.keys())) self.environmentComboBox.setToolTip( "Environment in which the agent will act") environmentConfigureButton = QtGui.QPushButton("Configure") if parent: # Sometime we use this only for loading ... parent.connect(self.environmentComboBox, QtCore.SIGNAL('activated (const QString&)'), self._environmentSelectionChanged) parent.connect(environmentConfigureButton, QtCore.SIGNAL('clicked()'), self._configureEnvironment) # Agent Configuration agentLabel = QtGui.QLabel("Agent") self.agentComboBox = QtGui.QComboBox(self.parent) self._updateAvailableAgents(self.selectedEnvironment) self.agentComboBox.setToolTip("The learning agent") agentConfigureButton = QtGui.QPushButton("Configure") if parent: # Sometimes we use this only for loading ... parent.connect(self.agentComboBox, QtCore.SIGNAL('activated (const QString&)'), self._agentSelectionChanged) parent.connect(agentConfigureButton, QtCore.SIGNAL('clicked()'), self._configureAgent) # If we start with a non-default world configuration if worldConfigObject is not None: # We overwrite the default config self._initFromWorldConfigObject(worldConfigObject) if vlayout is not None: # Sometimes we use this only for loading ... # Adding GUI elements to external vlayout self.hlayoutEnvironment = QtGui.QHBoxLayout() self.hlayoutEnvironment.addWidget(environmentLabel) self.hlayoutEnvironment.addWidget(self.environmentComboBox) self.hlayoutEnvironment.addWidget(environmentConfigureButton) self.hlayoutAgent = QtGui.QHBoxLayout() self.hlayoutAgent.addWidget(agentLabel) self.hlayoutAgent.addWidget(self.agentComboBox) self.hlayoutAgent.addWidget(agentConfigureButton) vlayout.addLayout(self.hlayoutEnvironment) vlayout.addLayout(self.hlayoutAgent)
def __init__(self, tableModel, parent): super(ExperimentViewer, self).__init__() self.parent = parent # set the table model self.tableModel = tableModel # Combobox to select metric (FloatStreamObservable) that is shown self.metricLabel = QtGui.QLabel("Metric") self.metricComboBox = QtGui.QComboBox(self) self.metricComboBox.addItems(self.tableModel.metrics) self.connect(self.metricComboBox, QtCore.SIGNAL('activated (const QString&)'), self.tableModel.metricSelectionChanged) # Automatically update metric combobox when new metric observables # are created during runtime def addMetric(metric): self.metricComboBox.addItem(metric) self.tableModel.metricsObserver.append(addMetric) self.plotButton = QtGui.QPushButton("Visualize") self.connect(self.plotButton, QtCore.SIGNAL('clicked()'), self._plotResults) self.statisticsButton = QtGui.QPushButton("Statistics") self.connect(self.statisticsButton, QtCore.SIGNAL('clicked()'), self._analyzeStatistics) # create the view self.tableView = QtGui.QTableView() self.tableView.setModel(self.tableModel) self.tableView.setMinimumSize(400, 300) # set the minimum size self.tableView.setShowGrid(False) # hide grid # Start layouting ... self.topLineLayout = QtGui.QHBoxLayout() self.topLineLayout.addWidget(self.metricLabel) self.topLineLayout.addWidget(self.metricComboBox) self.topLineLayout.addWidget(self.plotButton) self.topLineLayout.addWidget(self.statisticsButton) self.layout = QtGui.QVBoxLayout() self.layout.addLayout(self.topLineLayout) self.layout.addWidget(self.tableView) self.setLayout(self.layout)
def __init__(self, possibleEntries, initialList, title, closeCallback, parent=None): super(ListEditorWindow, self).__init__(parent) self.setWindowTitle(title) self.closeCallback = closeCallback self.parent = parent self.currentList = [] self.closeButton = QtGui.QPushButton("Save") self.connect(self.closeButton, QtCore.SIGNAL('clicked()'), self.onClose) self.vlayout = QtGui.QVBoxLayout() self.checkboxes = [] for entry in possibleEntries: checkbox = QtGui.QCheckBox(str(entry)) if initialList is not None and entry in initialList: checkbox.setChecked(True) self.checkboxes.append(checkbox) self.vlayout.addWidget(checkbox) self.closeButton = QtGui.QPushButton("Save") self.connect(self.closeButton, QtCore.SIGNAL('clicked()'), self.onClose) self.vlayout.addWidget(self.closeButton) centralWidget = QtGui.QWidget(self) centralWidget.setLayout(self.vlayout) self.setCentralWidget(centralWidget)
def __init__(self, initialConfigDict, infoString, closeCallback, nonStandardConfigs={}, parent=None): super(ConfigEditorWidget, self).__init__(parent) self.infoString = infoString self.closeCallback = closeCallback self.parent = parent self.currentDict = {} self.vspace = QtGui.QLabel("") self.infoLabel = QtGui.QLabel("Info") self.infoLabel.setAlignment(QtCore.Qt.AlignCenter) self.infoBox = QtGui.QTextBrowser(self) if infoString: self.infoBox.setText(infoString) else: self.infoBox.setText("Documentation missing") self.closeButton = QtGui.QPushButton("Save") self.connect(self.closeButton, QtCore.SIGNAL('clicked()'), self.onClose) self.vlayoutLeft = QtGui.QVBoxLayout() self.vlayoutRight = QtGui.QVBoxLayout() self.fillLayoutFromDict(initialConfigDict, self.currentDict, infoString, prefix="", nonStandardConfigs=nonStandardConfigs) self.hlayout = QtGui.QHBoxLayout() self.hlayout.addLayout(self.vlayoutLeft) self.hlayout.addLayout(self.vlayoutRight) self.vlayout = QtGui.QVBoxLayout() self.vlayout.addLayout(self.hlayout) self.vlayout.addWidget(self.vspace) self.vlayout.addWidget(self.infoLabel) self.vlayout.addWidget(self.infoBox) self.vlayout.addWidget(self.closeButton) self.setLayout(self.vlayout)
def __init__(self, onCloseCallback=None, parent=None, worldConfigObject=None): super(WorldConfigEditorWindow, self).__init__(parent) self.onCloseCallback = onCloseCallback self.parent = parent self.setWindowTitle("MMLF World Configuration Editor") self.centralWidget = QtGui.QWidget() self.vlayout = QtGui.QVBoxLayout() self.worldConfigEditor = \ WorldConfigEditor(self, self.vlayout, worldConfigObject) self.saveButton = QtGui.QPushButton("Save") self.connect(self.saveButton, QtCore.SIGNAL('clicked()'), self._onClose) self.vlayout.addWidget(self.saveButton) self.centralWidget.setLayout(self.vlayout) self.setCentralWidget(self.centralWidget)
def fillLayoutFromDict(self, configDict, currentDict, infoString, prefix="", nonStandardConfigs={}): for key, value in sorted(configDict.items()): self.vlayoutLeft.addWidget(QtGui.QLabel(prefix + str(key))) if isinstance(value, dict): from mmlf.resources.function_approximators.function_approximator \ import FunctionApproximator from mmlf.resources.model.model import Model from mmlf.resources.planner.planner import Planner from mmlf.resources.policy_search.policy_search \ import PolicySearch from mmlf.resources.policies.policy import Policy from mmlf.resources.optimization.optimizer import Optimizer from mmlf.resources.skill_discovery.skill_discovery \ import SkillDiscovery entryDicts = { "function_approximator": FunctionApproximator.getFunctionApproximatorDict(), "preferences_approximator": FunctionApproximator.getFunctionApproximatorDict(), "model": Model.getModelDict(), "planner": Planner.getPlannerDict(), "policy_search": PolicySearch.getPolicySearchDict(), "policy": Policy.getPolicyDict(), "optimizer": Optimizer.getOptimizerDict(), "skill_discovery": SkillDiscovery.getSkillDiscoveryDict() } if key in entryDicts.keys(): comboBox = QtGui.QComboBox(self) configureButton = QtGui.QPushButton("Configure") config = MMLFModuleGUIConfig(value, entryDicts[key], comboBox, configureButton, self) currentDict[key] = ( lambda config: lambda: config.getConfig())(config) comboBox.setToolTip(self._searchTooltip(key, infoString)) hlayout = QtGui.QHBoxLayout() hlayout.addWidget(comboBox) hlayout.addWidget(configureButton) self.vlayoutRight.addLayout(hlayout) else: self.vlayoutRight.addWidget(QtGui.QLabel("")) someDict = dict() # Recursive call self.fillLayoutFromDict( value, someDict, infoString, prefix=prefix + "\t", nonStandardConfigs=nonStandardConfigs) currentDict[key] = someDict elif key in nonStandardConfigs.keys(): # this key should be handled differently currentDict[key] = value configureButton = QtGui.QPushButton("Configure") configureButton.setToolTip(self._searchTooltip( key, infoString)) def createFunction(currentDict, key, value): def callbackFunction(config): currentDict[key] = config def configureNonStandardConfig(): config = nonStandardConfigs[key](value, callbackFunction, parent=self) config.show() return configureNonStandardConfig self.connect(configureButton, QtCore.SIGNAL('clicked()'), createFunction(currentDict, key, value)) self.vlayoutRight.addWidget(configureButton) elif value is True or value is False or value in ["True", "False"]: checkbox = QtGui.QCheckBox() if value in [True, "True"]: checkbox.setChecked(True) checkbox.setToolTip(self._searchTooltip(key, infoString)) self.vlayoutRight.addWidget(checkbox) currentDict[key] = (lambda func: lambda: func())( checkbox.isChecked) else: lineEdit = QtGui.QLineEdit(str(value)) lineEdit.setToolTip(self._searchTooltip(key, infoString)) self.vlayoutRight.addWidget(lineEdit) currentDict[key] = (lambda func: lambda: func())(lineEdit.text)
def __init__(self, experimentResults, parent=None): super(StatisticalAnalysisWidget, self).__init__(parent) self.experimentResults = experimentResults # Statistical test self.TESTS = {'MannWhitney U-Test': lambda x, y: scipy.stats.mannwhitneyu(x,y)[1], 'Student t-test': lambda x, y: scipy.stats.ttest_ind(x,y)[1]/2} # Create combobox for selecting the metric metricsLabel = QtGui.QLabel("Metric") self.metricsComboBox = QtGui.QComboBox(self) self.metricsComboBox.addItems(self.experimentResults.metrics) # Text field for the aggregation function aggregationLabel = QtGui.QLabel("Aggregation") self.aggregationFctEdit = QtGui.QLineEdit("lambda x: mean(x[:])") self.aggregationFctEdit.minimumSizeHint = lambda : QtCore.QSize(100,30) self.aggregationFctEdit.setToolTip("Function which maps a time series " "onto a single scalar value, which " "is then used as a sample in " "the statistical hypothesis testing." "The functions min, max, mean, and " "median may be used.") # Create combobox for selecting the test testLabel = QtGui.QLabel("Hypothesis test") self.testComboBox = QtGui.QComboBox(self) self.testComboBox.addItems(self.TESTS.keys()) # Text field for the p-Value pValueLabel = QtGui.QLabel("p <") self.pValueEdit = QtGui.QLineEdit("0.05") self.pValueEdit.minimumSizeHint = lambda : QtCore.QSize(100,30) self.pValueEdit.setToolTip("Significance level: The minimal p-Value " "which is required for something to be " "considered as significant.") # button for redoing the statistics for the current setting self.updateButton = QtGui.QPushButton("Update") self.connect(self.updateButton, QtCore.SIGNAL('clicked()'), self._analyze) # Create matplotlib widget plotWidget = QtGui.QWidget(self) plotWidget.setMinimumSize(500, 500) fig = Figure((5.0, 5.0), dpi=100) fig.subplots_adjust(0.2) self.canvas = FigureCanvas(fig) self.canvas.setParent(plotWidget) self.axis = fig.gca() # The table for statistics results self.significanceTable = QtGui.QTableWidget(self) # Do the analyzing once for the default values self._analyze() # Create layout layout = QtGui.QVBoxLayout() hlayout1 = QtGui.QHBoxLayout() hlayout1.addWidget(metricsLabel) hlayout1.addWidget(self.metricsComboBox) hlayout1.addWidget(aggregationLabel) hlayout1.addWidget(self.aggregationFctEdit) hlayout1.addWidget(testLabel) hlayout1.addWidget(self.testComboBox) hlayout1.addWidget(pValueLabel) hlayout1.addWidget(self.pValueEdit) hlayout1.addWidget(self.updateButton) hlayout2 = QtGui.QHBoxLayout() hlayout2.addWidget(plotWidget) hlayout2.addWidget(self.significanceTable) layout.addLayout(hlayout1) layout.addLayout(hlayout2) self.setLayout(layout)
def __init__(self, tableModel, parent): super(PlotExperimentWindow, self).__init__(parent) self.tableModel = tableModel # Colors used for different configurations in plots self.colors = cycle(["b", "g", "r", "c", "m", "y", "k"]) self.colorMapping = defaultdict(lambda : self.colors.next()) # The length of the moving window average self.mwaSize = 2**0 # Whether we plot each run separately or only their mean self.linePlotTypes = ["Each Run", "Average"] self.linePlot = self.linePlotTypes[0] # The central widget self.centralWidget = QtGui.QWidget(self) # Create matplotlib widget self.plotWidget = QtGui.QWidget(self.centralWidget) self.plotWidget.setMinimumSize(800, 500) self.fig = Figure((8.0, 5.0), dpi=100) self.canvas = FigureCanvas(self.fig) self.canvas.setParent(self.plotWidget) self.axis = self.fig.gca() self.mplToolbar = NavigationToolbar(self.canvas, self.centralWidget) self.mwaLabel = QtGui.QLabel("Moving Window Average: %s" % self.mwaSize) # Slider for controlling the moving average window self.mwaSlider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.mwaSlider.setValue(0) self.mwaSlider.setMinimum(0) self.mwaSlider.setMaximum(10) self.mwaSlider.setTickInterval(10) self.mwaSlider.setTickPosition(QtGui.QSlider.TicksBelow) self.connect(self.mwaSlider, QtCore.SIGNAL('sliderReleased()'), self._changeMWA) self.lineLabel = QtGui.QLabel("Plot of agent: ") # Combo Box for selecting the observable self.lineComboBox = QtGui.QComboBox(self) self.lineComboBox.addItems(["Each Run", "Average"]) self.connect(self.lineComboBox, QtCore.SIGNAL('currentIndexChanged (int)'), self._linePlotChanged) # Add a button for replotting self.replotButton = QtGui.QPushButton("Update") self.connect(self.replotButton, QtCore.SIGNAL('clicked()'), self._plot) # Add a button for saving a plot self.saveButton = QtGui.QPushButton("Save") self.connect(self.saveButton, QtCore.SIGNAL('clicked()'), self._save) # Set layout self.topLinelayout = QtGui.QHBoxLayout() self.topLinelayout.addWidget(self.mwaLabel) self.topLinelayout.addWidget(self.mwaSlider) self.topLinelayout.addWidget(self.lineLabel) self.topLinelayout.addWidget(self.lineComboBox) self.topLinelayout.addWidget(self.replotButton) self.topLinelayout.addWidget(self.saveButton) self.vlayout = QtGui.QVBoxLayout() self.vlayout.addLayout(self.topLinelayout) self.vlayout.addWidget(self.plotWidget) self.vlayout.addWidget(self.mplToolbar) self.centralWidget.setLayout(self.vlayout) self.setCentralWidget(self.centralWidget) self.setWindowTitle("Current experiment's results") # Plot the results once upon creation self._plot()
def __init__(self, maze, stateSpace): super(Maze2DFunctionViewer, self).__init__() self.maze = maze self.stateSpace = stateSpace self.updateCounter = 0 self.updatePlotNow = False self.evalFunction = None self.lock = threading.Lock() # Create matplotlib widgets plotWidget = QtGui.QWidget(self) plotWidget.setMinimumSize(600, 500) plotWidget.setWindowTitle("Maze2D") self.fig = Figure((6.0, 5.0), dpi=100) self.axis = self.fig.gca() self.axis.clear() self.maze.drawIntoAxis(self.axis) self.canvas = FigureCanvas(self.fig) self.canvas.setParent(plotWidget) self.canvas.draw() self.plottedPatches = [] # Add a combobox for selecting the function over state space that is observed self.selectedFunctionObservable = None self.functionObservableLabel = QtGui.QLabel( "Function over State Space") self.functionObservableComboBox = QtGui.QComboBox(self) functionObservables = OBSERVABLES.getAllObservablesOfType( FunctionOverStateSpaceObservable) stateActionValueObservables = \ OBSERVABLES.getAllObservablesOfType(StateActionValuesObservable) functionObservables.extend(stateActionValueObservables) self.functionObservableComboBox.addItems([ functionObservable.title for functionObservable in functionObservables ]) if len(functionObservables) > 0: self.selectedFunctionObservable = functionObservables[0].title self.connect(self.functionObservableComboBox, QtCore.SIGNAL('activated (const QString&)'), self._functionObservableChanged) # Automatically update funtion observable combobox when new observables # are created during runtime def updateFunctionObservableBox(viewer, action): self.functionObservableComboBox.clear() functionObservables = \ OBSERVABLES.getAllObservablesOfType(FunctionOverStateSpaceObservable) stateActionValueObservables = \ OBSERVABLES.getAllObservablesOfType(StateActionValuesObservable) functionObservables.extend(stateActionValueObservables) self.functionObservableComboBox.addItems([ functionObservable.title for functionObservable in functionObservables ]) if self.selectedFunctionObservable is None \ and len(functionObservables) > 0: self.selectedFunctionObservable = functionObservables[0].title else: # Let combobox still show the selected observable index = self.functionObservableComboBox.findText( self.selectedFunctionObservable) if index != -1: self.functionObservableComboBox.setCurrentIndex(index) OBSERVABLES.addObserver(updateFunctionObservableBox) # Add a combobox for for selecting the suboption that is used when # a StateActionValuesObservable is observed self.selectedSuboption = None self.suboptionLabel = QtGui.QLabel("Suboption") self.suboptionComboBox = QtGui.QComboBox(self) # Slider that controls the frequency of update the plot self.updateFrequency = 0.0 self.updateFrequencySlider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.updateFrequencySlider.setValue(int(self.updateFrequency * 100)) self.updateFrequencySlider.setMinimum(0) self.updateFrequencySlider.setMaximum(100) self.updateFrequencySlider.setTickInterval(0.1) self.updateFrequencySlider.setTickPosition(QtGui.QSlider.TicksBelow) self.connect(self.updateFrequencySlider, QtCore.SIGNAL('sliderReleased()'), self._changeUpdateFrequency) self.updateFrequencyLabel = QtGui.QLabel("UpdateFrequency: %s" % self.updateFrequency) # Button to enforce update of plot self.updatePlotButton = QtGui.QPushButton("Update Plot") self.connect(self.updatePlotButton, QtCore.SIGNAL('clicked()'), self._updatePlot) # Legend of plot self.legendLabel = QtGui.QLabel("Legend:") self.legendWidget = QtGui.QListWidget(self) self.hlayout = QtGui.QHBoxLayout() self.hlayout.addWidget(plotWidget) self.vlayout = QtGui.QVBoxLayout() self.functionObservableLayout = QtGui.QHBoxLayout() self.functionObservableLayout.addWidget(self.functionObservableLabel) self.functionObservableLayout.addWidget( self.functionObservableComboBox) self.vlayout.addLayout(self.functionObservableLayout) self.suboptionLayout = QtGui.QHBoxLayout() self.suboptionLayout.addWidget(self.suboptionLabel) self.suboptionLayout.addWidget(self.suboptionComboBox) self.vlayout.addLayout(self.suboptionLayout) self.updateFrequencyLayout = QtGui.QHBoxLayout() self.updateFrequencyLayout.addWidget(self.updateFrequencyLabel) self.updateFrequencyLayout.addWidget(self.updateFrequencySlider) self.vlayout.addLayout(self.updateFrequencyLayout) self.vlayout.addWidget(self.updatePlotButton) self.vlayout.addWidget(self.legendLabel) self.vlayout.addWidget(self.legendWidget) self.hlayout.addLayout(self.vlayout) self.setLayout(self.hlayout) # Connect to observer (has to be the last thing!!) self.functionObservable = None if self.selectedFunctionObservable is not None: self._functionObservableChanged(self.selectedFunctionObservable)
def __init__(self, pinballMazeEnv, stateSpace): super(PinballMazeFunctionViewer, self).__init__() self.pinballMazeEnv = pinballMazeEnv self.stateSpace = stateSpace self.actions = [] self.updateCounter = 0 self.updatePlotNow = False self.evalFunction = None self.lock = threading.Lock() # Create matplotlib widgets plotWidget = QtGui.QWidget(self) plotWidget.setMinimumSize(600, 500) plotWidget.setWindowTitle("Pinball Maze") self.fig = Figure((6.0, 5.0), dpi=100) self.axis = self.fig.gca() self.pinballMazeEnv.plotStateSpaceStructure(self.axis) self.canvas = FigureCanvas(self.fig) self.canvas.setParent(plotWidget) self.canvas.draw() self.plottedPatches = [] # Add a combobox for selecting the function over state space that is observed self.selectedFunctionObservable = None self.functionObservableLabel = QtGui.QLabel( "Function over State Space") self.functionObservableComboBox = QtGui.QComboBox(self) functionObservables = OBSERVABLES.getAllObservablesOfType( FunctionOverStateSpaceObservable) self.functionObservableComboBox.addItems([ functionObservable.title for functionObservable in functionObservables ]) if len(functionObservables) > 0: self.selectedFunctionObservable = functionObservables[0].title self.connect(self.functionObservableComboBox, QtCore.SIGNAL('activated (const QString&)'), self._functionObservableChanged) # Automatically update funtion observable combobox when new observables # are created during runtime def updateFunctionObservableBox(viewer, action): self.functionObservableComboBox.clear() functionObservables = \ OBSERVABLES.getAllObservablesOfType(FunctionOverStateSpaceObservable) self.functionObservableComboBox.addItems([ functionObservable.title for functionObservable in functionObservables ]) if len(functionObservables) > 0: self.selectedFunctionObservable = functionObservables[0].title OBSERVABLES.addObserver(updateFunctionObservableBox) # Slider that controls the granularity of the plot-grid self.gridNodesPerDim = 50 self.gridNodesSlider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.gridNodesSlider.setValue(self.gridNodesPerDim) self.gridNodesSlider.setMinimum(0) self.gridNodesSlider.setMaximum(100) self.gridNodesSlider.setTickInterval(10) self.gridNodesSlider.setTickPosition(QtGui.QSlider.TicksBelow) self.connect(self.gridNodesSlider, QtCore.SIGNAL('sliderReleased()'), self._changeGridNodes) self.gridNodesLabel = QtGui.QLabel("Grid Nodes Per Dimension: %s" % self.gridNodesPerDim) # Slider that controls the frequency of update the plot self.updateFrequency = 0.0 self.updateFrequencySlider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.updateFrequencySlider.setValue(int(self.updateFrequency * 100)) self.updateFrequencySlider.setMinimum(0) self.updateFrequencySlider.setMaximum(100) self.updateFrequencySlider.setTickInterval(0.1) self.updateFrequencySlider.setTickPosition(QtGui.QSlider.TicksBelow) self.connect(self.updateFrequencySlider, QtCore.SIGNAL('sliderReleased()'), self._changeUpdateFrequency) self.updateFrequencyLabel = QtGui.QLabel("UpdateFrequency: %s" % self.updateFrequency) # Button to enforce update of plot self.updatePlotButton = QtGui.QPushButton("Update Plot") self.connect(self.updatePlotButton, QtCore.SIGNAL('clicked()'), self._updatePlot) # Chosen xvel and yvel values self.xVel = 0.5 self.xVelSlider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.xVelSlider.setValue(int(self.xVel * 10)) self.xVelSlider.setMinimum(0) self.xVelSlider.setMaximum(10) self.xVelSlider.setTickInterval(1) self.xVelSlider.setTickPosition(QtGui.QSlider.TicksBelow) self.connect(self.xVelSlider, QtCore.SIGNAL('sliderReleased()'), self._changeXVel) self.xVelLabel = QtGui.QLabel("xvel value: %s" % self.xVel) self.yVel = 0.5 self.yVelSlider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.yVelSlider.setValue(int(self.yVel * 10)) self.yVelSlider.setMinimum(0) self.yVelSlider.setMaximum(10) self.yVelSlider.setTickInterval(1) self.yVelSlider.setTickPosition(QtGui.QSlider.TicksBelow) self.connect(self.yVelSlider, QtCore.SIGNAL('sliderReleased()'), self._changeYVel) self.yVelLabel = QtGui.QLabel("yvel value: %s" % self.xVel) # Legend of plot self.legendLabel = QtGui.QLabel("Legend:") self.legendWidget = QtGui.QListWidget(self) self.hlayout = QtGui.QHBoxLayout() self.hlayout.addWidget(plotWidget) self.vlayout = QtGui.QVBoxLayout() self.functionObservableLayout = QtGui.QHBoxLayout() self.functionObservableLayout.addWidget(self.functionObservableLabel) self.functionObservableLayout.addWidget( self.functionObservableComboBox) self.vlayout.addLayout(self.functionObservableLayout) self.gridNodesLayout = QtGui.QHBoxLayout() self.gridNodesLayout.addWidget(self.gridNodesLabel) self.gridNodesLayout.addWidget(self.gridNodesSlider) self.vlayout.addLayout(self.gridNodesLayout) self.updateFrequencyLayout = QtGui.QHBoxLayout() self.updateFrequencyLayout.addWidget(self.updateFrequencyLabel) self.updateFrequencyLayout.addWidget(self.updateFrequencySlider) self.vlayout.addLayout(self.updateFrequencyLayout) self.vlayout.addWidget(self.updatePlotButton) self.xVelLayout = QtGui.QHBoxLayout() self.xVelLayout.addWidget(self.xVelLabel) self.xVelLayout.addWidget(self.xVelSlider) self.vlayout.addLayout(self.xVelLayout) self.yVelLayout = QtGui.QHBoxLayout() self.yVelLayout.addWidget(self.yVelLabel) self.yVelLayout.addWidget(self.yVelSlider) self.vlayout.addLayout(self.yVelLayout) self.vlayout.addWidget(self.legendLabel) self.vlayout.addWidget(self.legendWidget) self.hlayout.addLayout(self.vlayout) self.setLayout(self.hlayout) # Connect to observer (has to be the last thing!!) self.functionObservable = None if self.selectedFunctionObservable: self.functionObservable = \ OBSERVABLES.getObservable(self.selectedFunctionObservable, FunctionOverStateSpaceObservable) self.functionObservableCallback = \ lambda evalFunction: self._updateFunction(evalFunction) self.functionObservable.addObserver( self.functionObservableCallback)