Beispiel #1
0
class StorageUsage(QThread):
    StoragSignal = Signal(int)

    def __init__(self):
        super().__init__()

    def run(self):
        p = os.popen("df -h /")
        i = 0
        while True:
            i = i + 1
            line = p.readline()
            if i == 2:
                DISK_stats = line.split()[1:5]
                DISK_total = round(float(str(DISK_stats[0][0:2])))
                DISK_used = round(float(str(DISK_stats[1][0:2])))

                # logging.info("DISK_total",DISK_total)
                # logging.info("DISK_used",DISK_used)

                val = round(int((DISK_used / DISK_total) * 100), 0)
                # logging.info("StorageUsage",val)
                self.StoragSignal.emit(int(val))
                self.sleep(1)
                p = os.popen("df -h /")
                i = 0
Beispiel #2
0
class DisplayThread(QThread):
    labeltext = Signal(str)

    def __init__(self, parent=None):
        super(DisplayThread, self).__init__(parent)
        self.filename = "........Select song to enjoy the moment........"

    def run(self):
        filelist = []
        filelist_rev = []
        loop_list = []
        filename = self.filename
        while True:
            for element in self.filename_list2(self.filename):
                self.labeltext.emit("text: {}, loop: 2".format(element))
                time.sleep(0.2)
            for element in self.filename_list(self.filename):
                self.labeltext.emit("text: {}, loop: 2".format(element))
                time.sleep(0.15)

    def filename_list(self, filename):
        string_list = []
        if len(filename.split("/")) > 1:
            filename = "Now playing......  " + filename.split("/")[-1]
        for i in range(len(filename)):
            string_list.append(filename[:i])
        return string_list

    def filename_list2(self, filename):
        string_list = []
        if len(filename.split("/")) > 1:
            filename = "Now playing......  " + filename.split("/")[-1]
        for i in range(len(filename)):
            string_list.append(filename[i:])
        return string_list
Beispiel #3
0
class ColorButton(QPushButton):
    """
    Color choosing push button
    """

    colorChanged = Signal(QColor)

    def __init__(self, parent=None):
        QPushButton.__init__(self, parent)
        self.setFixedSize(20, 20)
        self.setIconSize(QSize(12, 12))
        self.clicked.connect(self.choose_color)
        self._color = QColor()

    def choose_color(self):
        color = QColorDialog.getColor(self._color, self.parentWidget())
        if color.isValid():
            self.set_color(color)

    def get_color(self):
        return self._color

    @Slot(QColor)
    def set_color(self, color):
        if color != self._color:
            self._color = color
            self.colorChanged.emit(self._color)
            pixmap = QPixmap(self.iconSize())
            pixmap.fill(color)
            self.setIcon(QIcon(pixmap))

    color = Property("QColor", get_color, set_color)
Beispiel #4
0
class Accelerator(QThread):
    AxisSignal = Signal(int,str)
    Path = None
    def __init__(self,path):
        super().__init__()
        if path:
            self.Path = path
    
    def run(self):    
        while True:
            abs = InputDevice(self.Path)
            for event in abs.read_loop():
                if event.type == ecodes.EV_ABS:
                    val = repr(event)
                    val_list = val.replace('(','').replace(')','').replace(' ','').split(',')
                    if val_list[3] == '0':
                        axis_x = int(val_list[4])
                        self.AxisSignal.emit(axis_x,'x')
                    if val_list[3] == '1':
                        axix_y = int(val_list[4])
                        self.AxisSignal.emit(axix_y,'y')
                    if val_list[3] == '2':
                        axis_z = int(val_list[4])
                        self.AxisSignal.emit(axis_z,'z') 
                    # self.sleep(1)
Beispiel #5
0
class ListSingleSelectionModel(QItemSelectionModel):
    """ Item selection model for list item models with single selection.

    Defines signal:
        - selectedIndexChanged(QModelIndex)

    """
    selectedIndexChanged = Signal(QModelIndex)

    def __init__(self, model, parent=None):
        QItemSelectionModel.__init__(self, model, parent)
        self.selectionChanged.connect(self.onSelectionChanged)

    def onSelectionChanged(self, new, _):
        index = list(new.indexes())
        if index:
            index = index.pop()
        else:
            index = QModelIndex()

        self.selectedIndexChanged.emit(index)

    def selectedRow(self):
        """ Return QModelIndex of the selected row or invalid if no selection.
        """
        rows = self.selectedRows()
        if rows:
            return rows[0]
        else:
            return QModelIndex()

    def select(self, index, flags=QItemSelectionModel.ClearAndSelect):
        if isinstance(index, int):
            index = self.model().index(index)
        return QItemSelectionModel.select(self, index, flags)
Beispiel #6
0
class FavDemandFetcher(CheckableModel, QObject):
    endHit = Signal()

    def __init__(self, weboob):
        super(FavDemandFetcher, self).__init__(weboob)

        app = QApplication.instance()
        app.dataChanged.connect(self._reemit)
        self.counter = 0
        self.on_demand = False
        self.reqs = {}

    @Slot(int)
    def _reemit(self, cookie):
        item = self.reqs[cookie]
        assert item.parent
        qidx = self.createIndex(item.parent.children.index(item), 0, item)
        self.dataChanged.emit(qidx, qidx)

    def fillObj(self, obj, fields, qidx):
        if self.on_demand:
            self.counter += 1

            app = QApplication.instance()
            self.reqs[self.counter] = qidx.internalPointer()
            app.fetchFill((obj, fields, self.counter))
        else:
            super(FavDemandFetcher, self).fillObj(obj, fields, qidx)
Beispiel #7
0
class AppUpdateScreen(UpdateScreen):
    """Screen to display message that image update is available."""

    goto_next = Signal()
    update_text = (
        "<b>Update available</b><br>"
        "An update to the EPI2MELabs Launcher is available. Updating the "
        "Launcher is recommended for all users. Please use the Download "
        "button below to open the downloads page in your web browser.<br><br>"
        "Current version: {}.<br>"
        "Latest version: {}.<br>"
        "<br>{}")

    def __init__(self, parent=None):
        """Initialize the screen."""
        super().__init__(parent=parent)

        self.download_btn = QPushButton("Download")
        self.download_btn.clicked.connect(self.open_download)
        self.l0.addWidget(self.download_btn)

    def open_download(self):
        """Open download page in web browser."""
        webbrowser.open(self.app.settings['download_link'])
        self.goto_next.emit()
Beispiel #8
0
class DlPrompt(Prompt):
    keymap = DL_PROMPT_KEYMAP
    complete_options = {
        "autocomplete": True
    }
    download_started = Signal(object)

    def __init__(self, dl):
        Prompt.__init__(self)
        self._dl = dl
        self.label = "Download file [{}]:".format(dl.mimeType())

    def completer_model(self):
        # todo, not working
        model = FSModel(self)
        return model

    def enable(self, minibuffer):
        Prompt.enable(self, minibuffer)
        minibuffer.input().setText(self._dl.path())

    def _on_edition_finished(self):
        path = self.minibuffer.input().text()
        self._dl.setPath(path)
        self._dl.accept()
        self.download_started.emit(self._dl)
        Prompt._on_edition_finished(self)
Beispiel #9
0
class UpdateScreen(Screen):
    """Screen to display message that image update is available."""

    goto_next = Signal()
    update_text = (
        "<b>Update available</b><br>"
        "An update to the notebook server is available. Updating the "
        "notebook server will allow continued use of the most recent "
        "EPI2ME Labs notebooks on GitHub. Please press the Update "
        "button on the main screen to update.<br><br>"
        "Current version: {}.<br>"
        "Latest version: {}.")

    def __init__(self, parent=None):
        """Initialize the screen."""
        super().__init__(parent=parent)

        self.layout = QVBoxLayout()

        self.update_lbl = QLabel()
        self.layout.addWidget(self.update_lbl)
        self.layout.insertStretch(-1)

        self.l0 = QHBoxLayout()
        self.layout.insertStretch(-1)
        self.dismiss_btn = QPushButton("OK")
        self.dismiss_btn.clicked.connect(self.goto_next.emit)
        self.l0.addWidget(self.dismiss_btn)
        self.layout.addLayout(self.l0)

        self.setLayout(self.layout)
Beispiel #10
0
class WKeySequenceInput(QKeySequenceEdit):
    """An improved version of QKeySequenceEdit"""
    keySequenceCleared=Signal()

    def __init__(self, parent=None):
        super(WKeySequenceInput, self).__init__(parent)

        self.__lineEdit=self.findChild(QLineEdit)
        self.__lineEdit.textChanged.connect(self.__textChanged)

    def __textChanged(self, value):
        """Text has been changed"""
        if value=='':
            self.clear()
            self.keySequenceCleared.emit()

    def isClearButtonEnabled(self, value):
        """Return if clear button is displayed or not"""
        self.__lineEdit.isClearButtonEnabled()

    def setClearButtonEnabled(self, value):
        """Display or not clear button"""
        self.__lineEdit.setClearButtonEnabled(value)
        if value:
            replaceLineEditClearButton(self.__lineEdit)
Beispiel #11
0
class number(QObject):
    def __init__(self):
        QObject.__init__(self)
        self.now = datetime.now()
        self.fromDB = database.database()
        self.sqlString = None
        self.sqlData = None
        self.sqlList = None

    signalNumber = Signal(int)

    @Slot()
    def getNumber(self):
        self.sqlString = "SELECT number FROM queue"
        self.sqlList = self.fromDB.selectall(self.sqlString)
        for x in self.sqlList:
            self.signalNumber.emit(int(x[0]))

    @Slot(int)
    def incrementNumber(self, number):
        self.sqlString = "UPDATE queue SET number = %s WHERE number = %s"
        self.sqlData = ((number + 1), number)
        self.fromDB.setValues(self.sqlString, self.sqlData)

    @Slot(str)
    def saveReport(self, queueNumber):
        dateToday = self.now.strftime("%d %B %Y")
        timeToday = self.now.strftime("%I:%M %p")
        self.sqlString = "INSERT INTO enrollmentreport (queuenumber, date, time) VALUES (%s, %s, %s)"
        self.sqlData = (queueNumber, dateToday, timeToday)
        self.fromDB.setValues(self.sqlString, self.sqlData)
Beispiel #12
0
class TagChooser(QListView):
	changed = Signal()

	def __init__(self, *args, **kwargs):
		super(TagChooser,self).__init__(*args, **kwargs)
		self.db = None

		self.filter = u''

		self.data = QStandardItemModel(self)
		self.proxy = QSortFilterProxyModel(self)
		self.proxy.setSourceModel(self.data)
		self.setModel(self.proxy)

		self.data.itemChanged.connect(self.changed)

		self.setContextMenuPolicy(Qt.ActionsContextMenu)
		act = QAction('&Refresh tags', self)
		act.triggered.connect(self.refreshTags)
		self.addAction(act)

	def setDb(self, db):
		self.db = db

		for t in sorted(self.db.list_tags()):
			item = QStandardItem(t)
			item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
			item.setCheckState(Qt.Unchecked)
			self.data.appendRow(item)

	def setTags(self, tags):
		for i in range(self.data.rowCount()):
			item = self.data.item(i)
			if item.text() in tags:
				item.setCheckState(Qt.Checked)
			else:
				item.setCheckState(Qt.Unchecked)

	def selectedTags(self):
		tags = []
		for i in range(self.data.rowCount()):
			item = self.data.item(i)
			if item.checkState() == Qt.Checked:
				tags.append(item.text())
		return tags

	def matchingFiles(self):
		tags = self.selectedTags()

		if not tags:
			return []
		res = list(self.db.find_files_by_tags(tags))
		res.sort()
		return res

	@Slot()
	def refreshTags(self):
		selected = self.selectedTags()
		self.setDb(self.db)
		self.setTags(selected)
Beispiel #13
0
class ClickLabel(QLabel):
    """A Label that can be clicked."""

    clicked = Signal()

    def __init__(self, parent=None):
        """Initialize the widget."""
        super().__init__(parent=parent)
        self.setStyleSheet("color: blue; text-decoration: underline;")
        self.setFocusPolicy(Qt.NoFocus)
        self.setClickable(True)

    def mousePressEvent(self, event):
        """Emit clicked signal when pressed."""
        if self.enabled and event.button() == Qt.LeftButton:
            self.clicked.emit()
        else:
            super().mousePressEvent(event)

    def setClickable(self, enabled):
        """Set whether label is clickable.

        :param enabled: boolean.
        """
        self.enabled = enabled
        if self.enabled:
            self.setCursor(QCursor(Qt.PointingHandCursor))
        else:
            self.setCursor(QCursor(Qt.ArrowCursor))
Beispiel #14
0
class SourceDatasets(QWidget):
    modified = Signal()

    def __init__(self):
        super().__init__()

        # static widgets with stored user input data
        self.doi_value = None
        self.url_value = None
        self.version_value = None

        # UI setup
        self.layout = QGridLayout()
        self.setLayout(self.layout)
        self.init_ui()

    def init_ui(self):
        self.layout.setContentsMargins(0, 0, 0, 0)
        row = 0

        # DOI
        doi_label = QLabel('DOI')
        self.doi_value = new_line_edit(self.modified.emit)
        self.layout.addWidget(doi_label, row, 0)
        self.layout.addWidget(self.doi_value, row, 1, 1, -1)
        row += 1

        # URL
        url_label = QLabel('URL')
        self.url_value = new_line_edit(self.modified.emit)
        self.layout.addWidget(url_label, row, 0)
        self.layout.addWidget(self.url_value, row, 1, 1, -1)
        row += 1

        # Version
        version_label = QLabel('Version')
        self.version_value = new_line_edit(self.modified.emit)
        self.layout.addWidget(version_label, row, 0)
        self.layout.addWidget(self.version_value, row, 1, 1, -1)
        row += 1

        # separator line
        h_line = HLine()
        self.layout.addWidget(h_line, row, 1, 1, -1)
        row += 1

        # spacer to push content to top
        self.layout.addItem(QSpacerItem(0, 0), row, 0, 2, -1)

    def get_data(self):
        """
        get relevant data from the user filled fields
        :return:
        """
        data = {
            'DOI': self.doi_value.text(),
            'URL': self.url_value.text(),
            'Version': self.version_value.text()
        }
        return data
Beispiel #15
0
class MenuManager(QObject):
    clickedIdChanged = Signal()

    def __init__(self):
        QObject.__init__(self)
        self.m_clickedId = ""
        self.clickedIdChanged.connect(self.on_clickedIdChanged)

    def setAction(self, action):
        self.actionFunc = action

    @Property(str, notify=clickedIdChanged)
    def clickedId(self):
        return self.m_clickedId

    @clickedId.setter
    def setclickedId(self, val):
        # if self.m_clickedId == val:
        #    return
        self.m_clickedId = val
        self.clickedIdChanged.emit()

    @Slot()
    def on_clickedIdChanged(self):
        print(self.m_clickedId)
        self.actionFunc(self.m_clickedId)
class RecordTime(QWidget):
    """ The record time control widget"""
    valueChanged = Signal(float)

    def __init__(self, parent=None):
        super(RecordTime, self).__init__(parent)

        self.time = time = QDoubleSpinBox()
        time.setDecimals(2)
        time.setSuffix(' seconds')
        time.setRange(0, maxRecordTime)
        time.setSingleStep(0.01)
        time.setValue(1)

        label = QLabel('&Record Time')
        label.setBuddy(time)
        layout = QVBoxLayout()
        layout.addWidget(label)
        layout.addWidget(time)

        self.setLayout(layout)

        time.valueChanged.connect(self.timeChanged)

    def timeChanged(self, val):
        self.valueChanged.emit(val)
Beispiel #17
0
class MainView(QtWidgets.QMainWindow):
    closeEventSignal = Signal(QtGui.QCloseEvent)

    def __init__(self, parent=None):
        super(MainView, self).__init__(parent, flags=Qt.WindowFlags())
        self._init_ui()

    def show(self):
        super(MainView, self).show()

    def hide(self):
        super(MainView, self).hide()

    def _init_ui(self):
        self.setWindowTitle('CompanyStatistics')

        # self.splitter = QtWidgets.QSplitter()
        # self.splitter.setHandleWidth(1)
        #
        # self.left_panel = LeftPanelView(self.splitter)
        # self.right_panel = RightPanelView(self.splitter)
        #
        # self.setCentralWidget(self.splitter)

        self.right_panel = RightPanelView(parent=None)
        self.setCentralWidget(self.right_panel)

        self.resize(870, 650)
        # self.splitter.setSizes([300, 550])

    def closeEvent(self, closeEvent):
        super(MainView, self).closeEvent(closeEvent)
        self.closeEventSignal.emit(closeEvent)
Beispiel #18
0
class CollapsedMessageWidget(QFrame, CollapsedMessageUi_Frame):
    def __init__(self, message, *args, **kwargs):
        super(CollapsedMessageWidget, self).__init__(*args, **kwargs)
        self.setupUi(self)

        EXCERPT_BUILDER.builtExcerpt.connect(self._builtExcerpt)

        self.message_id = message.get_message_id()
        self.fromLabel.setText(message.get_header('From'))
        self.toLabel.setText(message.get_header('To'))
        self.dateLabel.setText(short_datetime(message.get_date()))
        self.excerptLabel.setText(
            EXCERPT_BUILDER.getOrBuild(message.get_message_id()) or '')

        tags = set(message.get_tags())
        if 'unread' in tags:
            self.unreadLabel.setPixmap(
                QIcon.fromTheme('mail-unread').pixmap(16, 16))
        if 'attachment' in tags:
            self.attachmentLabel.setPixmap(
                QIcon.fromTheme('mail-attachment').pixmap(16, 16))

    def mousePressEvent(self, ev):
        self.toggle.emit()

    toggle = Signal()

    @Slot(str, str)
    def _builtExcerpt(self, message_id, text):
        if message_id == self.message_id:
            self.excerptLabel.setText(text)
Beispiel #19
0
class OptionWidget(QWidget):
    # signal should pass label, option
    option_selected = Signal(str, str)

    def __init__(self, *args, label, options, **kwargs):
        super().__init__(*args, **kwargs)
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        # fields
        self.label = label
        self.selected_option = None
        self.label_widget = QLabel('Choose {}:'.format(label))
        self.options = []  # add radio buttons here?

        self.setup_ui(options)

    def setup_ui(self, options):
        self.layout.addWidget(self.label_widget)
        for option in options:
            radio_button = QRadioButton(option)
            radio_button.clicked.connect(self.emit_clicked)
            self.layout.addWidget(radio_button)
        self.layout.addWidget(HLine())

    def emit_clicked(self):
        radio_bttn = self.sender()
        self.selected_option = radio_bttn.text()
        self.option_selected.emit(self.label, self.selected_option)
Beispiel #20
0
class WebJumpCompleter(object if version.building_doc else QObject):

    """
    Provides auto-completion in webjumps.

    An instance is created automatically when required, and lives while the
    webjump is active. When a key is entered in the minibuffer input, the
    method :meth:`complete` is called with the current text, asking for
    completion.

    The signal `completed` must then be emitted with the list of possible
    completions.

    Note that there is no underlying thread in the completion framework.
    """
    completed = Signal(list)

    def complete(self, text):
        """Must be implemented by subclasses."""
        raise NotImplementedError

    def abort(self):
        """
        Called when the completion request should be aborted.

        Subclasses should implement this if possible.
        """
        pass
Beispiel #21
0
class Property(QObject):
    """A variable which emits its value when changed.

    For example:
        variable = Property("value")
        variable.connect(callback)
    """

    changed = Signal(object)

    def __init__(self, value):
        """Initialize the property."""
        super().__init__()
        self._value = value

    @property
    def value(self):
        """Return the value of the property."""
        return self._value

    @value.setter
    def value(self, new_val):
        """Set the value of the property."""
        self._value = new_val
        self.changed.emit(new_val)

    def __str__(self):
        """Retun string reprepresentation of property value."""
        return str(self._value)
Beispiel #22
0
class Platform(Product.Product):
    def __init__(self, parent=None, path=''):
        super(Platform, self).__init__(parent)
        self._path = path
        self._platform = None

    Product.InputProperty(vars(), str, 'path')

    sensorNamesChanged = Signal()

    @Property(QVariant, notify=sensorNamesChanged)
    def sensorNames(self):
        if self._platform is None:
            return QVariant([])
        return QVariant(list(self._platform.sensors.keys()))

    datasourcesNamesChanged = Signal()

    @Property(QVariant, notify=datasourcesNamesChanged)
    def datasourcesNames(self):
        if self._platform is None:
            return QVariant([])
        return QVariant(self._platform.datasource_names())

    orientationChanged = Signal()

    @Property(QVariant, notify=orientationChanged)
    def orientation(self):
        if self._platform is None:
            return QVariant([])
        return QVariant(self._platform.orientation)

    @Slot(list, result=list)
    def expandWildcards(self, labels):
        if self._platform is not None:
            return self._platform.expand_wildcards(labels)

    def _update(self):
        if self._platform is None:
            self._platform = platform.Platform(dataset=self._path)

        self.orientationChanged.emit()
        self.sensorNamesChanged.emit()
        self.datasourcesNamesChanged.emit()

    def __getitem__(self, key):
        return self._platform[key]
Beispiel #23
0
class AnchorPoint(QGraphicsObject):
    """
    A anchor indicator on the :class:`NodeAnchorItem`.
    """

    #: Signal emitted when the item's scene position changes.
    scenePositionChanged = Signal(QPointF)

    #: Signal emitted when the item's `anchorDirection` changes.
    anchorDirectionChanged = Signal(QPointF)

    def __init__(self, *args):
        QGraphicsObject.__init__(self, *args)
        self.setFlag(QGraphicsItem.ItemSendsScenePositionChanges, True)
        self.setFlag(QGraphicsItem.ItemHasNoContents, True)

        self.__direction = QPointF()

    def anchorScenePos(self):
        """
        Return anchor position in scene coordinates.
        """
        return self.mapToScene(QPointF(0, 0))

    def setAnchorDirection(self, direction):
        """
        Set the preferred direction (QPointF) in item coordinates.
        """
        if self.__direction != direction:
            self.__direction = direction
            self.anchorDirectionChanged.emit(direction)

    def anchorDirection(self):
        """
        Return the preferred anchor direction.
        """
        return self.__direction

    def itemChange(self, change, value):
        if change == QGraphicsItem.ItemScenePositionHasChanged:
            self.scenePositionChanged.emit(qtcompat.qunwrap(value))

        return QGraphicsObject.itemChange(self, change, value)

    def boundingRect(self,):
        return QRectF()
Beispiel #24
0
class DataListWidget(QtWidgets.QListWidget):
    changed = Signal()
    def __init__(self,parent):
        super().__init__(parent)

    def dropEvent(self,event):
        super().dropEvent(event)
        self.changed.emit()
class NFCWorker(QObject):
    cardDetected = Signal(str)
    finished = Signal()

    def __init__(self):
        super().__init__()
        self._read_result = None
        self.reader = nfc.ContactlessFrontend()
        self.reader.open('usb')

    @Slot(bool)
    def setReadResult(self, result: bool) -> None:
        self._read_result = result

    @Slot()
    def run(self):
        print("Starting NFC Worker")
        while True:
            try:
                tag = self.reader.connect(
                    rdwr={'on-connect': lambda tag: False})
            except OSError as e:
                print("FAILED TO FIND THE READER", e)
                time.sleep(5)
                # Couldn't find serial connection. Try again in a bit!
                self.reader.close()
                self.reader = nfc.ContactlessFrontend()
                self.reader.open('usb')

                continue
            try:
                uid = tag.identifier

                card_uid = ''
                for part in uid:
                    card_uid += "%02X" % part
                self.cardDetected.emit(card_uid)

            except AttributeError:  # can happen on a misread from pynfc
                self.reader.close()
                self.reader = nfc.ContactlessFrontend()
                self.reader.open('usb')

            finally:
                time.sleep(1)  # Only a single read per second
Beispiel #26
0
class RandomTimer(QObject):
    timeout = Signal()
    intervalChanged = Signal()
    activeChanged = Signal()

    def __init__(self, parent=None):
        super(RandomTimer, self).__init__()

        self.timer = QTimer()
        self.timer.timeout.connect(self.timeout)

    @Slot()
    def start(self):
        print("timer start")
        if not self.timer.isActive():
            self.timer.start()
            self.activeChanged.emit()

    @Slot()
    def stop(self):
        print("timer stop")
        if self.timer.isActive():
            self.timer.stop()
            self.activeChanged.emit()

    @Slot(int, int, result=int)
    def randomInterval(self, min, max):
        range = max - min
        msec = min + random.randint(0, range)
        return msec

    @pyqtProperty(int, notify=intervalChanged)
    def interval(self):
        return self.timer.interval()

    @interval.setter
    def interval(self, msec):
        if self.timer.interval() != msec:
            self.timer.setInterval(msec)
            self.intervalChanged.emit()
            print("interval = {}".format(self.timer.interval()))

    @pyqtProperty(bool, notify=activeChanged)
    def active(self):
        return self.timer.isActive()
Beispiel #27
0
class Rectangle(QGraphicsRectItem):
    window = 0
    chromosome = []
    fitness = 0
    itemDoubleClicked = Signal(object)

    def mouseDoubleClickEvent(self, event):
        self.window.chosenChromosome.setText(str(self.chromosome))
        self.window.chosenFitness.setText(str(self.fitness))
Beispiel #28
0
class QVTKWidgetKeyEvents(QVTKWidget):
    def __init__(self, parent=None):
        super(QVTKWidgetKeyEvents, self).__init__(parent)

    keyEventRequested = Signal(int)

    def keyPressEvent(self, ev):
        super(QVTKWidgetKeyEvents, self).keyPressEvent(ev)
        self.keyEventRequested.emit(ev.key())
Beispiel #29
0
 def __new__(mcs, name, bases, attrs):
     for key in list(attrs.keys()):
         attr = attrs[key]
         if not isinstance(attr, HecProperty):
             continue
         value = attr.value
         notifier = Signal(type(value))
         attrs[key] = HecProperty(value, key, type(value), notify=notifier)
         attrs['_%s_prop_signal_' % key] = notifier
     return super().__new__(mcs, name, bases, attrs)
class GPSWidget(QWidget):
    """ Provides methods to connect to the GPS module"""
    noGpsdevice = Signal()
    noPositionLock = Signal()
    startRecord = Signal(dict, str)

    def __init__(self, parent=None):
        super(GPSWidget, self).__init__(parent)
        self.map = Mapview()
        self.mapSettings = mapSettings = MapSettings()
        self.currentPosition = (None, None)

        splitter = QSplitter(Qt.Horizontal)
        splitter.addWidget(self.map)
        splitter.addWidget(mapSettings)
        splitter.setStretchFactor(0, 3)
        splitter.setStretchFactor(1, 1)

        layout = QHBoxLayout()
        layout.addWidget(splitter)

        self.setLayout(layout)
        mapSettings.locationRequested.connect(self.getLocation)
        mapSettings.recordRequested.connect(self.record)

    def getLocation(self):
        try:
            gps = GPSObject()
            position = gps.Position()
            if (position[0] is None):
                print('Location Not Found!')
                self.noPositionLock.emit()
                self.mapSettings.locationNotFound()
            else:
                self.mapSettings.locationFound()
                self.currentPosition = position
                self.map.addMarker(position)
                self.mapSettings.display.updatePosition(position)
                return position
        except Exception, e:
            self.mapSettings.locationNotFound()
            self.noGpsdevice.emit()