def VerifyCheckingPossiblities(self, signal): ##First detect problematic unchecking, and adjust comboboxes accordingly if QtCore.QObject().sender().objectName() == "Display_Measures_Button": if Main.Display_Measures_Button.checkState() == 0: Main.Remove_Leak_Button.setCheckState(0) Main.Measure_From_Baseline1_Button.setCheckState(0) Main.Measure_From_Zero_Button.setCheckState(0) Main.Display_Charge_Button.setCheckState(0) return True elif QtCore.QObject().sender().objectName( ) == "Measure_From_Zero_Button": if Main.Measure_From_Zero_Button.checkState() == 2: if Main.Measure_From_Baseline1_Button.checkState() == 2: Main.Measure_From_Baseline1_Button.setCheckState(0) Main.Remove_Leak_Button.setCheckState(2) return True elif QtCore.QObject().sender().objectName() == "Remove_Leak_Button": if Main.Remove_Leak_Button.checkState() == 0: Main.Measure_From_Zero_Button.setCheckState(0) return True ##Second, adjust checking combination to prevent bugs if Main.Measure_From_Baseline1_Button.checkState() == 2: if Main.Measure_From_Zero_Button.checkState() == 2: Main.Measure_From_Zero_Button.setCheckState(0) return True if Main.Display_Measures_Button.checkState() == 0: Main.Display_Measures_Button.setCheckState(2) return True if Main.Measure_From_Zero_Button.checkState() == 2: if Main.Remove_Leak_Button.checkState() == 0: Main.Remove_Leak_Button.setCheckState(2) return True if Main.Display_Measures_Button.checkState() == 0: Main.Display_Measures_Button.setCheckState(2) return True if Main.Measure_From_Baseline1_Button.checkState() == 2: Main.Measure_From_Baseline1_Button.setCheckState(0) if Main.Remove_Leak_Button.checkState( ) == 2: #display a dotted line at 0 if Main.Display_Measures_Button.checkState() == 0: Main.Display_Measures_Button.setCheckState(2) return True if Main.Display_Charge_Button.checkState() == 2: if Main.Display_Measures_Button.checkState() == 0: Main.Display_Measures_Button.setCheckState(2) return True return False
def __init__(self, argv, locale=None, gui=True): cfgactions.install() i18n.install(locale) qtcompat.install() qtutils.install() icons.install() self.notifier = QtCore.QObject() self.notifier.connect(self.notifier, SIGNAL('update_files()'), self._update_files, Qt.QueuedConnection) # Call _update_files when inotify detects changes inotify.observer(self._update_files_notifier) if gui: self._app = current(tuple(argv)) self._app.setWindowIcon(icons.cola()) self._app.setStyleSheet(""" QMainWindow::separator { width: 3px; height: 3px; } QMainWindow::separator:hover { background: white; } """) else: self._app = QtCore.QCoreApplication(argv)
def mousePressEvent(self, event): if event.button() & QtCore.Qt.RightButton: if event.modifiers() == (QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier): if len(self.selected_lane_edges) == 0: point = self.mapToScene(event.pos()) object = QtCore.QObject() object.road_item = Point(point.x(), point.y()) object.is_a_line = False self.add_item_to_scraping(object) else: graphics_item = None for item in self.filter_out_lower_items(self.items(event.x(), event.y(), 5, 5)): graphics_item = item break if graphics_item: if len(self.selected_lane_edges): if graphics_item.zValue() > 0: if event.modifiers() != QtCore.Qt.ShiftModifier: while len(self.selected_lane_edges): selected_lane_edge = self.selected_lane_edges.pop() selected_lane_edge.clear(selected_lane_edge.lane_edge) for selected_lane_edge in self.selected_lane_edges: if selected_lane_edge.lane_edge == graphics_item.lane_edge: break else: self.selected_lane_edges.append(Selected_lane_edge(graphics_item)) elif graphics_item.zValue() == 0: self.add_item_to_scraping(graphics_item) else: self.selected_lane_edges.append(Selected_lane_edge(graphics_item)) super(Graphics_view, self).mousePressEvent(event)
def __init__(self): self._rsock, self._wsock = socket.socketpair() self._queue = Queue.Queue() self._qt_object = QtCore.QObject() self._notifier = QtCore.QSocketNotifier(self._rsock.fileno(), QtCore.QSocketNotifier.Read) self._notifier.activated.connect(self._recv)
def __init__(self, argv, locale=None, gui=True, git_path=None): cfgactions.install() i18n.install(locale) qtcompat.install() qtutils.install() self.notifier = QtCore.QObject() self.notifier.connect(self.notifier, SIGNAL('update_files'), self._update_files) # Call _update_files when inotify detects changes inotify.observer(self._update_files_notifier) # Add the default style dir so that we find our icons icon_dir = resources.icon_dir() qtcompat.add_search_path(os.path.basename(icon_dir), icon_dir) if gui: self._app = current(tuple(argv), git_path) self._app.setWindowIcon(qtutils.git_icon()) self._app.setStyleSheet(""" QMainWindow::separator { width: 3px; height: 3px; } QMainWindow::separator:hover { background: white; } """) else: self._app = QtCore.QCoreApplication(argv)
def createData(self, scene): main = scene.views()[0] self.data = QtGui.QFileDialog.getOpenFileName( main, QtCore.QObject().tr("Open Video File"), QtCore.QDir.homePath()) if self.data: self.data = str(self.data)
def __init__(self, parent, *args, **kwargs): QtCore.QRunnable.__init__(self) self.channel = QtCore.QObject(parent) self.result = None self.setAutoDelete(False)
def __init__(self): super(Window, self).__init__() # Layout textBox = QtGui.QTextBrowser() self.button = QtGui.QPushButton() vertLayout = QtGui.QVBoxLayout() vertLayout.addWidget(textBox) vertLayout.addWidget(self.button) self.setLayout(vertLayout) # Connect button self.button.clicked.connect(self.buttonPressed) # Thread self.bee = Worker(self.someProcess, ()) self.bee.finished.connect(self.restoreUi) self.bee.terminated.connect(self.restoreUi) # Console handler dummyEmitter = QtCore.QObject() self.connect(dummyEmitter, QtCore.SIGNAL("logMsg(QString)"), textBox.append) consoleHandler = ConsoleWindowLogHandler(dummyEmitter) logger.addHandler(consoleHandler)
def __init__(self, parent, x, y, w, h, item): self.cmptEmitter = QtCore.QObject() iParent = item ''' self._rect = QtCore.QRectF(x,y,w,h) self._scene = parent print "self comptItem",self._scene.sceneContainer ," and",self._scene.sceneContainer.graphicsView self.mouseOver = False self.resizeHandleSize = 4.0 self.mousePressPos = None self.mouseMovePos = None self.mouseIsPressed = False #self.setAcceptsHoverEvents(True) self.updateResizeHandles() ''' if hasattr(iParent, "__iter__"): self.mobj = iParent[0] else: self.mobj = iParent self.layoutWidgetPt = parent QtGui.QGraphicsRectItem.__init__(self, x, y, w, h) self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True) self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable) #self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1) if config.QT_MINOR_VERSION >= 6: self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1)
def __init__(self): self.tasks = set() self.threadpool = QtCore.QThreadPool.globalInstance() self.notifier = QtCore.QObject() self.notifier.connect(self.notifier, SIGNAL('task_done(PyQt_PyObject)'), self.task_done, Qt.QueuedConnection)
def __init__(self, pos, size, type_, parent=None, scene=None, areaBorder=2, index=0, textSize=50): QtGui.QGraphicsRectItem.__init__(self, 0, 0, size.width(), size.height(), parent, scene) self.setPos(pos) #self.setAcceptedMouseButtons(QtCore.Qt.NoButton) self.setFlags(QtGui.QGraphicsItem.ItemIsMovable | QtGui.QGraphicsItem.ItemIsFocusable | QtGui.QGraphicsItem.ItemIsSelectable) ## set index label self.text = QtGui.QGraphicsTextItem("%d" % index, self) self.setTextSize(textSize) ## TODO: How to create constants for the type? ## (such as constants in Qt) (enum?) self.type = type_ pen = QtGui.QPen(self.color, areaBorder, QtCore.Qt.SolidLine, QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin) self.setPen(pen) self.setAcceptsHoverEvents(True) # self.text.setFlag(QtGui.QGraphicsItem.ItemIgnoresTransformations) # needed for the emission of a signal self.newEvent = QtCore.QObject() self.newEvent.area = self
def __init__(self, libMgr): self.libMgr = libMgr self.fileList = [] self.fileDirs = None self.regexs = self.initRegexs() self.ignoreFileChanged = { } #key/value is explained in ignoreFileChanged #Setup the file watcher related stuff self.rTimer = QtCore.QObject() self.rTimerSignal = QtCore.pyqtSignal() self.fWatcher = QtCore.QFileSystemWatcher() QtCore.QObject.connect(self.fWatcher, QtCore.SIGNAL("fileChanged(const QString&)"), self.__fileChanged) QtCore.QObject.connect(self.rTimer, QtCore.SIGNAL("reloadFile(const QString&)"), self.__reloadFile) QtCore.QObject.connect(self.rTimer, QtCore.SIGNAL("skipReloadFile(const QString&)"), self.__skipReloadFile) QtCore.QObject.connect( self.fWatcher, QtCore.SIGNAL("directoryChanged(const QString&)"), self.__directoryChanged)
def __init__(self, bucketName, key, parent=None): self.emitter = QtCore.QObject() QtCore.QRunnable.__init__(self) self.bucketName = bucketName self.key = key self.filePath = None self.mutex = QtCore.QMutex()
def __init__(self, notifier, parent): QtGui.QWidget.__init__(self, parent) author_font = QtGui.QFont(self.font()) author_font.setPointSize(int(author_font.pointSize() * 1.1)) summary_font = QtGui.QFont(author_font) summary_font.setWeight(QtGui.QFont.Bold) policy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum) self.gravatar_label = gravatar.GravatarLabel() self.author_label = TextLabel() self.author_label.setTextFormat(Qt.RichText) self.author_label.setFont(author_font) self.author_label.setSizePolicy(policy) self.author_label.setAlignment(Qt.AlignBottom) self.author_label.elide() self.summary_label = TextLabel() self.summary_label.setTextFormat(Qt.PlainText) self.summary_label.setFont(summary_font) self.summary_label.setSizePolicy(policy) self.summary_label.setAlignment(Qt.AlignTop) self.summary_label.elide() self.sha1_label = TextLabel() self.sha1_label.setTextFormat(Qt.PlainText) self.sha1_label.setSizePolicy(policy) self.sha1_label.setAlignment(Qt.AlignTop) self.sha1_label.elide() self.diff = DiffTextEdit(self, whitespace=False) self.tasks = set() self.reflector = QtCore.QObject(self) self.info_layout = qtutils.vbox(defs.no_margin, defs.no_spacing, self.author_label, self.summary_label, self.sha1_label) self.logo_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.gravatar_label, self.info_layout) self.logo_layout.setContentsMargins(defs.margin, 0, defs.margin, 0) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.logo_layout, self.diff) self.setLayout(self.main_layout) notifier.add_observer(COMMITS_SELECTED, self.commits_selected) notifier.add_observer(FILES_SELECTED, self.files_selected) self.connect(self.reflector, SIGNAL('diff(PyQt_PyObject)'), self.diff.setText, Qt.QueuedConnection) self.connect(self.reflector, SIGNAL('task_done(PyQt_PyObject)'), self.task_done, Qt.QueuedConnection)
def __init__(self, parent, x, y, w, h, item): self.grpEmitter = QtCore.QObject() QtGui.QGraphicsRectItem.__init__(self, x, y, w, h, parent) self.mobj = item self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True) self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable) QT_VERSION = str(QtCore.QT_VERSION_STR).split('.') QT_MINOR_VERSION = int(QT_VERSION[1]) if config.QT_MINOR_VERSION >= 6: self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1)
def __init__(self, game_dir=None, uses_qt=False): self.craft_files = [] self.craft_parts = set() self.parts = dict() self.temp_files = set() self.uses_qt = uses_qt if self.uses_qt: from PyQt4 import QtCore self.emitter = QtCore.QObject() self.sign = None self.set_game_dir(game_dir or 'C:\\Kerbal Space Program')
def __init__(self): # Create a socket pair for signalling between the two threads self._rsock, self._wsock = createSocketPair() # A queue to store messages self._queue = Queue.Queue() # A QtObject to trigger Qt signals self._qt_object = QtCore.QObject() # A notifier which will call self._recv() when there is data on the socket self._notifier = QtCore.QSocketNotifier(self._rsock.fileno(), QtCore.QSocketNotifier.Read) self._notifier.activated.connect(self._recv)
def test_add_action_different_context(self): """ ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and both have the QtCore.Qt.WidgetShortcut shortcut context set. """ # GIVEN: Two actions with the same shortcuts. parent = QtCore.QObject() action3 = QtGui.QAction(parent) action3.setObjectName('action3') action3.setShortcutContext(QtCore.Qt.WidgetShortcut) second_parent = QtCore.QObject() action_with_same_shortcuts3 = QtGui.QAction(second_parent) action_with_same_shortcuts3.setObjectName( 'action_with_same_shortcuts3') action_with_same_shortcuts3.setShortcutContext( QtCore.Qt.WidgetShortcut) # Add default shortcuts to Settings class. default_shortcuts = { 'shortcuts/action3': [QtGui.QKeySequence('e'), QtGui.QKeySequence('f')], 'shortcuts/action_with_same_shortcuts3': [QtGui.QKeySequence('e'), QtGui.QKeySequence('f')] } Settings.extend_default_settings(default_shortcuts) # WHEN: Add the two actions to the action list. self.action_list.add_action(action3, 'example_category2') self.action_list.add_action(action_with_same_shortcuts3, 'example_category2') # Remove the actions again. self.action_list.remove_action(action3, 'example_category2') self.action_list.remove_action(action_with_same_shortcuts3, 'example_category2') # THEN: Both action should keep their shortcuts. assert len(action3.shortcuts() ) == 2, 'The action should have two shortcut assigned.' assert len(action_with_same_shortcuts3.shortcuts() ) == 2, 'The action should have two shortcuts assigned.'
def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) self.retranslateUi(self) self.SearchInfo_Done = QtCore.QObject() self.GetOpenloadVideoDownloadInfo_Done = QtCore.QObject() QtCore.QObject.connect(self.SearchInfo_Done, QtCore.SIGNAL("SearchInfo_Done"), self.SearchInfo_Done_Action) QtCore.QObject.connect( self.GetOpenloadVideoDownloadInfo_Done, QtCore.SIGNAL("GetOpenloadVideoDownloadInfo_Done"), self.GetOpenloadVideoDownloadInfo_Action) self.pushButton_3.setEnabled(False) self.pushButton_2.setEnabled(False) self.pushButton_2.clicked.connect(self.ButtonToRenameFile) self.pushButton_3.clicked.connect(self.ButtonToDownload) self.pushButton.clicked.connect(self.ButtonToSearch) self.setAcceptDrops(True) self.connect(self, QtCore.SIGNAL('triggered()'), self.closeEvent)
def __init__(self, verbose=False, padre=QtCore.QObject()): self.estado = "creado" self.verbose = verbose self.nodos_conocidos = lista_nodos([], padre) self.procesadores = lista_procesadores([], padre) self.procesos_creados = lista_procesos() self.procesos_cola = lista_procesos() self.procesos_limbo = lista_procesos() self.ident = 0 #Se pone temporalmente a este valor, a menos que otro nodo le ordene lo contrario self.protocolo = zkomm_protocol_2.protocolo() self.retardo = 0.5 #retardo de espera entre cada revision de las conexiones self.acciones = dict()
def test_add_action_different_parent(self): """ ActionList test - Tests the add_action method. The actions have the different parent, the same shortcuts and both have the QtCore.Qt.WindowShortcut shortcut context set. """ # GIVEN: Two actions with the same shortcuts. parent = QtCore.QObject() action2 = QtGui.QAction(parent) action2.setObjectName('action2') second_parent = QtCore.QObject() action_with_same_shortcuts2 = QtGui.QAction(second_parent) action_with_same_shortcuts2.setObjectName( 'action_with_same_shortcuts2') # Add default shortcuts to Settings class. default_shortcuts = { 'shortcuts/action2': [QtGui.QKeySequence('c'), QtGui.QKeySequence('d')], 'shortcuts/action_with_same_shortcuts2': [QtGui.QKeySequence('d'), QtGui.QKeySequence('c')] } Settings.extend_default_settings(default_shortcuts) # WHEN: Add the two actions to the action list. self.action_list.add_action(action2, 'example_category') self.action_list.add_action(action_with_same_shortcuts2, 'example_category') # Remove the actions again. self.action_list.remove_action(action2, 'example_category') self.action_list.remove_action(action_with_same_shortcuts2, 'example_category') # THEN: As both actions have the same shortcuts, they should be removed from one action. assert len(action2.shortcuts() ) == 2, 'The action should have two shortcut assigned.' assert len(action_with_same_shortcuts2.shortcuts() ) == 0, 'The action should not have a shortcut assigned.'
def __init__(self, path): super(BinMapper, self).__init__() f = open(path) self.name = os.path.basename(path) self.data = f.read() self.size = len(self.data) self.depth = 1 self.stride = 1 self.bigendian = 1 self.maxDim = 600 self.setAcceptHoverEvents(True) self.rebuildImage() # Create a wrapped object for emitting events self.qobject = QtCore.QObject()
def __init__(self, func, *args, **kwargs): QtCore.QRunnable.__init__(self) self.notifier = QtCore.QObject() self.func = func self.args = args self.kwargs = kwargs self.pid = 'Waiting: {}'.format(func) logging.debug('RunMethod initialized', self.func, self.args, self.kwargs) self.runnables.append(self) self.error = False self.running = False self.done = False self.abort = self._abort
def __init__(self, bucketName, filePath, prefix, parent=None): self.emitter = QtCore.QObject() QtCore.QRunnable.__init__(self) self.parent = parent self.filePath = filePath self.bucketName = bucketName self.prefix = prefix self.mutex = QtCore.QMutex() self.total = 0 self.received = 0 self.useMultipartUpload = False #是否使用分片上传 self.multipart = None #分片上传结果 self.source_size = os.stat(self.filePath).st_size
def __init__(self, bucketName, prefix=None, marker=None, limit=None, delimiter=None, parent=None): self.emitter = QtCore.QObject() QtCore.QRunnable.__init__(self) self.bucketName = bucketName self.prefix = prefix self.marker = marker self.limit = limit self.delimiter = delimiter self.parent = parent self.mutex = QtCore.QMutex()
def __init__(self, parent=None): '''write is a function that printf the data of serial.''' super(SerialDev, self).__init__(parent) self.setting = { 'port': 'COM1', 'baudrate': 115200, 'bytesize': 8, 'stopbits': 1, 'parity': 'N', 'timeout': 300 } self.__serial = None self.__isOpen = False self.__isRun = False self.__com = [] self.__checkPort() self.___even_data = '' self.qObj = QtCore.QObject()
def __init__(self, parent, x, y, w, h, item): print " parent ", parent, "item ", item self.cmptEmitter = QtCore.QObject() iParent = item if hasattr(iParent, "__iter__"): self.mobj = iParent[0] else: self.mobj = iParent print " comptItem ", self.mobj, " parent ", self.layoutWidgetPt = parent QtGui.QGraphicsRectItem.__init__(self, x, y, w, h) self.setFlag(QtGui.QGraphicsItem.ItemIsMovable, True) self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable) #self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1) QT_VERSION = str(QtCore.QT_VERSION_STR).split('.') QT_MINOR_VERSION = int(QT_VERSION[1]) if config.QT_MINOR_VERSION >= 6: self.setFlag(QtGui.QGraphicsItem.ItemSendsGeometryChanges, 1)
def __init__(self, bucketName, filePath, prefix, parent=None): self.emitter = QtCore.QObject() QtCore.QRunnable.__init__(self) self.parent = parent self.filePath = filePath self.bucketName = bucketName self.prefix = prefix self.mutex = QtCore.QMutex() self.total = 0 self.received = 0 self.multipart = None #分片上传结果 self.source_size = os.stat(self.filePath).st_size '''操作列表,用于显示操作详情 {u'response':scsResponse, u'operation_name':u'合并分片', u'result':u'完成'} ''' self.operationList = []
def Execute_Script(self): clicked_widget = "self." + str( QtCore.QObject().sender().parent().accessibleName() + "_Window") #try: self.Save_Script( clicked_widget, name='temp' ) #so when excuting, the Original File is not overwritten for plugin in self.Plugin_List: try: reload(eval('sys.modules[__name__].' + plugin)) setattr(__builtin__, plugin, eval('sys.modules[__name__].' + plugin)) except: #BUG When a immediately excutable script is created, saved, and you start a separate new script, reload doesn't work (until next restart) pass execfile(str(Main.userpath) + '/.SynaptiQs/__temp.py')
def __init__(self, bucketName, key, fileMD5, destFilePath, tmpFilePath, parent=None): self.emitter = QtCore.QObject() QtCore.QRunnable.__init__(self) self.bucketName = bucketName self.key = key self.fileMD5 = fileMD5 self.destFilePath = destFilePath #下载完成后重命名至该文件路径 self.tmpFilePath = tmpFilePath #用于断点续传的临时文件路径 self.parent = parent self.received = 0 #已下载byte数量 self.total = 0 #文件总大小 self.isAbort = False self.mutex = QtCore.QMutex()