Ejemplo n.º 1
0
 def __init__(self, parent, suggestion: Suggestion):
     QWidget.__init__(self, parent)
     # defines whether the command has associated options
     self.has_options = True if hasattr(suggestion,
                                        "option_suggestions") else False
     # gets the current theme
     self.active_theme = parent.active_theme
     # gets the font
     self.custom_font = parent.custom_font
     # setting height the row
     width, height = [parent.width(), 57]
     self.resize(width, height)
     # makes command dictionary a class variable
     self.suggestion = suggestion  # Stores information about the command the row will hold
     # widget creation
     self.icon = None  # This can either be an svg or jpg file
     icon_path = self.suggestion.icon_name  # gets the icon path
     if "svg" in icon_path:
         self.icon = QSvgWidget(self)
         self.icon.load(icon_path)
     else:
         pixmap = QPixmap(icon_path)
         icon = QLabel(self)
         icon.setPixmap(pixmap)
         self.icon = icon
     self.title_lbl = QLabel(self.suggestion.title, self)
     self.description_lbl = QLabel(self.suggestion.description, self)
     self.option_icon = QSvgWidget(self)
     self.option_icon.load(f"{ASSETS_DIR}svg{sep}ellipsis.svg")
     self.set_style()
Ejemplo n.º 2
0
 def generateCheme(self):
     chemes = ChemeSvgGenerator(self.cheme)
     chemes.generate()
     self.shemeSvgShemeWidget = QSvgWidget("{0} {1} - Deffects.svg".format(
         self.cheme.calcNumber, self.cheme.owner))
     self.shemeSvgShemeWidget.setGeometry(500, 500, 850, 850)
     self.shemePreviewLayout.addWidget(self.shemeSvgShemeWidget)
     self.shemeSvgShemePreviewWidget = QSvgWidget(
         "{0} {1} - Cheme.svg".format(self.cheme.calcNumber,
                                      self.cheme.owner))
     self.shemeSvgShemePreviewWidget.setGeometry(500, 500, 850, 850)
     self.defectShemePreviewLayout.addWidget(self.shemeSvgShemeWidget)
Ejemplo n.º 3
0
    def __init__(self):
        """
        Initialize the chessboard.
        """
        super().__init__()

        self.setWindowTitle("DeepChess")
        self.setGeometry(300, 300, 800, 800)

        self.widgetSvg = QSvgWidget(parent=self)
        self.widgetSvg.setGeometry(10, 10, 600, 600)

        self.label = QLabel('---', parent=self)
        self.label.setGeometry(10, 600, 600, 100)

        self.boardSize = min(self.widgetSvg.width(), self.widgetSvg.height())
        self.coordinates = True
        self.margin = 0.05 * self.boardSize if self.coordinates else 0
        self.squareSize = (self.boardSize - 2 * self.margin) / 8.0
        self.playerMove = True

        self.engine = DeepChess('b')
        #self.board = chess.Board()
        self.pieceToMove = [None, None]
        self.updateBoard()
Ejemplo n.º 4
0
def createImage(window, settings, path):
    # Retrieve settings
    image = settings['path'] if 'path' in settings else ''
    geometry = settings['geometry'] if 'geometry' in settings else [
        0, 0, 50, 50, 7
    ]
    # Process alignment
    if len(geometry) == 4: geometry.append(7)
    geometry, _ = getPosFromGeometry(geometry)
    # Process image path
    path = path + '/Resources/' + image
    extension = path[(path.rfind('.') + 1):]
    # Create components
    elem = None
    if extension == 'svg':
        elem = QSvgWidget(path, window)
        elem.setGeometry(geometry[0], geometry[1], geometry[2], geometry[3])
        elem.show()
    else:
        elem = QLabel(window)
        elem.setGeometry(geometry[0], geometry[1], geometry[2], geometry[3])
        pixmap = QPixmap(path)
        elem.setPixmap(pixmap)
        elem.show()
    return elem
    def __init__(self, cover_path, figure_info, figure_title,
                 figure_score, figure_desc, figure_count, video_url, cover_url, img_path, *args, **kwargs):
        super(ItemWidget, self).__init__(*args, **kwargs)
        self.setMaximumSize(220, 380)
        self.setMaximumSize(220, 380)
        self.img_path = img_path
        self.cover_url = cover_url
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        # 图片label
        self.clabel = CoverLabel(cover_path, figure_info, video_url, self)
        layout.addWidget(self.clabel)

        # 片名和分数
        flayout = QHBoxLayout()
        flayout.addWidget(QLabel(figure_title, self))
        flayout.addItem(QSpacerItem(
            20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
        flayout.addWidget(QLabel(figure_score, self, styleSheet="color: red;"))
        layout.addLayout(flayout)

        # 主演
        layout.addWidget(
            QLabel(figure_desc, self, styleSheet="color: #999999;", openExternalLinks=True))

        # 播放量
        blayout = QHBoxLayout()
        count_icon = QSvgWidget(self)
        count_icon.setMaximumSize(16, 16)
        count_icon.load(Svg_icon_play_sm)
        blayout.addWidget(count_icon)
        blayout.addWidget(
            QLabel(figure_count, self, styleSheet="color: #999999;"))
        layout.addLayout(blayout)
Ejemplo n.º 6
0
    def __init__(self, color, ip, connected_ip, name):
        super().__init__()

        self.setWindowTitle("LAN Chess")
        self.setGeometry(300, 300, 800, 800)

        self.widgetSvg = QSvgWidget(parent=self)
        self.svgX = 50  # top left x-pos of chessboard
        self.svgY = 50  # top left y-pos of chessboard
        self.cbSize = 600  # size of chessboard
        self.widgetSvg.setGeometry(self.svgX, self.svgY, self.cbSize,
                                   self.cbSize)
        self.coordinates = True
        self.color = color  #True for white, False for black
        self.margin = 0.05 * self.cbSize if self.coordinates == True else 0
        self.squareSize = (self.cbSize - 2 * self.margin) / 8.0
        self.chessboard = chess.Board()
        self.squareToMove = None  #square of the selected piece as a string
        self.selectedPiece = None  #selected piece
        self.squares = None  #squares to be selected to show possible moves
        self.lastMove = None  #last move to highlight
        self.check = None  # not None if a player is in check
        self.connected_ip = connected_ip  #opponents ip
        self.ip = ip  #own ip
        self.port = 5000  #tcp port for sending moves
        self.name = name  #name of the player
    def get_svg_widget(self, element: Gui_Element, height: int,
                       width: int) -> QSvgWidget:

        filename = self.case[element.value]
        cwd = os.getcwd()
        directory = ""
        if sys.platform == 'win32':
            directory = strWinDirectory
        else:
            directory = strLinuxDirectory

        print(sys.platform)

        file_all = cwd + directory + filename
        # print("filename: " + cwd + strDirectory + filename)
        file = open(file_all, "r")
        data = file.read()
        strbackground = "{fill:" + '#ff9900;}'
        data = data.format(background=strbackground)
        file.close()

        svg_bytes = bytearray(data, encoding='utf-8')
        svg_widget = QSvgWidget()
        svg_widget.renderer().load(svg_bytes)
        if height > 0 and width > 0:
            size = QSize(width, height)
            svg_widget.setFixedSize(size)
        else:
            print("else")
            svg_widget.setFixedSize(svg_widget.renderer().defaultSize())

        return svg_widget
Ejemplo n.º 8
0
    def __init__(self, sysdat, parent=None, testcase=None):
        '''Setup the Lotto Settings Dialog

        :param parent:
        :param testcase:
        :return:
        '''
        super(LottoSettingsDialog, self).__init__(parent)

        def loadpath(*path):
            if not testcase:
                return (os.path.abspath(
                    os.path.join(os.path.dirname(sys.argv[0]), *path)))
            else:
                return os.path.join(*path)

        # Set up the user interface from Designer.
        self.ui = uic.loadUi(
            loadpath("pylottosimu", "dialog", "lottosystem.ui"))

        self.ui.setWindowIcon(QtGui.QIcon(loadpath("misc", "pyLottoSimu.svg")))
        self.imageLabel = QSvgWidget()
        self.imageLabel.renderer().load(
            loadpath("pylottosimu", "lottokugel.svg"))
        self.ui.scrollArea.setWidget(self.imageLabel)

        self.systemdata = sysdat
        for systemname in self.systemdata.data:
            self.ui.combo_name.addItem(systemname['name'])
        self.ui.combo_name.currentIndexChanged.connect(self.set_values)
        self.ui.check_with_addit.clicked.connect(self.with_addit)
        self.ui.check_sep_addit_numbers.clicked.connect(self.sep_addit_numbers)

        self.set_values()
Ejemplo n.º 9
0
    def __init__(self):
        super().__init__()

        self.setGeometry(500, 50, 1000, 1000)

        self.widgetSvg = QSvgWidget(parent=self)
        self.widgetSvg.setGeometry(0, 0, 1000, 1000)

        if args.board is not None:
            self.chessboard = chess.Board(args.board)
        else:
            self.chessboard = chess.Board()

        self.chessboardSvg = chess.svg.board(self.chessboard).encode("UTF-8")
        self.widgetSvg.load(self.chessboardSvg)
        self.widgetSvg.mousePressEvent = self.onclick
        self.human_first_click = True
        self.human_move = ''

        with open(os.path.join(os.getcwd(), 'config.json'), 'r') as f:
            self.config = json.load(f)

        self.use_nn = args.nn
        self.use_database = args.database
        self.use_mcts = args.mcts
Ejemplo n.º 10
0
 def visualizeAI(self):
     svgBytes = self.ai.visualize()
     dialog = QDialog(self)
     dialog.setWindowTitle("AI Algorithm Visualization")
     svgWidget = QSvgWidget(dialog)
     svgWidget.load(QByteArray(svgBytes))
     dialog.show()
Ejemplo n.º 11
0
    def Start(self):
        msg=core.common.trans(self.msg)

        top_right_layout=QVBoxLayout()
        if type(msg)==type('str'):
            label=QLabel(msg)
            label.setAlignment(Qt.AlignLeft)
            top_right_layout.addWidget(label)
        elif type(msg)==type([]) or type(msg)==type((0,)):
            labels=[]
            for n in msg:
                labels.append(QLabel('%s' %n))
                labels[-1].setAlignment(Qt.AlignLeft)
            for n in range(0,len(labels)):
                top_right_layout.addWidget(labels[n])
        top_right_layout.addStretch()

        label=QSvgWidget(self.img_path.question_blue)
        label.setFixedSize(100,100)
        
        top_layout=QHBoxLayout()
        top_layout.addWidget(label)
        top_layout.addLayout(top_right_layout)

        button_layout=QHBoxLayout()
        button_layout.addStretch()
        button_layout.addWidget(self.yes_button)
        button_layout.addWidget(self.no_button)

        dia_layout=QVBoxLayout()
        dia_layout.addLayout(top_layout)
        dia_layout.addLayout(button_layout)

        self.setLayout(dia_layout)
Ejemplo n.º 12
0
    def __init__(self, parent=None):
        super(SourceWidget, self).__init__(parent)

        self.mimeData = None

        imageFile = QFile(':/images/example.svg')
        imageFile.open(QIODevice.ReadOnly)
        self.imageData = imageFile.readAll()
        imageFile.close()

        imageArea = QScrollArea()
        self.imageLabel = QSvgWidget()
        self.imageLabel.renderer().load(self.imageData)
        imageArea.setWidget(self.imageLabel)

        instructTopLabel = QLabel("This is an SVG drawing:")
        instructBottomLabel = QLabel(
            "Drag the icon to copy the drawing as a PNG file:")
        dragIcon = QPushButton("Export")
        dragIcon.setIcon(QIcon(':/images/drag.png'))
        dragIcon.pressed.connect(self.startDrag)

        layout = QGridLayout()
        layout.addWidget(instructTopLabel, 0, 0, 1, 2)
        layout.addWidget(imageArea, 1, 0, 2, 2)
        layout.addWidget(instructBottomLabel, 3, 0)
        layout.addWidget(dragIcon, 3, 1)
        self.setLayout(layout)
        self.setWindowTitle("Delayed Encoding")
Ejemplo n.º 13
0
def _svg(src="",
         widget=None,
         layout=None,
         horizontal="Preferred",
         vertical="MinimumExpanding",
         name="svg",
         **kwargs):
    """
    Svg tag, provide a pointer to a valid svg file
    """
    try:
        svg = AspectRatioSvgWidget(src, kwargs["env"], kwargs['line'])
    except (errors.TagError, errors.ParseError):
        error_svg = """
                    <svg>
                    <rect width="100%" height="100%" fill='white' stroke="red" stroke-width="1"/>
                    <text fill="red" font-size="8" font-family="Verdana" x="30%" y="45%">
                    Error: Missing svg
                    </text>
                    </svg>"""
        svg = QSvgWidget()
        svg.load(QByteArray(error_svg))

    _set_widget(svg,
                layout=layout,
                parent=widget,
                horizontal=horizontal,
                vertical=vertical,
                name=name,
                **kwargs)
    # svg.setStyleSheet("SvgPlaceholder { background: yellow }")
    return svg
    def __init__(self):
        """
        Initialize the chessboard.
        """
        super().__init__()

        self.setWindowTitle("Chess GUI")
        self.setGeometry(300, 300, 610, 610)

        self.widgetSvg = QSvgWidget(parent=self)
        self.widgetSvg.setGeometry(10, 10, 600, 600)

        self.boardSize = min(self.widgetSvg.width(), self.widgetSvg.height())
        self.coordinates = True
        self.margin = 0.05 * self.boardSize if self.coordinates else 0
        self.squareSize = (self.boardSize - 2 * self.margin) / 8.0
        self.pieceToMove = [None, None]

        self.board = chess.Board()

        self.game = chess.pgn.Game()
        self.game.headers["Event"] = "test"
        self.game.headers["White"] = "user"
        self.game.headers["Black"] = "homemade engine"
        self.game.setup(self.board)
        self.node = self.game

        self.drawBoard()
Ejemplo n.º 15
0
 def __init__(self, parent, command_dict):
     QWidget.__init__(self, parent)
     # gets the current theme
     self.active_theme = parent.active_theme
     # gets the font
     self.custom_font = parent.custom_font
     # setting height the row
     height, width = [parent.width(), 114]
     self.resize(height, width)
     # makes command dictionary a class variable
     self.command_dict = command_dict  # Stores information about the command the row will hold
     # widget creation
     self.icon = None  # This can either be an svg or jpg file
     icon_path = command_dict["icon"]  # gets the icon path
     if "svg" in icon_path:
         self.icon = QSvgWidget(self)
         self.icon.load(icon_path)
     else:
         pixmap = QPixmap(icon_path)
         icon = QLabel(self)
         icon.setPixmap(pixmap)
         self.icon = icon
     self.title_lbl = QLabel(command_dict["title"], self)
     self.description_lbl = QLabel(command_dict["description"], self)
     self.set_style()
Ejemplo n.º 16
0
    def loadDecoration(self, decoKey, decoSize=None):

        if decoKey not in self.DECO_MAP:
            logger.error("Decoration with name '%s' does not exist" % decoKey)
            return QSvgWidget()

        svgPath = path.join(self.mainConf.graphPath, self.DECO_MAP[decoKey])
        if not path.isfile(svgPath):
            logger.error("Decoration file '%s' not in assets folder" %
                         self.DECO_MAP[decoKey])
            return QSvgWidget()

        svgDeco = QSvgWidget(svgPath)
        if decoSize is not None:
            svgDeco.setFixedSize(QSize(decoSize[0], decoSize[1]))

        return svgDeco
Ejemplo n.º 17
0
    def __init__(self, parent=None):
        super(DisplayImageWidget, self).__init__(parent)

        self.image_frame = QSvgWidget()

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.image_frame)
        self.setLayout(self.layout)
Ejemplo n.º 18
0
def __example_usage_latex_to_svg():
    plt.rc('mathtext', fontset='cm')
    latex = r'$1 + \dfrac{1}{1 + \dfrac{1}{3}}$'
    app = QApplication(sys.argv)
    svg = QSvgWidget()
    svg.load(latex_to_svg(latex))
    svg.show()
    sys.exit(app.exec_())
Ejemplo n.º 19
0
    def __init__(self, svg_board, **kwargs):
        super().__init__(**kwargs)
        self.svgWidget = QSvgWidget()
        layout = EvenLayout(self)
        layout.addWidget(self.svgWidget, 0, 0)

        self.press_pos = None
        self.refresh(svg_board)
Ejemplo n.º 20
0
    def __init__(self, filename):
        super().__init__()
        self.main_layout = QW.QVBoxLayout(self)
        self.setWindowTitle("DAG")

        if os.path.exists(filename):
            widget = QSvgWidget(filename)
            self.main_layout.addWidget(widget)
Ejemplo n.º 21
0
 def __init__(self, left=100, top=100, width=500, height=500):
     super().__init__()
     self.left = max(0, left)
     self.top = max(0, top)
     self.width = max(20, width)
     self.height = max(20, height)
     self.update_geometry()
     self.widgetSvg = QSvgWidget(parent=self)
     self.widgetSvg.setGeometry(10, 10, self.width - 20, self.height - 20)
Ejemplo n.º 22
0
    def __init__(self):
        super().__init__()

        self.setGeometry(100, 100, 1000, 1000)

        self.widgetSvg = QSvgWidget(parent=self)
        self.widgetSvg.setGeometry(10, 10, 900, 900)

        self.chessboard = chess.Board()
Ejemplo n.º 23
0
    def _setupPanel(self, iconSize):
        layout = QHBoxLayout()
        layout.setAlignment(Qt.AlignHCenter)

        svgWidget = QSvgWidget(':spinnerLoader.svg')
        svgWidget.setFixedSize(iconSize, iconSize)
        layout.addWidget(svgWidget)

        self.setLayout(layout)
Ejemplo n.º 24
0
    def __init__(self, board):
        super().__init__()

        self.setGeometry(100, 100, 520, 520)

        self.widgetSvg = QSvgWidget(parent=self)
        self.widgetSvg.setGeometry(10, 10, 500, 500)

        self.set_board(board)
Ejemplo n.º 25
0
    def _createIconLayout(self, iconSize):
        iconLayout = QHBoxLayout()
        iconLayout.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        svgWidget = QSvgWidget(':loader.svg')
        svgWidget.setFixedSize(iconSize, iconSize)
        iconLayout.addWidget(svgWidget)

        return iconLayout
Ejemplo n.º 26
0
	def translateScreenshot(self, path):
		"""
		Generate translations of a screen shot
		BONUS: if the screen shot is in dark screen mode, creates also
		SVG files for print usage, with light colors.
		:param path: the path to a svg file
		"""
		try:
			translate_svg_path = self.conf['DEFAULT']['translate_svg_path']
			supported_languages = self.conf['DEFAULT']['supported_languages']
		except:
			translate_svg_path = os.path.join(
				os.path.dirname(path), "screen", "{lang}", "{filename}"
			)
			supported_languages = "en,es,fr,ml"
		from translate_svg import translateDialog
		from PyQt5.QtSvg import QSvgWidget
		from PyQt5.QtWidgets import QVBoxLayout, QDialog, QCheckBox
		d = translateDialog(self)
		d.buttonBox.helpRequested.connect(self.translateScreenshotHelp)
		svg=QSvgWidget(path)
		d.imgFrame.setLayout(QVBoxLayout())
		d.imgFrame.layout().addWidget(svg)
		d.pathEdit.setText(translate_svg_path)
		d.langEdit.setText(supported_languages)
		width = int(self.conf['DEFAULT'].get('pngWidth', "400"))
		d.widthSpinBox.setValue(width)
		ok = d.exec_()
		if ok:
			self.translate_svg_path = d.pathEdit.text()
			supported_languages = d.langEdit.text()
			pngWanted=False
			if d.widthCheckBox.isChecked():
				pngWanted=True
				self.PNGwidth = d.widthSpinBox.value()
				self.setConfig('DEFAULT', 'pngWidth', str(self.PNGwidth))
			self.setConfig('DEFAULT', 'translate_svg_path', self.translate_svg_path)
			self.setConfig('DEFAULT', 'supported_languages', supported_languages)
			self.conf.read(cnf)
			self.targetLanguages = [l.strip() for l in supported_languages.split(",")]
			self.sourceSVGpath = path
			self.exportScreenshotBox = QDialog()
			self.exportScreenshotBox.setWindowTitle(self.tr("Translating ..."))
			self.translatedBoxes={}
			vl = QVBoxLayout()
			for e in languages:
				lang = e.ident[:2]
				if lang not in self.targetLanguages:
					continue
				cb = QCheckBox(self.tr("Export screenshot in {name} ({localname}).").format(name=e.name, localname=e.localName))
				self.translatedBoxes[lang] = cb
				vl.addWidget(cb)
			self.exportScreenshotBox.setLayout(vl)
			self.exportScreenshotBox.setModal(False)
			self.exportScreenshotBox.show()
			QTimer.singleShot(50, self.translate_screenshot)
		return
Ejemplo n.º 27
0
    def translateScreenshot(self, path):
        """
		Generate translations of a screen shot
		BONUS: if the screen shot is in dark screen mode, creates also
		SVG files for print usage, with light colors.
		:param path: the path to a svg file
		"""
        from screenshots.printableSVG import lightenSvgFile, svg2png
        try:
            translate_svg_path = self.conf['DEFAULT']['translate_svg_path']
            supported_languages = self.conf['DEFAULT']['supported_languages']
        except:
            translate_svg_path = os.path.join(os.path.dirname(path), "screen",
                                              "{lang}", "{filename}")
            supported_languages = "en,es,fr,ml"
        from translate_svg import translateDialog, SvgTranslator
        from PyQt5.QtSvg import QSvgWidget
        from PyQt5.QtWidgets import QVBoxLayout
        d = translateDialog(self)
        d.buttonBox.helpRequested.connect(self.translateScreenshotHelp)
        svg = QSvgWidget(path)
        d.imgFrame.setLayout(QVBoxLayout())
        d.imgFrame.layout().addWidget(svg)
        d.pathEdit.setText(translate_svg_path)
        d.langEdit.setText(supported_languages)
        width = int(self.conf['DEFAULT'].get('pngWidth', "400"))
        d.widthSpinBox.setValue(width)
        ok = d.exec_()
        if ok:
            translate_svg_path = d.pathEdit.text()
            supported_languages = d.langEdit.text()
            pngWanted = False
            if d.widthCheckBox.isChecked():
                pngWanted = True
                width = d.widthSpinBox.value()
                self.setConfig('DEFAULT', 'pngWidth', str(width))
            self.setConfig('DEFAULT', 'translate_svg_path', translate_svg_path)
            self.setConfig('DEFAULT', 'supported_languages',
                           supported_languages)
            self.conf.read(cnf)
            languages = [l.strip() for l in supported_languages.split(",")]
            filename = os.path.basename(path)
            for lang in languages:
                langpath = os.path.abspath(
                    translate_svg_path.format(filename=filename, lang=lang))
                os.makedirs(os.path.abspath(os.path.dirname(langpath)),
                            exist_ok=True)
                with open(langpath, "w") as outfile:
                    svgData = SvgTranslator(lang).translateSvg(path)
                    outfile.write(svgData)
                svg2png(langpath, app=self.app, width=width)
                if "-dark" in langpath:
                    lightFile = lightenSvgFile(langpath)
                    svg2png(lightFile, app=self.app, width=width)

        return
Ejemplo n.º 28
0
def main():
    FORMULA = r'\int_{-\infty}^\infty e^{-x^2}\,dx = \sqrt{\pi}'

    app = QApplication(sys.argv)

    svg = QSvgWidget()
    svg.load(tex2svg(FORMULA))
    svg.show()

    sys.exit(app.exec_())
 def create_widget_galvanometer(self):
     """
     Создаёт свг_виджет, устанавливает стрелку прибора на 0 градусов,
     тобишь на 0 вольт
     :return: готовый к интеграции виджет
     """
     svg_widget = QSvgWidget()
     svg_bytes = bytearray(self.svg_str.format('0'), encoding='utf-8')
     svg_widget.renderer().load(svg_bytes)
     return svg_widget
Ejemplo n.º 30
0
    def add_usb_image(self):

        self.usb_image = QSvgWidget(parent=self)
        self.usb_image.image0 = './images/usb-0.svg'
        self.usb_image.image1 = './images/usb-1.svg'
        self.usb_image.max_height = self.h / 2
        self.grid.addWidget(self.usb_image, 1, 0, Qt.AlignHCenter)
        self.spacing_label = QLabel(parent=self)
        self.grid.addWidget(self.spacing_label, 2, 0, Qt.AlignCenter)
        self.update_usb_image()