Ejemplo n.º 1
0
    def setCameraInformation(self, cameraInfo):
        """Take the camera information, format and display it.

        Parameters
        ----------
        cameraInfo : OrderedDict
            The set of camera information to display.
        """
        lines = []
        max_width = 0
        max_height = len(cameraInfo.keys())
        for key, value in cameraInfo.items():
            lines.append(f'<p><b>{key}</b>: {value}</p>')
            max_width = max(max_width, len(key) + len(str(value)) + 2)

        fontMetrics = QFontMetrics(self.cameraInfoTextBrowser.font())

        scale_factor = 1.75

        browser_height = int(max_height * fontMetrics.lineSpacing() *
                             scale_factor)
        browser_width = max_width * fontMetrics.averageCharWidth()

        self.cameraInfoTextBrowser.setHtml(os.linesep.join(lines))

        if self.cameraInfoTextBrowser.minimumHeight() < browser_height:
            self.cameraInfoTextBrowser.setMinimumHeight(browser_height)
            self.cameraInfoTextBrowser.setMaximumHeight(browser_height)
        if self.cameraInfoTextBrowser.minimumWidth() < browser_width:
            self.cameraInfoTextBrowser.setMinimumWidth(browser_width)
            self.cameraInfoTextBrowser.setMaximumWidth(browser_width)
Ejemplo n.º 2
0
 def __init__ (self, font):
     basefont = font
     boldfont = QFont(basefont)
     boldfont.setBold(True)
     italicfont = QFont(basefont)
     italicfont.setItalic(True)
     self.basefont = basefont
     self.boldfont = boldfont
     self.italicfont = italicfont
     
     basemetrics = QFontMetrics(basefont)
     self.basemetrics = basemetrics
     baseem = basemetrics.height()
     baseen = baseem // 2
     
     boldmetrics = QFontMetrics(boldfont)
     self.boldheight = boldmetrics.height()
     
     nodemargin = baseen*3//5
     itemmargin = baseen//2
     activemargin = baseen*3//4
     selectmargin = activemargin//2
     self.nodemargin = nodemargin
     self.itemmargin = itemmargin
     self.activemargin = activemargin
     self.selectmargin = selectmargin
     self.shadowoffset = selectmargin
     
     self.nodemargins = QMarginsF(*(nodemargin,)*4)
     self.banknodemargins = QMarginsF(*(nodemargin//2,)*4)
     self.itemmargins = QMarginsF(*(itemmargin,)*4)
     self.activemargins = QMarginsF(*(selectmargin//2,)*4)
     self.selectmargins = QMarginsF(*(selectmargin//2,)*4)
     
     self.nodetextwidth = basemetrics.averageCharWidth()*40
     
     nodewidth = self.nodetextwidth + 2*(activemargin+nodemargin+itemmargin)
     self.nodewidth = nodewidth
     
     rankgap = 7*activemargin
     self.rankgap = rankgap
     self.rankwidth = rankgap + nodewidth
     
     rowgap = 3*activemargin
     self.rowgap = rowgap
     
     # Edge style
     self.pensize = self.shadowoffset
     self.arrowsize = self.pensize * 3.5
Ejemplo n.º 3
0
    def __init__(self,
                 *,
                 win_id: int,
                 private: bool,
                 parent: QWidget = None) -> None:
        misc.CommandLineEdit.__init__(self, parent=parent)
        misc.MinimalLineEditMixin.__init__(self)
        self._win_id = win_id
        if not private:
            command_history = objreg.get('command-history')
            self.history.history = command_history.data
            self.history.changed.connect(command_history.changed)
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)

        self.cursorPositionChanged.connect(self.update_completion)
        self.textChanged.connect(self.update_completion)
        self.textChanged.connect(self.updateGeometry)
        self.textChanged.connect(self._incremental_search)

        qfm = QFontMetrics(self.font())
        style = LineEditStyle(self.style(), 3 * qfm.averageCharWidth())
        self.setStyle(style)