def __init__(self, parent=None, warningAction=None, warningService=None): """ Constructor @param parent: Qt widget parent of this dialog window @type parent: QWidget @param warningAction: The action to connect to. @type warningAction: QAction """ super(WarningsDialog, self).__init__(parent) self.setupUi(self) self.setWarningAction(warningAction) self.setWarningService(warningService) self.statusBarService = StatusBarService() self.errorString = "" self.errorMsgTextEdit.setPlainText(self.errorString) self.iconWarning = QIcon() self.iconWarning.addPixmap( QPixmap( ":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-severe-alert.png" ), QIcon.Normal, QIcon.Off) self.iconNoWarning = QIcon() self.iconNoWarning.addPixmap( QPixmap( ":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-clear.png" ), QIcon.Normal, QIcon.Off)
def load_more_images(self): if(self.within_set_index == -1): print "New set." self.current_set_index += 1 arr = self.sets["sets"][self.current_set_index] if(len(arr) == 0): ret = QMessageBox.information(self, "Image Verification UI", "Ran out of images to compare.", QMessageBox.Ok) self.close() self.image1_filepath = arr[0].strip() self.image2_filepath = arr[1].strip() #print self.image1_filepath #print self.image2_filepath self.image1.setPixmap(QPixmap(self.image1_filepath).scaledToHeight(192)) self.image2.setPixmap(QPixmap(self.image2_filepath).scaledToHeight(192)) self.within_set_index = 2 else: arr = self.sets["sets"][self.current_set_index] if(self.within_set_index >= len(arr)): self.within_set_index = -1 self.load_more_images() else: self.image2_filepath = arr[self.within_set_index].strip() #print self.image2_filepath self.image2.setPixmap(QPixmap(self.image2_filepath).scaledToHeight(192)) self.within_set_index += 1
def __init__(self, title, subtitle, icon_path): """ :param title: str title :param subtitle: str subtitle :param icon_path: path of picture """ super(MyLable, self).__init__() self.lb_title = QLabel(title) self.lb_title.setFont(QFont("Arial", 10, QFont.Bold)) self.lb_subtitle = QLabel(subtitle) self.lb_subtitle.setFont(QFont("Arial", 8, QFont.StyleItalic)) self.lb_subtitle1 = QLabel(subtitle) self.lb_subtitle1.setFont(QFont("Arial", 8, QFont.StyleItalic)) self.lb_icon = QLabel() self.lb_icon.setFixedSize(40, 40) pixMap = QPixmap(icon_path).scaled(self.lb_icon.width(), self.lb_icon.height()) self.lb_icon.setPixmap(pixMap) self.lb_icon1 = QLabel() self.lb_icon1.setFixedSize(40, 40) pixMap1 = QPixmap(icon_path).scaled(self.lb_icon.width(), self.lb_icon.height()) self.lb_icon1.setPixmap(pixMap1) self.double_click_fun = None self.init_ui()
def __init__(self, parent): '''Initialization''' QStyledItemDelegate.__init__(self, parent) self.bg_color = QColor('#000000') self.bg_alternate_color = QColor('#333333') self.new_bg_color = QColor('#0044dd') self.new_bg_alternate_color = QColor('#223399') self.user_color = QColor('#7AB4F5') self.time_color = QColor('#7AB4F5') self.replyto_color = QColor('#7AB4F5') self.text_color = QColor('#FFFFFF') self.separator_color = QColor('#000000') self.fsize = 1.0 self.fm = None self.minifm = None self.normFont = None self.miniFont = None # print os.path.join(os.path.dirname(__file__), # 'icons', 'reply.png') self.reply_icon = QPixmap( os.path.join(os.path.dirname(__file__), 'icons', 'reply.png')) # print dir(self.reply_icon) self.retweet_icon = QPixmap( os.path.join(os.path.dirname(__file__), 'icons', 'retweet.png')) self.geoloc_icon = QPixmap( os.path.join(os.path.dirname(__file__), 'icons', 'geoloc.png'))
def setUp(self): super(QPixmapQDatastream, self).setUp() self.source_pixmap = QPixmap(100, 100) self.source_pixmap.fill(Qt.red) self.output_pixmap = QPixmap() self.buffer = QByteArray() self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly) self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)
def __init__(self, parent=None): super(SeparatorButton, self).__init__(parent) self.pix = (QPixmap(':/ShortCloseBar.png'), QPixmap(':/ShortOpenBar.png')) self.is_collapsed = False self.icon = self.pix[1] self.setFlat(True) self.setFixedSize(TOOLBAR_SEPARATOR_WIDTH, 20)
def __init__(self, firstIcon, secondIcon, parent=None): super(CheckIconWidget, self).__init__(parent) self.setMouseTracking(True) self._mouse_over = False self._checked = False self._first_icon = QPixmap(firstIcon) self._second_icon = QPixmap(secondIcon) w1, w2 = self._first_icon.width(), self._second_icon.width() h1, h2 = self._first_icon.height(), self._second_icon.height() max_w = w1 if w1 > w2 else w2 max_h = h1 if h1 > h2 else h2 # set the size to contain both images, but they should have the same size self.setFixedSize(max_w, max_h)
def __init__(self, parent): super(EmbroidermodderLogo, self).__init__(parent) self.pixmap = QPixmap(parent.gImgDir + os.sep + 'logo_embroidermodder_2_0.png') self.setPixmap(self.pixmap) self.setWhatsThis( self.tr( 'This is the AWESOME Embroidermodder 2.0 About dialog image.')) # We will probably want to use this image elsewhere so # we will overlay the other graphics in the open spot in the image. self.paintThisText = 'About' self.pixmap1ForPaintEvent = QPixmap(parent.gImgDir + os.sep + 'text_about.png')
def showProtoDialog(self): fname, _ = QtGui.QFileDialog.getOpenFileName( self, 'Open file', '/home', "Image Files (*.png *.jpg *.bmp)") if fname != None and fname != '': self.protoPath = fname self.protoLabel.setPixmap(QPixmap(self.protoPath))
def __init__(self, parent=None): super(SyncWindow, self).__init__(parent) # Sets up several UI aspects self.tray = QSystemTrayIcon(self) self.tray.setIcon(QIcon(QPixmap(':/resources/icon.png'))) self.tray.show() self.setStyleSheet('SyncWindow {background: white}') self.setWindowTitle('IQBox') self.setWindowIcon(QIcon(QPixmap(':/resources/logobar.png'))) self.statusBar().setFont(View.labelsFont()) self.syncThread = None # Initializes the window with a `LoginView` widget. self.loginView()
def error_message(text): errorbox = QMessageBox() errorbox.setWindowIcon(QPixmap("../icons/desuratools_256.png")) errorbox.setWindowTitle("Error") errorbox.setText(text) errorbox.setIcon(QMessageBox.Critical) return errorbox
def main(): app = QApplication(sys.argv) import qdarkstyle # setup stylesheet app.setStyleSheet(qdarkstyle.load_stylesheet()) pixmap = QPixmap(os.path.join(_resourcepath('images'), "splash.png")) splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) splash_font = splash.font() splash_font.setPixelSize(14) splash.setFont(splash_font) splash.show() splash.showMessage('Initialising...', Qt.AlignBottom | Qt.AlignLeft | Qt.AlignAbsolute, Qt.white) app.processEvents() """ for count in range(1, 6): splash.showMessage('Processing {0}...'.format(count), Qt.AlignBottom | Qt.AlignLeft, Qt.white) QApplication.processEvents() QThread.msleep(1000) """ frame = ConfiguratorWindow() frame.show_and_raise() splash.finish(frame) sys.exit(app.exec_())
def paint(self, painter, option, index): rect = option.rect movie = index.data(Qt.UserRole) painter.setOpacity(0.7) if option.state & QStyle.State_Selected: painter.drawRect(rect) # draw poster background painter.setPen(self.outline) painter.setBrush(self.backgoundBrush) painter.drawRect(rect) # draw poster pixmap = QPixmap(movie.poster).scaled(rect.width() - 25, rect.height() - 50, Qt.KeepAspectRatio, Qt.SmoothTransformation) posterRect = QRect(rect.x() + 15, rect.y() + 15, pixmap.width(), pixmap.height()) painter.drawPixmap(posterRect, pixmap) # draw movie title titleRect = QRect(rect.x(), rect.bottom() - 30, rect.width(), rect.height()) releaseText = "({})".format( movie.releaseDate.split("-")[0]) if movie.releaseDate else "" painter.drawText(titleRect, Qt.AlignHCenter, u"{0} {1}".format(movie.name, releaseText))
def requestPixmap(self, path, rsize, size): """@reimp @public @param[in] providerId unicode unused @param[out] rsize QSize @param[in] size QSize @return QPixmap not None virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) """ ret = QPixmap(QUrl(path).toLocalFile()) if ret.isNull(): derror("failed to load image: '%s'" % path) elif size != ret.size() and not size.isEmpty() and not ret.size( ).isEmpty(): if ret.width() * size.height() > ret.height() * size.width(): ret = ret.scaledToHeight(min(800, size.height()), Qt.SmoothTransformation) else: w = 1000 if ret.width() > ret.height() else 600 ret = ret.scaledToWidth(min(w, size.width()), Qt.SmoothTransformation) #elif size != ret.size(): # ret = (ret.scaled(size, Qt.KeepAspectRatio, Qt.SmoothTransformation) if not size.isEmpty() else # ret.scaledToWidth(size.width(), Qt.SmoothTransformation) if size.width() > 0 else # ret.scaledToHeight(size.height(), Qt.SmoothTransformation) if size.height() > 0 else # ret) rsize.setWidth(ret.width()) rsize.setHeight(ret.height()) return ret
def update_data(self): """ Updates the data in the form """ try: data = self.backend_handle.read_report(code=int(self.code)) if data: if data[0]: data = data[1] self.code_line.setText(data['code']) self.code_line.setDisabled(True) self.date_line.setDate(data['date']) self.organization_line.setText(data['organization']) self.test_line.setText(data['test']) self.description_line.setText(data['description']) self.image_data = str(data['report']) self.pixmap = QPixmap() self.pixmap.loadFromData(self.image_data) self.image_label.setPixmap( self.pixmap.scaled(self.image_label.size(), Qt.KeepAspectRatio, Qt.FastTransformation)) except Exception: if settings.level == 10: logger.exception('raised exception') return False, 'Some Internal Error'
def _make_tabs_button(self, side_widgets, side_icons): if len(side_widgets) != len(side_icons): raise Exception( "Bad parameters : len(side_widgets) ({}) != len(side_icons) ({})" .format(len(side_widgets), len(side_icons))) layout = QVBoxLayout() self._side_icons = [] ndx = 0 for w in side_widgets: resource_name = side_icons[ndx] pixmap = QPixmap(os.path.join(resource_dir, resource_name)) icon = QIcon(pixmap) self._side_icons.append(icon) b = QToolButton() b.setIcon(icon) b.setIconSize(pixmap.rect().size()) b.setMaximumWidth(pixmap.rect().width() + 6) b.clicked.connect(self.signal_mapper_tab_changed.map) self.signal_mapper_tab_changed.setMapping(b, ndx) layout.addWidget(b) layout.setStretch(ndx, 1) ndx += 1 layout.addStretch() return layout
def showOriDialog(self): fname, _ = QtGui.QFileDialog.getOpenFileName( self, 'Open file', '/home', "Image Files (*.png *.jpg *.bmp)") if fname != None and fname != '': self.oriPath = fname print(self.oriPath) self.oriLabel.setPixmap(QPixmap(self.oriPath))
def pixmap(path): d = Resource.instance() f = d._pixmapPrefix + path p = QPixmap(f) if p.isNull(): print "Pixmap not found: ", f return p
def __init__(self): if self._model_instances is None: # This is the first time an instance of this class is # being instantiated. Register the atexit handler to # ensure the state get saved on exit. self.__class__._model_instances = [] atexit.register(KhweetsModel.save_all_config, lazily=False) self._model_instances.append(weakref.ref(self)) QAbstractListModel.__init__(self) # Cache the passed data list as a class member. # Status is a dict mapping uids to status self.statuses = {} # UIDs is an array of the UIDs in the current data set. self.uids = [] self.avatars = {} self.now = time.time() self.nothing_really_loaded = True self.call = None self.max_created_at = None self.new_message_horizon = self.now self.khweets_limit = 10000 try: self.default_avatar = QPixmap('/opt/usr/share/icons/hicolor/48x48/hildon/general_default_avatar.png') except: self.default_avatar = None self.data_cache = {}
def mathTex_to_QPixmap(self, mathTex, fs): self.fig.patch.set_facecolor('none') t = self.ax.text(0, 0, mathTex, ha='left', va='bottom', fontsize=fs) #---- fit figure size to text artist ---- fwidth, fheight = self.fig.get_size_inches() fig_bbox = self.fig.get_window_extent(self.renderer) text_bbox = t.get_window_extent(self.renderer) tight_fwidth = text_bbox.width * fwidth / fig_bbox.width tight_fheight = text_bbox.height * fheight / fig_bbox.height self.fig.set_size_inches(tight_fwidth, tight_fheight) #---- convert mpl figure to QPixmap ---- buf, size = self.fig.canvas.print_to_buffer() qimage = QImage.rgbSwapped(QImage(buf, size[0], size[1], QImage.Format_ARGB32)) qpixmap = QPixmap(qimage) self.ax.cla() return qpixmap
def set_button(self, glo): hlayout = QHBoxLayout() self.mbutton = QPushButton('Start', self) self.mbutton.clicked.connect(self.s_server) self.mbutton.setFont(self.Arials) self.mbutton.setIcon(QPixmap(r_path(solve_path('static/images/play.png')))) self.mbutton2 = QPushButton('Stop', self) self.mbutton2.clicked.connect(self.st_server) self.mbutton2.setIcon(QPixmap(r_path(solve_path('static/images/pause.png')))) self.mbutton.setToolTip(self.getTrans('4')) self.mbutton2.setToolTip(self.getTrans('6')) self.mbutton2.setEnabled(False) self.mbutton2.setFont(self.Arials) hlayout.addWidget(self.mbutton) hlayout.addWidget(self.mbutton2) glo.addLayout(hlayout)
def convertTextureSize(texturePath): if int(cmds.about(v=1)) < 2017: from PySide import QtCore from PySide.QtGui import QPixmap, QImage from PySide.QtCore import QFile, QIODevice else: from PySide2 import QtCore from PySide2.QtGui import QPixmap, QImage from PySide2.QtCore import QFile, QIODevice folder, fileName = ntpath.split(texturePath) origFileName = fileName if fileName[: 8] != 'resized_' else fileName[ 8:] origPath = folder + '/' + origFileName if not os.path.exists(origPath): cmds.warning("original is not exists : %s" % texturePath) return convertedFileName = 'resized_%d_' % ( int(resolusion)) + origFileName renamedPath = folder + "/" + convertedFileName ext = os.path.splitext(fileName)[-1] img = QImage(origPath) pixmap = QPixmap() pixmap = pixmap.fromImage( img.scaled(int(resolusion), int(resolusion), QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.FastTransformation)) qfile = QFile(renamedPath) qfile.open(QIODevice.WriteOnly) pixmap.save(qfile, ext[1:], 100) qfile.close() return renamedPath
def currentChanged(self, current, previous): row = current.row() proxyIndex = self.proxy.index(row, 0) sourceIndex = self.proxy.mapToSource(proxyIndex) row = sourceIndex.row() image = self.proxy.sourceModel().icons[row] self.image.setPixmap(QPixmap(image))
def __init__(self, parent, scene, view): super(QNodesEditor, self).__init__(parent) self.scene = scene self.scene.installEventFilter(self) gridSize = 25 gridMap = QPixmap(gridSize,gridSize) gridPainter = QPainter(gridMap) gridPainter.fillRect(0,0,gridSize,gridSize, QApplication.palette().window().color().darker(103)) gridPainter.fillRect(1,1,gridSize-2,gridSize-2, QApplication.palette().window()) gridPainter.end() self.scene.setBackgroundBrush( QBrush(gridMap) ) originSize = 50 originItem = QGraphicsPathItem() path = QPainterPath() path.moveTo(0,-originSize) path.lineTo(0,originSize) path.moveTo(-originSize,0) path.lineTo(originSize,0) originItem.setPath(path) originItem.setPen(QPen(QApplication.palette().window().color().darker(110),2)) originItem.setZValue(-2) self.scene.addItem(originItem) self.view = view self.view.setDragMode(QGraphicsView.RubberBandDrag) self.view.setRenderHint(QPainter.Antialiasing) self.connection = None
def __init__(self): super(SplashScreen, self).__init__(QPixmap("images/ubisoft.jpg")) self.setWindowModality(Qt.ApplicationModal) self.setWindowFlags(Qt.SplashScreen) self.showMessage("version: %s" % (version.CEED), Qt.AlignBottom | Qt.AlignRight, Qt.GlobalColor.white)
def set_Abutton(self, icon, glo): def show_about(nself): if nself.Arabic is None: Amsg = "<center>All credit reserved to the author of FQM " Amsg += " version " + version Amsg += ", This work is a free, open-source project licensed " Amsg += " under Mozilla Public License version 2.0 . <br><br>" Amsg += " visit us for more infos and how-tos :<br> " Amsg += "<b><a href='https://fqms.github.io/'> " Amsg += "https://fqms.github.io/ </a> </b></center>" Amsgb = "About FQM" else: Amsg = u" <center> " Amsg += u" إدارة الحشود الحر النسخة " + version + u" " Amsg += u"حقوق نشر هذا البرنامج محفوظة و تخضع " Amsg += u" لرخصة البرامج الحرة و مفتوحة المصدر " Amsg += u" Mozilla Public License version 2.0 . " Amsg += u"<br><br> " Amsg += u"للمزيد من المعلومات و الشروحات , قم بزيارة :" Amsg += u"<br> <b><a href='https://fqms.github.io/'>" Amsg += u"https://fqms.github.io </a> </b></center>" Amsgb = u"عن النظام" return QMessageBox.about(self, Amsgb, Amsg) self.abutton = QPushButton('', self) self.abutton.setIcon(QPixmap(icon)) self.abutton.setIconSize(QSize(150, 70)) self.abutton.setToolTip('About FQM') self.abutton.clicked.connect(partial(show_about, self)) glo.addWidget(self.abutton)
def show_calorie_calc(self, row_count=0): ''' show calorie calculator :return: ''' if row_count > 0: row_count += 1 self.clear_table(None, None) self.stuff_table.clearContents() self.stuff_table.setColumnCount(3) self.stuff_table.setRowCount(row_count) self.stuff_table.setHorizontalHeaderLabels(['Amount', 'Unit', 'Name']) if row_count > 0: stuff_widget = QWidget() stuff_pixmap = QPixmap('icons/add.png') stuff_icon = QIcon() stuff_add_bt = QToolButton() stuff_icon.addPixmap(stuff_pixmap) stuff_add_bt.setIcon(stuff_icon) stuff_add_bt.setIconSize(QSize(8, 8)) stuff_add_bt.clicked.connect( lambda: self.stuff_table.insertRow(row_count - 1)) stuff_layout = QHBoxLayout() stuff_layout.addWidget(stuff_add_bt) stuff_widget.setLayout(stuff_layout) self.stuff_table.setCellWidget(row_count - 1, 2, stuff_widget)
def __init__(self, mw, parent=None): """ Default class constructor. :param `mw`: Pointer to a application main window instance. :type `mw`: `MainWindow`_ :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ """ super(MdiArea, self).__init__(parent) self.mainWin = mw self.gSpiralsImgPath = mw.gImgDir + os.sep + 'texture-spirals.png' self.gLogoSpiralsImgPath = mw.gImgDir + os.sep + 'logo-spirals.png' try: #if QT_VERSION >= 0x040800 self.setTabsClosable(True) except AttributeError: pass self.useLogo = False self.useTexture = False self.useColor = False self.bgLogo = QPixmap() self.bgTexture = QPixmap(self.gSpiralsImgPath) self.bgColor = QColor() self.bgLogo = QPixmap(self.gLogoSpiralsImgPath) # Brushes self.colorBrush = QBrush(QColor(EMBROIDERBLUE1)) self.backgroundBrush = QBrush(QPixmap(self.gSpiralsImgPath)) linearGrad = QLinearGradient(QPointF(0, 0), QPointF(400, 400)) linearGrad.setColorAt(0, QColor(EMBROIDERBLUE1)) linearGrad.setColorAt(1, QColor(EMBROIDERBLUE2)) self.gradientBrush = QBrush(linearGrad) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.setActivationOrder(QMdiArea.ActivationHistoryOrder) self.setFocusPolicy(Qt.WheelFocus) self.setFocus() self.setAcceptDrops(True) self.doSetDocumentMode(True)
def paint(self, painter, option, widget=None): """@reimp @public virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) """ #Q_UNUSED(option) #Q_UNUSED(widget) d = self.__d key = d.hash pm = QPixmap() if not QPixmapCache.find(key, pm): # Set up a convenient path path = QPainterPath() path.setFillRule(Qt.OddEvenFill) path.addEllipse(QPointF(d.actualOuterRadius, d.actualOuterRadius), d.actualOuterRadius, d.actualOuterRadius) path.addEllipse(QPointF(d.actualOuterRadius, d.actualOuterRadius), d.actualInnerRadius, d.actualInnerRadius) nActualDiameter = 2.0 * d.actualOuterRadius pm = QPixmap(nActualDiameter, nActualDiameter) pm.fill(Qt.transparent) p = QPainter(pm) # Draw the ring background p.setPen(Qt.NoPen) p.setBrush(d.backgroundColor) p.setRenderHint(QPainter.Antialiasing) p.drawPath(path) # Draw the ring foreground # TODO: Expose this gradient as Qml Property gradient = QConicalGradient(d.actualOuterRadius, d.actualOuterRadius, 0.0) gradient.setColorAt(0.0, Qt.transparent) gradient.setColorAt(0.05, d.foregroundColor) gradient.setColorAt(0.8, Qt.transparent) p.setBrush(gradient) p.drawPath(path) p.end() QPixmapCache.insert(key, pm) # Draw pixmap at center of item w, h = self.width(), self.height() sz = min(w, h) painter.drawPixmap(0.5 * (w - sz), 0.5 * (h - sz), pm)
def test_capture_page(self): self.wizard.selected_devices = self.cams gui.QtGui.QImage = Mock() gui.QtGui.QPixmap.fromImage = Mock(return_value=QPixmap()) page = self.wizard.page(1) page.initializePage() # TODO: Test capture triggering, logbox updates, etc assert page.validatePage()