예제 #1
0
    def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton:
            if self.panActive:
                self.panActive = False

                if not ENABLE_KINETIC_PANNING or self.lastMoveTime.msecsTo(
                        QTime.currentTime()) > HOLD_TIME_THRESHOLD:
                    return

                self.kineticPanSpeed = QPointF()
                entriesConsidered = 0

                currentTime = QTime.currentTime()

                for entry in self.mouseHistory:
                    if not entry.time:
                        continue

                    if entry.time.msecsTo(currentTime) < HOLD_TIME_THRESHOLD:
                        self.kineticPanSpeed += entry.position
                        entriesConsidered += 1

                if entriesConsidered > 0:
                    self.kineticPanSpeed /= entriesConsidered

                self.lastMoveTime = currentTime

                self.kineticTimer.start()
                self.panDecellerate = True

        event.accept()
예제 #2
0
    def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton:
            if self.panActive:
                self.panActive = False

                if not ENABLE_KINETIC_PANNING or self.lastMoveTime.msecsTo(QTime.currentTime()) > HOLD_TIME_THRESHOLD:
                    return

                self.kineticPanSpeed = QPointF()
                entriesConsidered = 0

                currentTime = QTime.currentTime()

                for entry in self.mouseHistory:
                    if not entry.time:
                        continue

                    if entry.time.msecsTo(currentTime) < HOLD_TIME_THRESHOLD:
                        self.kineticPanSpeed += entry.position
                        entriesConsidered += 1

                if entriesConsidered > 0:
                    self.kineticPanSpeed /= entriesConsidered

                self.lastMoveTime = currentTime

                self.kineticTimer.start()
                self.panDecellerate = True

        event.accept()
예제 #3
0
    def TurnGenerator(self, startPosition):
        """
    Takes PointerPosition on explicit call to send().
    Generates turn positions between lines that lie on a axis (vertical or horizontal).
   
    Qt doesn't have event.time . Fabricate it here.  X11 has event.time.
    """
        position = None  # if events are: send(None), close(), need this defined
        previousPosition = startPosition
        positionClock = QTime.currentTime()  # note restart returns elapsed
        positionClock.restart()
        # I also tried countPositionsSinceTurn to solve lag for cusp-like
        # print "init turn"

        try:
            while True:
                position = (yield)
                positionElapsedTime = positionClock.restart()
                turn = self.detectTurn(previousPosition, position)
                if turn is not None:
                    self.lineGenerator.send((turn, positionElapsedTime))
                    previousPosition = position  # Roll forward
                else:  # path is still on an axis: wait
                    pass
        finally:
            # assert position is defined
            if previousPosition != position:
                """ Have position not sent. Fabricate a turn (equal to position) and send() """
                self.lineGenerator.send((position, 0))
            print "Closing turn generator"
예제 #4
0
    def setTodoStartTime(self, hour, minute):
        orig_date = self._todo.startDateTime().date()
        time = QTime(hour, minute)
        datetime = QDateTime(orig_date, time)

        self._todo.setStartDateTime(datetime)
        self.currentTodoChanged.emit()
예제 #5
0
 def show_time(self):
     '''
     clock
     :return:
     '''
     time = QTime.currentTime()
     text = time.toString('hh:mm:ss')
     self.time_lcd.display(text)
예제 #6
0
 def _update_time(self):
     # this gets called every seconds
     # adjust the remaining time
     self.countdown = self.countdown.addSecs(-1)
     # if the remaining time reached zero, stop the timer
     if self.countdown <= QTime(0, 0, 0):
         self.timer.stop()
     # update the display
     self.setText(self.countdown.toString(Qt.ISODate))
예제 #7
0
    def testQTime(self):
        time = datetime.time(11, 14, 0, 1000)
        other = QTime(time)
        self.assertEqual(time.hour, other.hour())
        self.assertEqual(time.minute, other.minute())
        self.assertEqual(time.second, other.second())
        self.assertEqual(time.microsecond / 1000, other.msec())

        self.assertEqual(time, other.toPython())
예제 #8
0
파일: editTeam.py 프로젝트: ldonjibson/FFL
    def __init__(self, playersOut, playersIn, parent=None):
        super(confirmSubsDialog, self).__init__(parent)

        self.now = QDateTime.currentDateTime()
        self.now.setTime(
            QTime(self.now.time().hour(),
                  self.now.time().minute()))

        self.setWindowTitle("Confirm Subs")
        mainVerticalLayout = QVBoxLayout(self)

        subsLayout = QGridLayout()
        mainVerticalLayout.addLayout(subsLayout)

        subsLayout.addWidget(QLabel("<b>Players Out</b>"), 0, 0)
        subsLayout.addWidget(QLabel("<b>Players In</b>"), 0, 1)

        for i, (playerOut, playerIn) in enumerate(zip(playersOut, playersIn)):
            playerOutLabel = QLabel()
            playerOutLabel.setText("<font color=red>{0}</font>".format(
                playerOut.name))
            subsLayout.addWidget(playerOutLabel, i + 1, 0)

            playerInLabel = QLabel()
            playerInLabel.setText("<font color=green>{0}</font>".format(
                playerIn.name))
            subsLayout.addWidget(playerInLabel, i + 1, 1)

        mainVerticalLayout.addItem(
            QSpacerItem(0, 15, QSizePolicy.Minimum, QSizePolicy.Expanding))

        dateTimeLayout = QHBoxLayout()
        mainVerticalLayout.addLayout(dateTimeLayout)
        dateTimeLayout.addWidget(QLabel("Date and time"))

        self.dateTimeEdit = QDateTimeEdit(self.now)
        self.dateTimeEdit.setMaximumDateTime(self.now)
        self.dateTimeEdit.setCalendarPopup(True)
        self.dateTimeEdit.setDisplayFormat("d MMM yy h:mm AP")

        dateTimeLayout.addWidget(self.dateTimeEdit)
        dateTimeLayout.addStretch()

        mainVerticalLayout.addItem(
            QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding))

        buttonBox = QDialogButtonBox(self)
        buttonBox.setStandardButtons(QDialogButtonBox.Cancel
                                     | QDialogButtonBox.Ok)
        buttonBox.button(QDialogButtonBox.Ok).setText("&Accept")
        mainVerticalLayout.addWidget(buttonBox)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
예제 #9
0
    def editNewTodo(self):
        """Sets the current todo to a newly created todo"""
        newTodo = QOrganizerTodo()
        newTodo.setPriority(QOrganizerItemPriority.HighPriority)
        newTodo.setStatus(QOrganizerTodoProgress.StatusNotStarted)
        currentDateTime = QDateTime(QDate.currentDate(), QTime.currentTime())
        newTodo.setStartDateTime(currentDateTime)
        newTodo.setDueDateTime(currentDateTime.addSecs(60 * 60))

        self._todo = newTodo
        self._todo.isNewTodo = True
        self.currentTodoChanged.emit()
예제 #10
0
파일: qmltodo.py 프로젝트: AmerGit/Examples
    def editNewTodo(self):
        """Sets the current todo to a newly created todo"""
        newTodo = QOrganizerTodo()
        newTodo.setPriority(QOrganizerItemPriority.HighPriority)
        newTodo.setStatus(QOrganizerTodoProgress.StatusNotStarted)
        currentDateTime = QDateTime(QDate.currentDate(), QTime.currentTime())
        newTodo.setStartDateTime(currentDateTime)
        newTodo.setDueDateTime(currentDateTime.addSecs(60*60))

        self._todo = newTodo
        self._todo.isNewTodo = True
        self.currentTodoChanged.emit()
예제 #11
0
    def testQDateTimeValid(self):
        '''QDataStream <<>> QDateTime - valid'''
        time = QTime(23, 23, 23)
        date = QDate(2009, 1, 1)

        self.stream << QDateTime(date, time)

        res = QDateTime()

        self.read_stream >> res
        self.assertEqual(res, QDateTime(date, time))
        self.assertTrue(res.isValid())
        self.assertFalse(res.isNull())
예제 #12
0
    def testQTime(self):
        time = datetime.time(11, 14, 0, 1000)
        other = QTime(time)
        self.assertEqual(time.hour, other.hour())
        self.assertEqual(time.minute, other.minute())
        self.assertEqual(time.second, other.second())
        self.assertEqual(time.microsecond/1000, other.msec())

        self.assertEqual(time, other.toPython())
예제 #13
0
    def testQTimeValid(self):
        '''QDataStream <<>> QTime - valid'''
        self.stream << QTime(12, 12, 21)

        res = QTime()

        self.read_stream >> res
        self.assertEqual(res, QTime(12, 12, 21))
        self.assertTrue(res.isValid())
        self.assertFalse(res.isNull())
예제 #14
0
    def kineticTimerEvent(self):

        currentTime = QTime.currentTime()

        deltaTime = self.lastMoveTime.msecsTo(currentTime)
        self.lastMoveTime = currentTime

        if self.panDecellerate:
            self.kineticPanSpeed *= pow(0.5, float(deltaTime / KINETIC_PANNING_HALFLIFE))

        scaledSpeed = self.kineticPanSpeed * deltaTime

        if self.kineticPanSpeed.manhattanLength() < KINETIC_PAN_SPEED_THRESHOLD:
            self.kineticTimer.stop()
            return
        self.panFloatWrapper(scaledSpeed)
예제 #15
0
    def mousePressEvent(self, event):
        self.setFocus()

        if event.button() == Qt.LeftButton:
            if event.modifiers() & Qt.ControlModifier:
                pass
            else:
                if self.coordQueryState:
                    self.coordQueryResult.emit(self.screenPositionToCoordinate(event.lastPos()))
                    return

                self.panActive = True

                self.kineticTimer.stop()
                self.kineticPanSpeed = QPointF()
                self.lastMoveTime = QTime.currentTime()

        event.accept()
예제 #16
0
    def testInsert(self):
        myHash = {}
        qdate = QDate.currentDate()
        qdatetime = QDateTime.currentDateTime()
        qtime = QTime.currentTime()
        qurl = QUrl("http://www.pyside.org")
        qpoint = QPoint(12, 42)

        myHash[qdate] = "QDate"
        myHash[qdatetime] = "QDateTime"
        myHash[qtime] = "QTime"
        myHash[qurl] = "QUrl"
        myHash[qpoint] = "QPoint"

        self.assertEqual(myHash[qdate], "QDate")
        self.assertEqual(myHash[qdatetime], "QDateTime")
        self.assertEqual(myHash[qtime], "QTime")
        self.assertEqual(myHash[qurl], "QUrl")
        self.assertEqual(myHash[qpoint], "QPoint")
예제 #17
0
    def testInsert(self):
        myHash = {}
        qdate = QDate.currentDate()
        qdatetime = QDateTime.currentDateTime()
        qtime = QTime.currentTime()
        qurl = QUrl("http://www.pyside.org")
        qpoint = QPoint(12, 42)

        myHash[qdate] = "QDate"
        myHash[qdatetime] = "QDateTime"
        myHash[qtime] = "QTime"
        myHash[qurl] = "QUrl"
        myHash[qpoint] = "QPoint"

        self.assertEqual(myHash[qdate], "QDate")
        self.assertEqual(myHash[qdatetime], "QDateTime")
        self.assertEqual(myHash[qtime], "QTime")
        self.assertEqual(myHash[qurl], "QUrl")
        self.assertEqual(myHash[qpoint], "QPoint")
예제 #18
0
    def mouseMoveEvent(self, event):
        if event.modifiers() & Qt.ControlModifier:
            if self.lastCircle:
                self.lastCircle.setCenter(self.screenPositionToCoordinate(event.pos()))
        elif self.panActive:
            currentTime = QTime.currentTime()
            deltaTime = self.lastMoveTime.msecsTo(currentTime)

            delta = event.lastPos() - event.pos()

            if deltaTime > 0:
                self.kineticPanSpeed = delta / deltaTime

                self.mouseHistory.popleft()
                self.mouseHistory.append(MouseHistoryEntry(self.kineticPanSpeed, currentTime))

            self.panFloatWrapper(delta)

        event.accept()
예제 #19
0
파일: Clock.py 프로젝트: staldates/aldatesx
 def updateClock(self):
     self.setText(QTime.currentTime().toString("hh:mm"))
예제 #20
0
 def run(self):
     t = QTime()
     t.start()
     time.sleep(2)  # Sleep 2 seconds
예제 #21
0
파일: dialogs.py 프로젝트: mousebaiker/WATS
    def __init__(self, groups):
        super(addBlockDialog, self).__init__()
        self.groups = groups

        # Status
        self.errorstatus = QLabel()

        # Layouts
        self.topLayout = QVBoxLayout()
        self.mainLayout = QGridLayout()
        self.timeLayout = QHBoxLayout()
        self.buttons = QHBoxLayout()

        # Main Elements
        self.statusLabel = QLabel(languagedict['addBlockStatus'])
        self.status = QComboBox()
        for status in groups:
            self.status.addItem(status.getName())
        self.status.activated.connect(self.updatetasks)

        self.tasksLabel = QLabel(languagedict['addBlockTask'])
        self.tasks = QComboBox()

        self.weekdayLabel = QLabel(languagedict['addBlockWeekday'])
        self.weekday = QComboBox()
        for weekday in languagedict['mainTableHeaders']:
            self.weekday.addItem(weekday)

        self.timeLabel = QLabel(languagedict['addBlockTime'])
        self.start = QTimeEdit(QTime(6, 0))
        self.start.setDisplayFormat('hh:mm')
        self.end = QTimeEdit(QTime(7, 0))
        self.end.setDisplayFormat('hh:mm')

        # Buttons
        self.ok = QPushButton(languagedict['OKButton'])
        self.ok.clicked.connect(self.check)
        self.cancel = QPushButton(languagedict['CancelButton'])
        self.cancel.clicked.connect(self.reject)

        # Laying out
        # Time
        self.timeLayout.addWidget(self.start)
        self.timeLayout.addWidget(self.end)

        # Central
        self.mainLayout.addWidget(self.statusLabel, 0, 0)
        self.mainLayout.addWidget(self.status, 1, 0)
        self.mainLayout.addWidget(self.tasksLabel, 0, 1)
        self.mainLayout.addWidget(self.tasks, 1, 1)
        self.mainLayout.addWidget(self.weekdayLabel, 2, 0)
        self.mainLayout.addWidget(self.weekday, 3, 0)
        self.mainLayout.addWidget(self.timeLabel, 2, 1)
        self.mainLayout.addLayout(self.timeLayout, 3, 1)

        # Buttons
        self.buttons.addWidget(self.ok)
        self.buttons.addWidget(self.cancel)

        # Top level
        self.topLayout.addWidget(self.errorstatus)
        self.topLayout.addLayout(self.mainLayout)
        self.topLayout.addLayout(self.buttons)

        # Main settings
        self.setLayout(self.topLayout)
        self.setWindowTitle(languagedict['addBlockTitle'])
예제 #22
0
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from PySide.QtCore import QTime, QTimer
from collections import deque

t = QTime()
t.start()
data = deque(maxlen=20)


class TimeAxisItem(pg.AxisItem):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def tickStrings(self, values, scale, spacing):
        # PySide's QTime() initialiser fails miserably and dismisses args/kwargs
        return [QTime().addMSecs(value).toString('mm:ss') for value in values]


app = QtGui.QApplication([])

win = pg.GraphicsWindow(title="Basic plotting examples")
win.resize(1000, 600)

plot = win.addPlot(title='Timed data',
                   axisItems={'bottom': TimeAxisItem(orientation='bottom')})
curve = plot.plot()


def update():
예제 #23
0
# Only Example: import, it's not recommended but for the simple app it's okay

from PySide.QtCore import QTime, QTimer, Qt
from PySide.QtGui import QApplication, QLabel

import sys
import time

app = QApplication(sys.argv)

# Hold the current time for the alarm clock
due = QTime.currentTime()

# Static message for Alert box
message = 'Alert!'


try:
    message = 'Alert!'

    # The application requires always an argument
    if len(sys.argv) < 2:
        sys.argv.append('%02d:%02d' % (due.hour(), due.minute()))
    elif len(sys.argv) > 2:
        message = ' '.join(sys.argv[2:])

    # class PySide.QtCore.QTime(h, m[, s=0[, ms=0]])
    hours, minutes = sys.argv[1].split(':')

    due = QTime(int(hours), int(minutes))
예제 #24
0
 def tickStrings(self, values, scale, spacing):
     # PySide's QTime() initialiser fails miserably and dismisses args/kwargs
     return [QTime().addMSecs(value).toString('mm:ss') for value in values]
예제 #25
0
 def testDateConversion(self):
     dateTime = QDateTime(QDate(2011, 5, 17), QTime(11, 1, 14, 15))
     dateTimePy = QDateTime(datetime.date(2011, 5, 17),
                            datetime.time(11, 1, 14, 15000))
     self.assertEqual(dateTime, dateTimePy)
예제 #26
0
def main():
    app = QApplication(sys.argv)
    widget = CountdownWidget(QTime(0, 0, 5))
    widget.start()
    widget.show()
    app.exec_()
from PySide.QtCore import QTime, QTimer, Qt
from PySide.QtGui import QApplication, QLabel

import sys
import time


def quitApplication(app):
    return app.quit


if __name__ == '__main__':

    app = QApplication(sys.argv)
    due = QTime.currentTime()
    message = "Alert! "

    try:
        if len(sys.argv) < 2:
            raise ValueError("Not enough arguments")

        hours, minutes = sys.argv[1].split(":")
        #python SimpleApp.py 09:32 <optional message>

        due = QTime(int(hours), int(minutes))
        if not due.isValid():
            raise ValueError("Input time is not Valid")

        if len(sys.argv) > 2:
            message += " ".join(sys.argv[2:])
예제 #28
0
 def updateClock(self):
     self.setText(QTime.currentTime().toString("hh:mm"))
예제 #29
0
 def setUp(self):
     self.original = QTime(11, 37, 55, 692)
예제 #30
0
 def run(self):
     t = QTime()
     t.start()
     time.sleep(2)  # Sleep 2 seconds