def __init__(self, *args): """ Initialize and configure the button widget """ Widgets.FilterablePopupButton.__init__(self, *args) self.setFixedHeight(24) self.setFlat(False) self.setSorting(False) QtCore.QObject.connect(self, QtCore.SIGNAL('aboutToShow'), self.__on_aboutToShow) QtCore.QObject.connect(self, QtCore.SIGNAL('itemChosen'), self.__on_itemChosen) self.__pathToDisplayInfo = {} self.__pixmaps = \ {'camera': QtGui.QPixmap(ScenegraphIconManager.GetPixmap('camera')), 'light': QtGui.QPixmap(ScenegraphIconManager.GetPixmap('light'))} self.__scenegraphPixmap = None # Argument is reference to the widget which allows us to get the node if args[0]: self.__node = args[0].getNode() # displayMode will be set to either <DISPLAY_LIGHTS, DISPLAY_CAMERAS, # DISPLAY_LIGHTS | DISPLAY_CAMERAS> if the mode is # DISPLAY_LIGHTS | DISPLAY_CAMERAS, then this indicates that the button # is the big center one at the bottom of the viewports. It will draw # the camera/light name in text, rather than pixmaps as its icon. self.__displayMode = 0 self.setAcceptDrops(True)
def create(self): widget = QtGui.QWidget() widget_a = QtGui.QWidget() widget_b = QtGui.QWidget() palette = widget.palette() palette.setColor(widget.backgroundRole(), QtGui.QColor(0.14 * 255, 0.14 * 255, 0.14 * 255)) widget.setPalette(palette) layout = QtGui.QVBoxLayout(widget) layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) layout_a = QtGui.QVBoxLayout(widget_a) layout_b = QtGui.QVBoxLayout(widget_b) layout_a.setContentsMargins(10, 10, 10, 10) layout_b.setContentsMargins(10, 10, 10, 10) widget_line = QtGui.QFrame() widget_line.setFrameShape(QtGui.QFrame.HLine) widget_line.setFrameShadow(QtGui.QFrame.Sunken) layout.addWidget(widget_a) layout.addWidget(widget_line) layout.addWidget(widget_b) self.pre_shot_image = kImageWidget() pre_shot_image_path = os.path.join(_iconsDir, "no-image.svg") pixmap = QtGui.QPixmap(pre_shot_image_path) self.pre_shot_image.setPixmap(pixmap) self.post_shot_image = kImageWidget() post_shot_image_path = os.path.join(_iconsDir, "no-image.svg") pixmap = QtGui.QPixmap(post_shot_image_path) self.post_shot_image.setPixmap(pixmap) self.pre_shot_label = QtGui.QLabel() self.pre_shot_label.setFont( QtGui.QFont("Rome times", 6, QtGui.QFont.Bold)) self.pre_shot_label.setText( "<font color='white'>Pre Shot : None</font>") self.pre_shot_label.setAlignment(QtCore.Qt.AlignLeft) self.pre_shot_label.setGeometry(5, 5, 300, 100) self.pre_shot_label.setParent(self.pre_shot_image) self.post_shot_label = QtGui.QLabel() self.post_shot_label.setFont( QtGui.QFont("Rome times", 6, QtGui.QFont.Bold)) self.post_shot_label.setText( "<font color='white'>Post Shot : None</font>") self.post_shot_label.setAlignment(QtCore.Qt.AlignLeft) self.post_shot_label.setGeometry(5, 5, 300, 100) self.post_shot_label.setParent(self.post_shot_image) layout_a.addWidget(self.pre_shot_image) layout_b.addWidget(self.post_shot_image) return widget
def displayImage(self, filePath): """ Changes the image displayed by the widget. """ self.__filePath = filePath if self.__filePath: self.setPixmap(QtGui.QPixmap(self.__filePath))
def clicked_ok(self, ptr): pre_image = post_image = "" if self.pre_shot_widget.text(): image_list = getImageList(self.pre_shot_widget.text()) if self.pre_frame_widget.text(): for image in image_list: _temp = image[:-len(image.split(".")[-1])-1] if _temp.endswith(self.pre_frame_widget.text()): pre_image = image if os.path.isfile(pre_image): ptr._pre_shot_name = self.pre_shot_widget.text() ptr._pre_shot_frame = self.pre_frame_widget.text() break if self.post_shot_widget.text(): image_list = getImageList(self.post_shot_widget.text()) if self.post_frame_widget.text(): for image in image_list: _temp = image[:-len(image.split(".")[-1])-1] if _temp.endswith(self.post_frame_widget.text()): post_image = image if os.path.isfile(post_image): ptr._post_shot_name = self.post_shot_widget.text() ptr._post_shot_frame = self.post_frame_widget.text() break if os.path.isfile(pre_image): ptr.pre_shot_label.setText( "<font color='gray'>Pre Shot: %s</font>"%ptr._pre_shot_name) pre_shot_pixmap = QtGui.QPixmap(pre_image) ptr.pre_shot_image.setPixmap(pre_shot_pixmap) if os.path.isfile(post_image): ptr.post_shot_label.setText( "<font color='gray'>Post Shot: %s</font>"%ptr._post_shot_name) post_shot_pixmap = QtGui.QPixmap(post_image) ptr.post_shot_image.setPixmap(post_shot_pixmap) ptr.update();ptr.hide();ptr.show() self.close()
def init(ptr): current_proj,current_sequence,current_shot,shot_list = shotInit() if current_shot in shot_list: index = shot_list.index(current_shot) pre_index = post_index = index JUMP_A = JUMP_B = False MIN_INDEX = 0 MAX_INDEX = len(shot_list) -1 pre_shot = post_shot = None while True: if not JUMP_A and pre_index > MIN_INDEX: pre_index -= 1 if not JUMP_B and post_index < MAX_INDEX: post_index += 1 pre_shot = shot_list[pre_index] post_shot = shot_list[post_index] if doseImageExist(pre_shot): JUMP_A = True if doseImageExist(post_shot): JUMP_B = True if JUMP_A and JUMP_B: break if pre_index < MIN_INDEX and post_index > MAX_INDEX: pre_shot=post_shot=None;break if JUMP_A and post_index == MAX_INDEX: post_shot=None;break if pre_index == MIN_INDEX and JUMP_B: pre_index=None;break else: pre_shot = post_shot = None if pre_shot is not None: pre_shot_label = pre_shot pre_shot_image = getImageList(pre_shot)[0] else: pre_shot_label = None pre_shot_image = _iconsDir if post_shot is not None: post_shot_label = post_shot post_shot_image = getImageList(post_shot)[0] else: post_shot_label = None post_shot_image = _iconsDir ptr.pre_shot_label.setText( "<font color='gray'>Pre Shot: %s</font>"%pre_shot_label) pre_shot_pixmap = QtGui.QPixmap(pre_shot_image) ptr.pre_shot_image.setPixmap(pre_shot_pixmap) ptr.post_shot_label.setText( "<font color='gray'>Post Shot: %s</font>"%post_shot_label) post_shot_pixmap = QtGui.QPixmap(post_shot_image) ptr.post_shot_image.setPixmap(post_shot_pixmap) ptr._pre_shot_name = pre_shot_label ptr._post_shot_name = post_shot_label if pre_shot_label is not None: ptr._pre_shot_frame_range = getImageRange(pre_shot_label) ptr._pre_shot_frame = ptr._pre_shot_frame_range[0] if post_shot_label is not None: ptr._post_shot_frame_range = getImageRange(post_shot_label) ptr._post_shot_frame = ptr._post_shot_frame_range[0] ptr.update();ptr.hide();ptr.show()