Пример #1
0
 def sizeHint(self):
     self.ensurePolished()
     width = self.style().pixelMetric(
         QtWidgets.QStyle.PM_TabCloseIndicatorWidth, None, self)
     height = self.style().pixelMetric(
         QtWidgets.QStyle.PM_TabCloseIndicatorHeight, None, self)
     return QtCore.QSize(width, height)
Пример #2
0
    def sizeHint(self, option, index):
        text = index.data()
        fontmetrics = option.fontMetrics

        try:
            get_width = fontmetrics.horizontalAdvance
        except AttributeError:
            # python 2.7 & earlier versions of PySide2
            get_width = fontmetrics.width

        width = get_width(text)

        column_width = self.column_width
        chars_per_line = 250
        while (width > column_width) and (chars_per_line > 10):
            width = get_width(text, chars_per_line)
            chars_per_line -= 10

        num_lines = math.ceil(len(text) / chars_per_line) + 0.5
        height = fontmetrics.height()
        height *= num_lines

        size = QtCore.QSize()
        size.setWidth(width)
        size.setHeight(height)

        # FIXME: the below causes recursion. we do want to figure out a way
        # to have the row height adjusted though. this just isn't it yet.
        # index.model().setData(index, size, QtCore.Qt.SizeHintRole)
        # index.model().dataChanged.emit(index, index)

        return size
Пример #3
0
    def setup_new_tab_btn(self):
        """
        Adds a new tab [+] button to the right of the tabs.
        """
        widget = QtWidgets.QWidget()
        widget.setObjectName('Tab_Widget_New_Button')
        self.insertTab(0, widget, '')
        nb = self.new_btn = QtWidgets.QToolButton()
        nb.setMinimumSize(QtCore.QSize(50, 10))
        nb.setText('+')  # you could set an icon instead of text
        nb.setAutoRaise(True)
        nb.clicked.connect(self.new_tab)

        tabBar = self.tabBar()
        tabBar.setTabButton(0, QtWidgets.QTabBar.RightSide, nb)
        tabBar.setTabEnabled(0, False)
Пример #4
0
 def sizeHint(self):
     return QtCore.QSize(self.lineNumberAreaWidth(), 0)
Пример #5
0
anim2 = QtCore.QPropertyAnimation(popup_bar, 'maximumHeight')
#anim2.setStartValue(popup_bar.maximumHeight())
anim2.setStartValue(46)
anim2.setEndValue(0)
anim2.setDuration(500)
from functools import partial
start = partial(QtCore.QTimer.singleShot, 1200, anim2.start)
anim.finished.connect(start)

#anim2.finished.connect(popup_bar.deleteLater)

#&&

anim = QtCore.QPropertyAnimation(popup_bar, 'size')
anim.setStartValue(QtCore.QSize(958, 0))
anim.setEndValue(QtCore.QSize(958, 46))
anim.setDuration(300)
anim.start()

#&&
item.geometry()
item.setGeometry(QtCore.QRect(0,0,958,0))
layout.setSpacing(0)
#layout.setSizeConstraint(layout.SetFixedSize)
layout.setSizeConstraint(layout.SetNoConstraint)
layout.setSizeConstraint(layout.SetDefaultConstraint)
#&&
anim = QtCore.QPropertyAnimation(popup_bar, 'height')
anim.setStartValue(0)
anim.setEndValue(246)