Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sebastian Steinlechner
pykat
Commits
9b6d80a6
Commit
9b6d80a6
authored
Nov 01, 2014
by
Daniel Brown
Browse files
adding in gui swtich to stop pyqt4 imports
parent
3dfb1e2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
pykat/__init__.py
View file @
9b6d80a6
__version__
=
"0.5"
__version__
=
"0.6.1"
# This flag is used to switch on the gui features in pkat at import time
USE_GUI
=
False
import
pykat.exceptions
as
pkex
NoGUIException
=
pkex
.
BasePyKatException
(
"No PyQt4 module was found so cannot open a GUI"
)
import
finesse
import
components
...
...
@@ -6,3 +13,7 @@ import detectors
import
commands
from
pykat.utilities.optics.gaussian_beams
import
beam_param
pykat/components.py
View file @
9b6d80a6
...
...
@@ -11,9 +11,6 @@ from pykat.node_network import *
from
pykat.exceptions
import
*
import
abc
import
pykat.gui.resources
import
pykat.gui.graphics
from
pykat.gui.graphics
import
*
from
pykat.SIfloat
import
*
from
pykat.param
import
Param
,
AttrParam
import
weakref
...
...
@@ -21,6 +18,13 @@ import pykat.exceptions as pkex
next_component_id
=
1
from
pykat
import
USE_GUI
,
NoGUIException
if
USE_GUI
:
import
pykat.gui.resources
import
pykat.gui.graphics
from
pykat.gui.graphics
import
*
class
NodeGaussSetter
(
object
):
def
__init__
(
self
,
component
,
node
):
self
.
__comp
=
weakref
.
ref
(
component
)
...
...
@@ -149,6 +153,9 @@ class Component(object):
@
abc
.
abstractmethod
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
return
None
@
property
...
...
@@ -403,6 +410,9 @@ class mirror(AbstractMirrorComponent):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
":/resources/mirror_flat.svg"
,
self
,[(
-
4
,
15
,
self
.
nodes
[
0
]),
(
14
,
15
,
self
.
nodes
[
1
])])
...
...
@@ -473,6 +483,9 @@ class beamSplitter(AbstractMirrorComponent):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
# FIXME: make proper SVG component for beam splitter
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
":/resources/mirror_flat.svg"
,
self
,[(
-
4
,
24
,
self
.
nodes
[
0
]),
(
-
4
,
6
,
self
.
nodes
[
1
]),
(
14
,
6
,
self
.
nodes
[
2
]),
(
14
,
24
,
self
.
nodes
[
3
])])
...
...
@@ -566,6 +579,9 @@ class space(Component):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_QItem
==
None
:
self
.
_QItem
=
pykat
.
gui
.
graphics
.
SpaceQGraphicsItem
(
self
)
...
...
@@ -696,6 +712,9 @@ class grating(Component):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
SpaceQGraphicsItem
(
self
)
# TODO: make SVG graphic for grating
...
...
@@ -742,6 +761,9 @@ class isolator(Component):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
":/resources/isolator.svg"
,
self
,[(
-
4
,
15
,
self
.
nodes
[
0
]),
(
14
,
15
,
self
.
nodes
[
1
]),
(
14
,
24
,
self
.
nodes
[
2
])])
...
...
@@ -784,6 +806,9 @@ class lens(Component):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
":/resources/lens.svg"
,
self
,[(
-
4
,
15
,
self
.
nodes
[
0
]),
(
14
,
15
,
self
.
nodes
[
1
])])
...
...
@@ -861,6 +886,9 @@ class modulator(Component):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
":/resources/modulator.svg"
,
self
,[(
-
4
,
15
,
self
.
nodes
[
0
]),
(
14
,
15
,
self
.
nodes
[
1
])])
...
...
@@ -926,6 +954,9 @@ class laser(Component):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
":/resources/laser.svg"
,
self
,
[(
65
,
25
,
self
.
nodes
[
0
])])
...
...
@@ -989,6 +1020,9 @@ class squeezer(Component):
return
rtn
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
if
self
.
_svgItem
==
None
:
self
.
_svgItem
=
pykat
.
gui
.
graphics
.
ComponentQGraphicsItem
(
":/resources/laser.svg"
,
self
,
[(
65
,
25
,
self
.
nodes
[
0
])])
...
...
pykat/detectors.py
View file @
9b6d80a6
...
...
@@ -5,17 +5,21 @@ Created on Fri Feb 01 0split()9:09:10 2013
@author: Daniel
"""
import
exceptions
import
pykat.gui.resources
from
pykat.utils
import
*
from
pykat.gui.graphics
import
*
from
pykat.node_network
import
*
from
pykat.param
import
Param
import
collections
import
pykat.exceptions
as
pkex
import
warnings
import
copy
from
pykat
import
USE_GUI
,
NoGUIException
if
USE_GUI
:
import
pykat.gui.resources
from
pykat.gui.graphics
import
*
class
BaseDetector
(
object
)
:
"""
This is a base class for all detectors. Classes Detector1 and Detector2 should be used directly.
...
...
@@ -94,6 +98,9 @@ class BaseDetector(object) :
raise
NotImplementedError
(
"This function is not implemented"
)
def
getQGraphicsItem
(
self
):
if
not
USE_GUI
:
raise
NoGUIException
return
None
@
property
...
...
pykat/finesse.py
View file @
9b6d80a6
...
...
@@ -46,18 +46,20 @@ from pykat.node_network import NodeNetwork
from
pykat.detectors
import
BaseDetector
as
Detector
from
pykat.components
import
Component
from
pykat.commands
import
Command
,
xaxis
from
pykat.gui.gui
import
pyKatGUI
from
pykat.SIfloat
import
*
from
pykat.param
import
Param
,
AttrParam
import
pykat.exceptions
as
pkex
from
PyQt4.QtCore
import
QCoreApplication
from
PyQt4.QtGui
import
QApplication
from
pykat
import
USE_GUI
,
NoGUIException
if
USE_GUI
:
from
pykat.gui.gui
import
pyKatGUI
from
PyQt4.QtCore
import
QCoreApplication
from
PyQt4.QtGui
import
QApplication
from
multiprocessing
import
Process
,
Manager
NO_GUI
=
False
NO_BLOCK
=
"NO_BLOCK"
pykat_web
=
"www.gwoptics.org/pykat"
...
...
@@ -1323,8 +1325,8 @@ class kat(object):
return
out
def
openGUI
(
self
):
if
NO
_GUI
:
print
"No PyQt4 module was installed so cannot open a GUI"
if
not
USE
_GUI
:
raise
NoGUIException
else
:
self
.
app
=
QCoreApplication
.
instance
()
created
=
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment