Force usage of QtConsole under Windows
342234
def launch_ipython(argv=None):
    
    from .linux import launch_ipython as _launch_ipython_linux
    os.environ = {str(k): str(v) for k,v in os.environ.items()}
    try:
        from qtconsole.qtconsoleapp import JupyterQtConsoleApp
    except ImportError:
        sys.exit("ERROR: IPython QtConsole not installed in this environment. "
                 "Try with `conda install jupyter ipython qtconsole`")
    else:
        _launch_ipython_linux(ipython_app=JupyterQtConsoleApp)
975956
def accept(self):
        """"""
        if not self.runconfigoptions.is_valid():
            return
        configurations = _get_run_configurations()
        configurations.insert(0, (self.filename, self.runconfigoptions.get()))
        _set_run_configurations(configurations)
        QDialog.accept(self)
1318722
def require_qt(func):
    
    @wraps(func)
    def wrapped(*args, **kwargs):
        if not QApplication.instance():  # pragma: no cover
            raise RuntimeError("A Qt application must be created.")
        return func(*args, **kwargs)
    return wrapped
527050
def reset_window_layout(self):
        """"""
        answer = QMessageBox.warning(self, _("Warning"),
                     _("Window layout will be reset to default settings: "
                       "this affects window position, size and dockwidgets.\n"
                       "Do you want to continue?"),
                     QMessageBox.Yes | QMessageBox.No)
        if answer == QMessageBox.Yes:
            self.setup_layout(default=True)
1321675
def refresh_fqdn_cache(force=False):
    '''
    

    '''
    if not isinstance(force, bool):
        raise CommandExecutionError("Force option must be boolean.")

    if force:
        query = {'type': 'op',
                 'cmd': '<request><system><fqdn><refresh><force>yes</force></refresh></fqdn></system></request>'}
    else:
        query = {'type': 'op', 'cmd': '<request><system><fqdn><refresh></refresh></fqdn></system></request>'}

    return __proxy__['panos.call'](query)
268808
def reset(self, force=False):
        
        answer = QtGui.QMessageBox.Yes
        opts = QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
        
        if not force:
            answer = QtGui.QMessageBox.question(self,
                                                'Reset Layout',
                                                'Are you sure you want to reset?',
                                                opts)
        
        if answer == QtGui.QMessageBox.No:
            return
        
        widget = self.widget()
        
        # we should always have a widget, but double check
        if not widget:
            return False
        
        # make sure we can close the current view
        if not widget.close():
            return False
        
        # reset the system
        self.takeWidget()
        
        # restore a default profile
        prof = self.defaultProfile()
        if prof:
            return prof.restore(self)
        
        # otherwise create a new panel
        else:
            self.setLocked(False)
            self.setWidget(XViewPanel(self, False))

        self.resetFinished.emit()
        return True
202215
def get_QApplication(args=[]):
    """"""
    global _qapp
    if _qapp is None:
        QCoreApplication.setAttribute(Qt.AA_X11InitThreads)
        _qapp = QApplication(args)

    return _qapp
351537
def setActiveWindow(self, win):
        
        self._setProperty('_NET_ACTIVE_WINDOW', [1, X.CurrentTime, win.id],
                          win)
1125288
function tryWindowsKey (key, device, mac) {
  // Skip the Properties key to avoid problems with permissions
  if (key.indexOf('Properties') > -1) {
    return false
  }

  const networkAdapterKeyPath = new Winreg({
    hive: Winreg.HKLM,
    key: key
  })

  // we need to format the MAC a bit for Windows
  mac = mac.replace(/:/g, '')

  networkAdapterKeyPath.values((err, values) => {
    let gotAdapter = false
    if (err) {
      console.log('ERROR: ' + err)
    } else {
      for (let x = 0; x < values.length; x++) {
        if (values[x].name === 'AdapterModel') {
          gotAdapter = true
          break
        }
      }

      if (gotAdapter) {
        networkAdapterKeyPath.set('NetworkAddress', 'REG_SZ', mac, () => {
          try {
            cp.execSync('netsh interface set interface "' + device + '" disable')
            cp.execSync('netsh interface set interface "' + device + '" enable')
          } catch (err) {
            throw new Error('Unable to restart device, is the cmd running as admin?')
          }
        })
      }
    }
  })
}
963256
def on_use_runtime_value_toggled(self, widget, path):
        
        try:
            data_port_id = self.list_store[path][self.ID_STORAGE_ID]
            self.toggle_runtime_value_usage(data_port_id)
        except TypeError as e:
            logger.exception("Error while trying to change the use_runtime_value flag")
1093513
def eventFilter(self, widget, event):
        """"""
        if ((event.type() == QEvent.MouseButtonPress and
                 not self.geometry().contains(event.globalPos())) or
                (event.type() == QEvent.KeyPress and
                 event.key() == Qt.Key_Escape)):
            # Exits editing
            self.hide()
            self.setFocus(False)
            return True

        # Event is not interessant, raise to parent
        return QLineEdit.eventFilter(self, widget, event)
1240376
def _in_qtconsole() -> bool:
    
    try:
        from IPython import get_ipython
        try:
            from ipykernel.zmqshell import ZMQInteractiveShell
            shell_object = ZMQInteractiveShell
        except ImportError:
            from IPython.kernel.zmq import zmqshell
            shell_object = zmqshell.ZMQInteractiveShell
        return isinstance(get_ipython(), shell_object)
    except Exception:
        return False
470138
def accept(self):
        """"""
        configurations = []
        for index in range(self.stack.count()):
            filename = to_text_string(self.combo.itemText(index))
            runconfigoptions = self.stack.widget(index)
            if index == self.stack.currentIndex() and\
               not runconfigoptions.is_valid():
                return
            options = runconfigoptions.get()
            configurations.append( (filename, options) )
        _set_run_configurations(configurations)
        QDialog.accept(self)
758939
def accept(self):
        """"""
        for index in range(self.stack.count()):
            self.stack.widget(index).accept_changes()
        QDialog.accept(self)
363803
def _pyqt5():
    """"""

    import PyQt5 as module
    _setup(module, ["uic"])

    try:
        import sip
        Qt.QtCompat.wrapInstance = (
            lambda ptr, base=None: _wrapinstance(
                sip.wrapinstance, ptr, base)
        )
        Qt.QtCompat.getCppPointer = lambda object: \
            sip.unwrapinstance(object)

    except ImportError:
        pass  # Optional

    if hasattr(Qt, "_uic"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR
        Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR
        Qt.QtCompat.qInstallMessageHandler = _qInstallMessageHandler
        Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("PyQt5")
    _build_compatibility_members('PyQt5')
104511
private void setOfflinePresences() {
        Presence packetUnavailable;
        outerloop: for (Jid user : presenceMap.keySet()) {
            Map<Resourcepart, Presence> resources = presenceMap.get(user);
            if (resources != null) {
                for (Resourcepart resource : resources.keySet()) {
                    packetUnavailable = new Presence(Presence.Type.unavailable);
                    EntityBareJid bareUserJid = user.asEntityBareJidIfPossible();
                    if (bareUserJid == null) {
                        LOGGER.warning("Can not transform user JID to bare JID: '" + user + "'");
                        continue;
                    }
                    packetUnavailable.setFrom(JidCreate.fullFrom(bareUserJid, resource));
                    try {
                        presencePacketListener.processStanza(packetUnavailable);
                    }
                    catch (NotConnectedException e) {
                        throw new IllegalStateException(
                                        "presencePacketListener should never throw a NotConnectedException when processStanza is called with a presence of type unavailable",
                                        e);
                    }
                    catch (InterruptedException e) {
                        break outerloop;
                    }
                }
            }
        }
    }
1083901
def mousePressEvent(self, event):
        """"""
        # Raise the main application window on click
        self.parent.raise_()
        self.raise_()

        if event.button() == Qt.RightButton:
            pass