Import from python2_3 for all uses of basestring, cmp, and xrange

This commit is contained in:
Luke Campagnola 2015-05-19 09:29:55 -04:00
parent b549b93ade
commit 0976991efd
33 changed files with 108 additions and 113 deletions

View File

@ -8,6 +8,7 @@ if __name__ == "__main__" and (__package__ is None or __package__==''):
from . import initExample from . import initExample
from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5 from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5
from pyqtgraph.python2_3 import basestring
import pyqtgraph as pg import pyqtgraph as pg
if USE_PYSIDE: if USE_PYSIDE:

View File

@ -14,11 +14,11 @@ to avoid re-reading the entire visible waveform at every update.
import initExample ## Add path to library (just for examples; you do not need this) import initExample ## Add path to library (just for examples; you do not need this)
import pyqtgraph as pg import sys, os
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np import numpy as np
import h5py import h5py
import sys, os import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
pg.mkQApp() pg.mkQApp()

View File

@ -23,8 +23,8 @@ def plot():
pts = 100 pts = 100
x = np.linspace(0, 0.8, pts) x = np.linspace(0, 0.8, pts)
y = np.random.random(size=pts)*0.8 y = np.random.random(size=pts)*0.8
for i in xrange(n): for i in range(n):
for j in xrange(n): for j in range(n):
## calling PlotWidget.plot() generates a PlotDataItem, which ## calling PlotWidget.plot() generates a PlotDataItem, which
## has a bit more overhead than PlotCurveItem, which is all ## has a bit more overhead than PlotCurveItem, which is all
## we need here. This overhead adds up quickly and makes a big ## we need here. This overhead adds up quickly and makes a big

View File

@ -1,9 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import initExample ## Add path to library (just for examples; you do not need this) import initExample ## Add path to library (just for examples; you do not need this)
import time
import numpy as np import numpy as np
import pyqtgraph.multiprocess as mp import pyqtgraph.multiprocess as mp
import pyqtgraph as pg import pyqtgraph as pg
import time from pyqtgraph.python2_3 import xrange
print( "\n=================\nParallelize") print( "\n=================\nParallelize")

View File

@ -1,12 +1,12 @@
import numpy as np
import collections
import sys, os
import pyqtgraph as pg import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.parametertree import Parameter, ParameterTree from pyqtgraph.parametertree import Parameter, ParameterTree
from pyqtgraph.parametertree import types as pTypes from pyqtgraph.parametertree import types as pTypes
import pyqtgraph.configfile import pyqtgraph.configfile
import numpy as np from pyqtgraph.python2_3 import xrange
import collections
import sys, os
class RelativityGUI(QtGui.QWidget): class RelativityGUI(QtGui.QWidget):

View File

@ -1,12 +1,13 @@
from ..Qt import QtCore, QtGui
from ..python2_3 import sortList
import weakref import weakref
from ..Qt import QtCore, QtGui
from ..python2_3 import sortList, cmp
from ..Point import Point from ..Point import Point
from .. import functions as fn from .. import functions as fn
from .. import ptime as ptime from .. import ptime as ptime
from .mouseEvents import * from .mouseEvents import *
from .. import debug as debug from .. import debug as debug
if hasattr(QtCore, 'PYQT_VERSION'): if hasattr(QtCore, 'PYQT_VERSION'):
try: try:
import sip import sip

View File

@ -346,7 +346,7 @@ def exit():
## close file handles ## close file handles
if sys.platform == 'darwin': if sys.platform == 'darwin':
for fd in xrange(3, 4096): for fd in range(3, 4096):
if fd not in [7]: # trying to close 7 produces an illegal instruction on the Mac. if fd not in [7]: # trying to close 7 produces an illegal instruction on the Mac.
os.close(fd) os.close(fd)
else: else:

View File

@ -1,5 +1,7 @@
import numpy as np import numpy as np
from .Qt import QtGui, QtCore from .Qt import QtGui, QtCore
from .python2_3 import basestring
class ColorMap(object): class ColorMap(object):
""" """

View File

@ -10,14 +10,15 @@ as it can be converted to/from a string using repr and eval.
""" """
import re, os, sys import re, os, sys
import numpy
from .pgcollections import OrderedDict from .pgcollections import OrderedDict
GLOBAL_PATH = None # so not thread safe.
from . import units from . import units
from .python2_3 import asUnicode from .python2_3 import asUnicode, basestring
from .Qt import QtCore from .Qt import QtCore
from .Point import Point from .Point import Point
from .colormap import ColorMap from .colormap import ColorMap
import numpy GLOBAL_PATH = None # so not thread safe.
class ParseError(Exception): class ParseError(Exception):
def __init__(self, message, lineNum, line, fileName=None): def __init__(self, message, lineNum, line, fileName=None):

View File

@ -1,16 +1,17 @@
import sys, re, os, time, traceback, subprocess
import pickle
from ..Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5 from ..Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5
import sys, re, os, time, traceback, subprocess from ..python2_3 import basestring
from .. import exceptionHandling as exceptionHandling
from .. import getConfigOption
if USE_PYSIDE: if USE_PYSIDE:
from . import template_pyside as template from . import template_pyside as template
elif USE_PYQT5: elif USE_PYQT5:
from . import template_pyqt5 as template from . import template_pyqt5 as template
else: else:
from . import template_pyqt as template from . import template_pyqt as template
from .. import exceptionHandling as exceptionHandling
import pickle
from .. import getConfigOption
class ConsoleWidget(QtGui.QWidget): class ConsoleWidget(QtGui.QWidget):
""" """

View File

@ -723,7 +723,6 @@ class ObjTracker(object):
for k in self.startCount: for k in self.startCount:
c1[k] = c1.get(k, 0) - self.startCount[k] c1[k] = c1.get(k, 0) - self.startCount[k]
typs = list(c1.keys()) typs = list(c1.keys())
#typs.sort(lambda a,b: cmp(c1[a], c1[b]))
typs.sort(key=lambda a: c1[a]) typs.sort(key=lambda a: c1[a])
for t in typs: for t in typs:
if c1[t] == 0: if c1[t] == 0:
@ -824,7 +823,6 @@ class ObjTracker(object):
c = count.get(typ, [0,0]) c = count.get(typ, [0,0])
count[typ] = [c[0]+1, c[1]+objectSize(obj)] count[typ] = [c[0]+1, c[1]+objectSize(obj)]
typs = list(count.keys()) typs = list(count.keys())
#typs.sort(lambda a,b: cmp(count[a][1], count[b][1]))
typs.sort(key=lambda a: count[a][1]) typs.sort(key=lambda a: count[a][1])
for t in typs: for t in typs:

View File

@ -1,17 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import weakref
from ..Qt import QtCore, QtGui from ..Qt import QtCore, QtGui
from .Container import * from .Container import *
from .DockDrop import * from .DockDrop import *
from .Dock import Dock from .Dock import Dock
from .. import debug as debug from .. import debug as debug
import weakref from ..python2_3 import basestring
## TODO:
# - containers should be drop areas, not docks. (but every slot within a container must have its own drop areas?)
# - drop between tabs
# - nest splitters inside tab boxes, etc.
class DockArea(Container, QtGui.QWidget, DockDrop): class DockArea(Container, QtGui.QWidget, DockDrop):

View File

@ -1,6 +1,6 @@
from ..widgets.FileDialog import FileDialog from ..widgets.FileDialog import FileDialog
from ..Qt import QtGui, QtCore, QtSvg from ..Qt import QtGui, QtCore, QtSvg
from ..python2_3 import asUnicode from ..python2_3 import asUnicode, basestring
from ..GraphicsScene import GraphicsScene from ..GraphicsScene import GraphicsScene
import os, re import os, re
LastExportDirectory = None LastExportDirectory = None

View File

@ -352,7 +352,6 @@ class Flowchart(Node):
#tdeps[t] = lastNode #tdeps[t] = lastNode
if lastInd is not None: if lastInd is not None:
dels.append((lastInd+1, t)) dels.append((lastInd+1, t))
#dels.sort(lambda a,b: cmp(b[0], a[0]))
dels.sort(key=lambda a: a[0], reverse=True) dels.sort(key=lambda a: a[0], reverse=True)
for i, t in dels: for i, t in dels:
ops.insert(i, ('d', t)) ops.insert(i, ('d', t))
@ -467,7 +466,6 @@ class Flowchart(Node):
self.clear() self.clear()
Node.restoreState(self, state) Node.restoreState(self, state)
nodes = state['nodes'] nodes = state['nodes']
#nodes.sort(lambda a, b: cmp(a['pos'][0], b['pos'][0]))
nodes.sort(key=lambda a: a['pos'][0]) nodes.sort(key=lambda a: a['pos'][0])
for n in nodes: for n in nodes:
if n['name'] in self._nodes: if n['name'] in self._nodes:

View File

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import numpy as np
from ...Qt import QtCore, QtGui from ...Qt import QtCore, QtGui
from ..Node import Node from ..Node import Node
from . import functions from . import functions
from ... import functions as pgfn from ... import functions as pgfn
from .common import * from .common import *
import numpy as np from ...python2_3 import xrange
from ... import PolyLineROI from ... import PolyLineROI
from ... import Point from ... import Point
from ... import metaarray as metaarray from ... import metaarray as metaarray

View File

@ -1,5 +1,7 @@
import numpy as np import numpy as np
from ...metaarray import MetaArray from ...metaarray import MetaArray
from ...python2_3 import basestring, xrange
def downsample(data, n, axis=0, xvals='subsample'): def downsample(data, n, axis=0, xvals='subsample'):
"""Downsample by averaging points together across axis. """Downsample by averaging points together across axis.

View File

@ -6,7 +6,7 @@ Distributed under MIT/X11 license. See license.txt for more infomation.
""" """
from __future__ import division from __future__ import division
from .python2_3 import asUnicode from .python2_3 import asUnicode, basestring
from .Qt import QtGui, QtCore, USE_PYSIDE from .Qt import QtGui, QtCore, USE_PYSIDE
Colors = { Colors = {
'b': QtGui.QColor(0,0,255,255), 'b': QtGui.QColor(0,0,255,255),

View File

@ -1,14 +1,15 @@
import weakref
import numpy as np
from ..Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from ..python2_3 import sortList from ..python2_3 import sortList
from .. import functions as fn from .. import functions as fn
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
from .GraphicsWidget import GraphicsWidget from .GraphicsWidget import GraphicsWidget
from ..widgets.SpinBox import SpinBox from ..widgets.SpinBox import SpinBox
import weakref
from ..pgcollections import OrderedDict from ..pgcollections import OrderedDict
from ..colormap import ColorMap from ..colormap import ColorMap
from ..python2_3 import cmp
import numpy as np
__all__ = ['TickSliderItem', 'GradientEditorItem'] __all__ = ['TickSliderItem', 'GradientEditorItem']
@ -26,8 +27,6 @@ Gradients = OrderedDict([
class TickSliderItem(GraphicsWidget): class TickSliderItem(GraphicsWidget):
## public class ## public class
"""**Bases:** :class:`GraphicsWidget <pyqtgraph.GraphicsWidget>` """**Bases:** :class:`GraphicsWidget <pyqtgraph.GraphicsWidget>`

View File

@ -1,13 +1,14 @@
import numpy as np
from .. import metaarray as metaarray from .. import metaarray as metaarray
from ..Qt import QtCore from ..Qt import QtCore
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
from .PlotCurveItem import PlotCurveItem from .PlotCurveItem import PlotCurveItem
from .ScatterPlotItem import ScatterPlotItem from .ScatterPlotItem import ScatterPlotItem
import numpy as np
from .. import functions as fn from .. import functions as fn
from .. import debug as debug from .. import debug as debug
from .. import getConfigOption from .. import getConfigOption
class PlotDataItem(GraphicsObject): class PlotDataItem(GraphicsObject):
""" """
**Bases:** :class:`GraphicsObject <pyqtgraph.GraphicsObject>` **Bases:** :class:`GraphicsObject <pyqtgraph.GraphicsObject>`

View File

@ -16,22 +16,14 @@ This class is very heavily featured:
- Control panel with a huge feature set including averaging, decimation, - Control panel with a huge feature set including averaging, decimation,
display, power spectrum, svg/png export, plot linking, and more. display, power spectrum, svg/png export, plot linking, and more.
""" """
from ...Qt import QtGui, QtCore, QT_LIB
from ... import pixmaps
import sys import sys
if QT_LIB == 'PyQt4':
from .plotConfigTemplate_pyqt import *
elif QT_LIB == 'PySide':
from .plotConfigTemplate_pyside import *
elif QT_LIB == 'PyQt5':
from .plotConfigTemplate_pyqt5 import *
from ... import functions as fn
from ...widgets.FileDialog import FileDialog
import weakref import weakref
import numpy as np import numpy as np
import os import os
from ...Qt import QtGui, QtCore, QT_LIB
from ... import pixmaps
from ... import functions as fn
from ...widgets.FileDialog import FileDialog
from .. PlotDataItem import PlotDataItem from .. PlotDataItem import PlotDataItem
from .. ViewBox import ViewBox from .. ViewBox import ViewBox
from .. AxisItem import AxisItem from .. AxisItem import AxisItem
@ -41,6 +33,14 @@ from .. GraphicsWidget import GraphicsWidget
from .. ButtonItem import ButtonItem from .. ButtonItem import ButtonItem
from .. InfiniteLine import InfiniteLine from .. InfiniteLine import InfiniteLine
from ...WidgetGroup import WidgetGroup from ...WidgetGroup import WidgetGroup
from ...python2_3 import basestring
if QT_LIB == 'PyQt4':
from .plotConfigTemplate_pyqt import *
elif QT_LIB == 'PySide':
from .plotConfigTemplate_pyside import *
elif QT_LIB == 'PyQt5':
from .plotConfigTemplate_pyqt5 import *
__all__ = ['PlotItem'] __all__ = ['PlotItem']
@ -773,14 +773,6 @@ class PlotItem(GraphicsWidget):
y = pos.y() * sy y = pos.y() * sy
fh.write('<circle cx="%f" cy="%f" r="1" fill="#%s" stroke="none" fill-opacity="%f"/>\n' % (x, y, color, opacity)) fh.write('<circle cx="%f" cy="%f" r="1" fill="#%s" stroke="none" fill-opacity="%f"/>\n' % (x, y, color, opacity))
#fh.write('<path fill="none" stroke="#%s" stroke-opacity="%f" stroke-width="1" d="M%f,%f ' % (color, opacity, x[0], y[0]))
#for i in xrange(1, len(x)):
#fh.write('L%f,%f ' % (x[i], y[i]))
#fh.write('"/>')
## get list of curves, scatter plots
fh.write("</svg>\n") fh.write("</svg>\n")

View File

@ -1,8 +1,3 @@
from ..Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5
from ..Point import Point
from .. import functions as fn
from .GraphicsItem import GraphicsItem
from .GraphicsObject import GraphicsObject
from itertools import starmap, repeat from itertools import starmap, repeat
try: try:
from itertools import imap from itertools import imap
@ -10,10 +5,15 @@ except ImportError:
imap = map imap = map
import numpy as np import numpy as np
import weakref import weakref
from ..Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5
from ..Point import Point
from .. import functions as fn
from .GraphicsItem import GraphicsItem
from .GraphicsObject import GraphicsObject
from .. import getConfigOption from .. import getConfigOption
from .. import debug as debug
from ..pgcollections import OrderedDict from ..pgcollections import OrderedDict
from .. import debug from .. import debug
from ..python2_3 import basestring
__all__ = ['ScatterPlotItem', 'SpotItem'] __all__ = ['ScatterPlotItem', 'SpotItem']
@ -455,8 +455,6 @@ class ScatterPlotItem(GraphicsObject):
brushes = brushes[kargs['mask']] brushes = brushes[kargs['mask']]
if len(brushes) != len(dataSet): if len(brushes) != len(dataSet):
raise Exception("Number of brushes does not match number of points (%d != %d)" % (len(brushes), len(dataSet))) raise Exception("Number of brushes does not match number of points (%d != %d)" % (len(brushes), len(dataSet)))
#for i in xrange(len(brushes)):
#self.data[i]['brush'] = fn.mkBrush(brushes[i], **kargs)
dataSet['brush'] = brushes dataSet['brush'] = brushes
else: else:
self.opts['brush'] = fn.mkBrush(*args, **kargs) self.opts['brush'] = fn.mkBrush(*args, **kargs)
@ -815,7 +813,6 @@ class ScatterPlotItem(GraphicsObject):
#else: #else:
#print "No hit:", (x, y), (sx, sy) #print "No hit:", (x, y), (sx, sy)
#print " ", (sx-s2x, sy-s2y), (sx+s2x, sy+s2y) #print " ", (sx-s2x, sy-s2y), (sx+s2x, sy+s2y)
#pts.sort(lambda a,b: cmp(b.zValue(), a.zValue()))
return pts[::-1] return pts[::-1]

View File

@ -1,15 +1,15 @@
from ...Qt import QtGui, QtCore import weakref
from ...python2_3 import sortList import sys
from copy import deepcopy
import numpy as np import numpy as np
from ...Qt import QtGui, QtCore
from ...python2_3 import sortList, basestring, cmp
from ...Point import Point from ...Point import Point
from ... import functions as fn from ... import functions as fn
from .. ItemGroup import ItemGroup from .. ItemGroup import ItemGroup
from .. GraphicsWidget import GraphicsWidget from .. GraphicsWidget import GraphicsWidget
import weakref
from copy import deepcopy
from ... import debug as debug from ... import debug as debug
from ... import getConfigOption from ... import getConfigOption
import sys
from ...Qt import isQObjectAlive from ...Qt import isQObjectAlive
__all__ = ['ViewBox'] __all__ = ['ViewBox']

View File

@ -10,10 +10,11 @@ new methods for slicing and indexing the array based on this meta data.
More info at http://www.scipy.org/Cookbook/MetaArray More info at http://www.scipy.org/Cookbook/MetaArray
""" """
import numpy as np
import types, copy, threading, os, re import types, copy, threading, os, re
import pickle import pickle
from functools import reduce from functools import reduce
import numpy as np
from ..python2_3 import basestring
#import traceback #import traceback
## By default, the library will use HDF5 when writing files. ## By default, the library will use HDF5 when writing files.

View File

@ -1,6 +1,8 @@
import os, sys, time, multiprocessing, re import os, sys, time, multiprocessing, re
from .processes import ForkedProcess from .processes import ForkedProcess
from .remoteproxy import ClosedError from .remoteproxy import ClosedError
from ..python2_3 import basestring, xrange
class CanceledError(Exception): class CanceledError(Exception):
"""Raised when the progress dialog is canceled during a processing operation.""" """Raised when the progress dialog is canceled during a processing operation."""

View File

@ -1,7 +1,9 @@
from ..Qt import QtGui, QtCore
from .. import Transform3D
from OpenGL.GL import * from OpenGL.GL import *
from OpenGL import GL from OpenGL import GL
from ..Qt import QtGui, QtCore
from .. import Transform3D
from ..python2_3 import basestring
GLOptions = { GLOptions = {
'opaque': { 'opaque': {

View File

@ -1,6 +1,8 @@
import numpy as np
from ..Qt import QtGui from ..Qt import QtGui
from .. import functions as fn from .. import functions as fn
import numpy as np from ..python2_3 import xrange
class MeshData(object): class MeshData(object):
""" """

View File

@ -1,7 +1,7 @@
from ..Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
import os, weakref, re import os, weakref, re
from ..pgcollections import OrderedDict from ..pgcollections import OrderedDict
from ..python2_3 import asUnicode from ..python2_3 import asUnicode, basestring
from .ParameterItem import ParameterItem from .ParameterItem import ParameterItem
PARAM_TYPES = {} PARAM_TYPES = {}

View File

@ -6,6 +6,7 @@ Provides support for frozen environments as well.
import os, sys, pickle import os, sys, pickle
from ..functions import makeQImage from ..functions import makeQImage
from ..Qt import QtGui from ..Qt import QtGui
from ..python2_3 import basestring
if sys.version_info[0] == 2: if sys.version_info[0] == 2:
from . import pixmapData_2 as pixmapData from . import pixmapData_2 as pixmapData
else: else:

View File

@ -40,10 +40,6 @@ def sortList(l, cmpFunc):
l.sort(key=cmpToKey(cmpFunc)) l.sort(key=cmpToKey(cmpFunc))
if sys.version_info[0] == 3: if sys.version_info[0] == 3:
import builtins
builtins.basestring = str
#builtins.asUnicode = asUnicode
#builtins.sortList = sortList
basestring = str basestring = str
def cmp(a,b): def cmp(a,b):
if a>b: if a>b:
@ -52,9 +48,11 @@ if sys.version_info[0] == 3:
return -1 return -1
else: else:
return 0 return 0
builtins.cmp = cmp xrange = range
builtins.xrange = range else:
#else: ## don't use __builtin__ -- this confuses things like pyshell and ActiveState's lazy import recipe import __builtin__
#import __builtin__ basestring = __builtin__.basestring
#__builtin__.asUnicode = asUnicode cmp = __builtin__.cmp
#__builtin__.sortList = sortList xrange = __builtin__.xrange

View File

@ -7,6 +7,7 @@ import sys, re
from .colorama.winterm import WinTerm, WinColor, WinStyle from .colorama.winterm import WinTerm, WinColor, WinStyle
from .colorama.win32 import windll from .colorama.win32 import windll
from ..python2_3 import basestring
_WIN = sys.platform.startswith('win') _WIN = sys.platform.startswith('win')
if windll is not None: if windll is not None:

View File

@ -1,8 +1,9 @@
import sys
from ..Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from ..SignalProxy import SignalProxy from ..SignalProxy import SignalProxy
import sys
from ..pgcollections import OrderedDict from ..pgcollections import OrderedDict
from ..python2_3 import asUnicode from ..python2_3 import asUnicode, basestring
class ComboBox(QtGui.QComboBox): class ComboBox(QtGui.QComboBox):
"""Extends QComboBox to add extra functionality. """Extends QComboBox to add extra functionality.

View File

@ -1,13 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from ..Qt import QtGui, QtCore
from ..python2_3 import asUnicode
import numpy as np import numpy as np
try: from ..Qt import QtGui, QtCore
import metaarray from ..python2_3 import asUnicode, basestring
HAVE_METAARRAY = True from .. import metaarray
except ImportError:
HAVE_METAARRAY = False
__all__ = ['TableWidget'] __all__ = ['TableWidget']
@ -207,7 +202,7 @@ class TableWidget(QtGui.QTableWidget):
return lambda d: d.__iter__(), None return lambda d: d.__iter__(), None
elif isinstance(data, dict): elif isinstance(data, dict):
return lambda d: iter(d.values()), list(map(asUnicode, data.keys())) return lambda d: iter(d.values()), list(map(asUnicode, data.keys()))
elif HAVE_METAARRAY and (hasattr(data, 'implements') and data.implements('MetaArray')): elif (hasattr(data, 'implements') and data.implements('MetaArray')):
if data.axisHasColumns(0): if data.axisHasColumns(0):
header = [asUnicode(data.columnName(0, i)) for i in range(data.shape[0])] header = [asUnicode(data.columnName(0, i)) for i in range(data.shape[0])]
elif data.axisHasValues(0): elif data.axisHasValues(0):
@ -491,14 +486,13 @@ if __name__ == '__main__':
t.setData(ll) t.setData(ll)
if HAVE_METAARRAY: ma = metaarray.MetaArray(np.ones((20, 3)), info=[
ma = metaarray.MetaArray(np.ones((20, 3)), info=[ {'values': np.linspace(1, 5, 20)},
{'values': np.linspace(1, 5, 20)}, {'cols': [
{'cols': [ {'name': 'x'},
{'name': 'x'}, {'name': 'y'},
{'name': 'y'}, {'name': 'z'},
{'name': 'z'}, ]}
]} ])
]) t.setData(ma)
t.setData(ma)

View File

@ -1,8 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from ..Qt import QtGui, QtCore
from weakref import * from weakref import *
from ..Qt import QtGui, QtCore
from ..python2_3 import xrange
__all__ = ['TreeWidget', 'TreeWidgetItem'] __all__ = ['TreeWidget', 'TreeWidgetItem']
class TreeWidget(QtGui.QTreeWidget): class TreeWidget(QtGui.QTreeWidget):
"""Extends QTreeWidget to allow internal drag/drop with widgets in the tree. """Extends QTreeWidget to allow internal drag/drop with widgets in the tree.
Also maintains the expanded state of subtrees as they are moved. Also maintains the expanded state of subtrees as they are moved.