Ejemplo n.º 1
0
def translate(*args):
    """
    Module function to handle different PyQt 4/5 QCoreApplication.translate
    parameter.
    
    @param args tuple of arguments from QCoreApplication.translate (tuple)
    @return translated string (string)
    """
    if QT_VERSION_STR.startswith('4.'):
        args = list(args)
        args.insert(3, QCoreApplication.CodecForTr)
    return QCoreApplication.translate(*args)
Ejemplo n.º 2
0
def get_scalefactor(widget: QWidget) -> float:
    version = QT_VERSION_STR.split(".")
    screen: QScreen
    if int(version[0]) >= 5 and int(version[1]) >= 10:
        screen = QGuiApplication.screenAt(widget.mapToGlobal(QPoint(0, 0)))
    else:
        screen_nbr = QApplication.desktop().screenNumber(
            widget.mapToGlobal(QPoint(0, 0))
        )
        screens = QGuiApplication.screens()
        screen = screens[screen_nbr]

    factor = screen.logicalDotsPerInchY() / 96.0

    return factor
Ejemplo n.º 3
0
    def __init__(self, parent):
        super().__init__()
        self.parent = parent
        self.width = self.geometry().width()
        self.height = self.geometry().height()
        self.svg_data = None
        self.map_height = 2000
        self.map_width = 3000

        self.mouse_pos = QPoint(0, 0)
        self.relative_mspos = [0, 0]
        self.selected_robot = None
        self.mouse_pos_init = QPoint(0, 0)
        self.relative_init_mspos = [0, 0]

        self.clicking = False
        self.keys = [0, 0, 0, 0, 0]

        self.color_dict = {}
        self.robot_number = 0
        self.old_pos_dict = {}
        self.old_selected = None
        self.last_repaint = 0

        version = QT_VERSION_STR.split(".")
        self.qt_is_compatible = float(version[0]) >= 5 and float(
            version[1]) >= 15
        self.svg_scl = False

        self.parent.backend.widget.MapTrigger.connect(self.should_repaint)

        self.setMouseTracking(True)
        self.key_binding = {}

        self.selected_robot_signal.connect(self.select_robot)

        self.setFocusPolicy(Qt.StrongFocus)

        self.show()
Ejemplo n.º 4
0
            return "DIRECT";
        }}
    """.format('true' if (has_secret or from_file) else 'false')
    res = pac.PACResolver(test_str)
    res.resolve(QNetworkProxyQuery(QUrl(url)), from_file=from_file)


# See https://github.com/qutebrowser/qutebrowser/pull/1891#issuecomment-259222615

try:
    from PyQt5 import QtWebEngineWidgets
except ImportError:
    QtWebEngineWidgets = None


@pytest.mark.skipif(QT_VERSION_STR.startswith('5.7')
                    and QtWebEngineWidgets is not None
                    and sys.platform == "linux",
                    reason="Segfaults when run with QtWebEngine tests on Linux"
                    )
def test_fetch():
    test_str = """
        function FindProxyForURL(domain, host) {
            return "DIRECT; PROXY 127.0.0.1:8080; SOCKS 192.168.1.1:4444";
        }
    """

    class PACHandler(http.server.BaseHTTPRequestHandler):
        def do_GET(self):
            self.send_response(200)
Ejemplo n.º 5
0
try:
    from PyQt5.QtCore import Qt
    from PyQt5.QtWidgets import QDialog, QVBoxLayout, QGridLayout, \
        QLabel, QComboBox, QHBoxLayout, QRadioButton, \
        QPushButton, QApplication, QColorDialog, QMainWindow, \
        QWidget, QTreeWidgetItem, QButtonGroup, QTreeWidget, \
        QSplitter,  QTabWidget, QMenuBar, QMessageBox, QSpacerItem,  \
        QLineEdit, QHeaderView, QSpinBox, QTextBrowser,  \
        QMenu, QAction, QTabBar, QStackedWidget,  QFileDialog,  \
        QScrollArea, QProgressBar, QStyleOptionSlider, QGroupBox,  \
        QAbstractItemView, QSizePolicy, QFrame, QStyle, QScrollBar, QToolBar, \
        QDialogButtonBox, QToolButton, QCheckBox, QLayout

    from PyQt5.QtGui import QFont, QIcon, QFontMetrics, QPen, QColor, QPainter, \
        QPixmap, QBrush, QPainterPath , QDesktopServices

    from PyQt5.QtCore import QObject, QTimer,  QProcess, QEvent, QSize, \
         QLine, QRect, QPoint, QRectF, QUrl, QUrlQuery, QCoreApplication, \
         pyqtSignal

    from PyQt5.QtPrintSupport import QPrinter, QPrintDialog
    from PyQt5.QtCore import QT_VERSION_STR

    getQApp = QCoreApplication.instance

    g_rc.qt_imported = True
    g_rc.qt_variant = 'PyQt5'
    g_rc.qt_version = list(map(int, QT_VERSION_STR.split(".")))
except:
    pass
Ejemplo n.º 6
0
import sys
from collections import namedtuple

from pkg_resources import get_distribution, resource_filename
from PyQt5.QtCore import (QT_VERSION_STR, QCoreApplication, QFile, QObject,
                          QSettings, Qt, pyqtSignal)

if sys.platform == 'win':
    DEFAULT_FONT = 'MS Shell Dlg 2'
elif sys.platform == 'darwin':
    DEFAULT_FONT = 'Helvetica Neue'
else:
    DEFAULT_FONT = 'Sans'

# @Future: when Qt 5.6 becomes standard, remove this:
QT_VER = QT_VERSION_STR.split('.')
if QT_VER[0] == '5' and int(QT_VER[1]) < 6:
    QT55_COMPAT = True
else:
    QT55_COMPAT = False

# There must be a better way to do this, right?
Option = namedtuple('Option', ['name', 'type', 'default'])
OPTION_SPEC = (
    # Appearance
    ('dark_theme_default', bool, False),
    ('logger_table_font', str, DEFAULT_FONT),
    ('logger_table_font_size', int, 9),
    ('text_view_dialog_font', str, 'Courier New'),
    ('text_view_dialog_font_size', int, 12),
    ('logger_row_height', int, 20),
Ejemplo n.º 7
0
import sys
import threading

from flask import Flask, render_template

from PyQt5.QtCore import QUrl, QT_VERSION_STR
from PyQt5.QtWidgets import QApplication

QV = [int(x) for x in QT_VERSION_STR.split('.')]

if QV[0] == 5 and QV[1] >= 6:
    print("Using QtWebEngine")
    from PyQt5.QtWebEngineWidgets import QWebEngineView
else:
    print("Using QtWebKit")
    from PyQt5 import QtWebKitWidgets



class FlaskServerThread(threading.Thread):

    def run(self):
        print("Start Flask Server!")
        flask_app.run(host="0.0.0.0")

flask_app = Flask(__name__)
@flask_app.route("/")
def hello():
    return render_template("index.html")

if __name__ == "__main__":
Ejemplo n.º 8
0
import argparse
import liblo
import os
import shlex
import socket
import subprocess
import sys
from liblo import Server, Address
from PyQt5.QtCore import QT_VERSION_STR, QFile
from PyQt5.QtGui import QIcon, QPalette

# get qt version in list of ints
QT_VERSION = []
for strdigit in QT_VERSION_STR.split('.'):
    QT_VERSION.append(int(strdigit))

QT_VERSION = tuple(QT_VERSION)

if QT_VERSION < (5, 6):
    sys.stderr.write(
        "WARNING: You are using a version of QT older than 5.6.\n" +
        "You won't be warned if a process can't be launch.\n")

VERSION = "0.9.3"

APP_TITLE = 'RaySession'
DEFAULT_SESSION_ROOT = "%s/Ray Sessions" % os.getenv('HOME')
SCRIPTS_DIR = 'ray-scripts'
NOTES_PATH = 'ray-notes'
factory_session_templates = ('with_jack_patch', 'with_jack_config', 'scripted')
Ejemplo n.º 9
0
from webview.localization import localization
from webview import escape_string, _js_bridge_call
from webview.util import convert_string, parse_api_js
from webview import OPEN_DIALOG, FOLDER_DIALOG, SAVE_DIALOG
from webview.js.css import disable_text_select

logger = logging.getLogger(__name__)

# Try importing Qt5 modules
try:
    from PyQt5 import QtCore

    # Check to see if we're running Qt > 5.5
    from PyQt5.QtCore import QT_VERSION_STR
    _qt_version = [int(n) for n in QT_VERSION_STR.split('.')]

    if _qt_version >= [5, 5] and platform.system() != 'OpenBSD':
        from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView, QWebEnginePage as QWebPage
        from PyQt5.QtWebChannel import QWebChannel
    else:
        from PyQt5 import QtWebKitWidgets
        from PyQt5.QtWebKitWidgets import QWebView, QWebPage

    from PyQt5.QtWidgets import QWidget, QMainWindow, QVBoxLayout, QApplication, QFileDialog, QMessageBox, QAction
    from PyQt5.QtGui import QColor

    logger.debug('Using Qt5')
except ImportError as e:
    logger.debug('PyQt5 or one of dependencies is not found', exc_info=True)
    _import_error = True
Ejemplo n.º 10
0
        from PyQt5.QtGui import (QBrush, QColor, QContextMenuEvent, QCursor,
                                 QDoubleValidator, QFocusEvent, QFont,
                                 QKeyEvent, QKeySequence, QIcon, QImage,
                                 QImageWriter, QIntValidator, QLinearGradient,
                                 QMouseEvent, QMovie, QPainter, QPainterPath,
                                 QPalette, QPen, QPixmap, QPolygon,
                                 QRegExpValidator, QTextCursor, QValidator)
        from PyQt5.uic import loadUi

        QStringList = list
        getQApp = QCoreApplication.instance
        qApp = QCoreApplication.instance

        qt_imported = True
        qt_variant = "PyQt5"
        qt_version_no = list(map(int, QT_VERSION_STR.split(".")))
        _ver = PYQT_VERSION_STR.split(".")
        ver = _ver + ["0"] * (3 - len(_ver))
        pyqt_version_no = list(map(int, ver))[:3]
    except ImportError:
        pass

    try:
        from PyQt5.QtWebKit import QWebPage
    except ImportError:
        pass

#
# PyQt4
#
if (qt_variant == "PyQt4") or (qt_variant is None and not qt_imported):
Ejemplo n.º 11
0
        ready_event.set()
        httpd.handle_request()
        httpd.server_close()

    serve_thread = threading.Thread(target=serve, daemon=True)
    serve_thread.start()
    try:
        ready_event.wait()
        res = pac.PACFetcher(QUrl("pac+http://127.0.0.1:8081"))
        assert res.fetch_error() is None
    finally:
        serve_thread.join()
    return res


@pytest.mark.skipif(QT_VERSION_STR.startswith('5.7') and
                    QtWebEngineWidgets is not None and
                    sys.platform == "linux",
                    reason="Segfaults when run with QtWebEngine tests on Linux")
def test_fetch_success():
    test_str = """
        function FindProxyForURL(domain, host) {
            return "DIRECT; PROXY 127.0.0.1:8080; SOCKS 192.168.1.1:4444";
        }
    """

    res = fetcher_test(test_str)
    proxies = res.resolve(QNetworkProxyQuery(QUrl("https://example.com/test")))
    assert len(proxies) == 3

Ejemplo n.º 12
0
'''This file holds constant variables'''
from PyQt5.QtCore import QT_VERSION_STR
import CONFIG as config
import secret
import os

'''Time constants'''
MILLISEC = 1000

'''Qt Version'''
QT_VERSION = [int(x) for x in QT_VERSION_STR.split(".")]

'''StyleSheet constants'''
SS_FONT = f"color: white; font-family: {config.Font}; font: {config.ClockFontSize}px;"
SS_RED_FONT = f"color: red; font-family: {config.Font}; font: {config.ClockFontSize}px;"
SS_BBOX = ("border-top-left-radius : 20px; border-top-right-radius : 20px; border-bottom-left-radius : 20px;"
           "border-bottom-right-radius : 20px; background-color : rgba(0,0,0,100);")
SS_NO_BACKGROUND = "background-color : rgba(0,0,0,0);"

'''Subfolders to hold background images'''
RAW_IMG_FOLDER = os.path.join(os.getcwd(), "img")
FIXED_IMG_FOLDER = os.path.join(os.getcwd(), ".img")

'''Folder for weather icons'''
WEATHER_ICON_FOLDER = os.path.join(os.getcwd(), "weather_icons", "color")
INDOOR_ICON = os.path.join(os.getcwd(), ".icon", "home.png")

'''Weather Codes (ClimaCell)'''
WEATHER_CODES = {
    "0": "Unknown",
    "1000": "Clear",
Ejemplo n.º 13
0
NAME = "gitpyman"

with open("README.md", "r", encoding="utf-8") as fp:
    long_description = fp.read()

BASE_REQUIRES = [
    'docopt',
    'lxml==4.2.1',
    'sqlalchemy',
    'github3.py',
    'eventlet',
]
global REQUIRES
try:
    from PyQt5.QtCore import QT_VERSION_STR
    if tuple(map(int, QT_VERSION_STR.split("."))) > (5, 10, 1):
        REQUIRES = BASE_REQUIRES + [
            'pyqt5',
            'PyQtWebEngine',
        ]
    else:
        REQUIRES = BASE_REQUIRES

except:
    REQUIRES = BASE_REQUIRES + [
        'pyqt5==5.10.1',
    ]

setup(
    name=NAME,
    version=VERSION,
Ejemplo n.º 14
0
            QPalette,
            QPen,
            QPixmap,
            QPolygon,
            QRegExpValidator,
            QValidator
        )
        from PyQt5.uic import loadUi

        QStringList = list
        getQApp = QCoreApplication.instance
        qApp = QCoreApplication.instance  

        qt_imported = True
        qt_variant = "PyQt5"
        qt_version_no = list(map(int, QT_VERSION_STR.split(".")))
        _ver = PYQT_VERSION_STR.split(".")
        ver = _ver + ["0"] * (3 - len(_ver))
        pyqt_version_no = list(map(int, ver))[:3]
    except ImportError:
        pass

    try:
        from PyQt5.QtWebKit import QWebPage
    except ImportError:
        pass

#
# PyQt4
#
if (qt_variant == "PyQt4") or (qt_variant is None and not qt_imported):