Python PySide2.QtGui.QPixmap() Examples

The following are 30 code examples of PySide2.QtGui.QPixmap(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PySide2.QtGui , or try the search function .
Example #1
Source File: universal_tool_template_0903.py    From universal_tool_template.py with MIT License 7 votes vote down vote up
def __init__(self, parent=None, mode=0):
        super_class.__init__(self, parent)
        #------------------------------
        # class variables
        #------------------------------
        self.version="0.1"
        self.help = "How to Use:\n1. Put source info in\n2. Click Process button\n3. Check result output\n4. Save memory info into a file."
        
        self.uiList={} # for ui obj storage
        self.memoData = {} # key based variable data storage
        
        self.location = ""
        if getattr(sys, 'frozen', False):
            # frozen - cx_freeze
            self.location = sys.executable
        else:
            # unfrozen
            self.location = os.path.realpath(__file__) # location: ref: sys.modules[__name__].__file__
            
        self.name = self.__class__.__name__
        self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png')
        self.iconPix = QtGui.QPixmap(self.iconPath)
        self.icon = QtGui.QIcon(self.iconPath)
        self.fileType='.{0}_EXT'.format(self.name) 
Example #2
Source File: ControlsWidget.py    From debugger with MIT License 6 votes vote down vote up
def load_icon(fname_icon):
	path_this_file = os.path.abspath(__file__)
	path_this_dir = os.path.dirname(path_this_file)
	path_icons = os.path.join(path_this_dir, '..', 'media', 'icons')
	path_icon = os.path.join(path_icons, fname_icon)

	pixmap = QtGui.QPixmap(path_icon)

	#pixmap.fill(QtGui.QColor('red'))
	#pixmap.setMask(pixmap.createMaskFromColor(QtGui.QColor('black'), QtGui.Qt.MaskOutColor))

	icon = QtGui.QIcon()
	icon.addPixmap(pixmap, QtGui.QIcon.Normal)
	icon.addPixmap(pixmap, QtGui.QIcon.Disabled)

	return icon 
Example #3
Source File: manager_ui.py    From spore with MIT License 6 votes vote down vote up
def build_spore_ui(self):

        self.item_wdg.setFrameStyle(QFrame.Raised | QFrame.StyledPanel)
        self.setStyleSheet("background-color: rgb(68,68,68);")

        pixmap = QPixmap(':/out_particle.png')
        icon_lbl = QLabel()
        icon_lbl.setMaximumWidth(18)
        icon_lbl.setPixmap(pixmap)
        self.item_lay.addWidget(icon_lbl, 0, 1, 1, 1)

        self.target_lbl = QLabel(self.name)
        self.item_lay.addWidget(self.target_lbl, 0, 2, 1, 1)

        self.target_edt = QLineEdit(self.item_wdg)
        self.target_edt.setStyleSheet("background-color: rgb(68,68,68);")
        self.target_edt.setMinimumWidth(180)
        self.target_edt.setVisible(False)
        self.item_lay.addWidget(self.target_edt, 0, 2, 1, 1)

        self.item_lay.setColumnStretch(2, 1)

        self.view_buttons = DisplayButtons(self)
        self.item_lay.addWidget(self.view_buttons, 0, 3, 1, 1) 
Example #4
Source File: display.py    From pylash_engine with MIT License 6 votes vote down vote up
def __updatePixelData(self):
		x = 0
		y = 0

		for i in range(len(self.__pixelData)):
			v = self.__pixelData[i]

			self.image.setPixel(x, y, v)

			x += 1

			if x >= self.width:
				x = 0
				y += 1

		self.image = QtGui.QPixmap(self.image)

		self.__pixelData = [] 
Example #5
Source File: display.py    From pylash_engine with MIT License 6 votes vote down vote up
def draw(self, source):
		if not isinstance(source, DisplayObject):
			raise TypeError("BitmapData.draw(source): parameter 'source' must be a display object.")

		w = source.endX()
		h = source.endY()

		self.image = QtGui.QPixmap(w, h)
		self.image.fill(QtCore.Qt.transparent)
		
		p = QtGui.QPainter()
		p.begin(self.image)

		if stage.useAntialiasing:
			p.setRenderHint(QtGui.QPainter.Antialiasing, True)
		else:
			p.setRenderHint(QtGui.QPainter.Antialiasing, False)

		source._show(p)

		p.end()

		self.width = w
		self.height = h 
Example #6
Source File: display.py    From pylash_engine with MIT License 6 votes vote down vote up
def __init__(self, image = QtGui.QImage(), x = 0, y = 0, width = 0, height = 0):
		super(BitmapData, self).__init__()

		if isinstance(image, QtGui.QImage):
			if stage.app:
				image = QtGui.QPixmap(image)
		elif not isinstance(image, QtGui.QPixmap):
			raise TypeError("BitmapData(image = QtGui.QImage(), x = 0, y = 0, width = 0, height = 0): parameter 'image' must be a QPixmap or QImage object.")

		self.image = image
		self.x = x
		self.y = y
		self.width = width
		self.height = height
		self.__locked = False
		self.__pixelData = []

		if image is not None:
			if width == 0:
				self.width = image.width()

			if height == 0:
				self.height = image.height() 
Example #7
Source File: BlenderUpdater.py    From BlenderUpdater with GNU General Public License v3.0 6 votes vote down vote up
def done(self):
        logger.info("Finished")
        donepixmap = QtGui.QPixmap(":/newPrefix/images/Check-icon.png")
        self.lbl_clean_pic.setPixmap(donepixmap)
        self.statusbar.showMessage("Ready")
        self.progressBar.setMinimum(0)
        self.progressBar.setMaximum(100)
        self.progressBar.setValue(100)
        self.lbl_task.setText("Finished")
        self.btn_Quit.setEnabled(True)
        self.btn_Check.setEnabled(True)
        self.btn_execute.show()
        opsys = platform.system()
        if opsys == "Windows":
            self.btn_execute.clicked.connect(self.exec_windows)
        if opsys.lower == "darwin":
            self.btn_execute.clicked.connect(self.exec_osx)
        if opsys == "Linux":
            self.btn_execute.clicked.connect(self.exec_linux) 
Example #8
Source File: FileSystem.py    From PyAero with MIT License 6 votes vote down vote up
def data(self, index, role):
        """
        This function partly overrides the standard QFileSystemModel data
        function to return custom file and folder icons
        """

        fileInfo = self.getFileInfo(index)[4]

        if role == QtCore.Qt.DecorationRole:
            if fileInfo.isDir():
                return QtGui.QPixmap(ICONS_L + 'Folder.png')
            elif fileInfo.isFile():
                return QtGui.QPixmap(ICONS_L + 'airfoil.png')

        # return QtWidgets.QFileSystemModel.data(self, index, role)
        return super().data(index, role)

    # @QtCore.Slot(QtCore.QModelIndex) 
Example #9
Source File: blender_application.py    From bqt with Mozilla Public License 2.0 6 votes vote down vote up
def _get_application_icon() -> QIcon:
        """
        This finds the running blender process, extracts the blender icon from the blender.exe file on disk and saves it to the user's temp folder.
        It then creates a QIcon with that data and returns it.

        Returns QIcon: Application Icon
        """

        icon_filepath = Path(__file__).parent / ".." / "blender_icon_16.png"
        icon = QIcon()

        if icon_filepath.exists():
            image = QImage(str(icon_filepath))
            if not image.isNull():
                icon = QIcon(QPixmap().fromImage(image))

        return icon 
Example #10
Source File: gui.py    From EvilOSX with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        super(_HomeTab, self).__init__()

        self._layout = QHBoxLayout()
        self.setLayout(self._layout)

        message_label = QLabel("""\
        Welcome to <b>EvilOSX</b>:<br/>
        An evil RAT (Remote Administration Tool) for macOS / OS X.<br/><br/><br/>

        Author: Marten4n6<br/>
        License: GPLv3<br/>
        Version: <b>{}</b>
        """.format(VERSION))
        logo_label = QLabel()

        logo_path = path.join(path.dirname(__file__), path.pardir, path.pardir, "data", "images", "logo_334x600.png")
        logo_label.setPixmap(QPixmap(logo_path))

        self._layout.setAlignment(Qt.AlignCenter)
        self._layout.setSpacing(50)
        self._layout.addWidget(message_label)
        self._layout.addWidget(logo_label) 
Example #11
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 5 votes vote down vote up
def tray_menu(self):
        """
        Create menu for the tray icon
        """
        self.menu = QMenu()
        for item in self.config['window']["SystemTrayIcon"]:
            try:
                self.action = QAction(f"{item['title']}", self)
                self.action.triggered.connect(item['action'])
                if item['icon']:
                    self.action.setIcon(QIcon(QPixmap(item['icon'])))
                self.menu.addAction(self.action)
            except KeyError:
                pass
        return self.menu 
Example #12
Source File: manager_ui.py    From spore with MIT License 5 votes vote down vote up
def build_ui(self):
        layout = QGridLayout(self)
        layout.setContentsMargins(5, 5, 5, 5)
        self.setLayout(layout)

        self.name_edt = QLineEdit()
        self.name_edt.setPlaceholderText('Create New')
        self.name_edt.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        layout.addWidget(self.name_edt, 0, 0, 1, 1)

        self.add_btn = QPushButton()
        self.add_btn.setIcon(QIcon(QPixmap(':/teAdditive.png')))
        self.add_btn.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
        layout.addWidget(self.add_btn, 0, 1, 1, 1)

        self.refresh_btn = QPushButton()
        self.refresh_btn.setIcon(QIcon(QPixmap(':/teKeyRefresh.png')))
        self.refresh_btn.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
        layout.addWidget(self.refresh_btn, 0, 2, 1, 1)

        scroll_wdg = QWidget(self)
        scroll_area = QScrollArea()
        scroll_area.setWidgetResizable(True)
        scroll_area.setStyleSheet("QScrollArea { background-color: rgb(57,57,57);}");
        scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll_area.setWidget(scroll_wdg)

        self.spore_layout = QVBoxLayout()
        self.spore_layout.setContentsMargins(1, 1, 3, 1)
        self.spore_layout.setSpacing(0)
        self.spore_layout.addStretch()
        scroll_wdg.setLayout(self.spore_layout)
        layout.addWidget(scroll_area, 1, 0, 1, 3)

        #  self.frame_lay.addWidget(ItemWidget())
        #  layout.addWidget(btn, 0, 0, 1, 1) 
Example #13
Source File: Widgets.py    From Jade-Application-Kit with GNU General Public License v3.0 5 votes vote down vote up
def setBackgroundImage(self, image):
        screen = getScreenGeometry()
        pixmap = QPixmap(QImage(image)).scaled(screen.width(), screen.height(), Qt.KeepAspectRatioByExpanding)
        self.label.setPixmap(pixmap)
        self.label.setGeometry(0, 0, screen.width(), self.label.sizeHint().height()) 
Example #14
Source File: universal_tool_template_0803.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def __init__(self, parent=None, mode=0):
        super_class.__init__(self, parent)
        #------------------------------
        # class variables
        #------------------------------
        self.version="0.1"
        self.help = "How to Use:\n1. Put source info in\n2. Click Process button\n3. Check result output\n4. Save memory info into a file."
        
        self.uiList={} # for ui obj storage
        self.memoData = {} # key based variable data storage
        
        self.location = ""
        if getattr(sys, 'frozen', False):
            # frozen - cx_freeze
            self.location = sys.executable
        else:
            # unfrozen
            self.location = os.path.realpath(__file__) # location: ref: sys.modules[__name__].__file__
            
        self.name = self.__class__.__name__
        self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png')
        self.iconPix = QtGui.QPixmap(self.iconPath)
        self.icon = QtGui.QIcon(self.iconPath)
        self.fileType='.{0}_EXT'.format(self.name)
        
        # Custom user variable
        #------------------------------
        # initial data
        #------------------------------
        self.memoData['data']=[]
        
        self.setupStyle()
        if isinstance(self, QtWidgets.QMainWindow):
            self.setupMenu()
        self.setupWin()
        self.setupUI()
        self.Establish_Connections()
        self.loadData()
        self.loadLang() 
Example #15
Source File: universal_tool_template_0904.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def __init__(self, parent=None, mode=0):
        super_class.__init__(self, parent)
        #------------------------------
        # class variables
        #------------------------------
        self.version="0.1"
        self.help = "How to Use:\n1. Put source info in\n2. Click Process button\n3. Check result output\n4. Save memory info into a file."
        
        self.uiList={} # for ui obj storage
        self.memoData = {} # key based variable data storage
        
        self.location = ""
        if getattr(sys, 'frozen', False):
            # frozen - cx_freeze
            self.location = sys.executable
        else:
            # unfrozen
            self.location = os.path.realpath(sys.modules[self.__class__.__module__].__file__)
            
        self.name = self.__class__.__name__
        self.iconPath = os.path.join(os.path.dirname(self.location),'icons',self.name+'.png')
        self.iconPix = QtGui.QPixmap(self.iconPath)
        self.icon = QtGui.QIcon(self.iconPath)
        self.fileType='.{0}_EXT'.format(self.name)
        
        #------------------------------
        # core function variable
        #------------------------------
        self.qui_core_dict = {
            'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout',
            'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget',
            'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox',
            'txt': 'QTextEdit',
            'list': 'QListWidget', 'tree': 'QTreeWidget', 'table': 'QTableWidget',
            'space': 'QSpacerItem', 
        }
        self.qui_user_dict = {}
        #------------------------------ 
Example #16
Source File: about.py    From angr-management with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _init_widgets(self):
        # icon
        icon_label = QLabel(self)
        icon_location = os.path.join(IMG_LOCATION, 'angr-ds.png')
        angr_icon = QPixmap(icon_location)
        icon_label.setPixmap(angr_icon)
        # textbox
        angr_text = QLabel("angr")
        angr_text.setFont(QFont("Consolas", 24, weight=QFont.Bold))
        version_text_tup = "Version: " + ".".join(str(x) for x in angr.__version__[0:4])
        version_text = QLabel(version_text_tup)
        version_text.setFont(QFont("Consolas", weight=QFont.Bold))
        version_text.setAlignment(Qt.AlignCenter)
        credits_text = QLabel("<a href=\"http://angr.io/\">Credits</a>")
        credits_text.setFont(QFont("Consolas", weight=QFont.Bold))
        credits_text.setTextFormat(Qt.RichText)
        credits_text.setTextInteractionFlags(Qt.TextBrowserInteraction)
        credits_text.setOpenExternalLinks(True)
        # buttons
        btn_ok = QPushButton('OK')
        btn_ok.clicked.connect(self._on_close_clicked)

        buttons_layout = QHBoxLayout()
        buttons_layout.addWidget(btn_ok)

        structure = QVBoxLayout()
        structure.addWidget(angr_text)
        structure.addWidget(version_text)
        structure.addWidget(credits_text)
        structure.addLayout(buttons_layout)

        layout = QHBoxLayout()
        layout.addWidget(icon_label)
        layout.addLayout(structure)

        self.setLayout(layout)

        #
        # Event handlers
        # 
Example #17
Source File: BlenderUpdater.py    From BlenderUpdater with GNU General Public License v3.0 5 votes vote down vote up
def extraction(self):
        logger.info("Extracting to temp directory")
        self.lbl_task.setText("Extracting...")
        self.btn_Quit.setEnabled(False)
        nowpixmap = QtGui.QPixmap(":/newPrefix/images/Actions-arrow-right-icon.png")
        donepixmap = QtGui.QPixmap(":/newPrefix/images/Check-icon.png")
        self.lbl_download_pic.setPixmap(donepixmap)
        self.lbl_extract_pic.setPixmap(nowpixmap)
        self.lbl_extraction.setText("<b>Extraction</b>")
        self.statusbar.showMessage("Extracting to temporary folder, please wait...")
        self.progressBar.setMaximum(0)
        self.progressBar.setMinimum(0)
        self.progressBar.setValue(-1) 
Example #18
Source File: BlenderUpdater.py    From BlenderUpdater with GNU General Public License v3.0 5 votes vote down vote up
def finalcopy(self):
        logger.info("Copying to " + dir_)
        nowpixmap = QtGui.QPixmap(":/newPrefix/images/Actions-arrow-right-icon.png")
        donepixmap = QtGui.QPixmap(":/newPrefix/images/Check-icon.png")
        self.lbl_extract_pic.setPixmap(donepixmap)
        self.lbl_copy_pic.setPixmap(nowpixmap)
        self.lbl_copying.setText("<b>Copying</b>")
        self.lbl_task.setText("Copying files...")
        self.statusbar.showMessage(f"Copying files to {dir_}, please wait... ") 
Example #19
Source File: BlenderUpdater.py    From BlenderUpdater with GNU General Public License v3.0 5 votes vote down vote up
def cleanup(self):
        logger.info("Cleaning up temp files")
        nowpixmap = QtGui.QPixmap(":/newPrefix/images/Actions-arrow-right-icon.png")
        donepixmap = QtGui.QPixmap(":/newPrefix/images/Check-icon.png")
        self.lbl_copy_pic.setPixmap(donepixmap)
        self.lbl_clean_pic.setPixmap(nowpixmap)
        self.lbl_cleanup.setText("<b>Cleaning up</b>")
        self.lbl_task.setText("Cleaning up...")
        self.statusbar.showMessage("Cleaning temporary files") 
Example #20
Source File: gui.py    From GridCal with GNU General Public License v3.0 5 votes vote down vote up
def setupUi(self, GisWindow):
        GisWindow.setObjectName("GisWindow")
        GisWindow.resize(938, 577)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/icons/icons/map.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        GisWindow.setWindowIcon(icon)
        self.centralwidget = QtWidgets.QWidget(GisWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.webFrame = QtWidgets.QFrame(self.centralwidget)
        self.webFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.webFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.webFrame.setObjectName("webFrame")
        self.verticalLayout.addWidget(self.webFrame)
        GisWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(GisWindow)
        self.statusbar.setObjectName("statusbar")
        GisWindow.setStatusBar(self.statusbar)
        self.toolBar = QtWidgets.QToolBar(GisWindow)
        self.toolBar.setMovable(False)
        self.toolBar.setFloatable(False)
        self.toolBar.setObjectName("toolBar")
        GisWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
        self.actionSave_map = QtWidgets.QAction(GisWindow)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/icons/icons/savec.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionSave_map.setIcon(icon1)
        self.actionSave_map.setObjectName("actionSave_map")
        self.toolBar.addAction(self.actionSave_map)

        self.retranslateUi(GisWindow)
        QtCore.QMetaObject.connectSlotsByName(GisWindow) 
Example #21
Source File: display.py    From pylash_engine with MIT License 5 votes vote down vote up
def __getPixelData(self):
		if isinstance(self.image, QtGui.QPixmap):
			self.image = self.image.toImage()

		for i in range(self.height):
			for j in range(self.width):
				self.__pixelData.append(self.image.pixel(j, i)) 
Example #22
Source File: display.py    From pylash_engine with MIT License 5 votes vote down vote up
def _loopDraw(self, c):
		bmpd = self.bitmapData
		image = bmpd.image

		if isinstance(image, QtGui.QPixmap):
			c.drawPixmap(0, 0, image, bmpd.x, bmpd.y, bmpd.width, bmpd.height)
		elif isinstance(image, QtGui.QImage):
			c.drawImage(0, 0, image, bmpd.x, bmpd.y, bmpd.width, bmpd.height) 
Example #23
Source File: tileGAN_client.py    From tileGAN with GNU General Public License v3.0 5 votes vote down vote up
def updateImage(self, image=None, fitToView=False, updateUI=True):
		"""
		update result image in image viewer and trigger all appropriate settings
		"""
		if image is not None:
			if type(image) is np.ndarray: #if input type is numpy array, convert to pixmap
				image = self.pixmapFromArray(image)

			self._image.setPixmap(image)

			if fitToView:
				self.fitInView()

			if updateUI:
				self.textEdited.emit('merge level: %d | latent size: %d | image size: %dx%d px | %.2f MP' % (self.mergeLevel, self.latentSize, image.width(), image.height(), float(image.width() * image.height()) / 1000000))
				self._empty = False

		else:
			self._empty = True

			self._image.setPixmap(QtGui.QPixmap())
			self._latentIndicator.hide()
			self._showLatentIndicator = False
		self._emptyUnmerged = True
		self._emptyClusters = True

		self.imageUpdated.emit(not self._empty)
		#update unmerged image, if necessary
		if self._imageUnmerged.isVisible():
			self.toggleMerging(False) 
Example #24
Source File: manager_ui.py    From spore with MIT License 5 votes vote down vote up
def build_geo_ui(self):

        #  self.setMaximumHeight(85)
        self.item_wdg.setFrameStyle(QFrame.Raised | QFrame.StyledPanel)
        self.item_wdg.setStyleSheet("QFrame { background-color: rgb(55,55,55);}")

        icon = QIcon()
        icon.addPixmap(QPixmap(':/nudgeDown.png'), QIcon.Normal, QIcon.On);
        icon.addPixmap(QPixmap(':/nudgeRight.png'), QIcon.Normal, QIcon.Off);
        self.expand_btn = QPushButton()
        self.expand_btn.setStyleSheet("QPushButton#expand_btn:checked {background-color: green; border: none}")
        self.expand_btn.setStyleSheet("QPushButton { color:white; }\
                                        QPushButton:checked { background-color: rgb(55,55, 55); border: none; }\
                                        QPushButton:pressed { background-color: rgb(55,55, 55); border: none; }") #\
                                        #  QPushButton:hover{ background-color: grey; border-style: outset; }")
        self.expand_btn.setFlat(True)
        self.expand_btn.setIcon(icon)
        self.expand_btn.setCheckable(True)
        self.expand_btn.setChecked(True)
        self.expand_btn.setFixedWidth(25)
        self.expand_btn.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
        self.item_lay.addWidget(self.expand_btn, 0, 0, 1, 1)

        pixmap = QPixmap(':/pickGeometryObj.png')
        icon_lbl = QLabel()
        icon_lbl.setMaximumWidth(18)
        icon_lbl.setPixmap(pixmap)
        self.item_lay.addWidget(icon_lbl, 0, 1, 1, 1)

        self.target_lbl = QLabel(self.name)
        self.item_lay.addWidget(self.target_lbl, 0, 2, 1, 1)
        #  self.target_edt = QLineEdit(item_wdg)
        #  self.target_edt.setMinimumWidth(180)
        #  self.target_edt.setVisible(False)

        self.item_lay.setColumnStretch(3, 1)

        #  self.view_buttons = DisplayButtons(self)
        #  self.item_lay.addWidget(self.view_buttons, 0, 4, 1, 1) 
Example #25
Source File: interactive.py    From hotbox_designer with BSD 3-Clause Clear License 5 votes vote down vote up
def synchronize_image(self):
        self.pixmap = QtGui.QPixmap(self.options['image.path'])
        if self.options['image.fit'] is True:
            self.image_rect = None
            return
        self.image_rect = QtCore.QRect(
            self.rect.left(),
            self.rect.top(),
            self.options['image.width'],
            self.options['image.height'])
        self.image_rect.moveCenter(self.rect.center().toPoint()) 
Example #26
Source File: account_widget.py    From Hands-On-Blockchain-for-Python-Developers with MIT License 5 votes vote down vote up
def _addAccountToWindow(self, account, balance, resize_parent=False):
        wrapper_layout = QVBoxLayout()
        account_layout = QHBoxLayout()
        rows_layout = QVBoxLayout()
        address_layout = QHBoxLayout()
        account_label = QLabel(account)
        account_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        copy_button = QPushButton()
        copy_button.setAutoFillBackground(True)
        copy_button.setIcon(QIcon('icons/copy.svg'))
        self.connect(copy_button, SIGNAL('clicked()'), lambda: self.copyAddress(account))
        address_layout.addWidget(account_label)
        address_layout.addWidget(copy_button)
        balance_label = QLabel('Balance: %.5f ethers' % balance)
        balance_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        self.balance_widgets[account] = balance_label
        rows_layout.addLayout(address_layout)
        rows_layout.addWidget(balance_label)
        avatar = QLabel()
        img_filename = render_avatar(account)
        pixmap = QPixmap(img_filename)
        avatar.setPixmap(pixmap)
        account_layout.addWidget(avatar)
        account_layout.addLayout(rows_layout)
        wrapper_layout.addLayout(account_layout)
        wrapper_layout.addSpacing(20)
        self.accounts_layout.addLayout(wrapper_layout)

        if resize_parent:
            sizeHint = self.sizeHint()
            self.parentWidget().parentWidget().resize(QSize(sizeHint.width(), sizeHint.height() + 40)) 
Example #27
Source File: send_widget.py    From Hands-On-Blockchain-for-Python-Developers with MIT License 5 votes vote down vote up
def setAvatar(self, code, avatar):
        img_filename = render_avatar(code)
        pixmap = QPixmap(img_filename)
        avatar.setPixmap(pixmap) 
Example #28
Source File: token_widget.py    From Hands-On-Blockchain-for-Python-Developers with MIT License 5 votes vote down vote up
def _addTokenToWindow(self, token_information, resize_parent=False):
        wrapper_layout = QVBoxLayout()
        token_layout = QHBoxLayout()
        rows_layout = QVBoxLayout()
        token_label = QLabel(token_information.name)
        token_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        symbol_label = QLabel(token_information.symbol)
        symbol_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        total_supply_label = QLabel('Total Supply: %d coins' % token_information.totalSupply)
        total_supply_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        rows_layout.addWidget(token_label)
        rows_layout.addWidget(symbol_label)
        rows_layout.addWidget(total_supply_label)
        avatar = QLabel()
        img_filename = render_avatar(token_information.address)
        pixmap = QPixmap(img_filename)
        avatar.setPixmap(pixmap)
        token_layout.addWidget(avatar)
        token_layout.addLayout(rows_layout)
        wrapper_layout.addLayout(token_layout)
        wrapper_layout.addSpacing(20)
        self.tokens_layout.addLayout(wrapper_layout)

        if resize_parent:
            sizeHint = self.size()
            self.parentWidget().parentWidget().resize(QSize(sizeHint.width(), sizeHint.height() + 100)) 
Example #29
Source File: tileGAN_client.py    From tileGAN with GNU General Public License v3.0 5 votes vote down vote up
def updateIndicatorSize(self, stroke=3, offset=2, crossSize=10):
		"""
		draw a box and crosshair under mouse cursor as rectangle of size latentSize
		"""
		multiplier = 1 #TODO optional: scale indicator with zoom level

		stroke *= multiplier
		offset *= multiplier
		crossSize *= multiplier

		halfStroke = stroke / 2
		rect = self.getImageDims()
		latentSize = self.latentSize * rect.width() / self.gridSize.width()
		halfSize = latentSize / 2
		crossSize = min(crossSize, int(halfSize - 3))

		pixmap = QPixmap(QSize(int(latentSize + stroke + offset), int(latentSize + stroke + offset)))
		#fill rectangle with transparent color
		pixmap.fill(QColor(0,0,0,0)) #transparent

		painter = QPainter(pixmap)
		r = QRectF(QPoint(), QSizeF(latentSize, latentSize))
		r.adjust(offset+halfStroke, offset+halfStroke, -halfStroke, -halfStroke)
		#draw shadow under rectangle
		pen = QPen(QColor(50, 50, 50, 100), stroke) #shadow
		painter.setPen(pen)
		painter.drawRect(r)
		if crossSize > 4:
			painter.drawLine(QPointF(offset+halfSize, offset+halfSize-crossSize), QPointF(offset+halfSize, offset+halfSize+crossSize))
			painter.drawLine(QPointF(offset+halfSize-crossSize, offset+halfSize), QPointF(offset+halfSize+crossSize, offset+halfSize))
		r.adjust(-offset, -offset, -offset, -offset)
		pen = QPen(QColor(styleColor[0], styleColor[1], styleColor[2], 200), stroke)
		painter.setPen(pen)
		painter.drawRect(r)
		if crossSize > 4:
			painter.drawLine(QPointF(halfSize, halfSize - crossSize), QPointF(halfSize, halfSize + crossSize))
			painter.drawLine(QPointF(halfSize - crossSize, halfSize), QPointF(halfSize + crossSize, halfSize))
		painter.end()

		self._latentIndicator.setPixmap(pixmap) 
Example #30
Source File: tileGAN_client.py    From tileGAN with GNU General Public License v3.0 5 votes vote down vote up
def pixmapFromArray(self, array):
		"""
		convert numpy array to QPixmap. Memory needs to be copied to avoid mem issues.
		"""
		print(array.shape)
		if array.shape[0] == 3:
			array = np.rollaxis(array, 0, 3)

		self.imageShape = QSize(array.shape[1], array.shape[0])
		cp = array.copy()
		image = QImage(cp, array.shape[1], array.shape[0], QImage.Format_RGB888)
		return QPixmap(image)