From 1e342a36528a72c2a129018224c813c243f64569 Mon Sep 17 00:00:00 2001 From: Daniel Brown <ddb@star.sr.bham.ac.uk> Date: Thu, 28 Nov 2013 12:34:51 +0000 Subject: [PATCH] fixing gui problems --- pykat/components.py | 13 ++++++------- pykat/finesse.py | 16 +++++++++++++--- pykat/gui/gui.py | 7 ------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pykat/components.py b/pykat/components.py index bbb62d1..c697662 100644 --- a/pykat/components.py +++ b/pykat/components.py @@ -5,13 +5,12 @@ Created on Mon Jan 28 11:10:01 2013 @author: Daniel """ import exceptions -import pykat.gui.resources import pykat -import pykat.gui.graphics -#from pykat.gui.graphics import * from pykat.node_network import * -#from PyQt4.QtGui import * -#from PyQt4.Qt import * + +import pykat.gui.resources +import pykat.gui.graphics +from pykat.gui.graphics import * class Component(object) : def __init__(self, name): @@ -172,8 +171,8 @@ class mirror(Component): def getQGraphicsItem(self): if self._svgItem == None: nodes = self.getNodes() - self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg",self - ,[(-4,15,nodes[0]),(14,15,nodes[1])]) + self._svgItem = pykat.gui.graphics.ComponentQGraphicsItem(":/resources/mirror_flat.svg", self ,[(-4,15,nodes[0]), (14,15,nodes[1])]) + return self._svgItem diff --git a/pykat/finesse.py b/pykat/finesse.py index 6622401..ccb16d2 100644 --- a/pykat/finesse.py +++ b/pykat/finesse.py @@ -37,7 +37,9 @@ from pykat.node_network import NodeNetwork from pykat.detectors import Detector from pykat.components import Component from pykat.commands import Command, xaxis -from pykat.gui.gui import openGUI +from pykat.gui.gui import pyKatGUI + +NO_GUI = False class MissingFinesseEnvVar(Exception) : def __str__(self) : @@ -93,7 +95,7 @@ class kat(object): self.__gui = None self.nodes = NodeNetwork(self) self.__katexe = katexe - + self.pykatgui = None # Various self.__phase = None self.__maxtem = None @@ -405,7 +407,15 @@ class kat(object): return out def openGUI(self): - self.__gui = openGUI(self) + if NO_GUI: + print "No PyQt4 module was installed so cannot open a GUI" + else: + if self.pykatgui == None: + #self.app = QtGui.QApplication([""]) + self.pykatgui = pyKatGUI(self) + self.pykatgui.main() + else: + self.pykatgui.show() def getComponents(self): return self.__components.values() diff --git a/pykat/gui/gui.py b/pykat/gui/gui.py index d59aba6..db41984 100644 --- a/pykat/gui/gui.py +++ b/pykat/gui/gui.py @@ -15,13 +15,6 @@ from pykat.gui.graphics import * import qt_gui import functools -def openGUI(kat): - app = QtGui.QApplication([""]) - pykatgui = pyKatGUI(kat) - pykatgui.main() - app.exec_() - - class pyKatGUI(QtGui.QMainWindow, qt_gui.Ui_MainWindow): def __init__(self, kat,parent=None): super(pyKatGUI, self).__init__(parent) -- GitLab