def __init__(self, funcOn, funcOff, text="", state=False): QtGui.QCheckBox.__init__(self,text) self.setChecked(state) def checkBoxCB(n): if n == 2: funcOn() elif n == 0: funcOff() connect(self, "stateChanged(int)", checkBoxCB)
def setupGui(self): ## self.widget has next, prev buttons, plus a QStackedWidget for holding per page controls self.widget = ChangePageUI() ## the initial state self.widget.previous.hide() self.widget.next.hide() connect(self.widget.next, "clicked(bool)", self.nextPage) connect(self.widget.previous, "clicked(bool)", self.prevPage) ## ============================ self.notesStack = QtGui.QStackedWidget()
def chain(animations, pause=100): ''' Runs all animations one after another @param animations: @param pause: ''' for i in range(len(animations)-1): animations[i].pauseTimer.setInterval(pause) connect(animations[i],"finished()",animations[i].pauseTimer.start) connect(animations[i].pauseTimer,"timeout()",animations[i+1].start)
def __init__(self, funcOn, funcOff, text="", state=False): QtGui.QCheckBox.__init__(self, text) self.setChecked(state) def checkBoxCB(n): if n == 2: funcOn() elif n == 0: funcOff() connect(self, "stateChanged(int)", checkBoxCB)
def chain(animations, pause=100): ''' Runs all animations one after another @param animations: @param pause: ''' for i in range(len(animations) - 1): animations[i].pauseTimer.setInterval(pause) connect(animations[i], "finished()", animations[i].pauseTimer.start) connect(animations[i].pauseTimer, "timeout()", animations[i + 1].start)
def __init__(self, duration, times): QtCore.QObject.__init__(self) self.times = self.timesleft = times self.oneshot = SoOneShot() self.oneshot.duration = duration self.oneshot.flags = SoOneShot.HOLD_FINAL ## necesitamos un SoField para poder extraer el ## valor con getValue() ## can't this value be obtained directly from a SoEngineOutput? self.value = SoSFFloat() self.value.connectFrom(self.oneshot.ramp) self.sensor = SoFieldSensor(self.callback, self.value) self.sensor.attach(self.value) connect(self, "finished()", self.cycle)
def __init__(self, text, iter, func, parent=None): QtGui.QSpinBox.__init__(self) (vmin, vmax, vini) = iter self.setMinimum(vmin) self.setMaximum(vmax) self.setValue(vini) self.func = func connect(self, "valueChanged(int)", lambda x: func(x)) layout = QtGui.QHBoxLayout() lab = QtGui.QLabel(text) layout.addWidget(lab) layout.addWidget(self) if parent: parent.addLayout(layout)
def __init__(self, text,iter,func,parent=None): QtGui.QSpinBox.__init__(self) (vmin, vmax, vini) = iter self.setMinimum(vmin) self.setMaximum(vmax) self.setSingleStep(.1) self.setValue(vini) self.func = func connect(self,"valueChanged(double)", lambda x: func(x)) layout = QtGui.QHBoxLayout() lab = QtGui.QLabel(text) layout.addWidget(lab) layout.addWidget(self) if parent: parent.addLayout(layout)
class Animation(OneShotTimeLine): def __init__(self, func, (duration, nmin, nmax)): self.functions = [func] super(Animation, self).__init__(duration) self.setFrameRange(nmin, nmax) connect(self, "frameChanged(int)", self.functions[-1]) ## ====================================== ## This is used for the static method "chain" ## it is the pause between animations self.pauseTimer = QtCore.QTimer() self.pauseTimer.setSingleShot(True) self.__anim_queue = []
def onStart(self, func): connect(self, "stateChanged(QTimeLine::State)", lambda state: func() if state == 2 else None) return self
# -*- coding: utf-8 -*- from PyQt4 import QtCore from superficie.util import connect from superficie.util import tuplize from one_shot import OneShot class Animation(OneShot): def __init__(self, func, (duration, nmin, nmax), times=1): self.functions = [func] super(Animation, self).__init__(duration / 1000.0, times) # self.setCurveShape(self.LinearCurve) self.setFrameRange(nmin, nmax) connect(self, "frameChanged(int)", self.functions[-1]) # connect(self, "ramp(float)", self.functions[-1]) ## ====================================== ## This is used for the static method "chain" ## it is the pause between animations self.pauseTimer = QtCore.QTimer() self.pauseTimer.setSingleShot(True) self.__anim_queue = [] @staticmethod def chain(animations, pause=100): ''' Runs all animations one after another @param animations: @param pause: ''' for i in range(len(animations) - 1):
def addFunction(self, func): self.functions.append(func) connect(self, "frameChanged(int)", self.functions[-1])
def onStart(self, func): "Executes func at the same time that this animation" for f in tuplize(func): connect(self, "started()", f) return self
def __init__(self,text,func,parent=None): QtGui.QPushButton.__init__(self,text) self.func = func connect(self,"clicked(bool)", lambda x: func()) if parent: parent.addWidget(self)
def __init__(self, duration): QtCore.QObject.__init__(self) self.time_line = QtCore.QTimeLine(duration) connect(self.time_line, "frameChanged(int)", self.relay_frame_changed) connect(self.time_line, "finished()", self.relay_finished)
def __init__(self, text, func, parent=None): QtGui.QPushButton.__init__(self, text) self.func = func connect(self, "clicked(bool)", lambda x: func()) if parent: parent.addWidget(self)
def addFunction(self,func): self.functions.append(func) connect(self, "frameChanged(int)", self.functions[-1])