merge fixes

This commit is contained in:
Luke Campagnola 2013-05-13 08:53:56 -04:00
commit 3344fb69ce
9 changed files with 71 additions and 16 deletions

View File

@ -1 +1 @@
from __main__ import run
from .__main__ import run

View File

@ -1,12 +1,19 @@
import sys, os, subprocess, time
import initExample
try:
from . import initExample
except ValueError:
#__package__ = os.path.split(os.path.dirname(__file__))[-1]
sys.excepthook(*sys.exc_info())
print("examples/ can not be executed as a script; please run 'python -m examples' instead.")
sys.exit(1)
from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE
if USE_PYSIDE:
from exampleLoaderTemplate_pyside import Ui_Form
from .exampleLoaderTemplate_pyside import Ui_Form
else:
from exampleLoaderTemplate_pyqt import Ui_Form
from .exampleLoaderTemplate_pyqt import Ui_Form
import os, sys
from pyqtgraph.pgcollections import OrderedDict

View File

@ -154,7 +154,8 @@ def importModules(path, globals, locals, excludes=()):
try:
if len(path) > 0:
modName = path + '.' + modName
mod = __import__(modName, globals, locals, fromlist=['*'])
#mod = __import__(modName, globals, locals, fromlist=['*'])
mod = __import__(modName, globals, locals, ['*'], 1)
mods[modName] = mod
except:
import traceback

View File

@ -281,7 +281,7 @@ class AxisItem(GraphicsWidget):
def setScale(self, scale=None):
"""
Set the value scaling for this axis. Values on the axis are multiplied
by this scale factor before being displayed as text. By default,
by this scale factor before being displayed as text. By default (scale=None),
this scaling value is automatically determined based on the visible range
and the axis units are updated to reflect the chosen scale factor.
@ -301,6 +301,7 @@ class AxisItem(GraphicsWidget):
self.setLabel(unitPrefix=prefix)
else:
scale = 1.0
self.autoScale = True
else:
self.setLabel(unitPrefix='')
self.autoScale = False
@ -499,6 +500,10 @@ class AxisItem(GraphicsWidget):
"""
minVal, maxVal = sorted((minVal, maxVal))
minVal *= self.scale
maxVal *= self.scale
#size *= self.scale
ticks = []
tickLevels = self.tickSpacing(minVal, maxVal, size)
@ -511,16 +516,25 @@ class AxisItem(GraphicsWidget):
## determine number of ticks
num = int((maxVal-start) / spacing) + 1
values = np.arange(num) * spacing + start
values = (np.arange(num) * spacing + start) / self.scale
## remove any ticks that were present in higher levels
## we assume here that if the difference between a tick value and a previously seen tick value
## is less than spacing/100, then they are 'equal' and we can ignore the new tick.
values = list(filter(lambda x: all(np.abs(allValues-x) > spacing*0.01), values) )
allValues = np.concatenate([allValues, values])
ticks.append((spacing, values))
ticks.append((spacing/self.scale, values))
if self.logMode:
return self.logTickValues(minVal, maxVal, size, ticks)
#nticks = []
#for t in ticks:
#nvals = []
#for v in t[1]:
#nvals.append(v/self.scale)
#nticks.append((t[0]/self.scale,nvals))
#ticks = nticks
return ticks
@ -731,6 +745,7 @@ class AxisItem(GraphicsWidget):
textRects = []
textSpecs = [] ## list of draw
textSize2 = 0
for i in range(len(tickLevels)):
## Get the list of strings to display for this level
if tickStrings is None:

View File

@ -73,6 +73,36 @@ class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
self.layout.addItem(sample, row, 0)
self.layout.addItem(label, row, 1)
self.updateSize()
#
#
# Ulrich
def removeItem(self, name):
"""
Removes one item from the legend.
=========== ========================================================
Arguments
title The title displayed for this item.
=========== ========================================================
"""
# cycle for a match
for sample, label in self.items:
print label.text, name
if label.text == name: # hit
self.items.remove( (sample, label) ) # remove from itemlist
self.layout.removeItem(sample) # remove from layout
sample.close() # remove from drawing
self.layout.removeItem(label)
label.close()
self.updateSize() # redraq box
# hcirlU
#
#
def updateSize(self):
if self.size is not None:

View File

@ -295,19 +295,21 @@ class PlotItem(GraphicsWidget):
def setLogMode(self, x, y):
def setLogMode(self, x=None, y=None):
"""
Set log scaling for x and y axes.
Set log scaling for x and/or y axes.
This informs PlotDataItems to transform logarithmically and switches
the axes to use log ticking.
Note that *no other items* in the scene will be affected by
this; there is no generic way to redisplay a GraphicsItem
this; there is (currently) no generic way to redisplay a GraphicsItem
with log coordinates.
"""
self.ctrl.logXCheck.setChecked(x)
self.ctrl.logYCheck.setChecked(y)
if x is not None:
self.ctrl.logXCheck.setChecked(x)
if y is not None:
self.ctrl.logYCheck.setChecked(y)
def showGrid(self, x=None, y=None, alpha=None):
"""

View File

@ -1771,7 +1771,7 @@ class PolyLineROI(ROI):
shape = [1] * data.ndim
shape[axes[0]] = sliced.shape[axes[0]]
shape[axes[1]] = sliced.shape[axes[1]]
return sliced * mask
return sliced * mask.reshape(shape)
class LineSegmentROI(ROI):

View File

@ -129,7 +129,7 @@ class Parallelize(object):
self.childs.append(proc)
## Keep track of the progress of each worker independently.
self.progress = {ch.childPid: [] for ch in self.childs}
self.progress = dict([(ch.childPid, []) for ch in self.childs])
## for each child process, self.progress[pid] is a list
## of task indexes. The last index is the task currently being
## processed; all others are finished.

View File

@ -803,7 +803,7 @@ class ObjectProxy(object):
return val
def _getProxyOptions(self):
return {k: self._getProxyOption(k) for k in self._proxyOptions}
return dict([(k, self._getProxyOption(k)) for k in self._proxyOptions])
def __reduce__(self):
return (unpickleObjectProxy, (self._processId, self._proxyId, self._typeStr, self._attributes))