我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PySide.QtGui.QPixmap()。
def catalogChange(self,*args): while self.form.Reference.count(): self.form.Reference.removeItem(0) for reference in self.form.Catalog.itemData(args[0]): red = QtGui.QPixmap(16, 16) red.fill(QtGui.QColor("red")) green = QtGui.QPixmap(16, 16) green.fill(QtGui.QColor("green")) if self.is_available(self.form.Catalog.currentText(),reference): color = green else: color = red self.form.Reference.addItem(color,reference) #item.setStyleSheet("color: green")
def __init__(self, filename=None): QtGui.QApplication.__init__(self, ['Talpa']) splash_img = QtGui.QPixmap( get_resource('talpa_splash.png'))\ .scaled(QtCore.QSize(400, 250), QtCore.Qt.KeepAspectRatio) self.splash = QtGui.QSplashScreen( splash_img, QtCore.Qt.WindowStaysOnTopHint) self.updateSplashMessage('') self.splash.show() self.processEvents() self.talpa_win = TalpaMainWindow(filename=filename) self.splash.finish(self.talpa_win) self.aboutToQuit.connect(self.splash.deleteLater) self.aboutToQuit.connect(self.deleteLater) self.talpa_win.show() rc = self.exec_() sys.exit(rc)
def init_middle_pane(self): self.mid_pane = QtGui.QHBoxLayout() # IMGS: images which will display the video preview pixmap = QtGui.QPixmap("0.jpg") pixmap.scaledToWidth(self.preview_size) pixmap.scaledToHeight(self.preview_size) img_lbl = QtGui.QLabel(self) img_lbl.setPixmap(pixmap) # Make sure the window isn't constantly resizing img_lbl.setScaledContents(True) img_lbl.setMaximumWidth(self.preview_size) img_lbl.setMaximumHeight(self.preview_size) self.img = img_lbl self.mid_pane.addWidget(self.img) # SLIDER: slide to rate the quality of the video self.slider = QtGui.QSlider(self, QtCore.Qt.Vertical) self.slider.setTickPosition(QtGui.QSlider.TicksBothSides) self.slider.setTickInterval(20) self.mid_pane.addWidget(self.slider) self.layout.addLayout(self.mid_pane)
def setimage_connection(self): ''' Setting image to connctivity. ''' self.ui.lbl_connectivity.show() loc = self.ui.comboConnLoc.currentText() if loc == "Column flange-Beam web": pixmap = QtGui.QPixmap(":/newPrefix/images/beam2.jpg") pixmap.scaledToHeight(50) pixmap.scaledToWidth(60) self.ui.lbl_connectivity.setPixmap(pixmap) # self.ui.lbl_connectivity.show() elif(loc == "Column web-Beam web"): picmap = QtGui.QPixmap(":/newPrefix/images/beam.jpg") picmap.scaledToHeight(50) picmap.scaledToWidth(60) self.ui.lbl_connectivity.setPixmap(picmap) else: self.ui.lbl_connectivity.hide()
def __init__(self, Rebar = None): self.CustomSpacing = None if not Rebar: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] self.SelectedObj = selected_obj.Object self.FaceName = selected_obj.SubElementNames[0] else: self.FaceName = Rebar.Base.Support[0][1][0] self.SelectedObj = Rebar.Base.Support[0][0] self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("RebarAddon", "Stirrup Rebar", None)) self.form.bentAngle.addItems(["135", "90"]) self.form.amount_radio.clicked.connect(self.amount_radio_clicked) self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked) self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0]+"/icons/Stirrup.svg")) self.form.customSpacing.clicked.connect(lambda: runRebarDistribution(self)) self.form.removeCustomSpacing.clicked.connect(lambda: removeRebarDistribution(self)) self.form.PickSelectedFace.clicked.connect(lambda: getSelectedFace(self)) self.form.toolButton.setIcon(self.form.toolButton.style().standardIcon(QtGui.QStyle.SP_DialogHelpButton)) self.form.toolButton.clicked.connect(lambda: showPopUpImageDialog(os.path.split(os.path.abspath(__file__))[0] + "/icons/StirrupDetailed.svg")) self.Rebar = Rebar
def __init__(self, Rebar = None): self.CustomSpacing = None if not Rebar: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] self.SelectedObj = selected_obj.Object self.FaceName = selected_obj.SubElementNames[0] else: self.FaceName = Rebar.Base.Support[0][1][0] self.SelectedObj = Rebar.Base.Support[0][0] self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("RebarAddon", "L-Shape Rebar", None)) self.form.orientation.addItems(["Bottom Right", "Bottom Left", "Top Right", "Top Left"]) self.form.amount_radio.clicked.connect(self.amount_radio_clicked) self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked) self.form.customSpacing.clicked.connect(lambda: runRebarDistribution(self)) self.form.removeCustomSpacing.clicked.connect(lambda: removeRebarDistribution(self)) self.form.PickSelectedFace.clicked.connect(lambda: getSelectedFace(self)) self.form.orientation.currentIndexChanged.connect(self.getOrientation) self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarBR.svg")) self.form.toolButton.setIcon(self.form.toolButton.style().standardIcon(QtGui.QStyle.SP_DialogHelpButton)) self.form.toolButton.clicked.connect(lambda: showPopUpImageDialog(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarDetailed.svg")) self.Rebar = Rebar
def __init__(self, Rebar = None): self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("Arch", "Helical Rebar", None)) if not Rebar: normal = facenormalDirection() else: normal = facenormalDirection(Rebar.Base.Support[0][0], Rebar.Base.Support[0][1][0]) if not round(normal.z) in {1, -1}: self.form.topCoverLabel.setText(translate("RebarAddon", "Left Cover")) self.form.bottomCoverLabel.setText(translate("RebarAddon", "Right Cover")) self.form.PickSelectedFace.clicked.connect(self.getSelectedFace) self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/HelicalRebar.svg")) self.form.toolButton.clicked.connect(lambda: showPopUpImageDialog(os.path.split(os.path.abspath(__file__))[0] + "/icons/HelicalRebarDetailed.svg")) self.form.toolButton.setIcon(self.form.toolButton.style().standardIcon(QtGui.QStyle.SP_DialogHelpButton)) self.Rebar = Rebar self.SelectedObj = None self.FaceName = None
def __init__(self, Rebar = None): self.CustomSpacing = None if not Rebar: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] self.SelectedObj = selected_obj.Object self.FaceName = selected_obj.SubElementNames[0] else: self.FaceName = Rebar.Base.Support[0][1][0] self.SelectedObj = Rebar.Base.Support[0][0] self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("RebarAddon", "U-Shape Rebar", None)) self.form.orientation.addItems(["Bottom", "Top", "Right", "Left"]) self.form.amount_radio.clicked.connect(self.amount_radio_clicked) self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked) self.form.customSpacing.clicked.connect(lambda: runRebarDistribution(self)) self.form.removeCustomSpacing.clicked.connect(lambda: removeRebarDistribution(self)) self.form.PickSelectedFace.clicked.connect(lambda: getSelectedFace(self)) self.form.orientation.currentIndexChanged.connect(self.getOrientation) self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/UShapeRebarBottom.svg")) self.form.toolButton.setIcon(self.form.toolButton.style().standardIcon(QtGui.QStyle.SP_DialogHelpButton)) self.form.toolButton.clicked.connect(lambda: showPopUpImageDialog(os.path.split(os.path.abspath(__file__))[0] + "/icons/UShapeRebarDetailed.svg")) self.Rebar = Rebar
def _new_graph(self): self._graph = QtGui.QPixmap(self.width(), self.height()) self._graph.fill(Qt.black)
def _new_reticle(self): self._reticle = QtGui.QPixmap(self.width(), self.height()) self._reticle.fill(Qt.transparent)
def __init__(self, *args, **kw): url = kw.pop('url', None) first = False if not url: url = "http://localhost:7070" path = os.path.join(get_path_prefix(), 'leap', 'authtoken') waiting = 20 while not os.path.isfile(path): if waiting == 0: # If we arrive here, something really messed up happened, # because touching the token file is one of the first # things the backend does, and this BrowserWindow # should be called *right after* launching the backend. raise NoAuthToken( 'No authentication token found!') time.sleep(0.1) waiting -= 1 token = open(path).read().strip() url += '#' + token first = True self.url = url self.closing = False super(QWebView, self).__init__(*args, **kw) self.setWindowTitle('Bitmask') self.bitmask_browser = NewPageConnector(self) if first else None self.loadPage(self.url) self.proxy = AppProxy(self) if first else None self.frame.addToJavaScriptWindowObject( "bitmaskApp", self.proxy) icon = QtGui.QIcon() icon.addPixmap( QtGui.QPixmap(":/mask-icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.setWindowIcon(icon)
def set_icon(self, icon): self.type_icon.setPixmap(QtGui.QPixmap(icon))
def set_icon(self, icon, width, height): self.icon.setPixmap(QtGui.QPixmap(icon).scaled(width, height, QtCore.Qt.KeepAspectRatio))
def __init__(self, parent=None): QtGui.QWizard.__init__(self, parent) self.setWindowTitle(u"Export PCB") self.setPixmap(QtGui.QWizard.LogoPixmap, QtGui.QPixmap(":/data/img/exportModel.png")) self.exportType = eagle() ### self.addPage(self.formatPliku()) self.addPage(self.exportUstawienia()) # self.listaFormatow.setCurrentRow(0) self.button(QtGui.QWizard.FinishButton).clicked.connect(self.export)
def __init__(self, parent=None): QtGui.QLabel.__init__(self, parent) # self.setPixmap(QtGui.QPixmap(':/data/img/user_profile.png')) self.setToolTip('Registration is necessary')
def __init__(self, parent=None): QtGui.QLabel.__init__(self, parent) # self.setPixmap(QtGui.QPixmap(':/data/img/arrow-forward.png'))
def images_loaded(self, result): self.midLabel.setText("Last submitted pack:") for (card, filename), label in zip(result, self.cardLabels): label.card = card if card.golden: res = QtGui.QMovie(filename) label.card_data = res label.setMovie(res) res.start() else: res = QtGui.QPixmap(filename) label.card_data = res label.setPixmap(res) label.show()
def additional_gui_setup(self): # Additional GUI setup self.graphicsView_banner.mouseDoubleClickEvent = MainWindow.banner_double_click self.setWindowTitle(__appname__) self.scene_banner = QtGui.QGraphicsScene() self.graphicsView_banner.setScene(self.scene_banner) self.scene_banner.addPixmap(QtGui.QPixmap(":images/banner.png")) self._path_message("", MainWindow.MSG_OK) self._avoid_message("", MainWindow.MSG_OK) self.lineEdit_source.setFocus() # Auto-completion system_list = self.nav.eve_db.system_name_list() for line_edit_field in [ self.lineEdit_source, self.lineEdit_destination, self.lineEdit_avoid_name, self.lineEdit_set_dest, ]: completer = QtGui.QCompleter(system_list, self) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) line_edit_field.setCompleter(completer) # Signals self.pushButton_eve_login.clicked.connect(self.btn_eve_login_clicked) self.pushButton_player_location.clicked.connect(self.btn_player_location_clicked) self.pushButton_find_path.clicked.connect(self.btn_find_path_clicked) self.pushButton_crest_config.clicked.connect(self.btn_crest_config_clicked) self.pushButton_trip_config.clicked.connect(self.btn_trip_config_clicked) self.pushButton_trip_get.clicked.connect(self.btn_trip_get_clicked) self.pushButton_avoid_add.clicked.connect(self.btn_avoid_add_clicked) self.pushButton_avoid_delete.clicked.connect(self.btn_avoid_delete_clicked) self.pushButton_avoid_clear.clicked.connect(self.btn_avoid_clear_clicked) self.pushButton_set_dest.clicked.connect(self.btn_set_dest_clicked) self.pushButton_reset.clicked.connect(self.btn_reset_clicked) self.lineEdit_source.returnPressed.connect(self.line_edit_source_return) self.lineEdit_destination.returnPressed.connect(self.line_edit_destination_return) self.lineEdit_avoid_name.returnPressed.connect(self.line_edit_avoid_name_return) self.lineEdit_set_dest.returnPressed.connect(self.btn_set_dest_clicked) self.tableWidget_path.itemSelectionChanged.connect(self.table_item_selection_changed)
def joinIconPaths(self): # Icon's aren't pathed properly if the CWD is somewhere else than the source folder, so... self.source_dir = os.path.dirname( os.path.realpath(__file__) ) # Join all the icons and reload them icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/CINAlogo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.MainWindow.setWindowIcon(icon) self.label_2.setPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/CINAlogo.png"))) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/folder.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbOpenCachePath.setIcon(icon1) self.tbOpenQsubHeader.setIcon(icon1) self.tbGautoOpenTemplate.setIcon(icon1) self.ui_FileLocDialog.tbOpenGainRefPath.setIcon(icon1) self.ui_FileLocDialog.tbOpenFiguresPath.setIcon(icon1) self.ui_FileLocDialog.tbOpenInputPath.setIcon(icon1) self.ui_FileLocDialog.tbOpenOutputPath.setIcon(icon1) self.ui_FileLocDialog.tbOpenRawPath.setIcon(icon1) self.ui_FileLocDialog.tbOpenSumPath.setIcon(icon1) self.ui_FileLocDialog.tbOpenAlignPath.setIcon(icon1) self.ui_OrienGainRefDialog.tbOrientGain_GainRef.setIcon(icon1) self.ui_OrienGainRefDialog.tbOrientGain_TargetStack.setIcon(icon1) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/go-next.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbRun.setIcon(icon2) icon3 = QtGui.QIcon() icon3.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/process-stop.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbKillAll.setIcon(icon3) icon4 = QtGui.QIcon() icon4.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/user-trash.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbDeleteFile.setIcon(icon4) icon5 = QtGui.QIcon() icon5.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/boxes.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbParticlePick.setIcon(icon5) icon6 = QtGui.QIcon() icon6.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/view-refresh.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbReprocess.setIcon(icon6)
def joinIconPaths(self): # Icon's aren't pathed properly if the CWD is somewhere else than the source folder, so... self.source_dir = os.path.dirname( os.path.realpath(__file__) ) # Join all the icons and reload them icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/application-resize.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbPopoutView.setIcon(icon) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/monitor-dead.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon1.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/monitor-live.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) self.tbLive.setIcon(icon1) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/color.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbChangeColormap.setIcon(icon2) icon3 = QtGui.QIcon() icon3.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/colorbar.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbToggleColorbar.setIcon(icon3) icon4 = QtGui.QIcon() icon4.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/magnifier-zoom-in.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbZoomIn.setIcon(icon4) icon5 = QtGui.QIcon() icon5.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/magnifier-zoom-out.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbZoomOut.setIcon(icon5) icon6 = QtGui.QIcon() icon6.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/boxes.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbShowBoxes.setIcon(icon6) icon7 = QtGui.QIcon() icon7.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/logscale.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbLogIntensity.setIcon(icon7) icon8 = QtGui.QIcon() icon8.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/histogram.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbToggleHistogramContrast.setIcon(icon8) icon9 = QtGui.QIcon() icon9.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/arrow-180.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbPrevImage.setIcon(icon9) icon10 = QtGui.QIcon() icon10.addPixmap(QtGui.QPixmap(os.path.join( self.source_dir, "icons/arrow.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.tbNextImage.setIcon(icon10)
def __init__(self): super(SplashScreen, self).__init__(QtGui.QPixmap(pathjoin(config.RESOURCES, "tray_icon.png")), QtCore.Qt.WindowStaysOnTopHint) # ??????? # ?? fade =1 ?? fade= 2 ??? t sleep ?? ??
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(680, 403) self.gridLayout = QtGui.QGridLayout(Dialog) self.gridLayout.setObjectName("gridLayout") self.labelVersion = QtGui.QLabel(Dialog) self.labelVersion.setObjectName("labelVersion") self.gridLayout.addWidget(self.labelVersion, 0, 0, 1, 1) self.labelSupport = QtGui.QLabel(Dialog) self.labelSupport.setObjectName("labelSupport") self.gridLayout.addWidget(self.labelSupport, 1, 0, 1, 1) self.labelLicense = QtGui.QLabel(Dialog) self.labelLicense.setObjectName("labelLicense") self.gridLayout.addWidget(self.labelLicense, 2, 0, 1, 1) self.pushButton = QtGui.QPushButton(Dialog) self.pushButton.setText("") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/icon/mpowertcx icon flat.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.pushButton.setIcon(icon) self.pushButton.setIconSize(QtCore.QSize(256, 256)) self.pushButton.setFlat(True) self.pushButton.setObjectName("pushButton") self.gridLayout.addWidget(self.pushButton, 3, 1, 1, 1) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 4, 1, 1, 1) self.licenseEdit = QtGui.QPlainTextEdit(Dialog) self.licenseEdit.setFrameShape(QtGui.QFrame.Box) self.licenseEdit.setReadOnly(True) self.licenseEdit.setObjectName("licenseEdit") self.gridLayout.addWidget(self.licenseEdit, 3, 0, 2, 1) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(True) self.buttonBox.setObjectName("buttonBox") self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 2) self.retranslateUi(Dialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(756, 395) self.gridLayout = QtGui.QGridLayout(Dialog) self.gridLayout.setObjectName("gridLayout") self.labelVersion = QtGui.QLabel(Dialog) self.labelVersion.setObjectName("labelVersion") self.gridLayout.addWidget(self.labelVersion, 0, 0, 1, 1) self.labelSupport = QtGui.QLabel(Dialog) self.labelSupport.setObjectName("labelSupport") self.gridLayout.addWidget(self.labelSupport, 1, 0, 1, 1) self.labelLicense = QtGui.QLabel(Dialog) self.labelLicense.setObjectName("labelLicense") self.gridLayout.addWidget(self.labelLicense, 2, 0, 1, 1) self.pushButton = QtGui.QPushButton(Dialog) self.pushButton.setText("") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/icon/mpowertcx icon flat.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.pushButton.setIcon(icon) self.pushButton.setIconSize(QtCore.QSize(256, 256)) self.pushButton.setFlat(True) self.pushButton.setObjectName("pushButton") self.gridLayout.addWidget(self.pushButton, 3, 1, 1, 1) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 4, 1, 1, 1) self.licenseEdit = QtGui.QPlainTextEdit(Dialog) self.licenseEdit.setFrameShape(QtGui.QFrame.NoFrame) self.licenseEdit.setReadOnly(True) self.licenseEdit.setObjectName("licenseEdit") self.gridLayout.addWidget(self.licenseEdit, 3, 0, 2, 1) self.buttonBox = QtGui.QDialogButtonBox(Dialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.buttonBox.setCenterButtons(True) self.buttonBox.setObjectName("buttonBox") self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 2) self.retranslateUi(Dialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog)
def set_bg_image(self): self.bgimage = QtGui.QPixmap("images/bg.png").scaled(self.size(), transformMode=QtCore.Qt.SmoothTransformation) palette = QtGui.QPalette() palette.setBrush(QtGui.QPalette.Window,self.bgimage) self.setPalette(palette)
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()
def showImg(self,label,img): if len(img.shape) == 2: img = cv2.applyColorMap(img, cv2.COLORMAP_JET) img = cv2.resize(img, (512, 512),cv2.INTER_AREA) height, width, byteValue = img.shape byteValue = byteValue * width timg = img.copy() image = QtGui.QImage(timg.data, width, height,byteValue, QtGui.QImage.Format_RGB888) label.setPixmap(QtGui.QPixmap(image).scaled(label.size(),aspectMode=QtCore.Qt.KeepAspectRatio)) """ visualize function from https://github.com/BVLC/caffe/blob/master/examples/00-classification.ipynb """
def vis_square(self, data): """Take an array of shape (n, height, width) or (n, height, width, 3) and visualize each (height, width) thing in a grid of size approx. sqrt(n) by sqrt(n)""" print "Data Shape : ", data.shape # normalize data for display data = (data - data.min()) / (data.max() - data.min()) # force the number of filters to be square n = int(np.ceil(np.sqrt(data.shape[0]))) padding = (((0, n ** 2 - data.shape[0]), (0, 1), (0, 1)) # add some space between filters + ((0, 0),) * (data.ndim - 3)) # don't pad the last dimension (if there is one) data = np.pad(data, padding, mode='constant', constant_values=0) # pad with ones (white) # tile the filters into an image data = data.reshape((n, n) + data.shape[1:]).transpose((0, 2, 1, 3) + tuple(range(4, data.ndim + 1))) data = data.reshape((n * data.shape[1], n * data.shape[3]) + data.shape[4:]) # show at display #print 'Data shape : ', data.shape , len(data.shape) img = 255 * data img = cv2.resize(img, (512, 512)) img = np.array(img, dtype='uint8') img_c = cv2.applyColorMap(img, cv2.COLORMAP_JET) height, width, byteValue = img_c.shape byteValue = byteValue * width self.image = QtGui.QImage(img_c.data, width, height, byteValue, QtGui.QImage.Format_RGB888) self.ui.labelDisplay.setPixmap(QtGui.QPixmap(self.image))
def tm_make_preview_ui(self): self.makePreviewDialog = QtGui.QDialog(self) self.makePreviewDialog.setModal(True) #self.makePreviewDialog.resize(300, 300) self.makePreviewDialog.setWindowTitle(('Make Preview: /// ' + self.current_task['asset'])) # add widgets v_layout = QtGui.QVBoxLayout() # -- image Label self.makePreviewDialog.imageLabel = QtGui.QLabel() self.makePreviewDialog.imageLabel.setFixedSize(300,300) v_layout.addWidget(self.makePreviewDialog.imageLabel) # -- button h__layout = QtGui.QHBoxLayout() button_frame = QtGui.QFrame(parent = self.makePreviewDialog) cansel_button = QtGui.QPushButton('Cansel', parent = button_frame) h__layout.addWidget(cansel_button) paste_button = QtGui.QPushButton('Paste', parent = button_frame) h__layout.addWidget(paste_button) save_button = QtGui.QPushButton('Save', parent = button_frame) h__layout.addWidget(save_button) button_frame.setLayout(h__layout) v_layout.addWidget(button_frame) self.makePreviewDialog.setLayout(v_layout) # connect buttons cansel_button.clicked.connect(partial(self.close_window, self.makePreviewDialog)) paste_button.clicked.connect(partial(self.tm_paste_image_from_clipboard, self.makePreviewDialog.imageLabel)) save_button.clicked.connect(partial(self.tm_save_preview_image_action, self.makePreviewDialog)) # -- load img to label img_path = os.path.join(self.db_chat.preview_img_path, (self.current_task['asset'] + '.png')) if not os.path.exists(img_path): self.makePreviewDialog.imageLabel.setText('No Image') else: image = QtGui.QImage(img_path) self.makePreviewDialog.imageLabel.setPixmap(QtGui.QPixmap.fromImage(image)) self.makePreviewDialog.show()
def tm_paste_image_from_clipboard(self, img_label): rand = hex(random.randint(0, 1000000000)).replace('0x', '') img_path = os.path.normpath(os.path.join(self.db_chat.tmp_folder, ('tmp_image_' + rand + '.png'))) clipboard = QtGui.QApplication.clipboard() img = clipboard.image() if img: img.save(img_path) cmd = '%s %s -resize 300 %s' % (os.path.normpath(self.db_chat.convert_exe), img_path, img_path) cmd2 = '%s %s -resize 300x300 %s' % (os.path.normpath(self.db_chat.convert_exe), img_path, img_path) cmd3 = '\"%s\" \"%s\" -resize 300 \"%s\"' % (os.path.normpath(self.db_chat.convert_exe), img_path, img_path) print(cmd) print(cmd2) print(cmd3) try: os.system(cmd) except: try: os.system(cmd2) except: try: os.system(cmd3) except: return(False, 'in tm_paste_image_from_clipboard - problems with conversion resize.png') else: self.message('Cannot Image!', 2) return(False, 'Cannot Image!') image = QtGui.QImage(img_path) img_label.setPixmap(QtGui.QPixmap.fromImage(image)) self.makePreviewDialog.img_path = img_path
def tm_save_preview_image_action(self, window): # self.preview_img_path if not os.path.exists(self.db_chat.preview_img_path): try: os.mkdir(self.db_chat.preview_img_path) except: print(self.db_chat.preview_img_path) # copyfile save_path = os.path.join(self.db_chat.preview_img_path, (self.current_task['asset'] + '.png')) icon_path = os.path.join(self.db_chat.preview_img_path, (self.current_task['asset'] + '_icon.png')) tmp_icon_path = window.img_path.replace('.png','_icon.png') # -- copy shutil.copyfile(window.img_path, save_path) # -- resize cmd = '%s %s -resize 100 %s' % (os.path.normpath(self.db_chat.convert_exe), window.img_path, tmp_icon_path) cmd2 = '%s %s -resize 100x100 %s' % (os.path.normpath(self.db_chat.convert_exe), window.img_path, tmp_icon_path) cmd3 = '\"%s\" \"%s\" -resize 100 \"%s\"' % (os.path.normpath(self.db_chat.convert_exe), window.img_path, tmp_icon_path) try: os.system(cmd) except: try: os.system(cmd2) except: try: os.system(cmd3) except: self.message('problems with conversion _icon.png', 2) return(False, 'in tm_save_preview_image_action - problems with conversion resize.png') shutil.copyfile(tmp_icon_path, icon_path) # load to preview image_label image = QtGui.QImage(save_path) self.myWidget.image_label.setPixmap(QtGui.QPixmap.fromImage(image)) self.close_window(window) # ------ show tz ------------
def setupLabelIcons(self): self.ui.label_highslot_icon.setPixmap(QtGui.QPixmap(":img/slot_high_small.png")) self.ui.label_midslot_icon.setPixmap(QtGui.QPixmap(":img/slot_med_small.png")) self.ui.label_lowslot_icon.setPixmap(QtGui.QPixmap(":img/slot_low_small.png")) self.ui.label_rig_icon.setPixmap(QtGui.QPixmap(":img/slot_rig_small.png")) self.ui.label_subsystem_icon.setPixmap(QtGui.QPixmap(":img/slot_subsystem_small.png"))
def __init__(self, parent=None): super(InstructionDialog, self).__init__(parent) self.setupUi(self) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":img/icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.setWindowIcon(icon) self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.pushButton_OK.clicked.connect(self.close)
def __init__(self, scene=None, import_data=None, load_file=None): QtGui.QApplication.__init__(self, ['Spool']) # self.setStyle('plastique') splash_img = QtGui.QPixmap(get_resource('spool_splash.png'))\ .scaled(QtCore.QSize(400, 250), QtCore.Qt.KeepAspectRatio) self.splash = QtGui.QSplashScreen( splash_img, QtCore.Qt.WindowStaysOnTopHint) self.updateSplashMessage('Scene') self.splash.show() self.processEvents() self.spool_win = SpoolMainWindow() self.spool_win.sigLoadingModule.connect(self.updateSplashMessage) self.spool_win.actionExit.triggered.connect(self.exit) self.aboutToQuit.connect(self.spool_win.model.worker_thread.quit) self.aboutToQuit.connect(self.spool_win.model.deleteLater) self.aboutToQuit.connect(self.splash.deleteLater) self.aboutToQuit.connect(self.deleteLater) if scene is not None: self.addScene(scene) if import_data is not None: self.importScene(import_data) if load_file is not None: self.loadScene(load_file) self.splash.finish(self.spool_win) self.spool_win.show() rc = self.exec_() sys.exit(rc)
def refresh_images(self): try: r = requests.get(self.cur_img) except: return None if r.status_code == 200: pixmap = QtGui.QPixmap() pixmap.loadFromData(r.content) pixmap.scaledToWidth(self.preview_size) pixmap.scaledToHeight(self.preview_size) self.img.setPixmap(pixmap) self.img.update() self.repaint() r.close() data = self.db.get(self.cur_vid) self.setWindowTitle(data["name"]) info_str = "dur: {}\n\nviews: {}\n\nprediction: {}\n\ntags: {}" n_tags = 15 tag_str = "" if data["tags"]: tags = [tag for tag in data["tags"] if len(tag) > 2] tags = tags[:min(n_tags, len(data["tags"]))] for tag in tags: tag_str += "\n" + tag info_str = info_str.format(data["dur"], data["views"], # old design had an out of 6 scale round(self.last_pred, 2), tag_str) self.info_box.setText(info_str)
def showWordCloud(self): wordcloud = WordCloud(width=800, height=400).generate(self.fullText) img = np.array(wordcloud.to_image()) height, width, byteValue = img.shape byteValue = byteValue * width image = QtGui.QImage(img.data, width, height, byteValue, QtGui.QImage.Format_RGB888) pxmp = QtGui.QPixmap(image) self.label.setPixmap(pxmp)
def updateShotThumbnail(self,*args): if not os.path.exists(self.thumbsPath): os.makedirs(self.thumbsPath) availthumbs=os.listdir(self.thumbsPath) if self.selShot+".jpg" in availthumbs: self.iconLabel.setPixmap(QtGui.QPixmap(self.thumbsPath+'/'+self.selShot+'.jpg')) else: self.iconLabel.setPixmap('')
def getOrientation(self): orientation = self.form.orientation.currentText() if orientation == "Bottom Right": self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarBR.svg")) elif orientation == "Bottom Left": self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarBL.svg")) elif orientation == "Top Right": self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarTR.svg")) else: self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarTL.svg"))
def __init__(self, Rebar = None): self.CustomSpacing = None if not Rebar: selected_obj = FreeCADGui.Selection.getSelectionEx()[0] self.SelectedObj = selected_obj.Object self.FaceName = selected_obj.SubElementNames[0] else: self.FaceName = Rebar.Base.Support[0][1][0] self.SelectedObj = Rebar.Base.Support[0][0] self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("RebarAddon", "Straight Rebar", None)) self.form.orientation.addItems(["Horizontal", "Vertical"]) self.form.coverAlong.addItems(["Bottom Side", "Top Side"]) self.form.amount_radio.clicked.connect(self.amount_radio_clicked) self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked) self.form.customSpacing.clicked.connect(lambda: runRebarDistribution(self)) self.form.removeCustomSpacing.clicked.connect(lambda: removeRebarDistribution(self)) self.form.PickSelectedFace.setCheckable(True) self.form.PickSelectedFace.toggle() self.form.PickSelectedFace.clicked.connect(lambda: getSelectedFace(self)) self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/StraightRebarH.svg")) self.form.orientation.currentIndexChanged.connect(self.changeOrientation) self.form.coverAlong.currentIndexChanged.connect(self.changeCoverAlong) self.form.toolButton.setIcon(self.form.toolButton.style().standardIcon(QtGui.QStyle.SP_DialogHelpButton)) self.form.toolButton.clicked.connect(lambda: showPopUpImageDialog(os.path.split(os.path.abspath(__file__))[0] + "/icons/StraightRebarDetailed.svg")) self.Rebar = Rebar
def changeOrientation(self): orientation = self.form.orientation.currentText() if orientation == "Horizontal": self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/StraightRebarH.svg")) self.form.r_sideCoverLabel.setText("Right Side Cover") self.form.l_sideCoverLabel.setText("Left Side Cover") self.form.coverAlong.clear() self.form.coverAlong.addItems(["Bottom Side", "Top Side"]) else: self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/StraightRebarV.svg")) self.form.r_sideCoverLabel.setText("Top Side Cover") self.form.l_sideCoverLabel.setText("Bottom Side Cover") self.form.coverAlong.clear() self.form.coverAlong.addItems(["Right Side", "Left Side"])
def getOrientation(self): orientation = self.form.orientation.currentText() #if orientation == "Bottom": # self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarBR.svg")) #elif orientation == "Top": # self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarBL.svg")) #elif orientation == "Right": # self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarTR.svg")) #else: # self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/LShapeRebarTL.svg"))
def __init__(self, frontCover, size): self.FrontCover = frontCover self.ExpandingLength = size self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("Arch", "Rebar Distribution", None)) self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/RebarDistribution.svg"))
def getOrientation(self): orientation = self.form.orientation.currentText() if orientation == "Bottom": self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/UShapeRebarBottom.svg")) elif orientation == "Top": self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/UShapeRebarTop.svg")) elif orientation == "Right": self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/UShapeRebarRight.svg")) else: self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/UShapeRebarLeft.svg"))
def startCapture(self): global currentSecond global delayVideoData #cap = self.capturer num = 0 while(self.capturing): while (self.paused and self.capturing): time.sleep(0.05) prevTime = datetime.now() if (self.frameNumberChanged): newFrameNumber = int(self.sliderVideoFrame.value()*30) num = newFrameNumber self.frameNumber = newFrameNumber self.frameNumberChanged = False frame = self.videoReader.get_data(num) num = num+1 if (num >= self.videoReader.get_length()): self.frameNumberChanged=True self.sliderVideoFrame.setValue(0) self.start_button.setText('Start') self.video_thread = False self.capturing = False break self.frameNumber = num currentSecond = self.frameNumber/fps #valor importante para sync datos self.labelCurrentVideoSecond.setText("{0:.1f}".format(currentSecond - delayVideoToData)) if (self.sliderWasReleased): self.sliderVideoFrame.setValue(int(self.frameNumber/fps)) #Convert opencv mat to QImage: imageQ = QtGui.QImage(frame.tostring(), frame.shape[1], frame.shape[0], QtGui.QImage.Format_RGB888) if (frame.shape[1] != videowidthShow or frame.shape[0] != videoheightShow): imageQ = imageQ.scaled(videowidthShow, videoheightShow) #resize image to fit #Convert QImage to pixmap: pixmap = QtGui.QPixmap.fromImage(imageQ) #Set pixmap to label: #self.labelImage.setPixmap(pixmap) #old mode, cuidado porque es un thread outside the GUI, esto da problemas en pyqt self.signalUpdatePixmap.emit(pixmap) #nuevo mode para evitar esos problemas self.updateScoreLabels() diftime = ((datetime.now()-prevTime).microseconds)/1000000.0 #print (diftime) #print(1/fps - diftime ) if (diftime < 1/fps): time.sleep (1/fps - diftime) else: time.sleep(0.01) app.processEvents() #prevents app from crashing because of lack of responsiveness