Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benjamin Jakimow
EO Time Series Viewer
Commits
41ada931
Commit
41ada931
authored
Apr 05, 2012
by
Luke Campagnola
Browse files
Fixed up JoystickButton example
parent
a3367280
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/JoystickButton.py
0 → 100644
View file @
41ada931
# -*- coding: utf-8 -*-
## Display an animated arrowhead following a curve.
## This example uses the CurveArrow class, which is a combination
## of ArrowItem and CurvePoint.
##
## To place a static arrow anywhere in a scene, use ArrowItem.
## To attach other types of item to a curve, use CurvePoint.
import
initExample
## Add path to library (just for examples; you do not need this)
from
pyqtgraph.Qt
import
QtGui
,
QtCore
import
pyqtgraph
as
pg
app
=
QtGui
.
QApplication
([])
mw
=
QtGui
.
QMainWindow
()
mw
.
resize
(
300
,
50
)
cw
=
QtGui
.
QWidget
()
mw
.
setCentralWidget
(
cw
)
layout
=
QtGui
.
QGridLayout
()
cw
.
setLayout
(
layout
)
mw
.
show
()
l1
=
pg
.
ValueLabel
(
siPrefix
=
True
,
suffix
=
'm'
)
l2
=
pg
.
ValueLabel
(
siPrefix
=
True
,
suffix
=
'm'
)
jb
=
pg
.
JoystickButton
()
jb
.
setFixedWidth
(
30
)
jb
.
setFixedHeight
(
30
)
layout
.
addWidget
(
l1
,
0
,
0
)
layout
.
addWidget
(
l2
,
0
,
1
)
layout
.
addWidget
(
jb
,
0
,
2
)
x
=
0
y
=
0
def
update
():
global
x
,
y
,
l1
,
l2
,
jb
dx
,
dy
=
jb
.
getState
()
x
+=
dx
*
1e-3
y
+=
dy
*
1e-3
l1
.
setValue
(
x
)
l2
.
setValue
(
y
)
timer
=
QtCore
.
QTimer
()
timer
.
timeout
.
connect
(
update
)
timer
.
start
(
30
)
## Start Qt event loop unless running in interactive mode or using pyside.
import
sys
if
(
sys
.
flags
.
interactive
!=
1
)
or
not
hasattr
(
QtCore
,
'PYQT_VERSION'
):
app
.
exec_
()
examples/__main__.py
View file @
41ada931
...
...
@@ -42,7 +42,7 @@ examples = OrderedDict([
(
'ColorButton'
,
'../widgets/ColorButton.py'
),
#('CheckTable', '../widgets/CheckTable.py'),
#('VerticalLabel', '../widgets/VerticalLabel.py'),
(
'JoystickButton'
,
'
../widgets/
JoystickButton.py'
),
(
'JoystickButton'
,
'JoystickButton.py'
),
])),
(
'GraphicsScene'
,
'GraphicsScene.py'
),
...
...
widgets/JoystickButton.py
View file @
41ada931
...
...
@@ -4,7 +4,7 @@ from pyqtgraph.Qt import QtGui, QtCore
__all__
=
[
'JoystickButton'
]
class
JoystickButton
(
QtGui
.
QPushButton
):
sigStateChanged
=
QtCore
.
Signal
(
object
,
object
)
sigStateChanged
=
QtCore
.
Signal
(
object
,
object
)
## self, state
def
__init__
(
self
,
parent
=
None
):
QtGui
.
QPushButton
.
__init__
(
self
,
parent
)
...
...
@@ -34,6 +34,9 @@ class JoystickButton(QtGui.QPushButton):
def
doubleClickEvent
(
self
,
ev
):
ev
.
accept
()
def
getState
(
self
):
return
self
.
state
def
setState
(
self
,
*
xy
):
xy
=
list
(
xy
)
d
=
(
xy
[
0
]
**
2
+
xy
[
1
]
**
2
)
**
0.5
...
...
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