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
450626a3
Commit
450626a3
authored
Oct 26, 2012
by
Luke Campagnola
Browse files
Fixes for PySide compatibility
parent
bbba3f1f
Changes
8
Hide whitespace changes
Inline
Side-by-side
examples/__main__.py
View file @
450626a3
...
...
@@ -87,7 +87,17 @@ class ExampleLoader(QtGui.QMainWindow):
self
.
ui
.
loadBtn
.
clicked
.
connect
(
self
.
loadFile
)
self
.
ui
.
exampleTree
.
currentItemChanged
.
connect
(
self
.
showFile
)
self
.
ui
.
exampleTree
.
itemDoubleClicked
.
connect
(
self
.
loadFile
)
self
.
ui
.
pyqtCheck
.
toggled
.
connect
(
self
.
pyqtToggled
)
self
.
ui
.
pysideCheck
.
toggled
.
connect
(
self
.
pysideToggled
)
def
pyqtToggled
(
self
,
b
):
if
b
:
self
.
ui
.
pysideCheck
.
setChecked
(
False
)
def
pysideToggled
(
self
,
b
):
if
b
:
self
.
ui
.
pyqtCheck
.
setChecked
(
False
)
def
populateTree
(
self
,
root
,
examples
):
for
key
,
val
in
examples
.
items
():
...
...
@@ -108,12 +118,19 @@ class ExampleLoader(QtGui.QMainWindow):
def
loadFile
(
self
):
fn
=
self
.
currentFile
()
extra
=
[]
if
self
.
ui
.
pyqtCheck
.
isChecked
():
extra
.
append
(
'pyqt'
)
elif
self
.
ui
.
pysideCheck
.
isChecked
():
extra
.
append
(
'pyside'
)
if
fn
is
None
:
return
if
sys
.
platform
.
startswith
(
'win'
):
os
.
spawnl
(
os
.
P_NOWAIT
,
sys
.
executable
,
sys
.
executable
,
'"'
+
fn
+
'"'
)
os
.
spawnl
(
os
.
P_NOWAIT
,
sys
.
executable
,
sys
.
executable
,
'"'
+
fn
+
'"'
,
*
extra
)
else
:
os
.
spawnl
(
os
.
P_NOWAIT
,
sys
.
executable
,
sys
.
executable
,
fn
)
os
.
spawnl
(
os
.
P_NOWAIT
,
sys
.
executable
,
sys
.
executable
,
fn
,
*
extra
)
def
showFile
(
self
):
...
...
examples/exampleLoaderTemplate.ui
View file @
450626a3
...
...
@@ -39,6 +39,24 @@
</column>
</widget>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QCheckBox"
name=
"pyqtCheck"
>
<property
name=
"text"
>
<string>
Force PyQt
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"pysideCheck"
>
<property
name=
"text"
>
<string>
Force PySide
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QPushButton"
name=
"loadBtn"
>
<property
name=
"text"
>
...
...
examples/exampleLoaderTemplate_pyqt.py
View file @
450626a3
...
...
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file './examples/exampleLoaderTemplate.ui'
#
# Created:
Sun Sep 9 14:41:31
2012
# Created:
Fri Oct 26 07:53:55
2012
# by: PyQt4 UI code generator 4.9.1
#
# WARNING! All changes made in this file will be lost!
...
...
@@ -35,6 +35,15 @@ class Ui_Form(object):
self
.
exampleTree
.
headerItem
().
setText
(
0
,
_fromUtf8
(
"1"
))
self
.
exampleTree
.
header
().
setVisible
(
False
)
self
.
verticalLayout
.
addWidget
(
self
.
exampleTree
)
self
.
horizontalLayout
=
QtGui
.
QHBoxLayout
()
self
.
horizontalLayout
.
setObjectName
(
_fromUtf8
(
"horizontalLayout"
))
self
.
pyqtCheck
=
QtGui
.
QCheckBox
(
self
.
layoutWidget
)
self
.
pyqtCheck
.
setObjectName
(
_fromUtf8
(
"pyqtCheck"
))
self
.
horizontalLayout
.
addWidget
(
self
.
pyqtCheck
)
self
.
pysideCheck
=
QtGui
.
QCheckBox
(
self
.
layoutWidget
)
self
.
pysideCheck
.
setObjectName
(
_fromUtf8
(
"pysideCheck"
))
self
.
horizontalLayout
.
addWidget
(
self
.
pysideCheck
)
self
.
verticalLayout
.
addLayout
(
self
.
horizontalLayout
)
self
.
loadBtn
=
QtGui
.
QPushButton
(
self
.
layoutWidget
)
self
.
loadBtn
.
setObjectName
(
_fromUtf8
(
"loadBtn"
))
self
.
verticalLayout
.
addWidget
(
self
.
loadBtn
)
...
...
@@ -51,5 +60,7 @@ class Ui_Form(object):
def
retranslateUi
(
self
,
Form
):
Form
.
setWindowTitle
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Form"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
pyqtCheck
.
setText
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Force PyQt"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
pysideCheck
.
setText
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Force PySide"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
loadBtn
.
setText
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Load Example"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
examples/exampleLoaderTemplate_pyside.py
View file @
450626a3
...
...
@@ -2,7 +2,7 @@
# Form implementation generated from reading ui file './examples/exampleLoaderTemplate.ui'
#
# Created:
Sun Sep 9 14:41:31
2012
# Created:
Fri Oct 26 07:53:57
2012
# by: pyside-uic 0.2.13 running on PySide 1.1.0
#
# WARNING! All changes made in this file will be lost!
...
...
@@ -30,6 +30,15 @@ class Ui_Form(object):
self
.
exampleTree
.
headerItem
().
setText
(
0
,
"1"
)
self
.
exampleTree
.
header
().
setVisible
(
False
)
self
.
verticalLayout
.
addWidget
(
self
.
exampleTree
)
self
.
horizontalLayout
=
QtGui
.
QHBoxLayout
()
self
.
horizontalLayout
.
setObjectName
(
"horizontalLayout"
)
self
.
pyqtCheck
=
QtGui
.
QCheckBox
(
self
.
layoutWidget
)
self
.
pyqtCheck
.
setObjectName
(
"pyqtCheck"
)
self
.
horizontalLayout
.
addWidget
(
self
.
pyqtCheck
)
self
.
pysideCheck
=
QtGui
.
QCheckBox
(
self
.
layoutWidget
)
self
.
pysideCheck
.
setObjectName
(
"pysideCheck"
)
self
.
horizontalLayout
.
addWidget
(
self
.
pysideCheck
)
self
.
verticalLayout
.
addLayout
(
self
.
horizontalLayout
)
self
.
loadBtn
=
QtGui
.
QPushButton
(
self
.
layoutWidget
)
self
.
loadBtn
.
setObjectName
(
"loadBtn"
)
self
.
verticalLayout
.
addWidget
(
self
.
loadBtn
)
...
...
@@ -46,5 +55,7 @@ class Ui_Form(object):
def
retranslateUi
(
self
,
Form
):
Form
.
setWindowTitle
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Form"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
pyqtCheck
.
setText
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Force PyQt"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
pysideCheck
.
setText
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Force PySide"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
loadBtn
.
setText
(
QtGui
.
QApplication
.
translate
(
"Form"
,
"Load Example"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
examples/initExample.py
View file @
450626a3
## make this version of pyqtgraph importable before any others
import
sys
,
os
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'..'
)))
if
'pyside'
in
sys
.
argv
:
## should force example to use PySide instead of PyQt
import
PySide
elif
'pyqt'
in
sys
.
argv
:
import
PyQt4
functions.py
View file @
450626a3
...
...
@@ -22,7 +22,7 @@ SI_PREFIXES_ASCII = 'yzafpnum kMGTPEZY'
from
.Qt
import
QtGui
,
QtCore
from
.Qt
import
QtGui
,
QtCore
,
USE_PYSIDE
import
numpy
as
np
import
decimal
,
re
import
ctypes
...
...
@@ -846,8 +846,12 @@ def makeQImage(imgData, alpha=None, copy=True, transpose=True):
if
copy
is
True
and
copied
is
False
:
imgData
=
imgData
.
copy
()
addr
=
ctypes
.
addressof
(
ctypes
.
c_char
.
from_buffer
(
imgData
,
0
))
img
=
QtGui
.
QImage
(
addr
,
imgData
.
shape
[
1
],
imgData
.
shape
[
0
],
imgFormat
)
if
USE_PYSIDE
:
ch
=
ctypes
.
c_char
.
from_buffer
(
imgData
,
0
)
img
=
QtGui
.
QImage
(
ch
,
imgData
.
shape
[
1
],
imgData
.
shape
[
0
],
imgFormat
)
else
:
addr
=
ctypes
.
addressof
(
ctypes
.
c_char
.
from_buffer
(
imgData
,
0
))
img
=
QtGui
.
QImage
(
addr
,
imgData
.
shape
[
1
],
imgData
.
shape
[
0
],
imgFormat
)
img
.
data
=
imgData
return
img
#try:
...
...
@@ -869,13 +873,19 @@ def imageToArray(img, copy=False, transpose=True):
the QImage is collected before the array, there may be trouble).
The array will have shape (width, height, (b,g,r,a)).
"""
ptr
=
img
.
bits
()
ptr
.
setsize
(
img
.
byteCount
())
fmt
=
img
.
format
()
ptr
=
img
.
bits
()
if
USE_PYSIDE
:
arr
=
np
.
frombuffer
(
ptr
,
dtype
=
np
.
ubyte
)
else
:
ptr
.
setsize
(
img
.
byteCount
())
arr
=
np
.
asarray
(
ptr
)
if
fmt
==
img
.
Format_RGB32
:
arr
=
np
.
asarray
(
ptr
)
.
reshape
(
img
.
height
(),
img
.
width
(),
3
)
arr
=
arr
.
reshape
(
img
.
height
(),
img
.
width
(),
3
)
elif
fmt
==
img
.
Format_ARGB32
or
fmt
==
img
.
Format_ARGB32_Premultiplied
:
arr
=
np
.
asarray
(
ptr
).
reshape
(
img
.
height
(),
img
.
width
(),
4
)
arr
=
arr
.
reshape
(
img
.
height
(),
img
.
width
(),
4
)
if
copy
:
arr
=
arr
.
copy
()
...
...
graphicsItems/LegendItem.py
View file @
450626a3
...
...
@@ -28,6 +28,7 @@ class LegendItem(GraphicsWidget):
def
addItem
(
self
,
item
,
title
):
"""
Add a new entry to the legend.
=========== ========================================================
Arguments
item A PlotDataItem from which the line and point style
...
...
graphicsItems/ScatterPlotItem.py
View file @
450626a3
from
pyqtgraph.Qt
import
QtGui
,
QtCore
from
pyqtgraph.Qt
import
QtGui
,
QtCore
,
USE_PYSIDE
from
pyqtgraph.Point
import
Point
import
pyqtgraph.functions
as
fn
from
.GraphicsItem
import
GraphicsItem
...
...
@@ -681,7 +681,7 @@ class ScatterPlotItem(GraphicsObject):
p
.
resetTransform
()
if
self
.
opts
[
'useCache'
]:
if
not
USE_PYSIDE
and
self
.
opts
[
'useCache'
]:
p
.
drawPixmapFragments
(
self
.
fragments
,
atlas
)
else
:
for
i
in
range
(
len
(
self
.
data
)):
...
...
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