当前位置: 首页>>代码示例>>Python>>正文


Python QPlainTextEdit.setFixedHeight方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QPlainTextEdit.setFixedHeight方法的典型用法代码示例。如果您正苦于以下问题:Python QPlainTextEdit.setFixedHeight方法的具体用法?Python QPlainTextEdit.setFixedHeight怎么用?Python QPlainTextEdit.setFixedHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QPlainTextEdit的用法示例。


在下文中一共展示了QPlainTextEdit.setFixedHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GalleryListEdit

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import setFixedHeight [as 别名]
class GalleryListEdit(misc.BasePopup):
    apply = pyqtSignal()
    def __init__(self, parent=None):
        super().__init__(parent, blur=False)
        main_layout = QFormLayout(self.main_widget)
        self.name_edit = QLineEdit(self)
        main_layout.addRow("Name:", self.name_edit)
        self.filter_edit = QPlainTextEdit(self)
        self.filter_edit.setPlaceholderText("tag1, namespace:tag2, namespace2:[tag1, tag2] ...")
        self.filter_edit.setFixedHeight(100)
        what_is_filter = misc.ClickedLabel("What is Filter/Enforce? (Hover)")
        what_is_filter.setToolTip(app_constants.WHAT_IS_FILTER)
        what_is_filter.setToolTipDuration(9999999999)
        self.enforce = QCheckBox(self)
        self.regex = QCheckBox(self)
        self.case = QCheckBox(self)
        self.strict = QCheckBox(self)
        main_layout.addRow(what_is_filter)
        main_layout.addRow("Filter", self.filter_edit)
        main_layout.addRow("Enforce", self.enforce)
        main_layout.addRow("Regex", self.regex)
        main_layout.addRow("Case sensitive", self.case)
        main_layout.addRow("Match whole terms", self.strict)
        main_layout.addRow(self.buttons_layout)
        self.add_buttons("Close")[0].clicked.connect(self.hide)
        self.add_buttons("Apply")[0].clicked.connect(self.accept)
        old_v = self.width()
        self.adjustSize()
        self.resize(old_v, self.height())

    def set_list(self, gallery_list, item):
        self.gallery_list = gallery_list
        self.name_edit.setText(gallery_list.name)
        self.enforce.setChecked(gallery_list.enforce)
        self.regex.setChecked(gallery_list.regex)
        self.case.setChecked(gallery_list.case)
        self.strict.setChecked(gallery_list.strict)
        self.item = item
        if gallery_list.filter:
            self.filter_edit.setPlainText(gallery_list.filter)
        else:
            self.filter_edit.setPlainText('')

    def accept(self):
        name = self.name_edit.text()
        self.item.setText(name)
        self.gallery_list.name = name
        self.gallery_list.filter = self.filter_edit.toPlainText()
        self.gallery_list.enforce = self.enforce.isChecked()
        self.gallery_list.regex = self.regex.isChecked()
        self.gallery_list.case = self.case.isChecked()
        self.gallery_list.strict = self.strict.isChecked()
        gallerydb.execute(gallerydb.ListDB.modify_list, True, self.gallery_list)
        self.apply.emit()
        self.hide()
开发者ID:Pewpews,项目名称:happypanda,代码行数:57,代码来源:misc_db.py

示例2: DialogSqlQuery

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import setFixedHeight [as 别名]
class DialogSqlQuery(QDialog):
    """
    Dialog for Sql query
    """
    # Slots
    @pyqtSlot()
    def __populate_select_template(self):
        self.__sql_input.setPlainText(self.__db_access.compose_select(self.__db_name,
                                                                      self.__table_name,
                                                                      self.__columns,
                                                                      self.__columns[0]))

    @pyqtSlot()
    def __populate_update_template(self):
        self.__sql_input.setPlainText(self.__db_access.compose_update(self.__db_name,
                                                                      self.__table_name,
                                                                      self.__columns))

    @pyqtSlot()
    def __execute_query(self):
        sql = self.__sql_input.toPlainText()
        if sql == '':
            return
        #self.__action_dict[[p for p in sql.split(' ') if p != ''][0]]()
        #self.__output.model().setColumnCount(len(self.__columns))
        #for (i, v) in zip(range(len(self.__columns)), self.__columns):
        #    self.__output.model().setHeaderData(i, Qt.Horizontal, v)
        lst = self.__db_access.query(sql)
        #for values in lst:
        #    items = []
        #    for v in values:
        #        items.append(QStandardItem(str(v)))
        #    self.__output.model().appendRow(items)

    @pyqtSlot()
    def __clear_query_input(self):
        self.__sql_input.clear()

    @pyqtSlot()
    def __populate_delete_template(self):
        self.__sql_input.setPlainText(self.__db_access.compose_delete(self.__db_name, self.__table_name))

    @pyqtSlot()
    def __populate_insert_template(self):
        self.__sql_input.setPlainText(self.__db_access.compose_insert(self.__db_name, self.__table_name, self.__columns))

    @staticmethod
    def none_to_space(s=None) -> str:
        if s is None:
            return ' '
        return s

    def __init__(self, db_access, table_name, db_name, columns):
        super().__init__()
        self.__init_consts()
        self.__init_ui()
        self.__db_access = db_access
        self.__table_name = self.none_to_space(table_name)
        self.__db_name = self.none_to_space(db_name)
        self.__columns = self.none_to_space(columns)
        self.__setup_output_creation()

    def __setup_output_creation(self) -> {dict}:
        return {
            self.__SELECT: self.__create_treeview_output,
            self.__UPDATE: self.__create_plaintext_output,
            self.__DELETE: self.__create_plaintext_output,
            self.__INSERT: self.__create_plaintext_output
        }

    def __create_treeview_output(self):
        self.__output = QTableView()
        self.__output.setModel(QStandardItemModel())

    def __create_plaintext_output(self):
        self.__output = QPlainTextEdit()

    def __init_consts(self):
        self.__LBL_SQL_QUERY= QLabel('SQL: ')
        self.__LBL_SQL_TEMPLATES = QLabel('Templates: ')
        self.__TITLE = 'SQL Query'
        self.__GO = 'Go'
        self.__CLEAR = 'Clear'
        self.__CANCEL = 'Cancel'
        self.__SELECT = 'SELECT'
        self.__UPDATE = 'UPDATE'
        self.__DELETE = 'DELETE'
        self.__INSERT = 'INSERT'
        self.__WIDTH = 800
        self.__HEIGHT = 600
        self.__SQL_INPUT_HEIGHT = 100

    def __init_ui(self):
        self.setLayout(self.__init_layout())
        self.__setup_event_handlers()
        self.setWindowTitle(self.__TITLE)
        self.setFixedWidth(self.__WIDTH)
        self.setFixedHeight(self.__HEIGHT)
        self.setModal(True)
        self.__action_dict = self.__setup_output_creation()
#.........这里部分代码省略.........
开发者ID:raof01,项目名称:utilities,代码行数:103,代码来源:DialogSqlQuery.py

示例3: VideoPlayer

# 需要导入模块: from PyQt5.QtWidgets import QPlainTextEdit [as 别名]
# 或者: from PyQt5.QtWidgets.QPlainTextEdit import setFixedHeight [as 别名]
class VideoPlayer(QWidget):
    """
    Arguments
    ---------
    parent: QWidget, the parent widget of VideoPlayer
    display_status: bool, default False, will show the status of the media player in the gui
    """

    def __init__(self, parent=None, display_status=False):
        super(VideoPlayer, self).__init__(parent)

        self.display_status = display_status

        self.mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)

        self.videoItem = QGraphicsVideoItem()

        scene = QGraphicsScene(self)
        graphicsView = QGraphicsView(scene)

        scene.addItem(self.videoItem)

        self.playButton = QPushButton()
        self.playButton.setEnabled(False)
        self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay))
        self.playButton.clicked.connect(self.play)

        self.positionSlider = QSlider(Qt.Horizontal)
        self.positionSlider.setRange(0, 0)
        self.positionSlider.sliderMoved.connect(self.setPosition)
        
        if self.display_status:
            self.status_mapping = {
                QMediaPlayer.UnknownMediaStatus: "UnknownMediaStatus",
                QMediaPlayer.NoMedia: "NoMedia",
                QMediaPlayer.LoadingMedia: "LoadingMedia",
                QMediaPlayer.LoadedMedia: "LoadedMedia",
                QMediaPlayer.StalledMedia: "StalledMedia", 
                QMediaPlayer.BufferingMedia: "BufferingMedia",
                QMediaPlayer.BufferedMedia: "BufferedMedia",
                QMediaPlayer.EndOfMedia: "EndOfMedia",
                QMediaPlayer.InvalidMedia: "InvalidMedia"
            }
            self.statusText = QPlainTextEdit()
            self.statusText.setReadOnly(True)
            self.statusText.setFixedHeight(25)
            self.statusText.setFixedWidth(150)
            self.mediaPlayer.mediaStatusChanged.connect(self.mediaStatusChanged)

        controlLayout = QHBoxLayout()
        controlLayout.setContentsMargins(0, 0, 0, 0)
        controlLayout.addWidget(self.playButton)
        controlLayout.addWidget(self.positionSlider)
        if self.display_status:
            controlLayout.addWidget(self.statusText)

        layout = QVBoxLayout()
        layout.addWidget(graphicsView)
        layout.addLayout(controlLayout)
        self.setFixedWidth(WIDTH + WIGGLE)

        self.setLayout(layout)

        self.mediaPlayer.setVideoOutput(self.videoItem)
        self.mediaPlayer.stateChanged.connect(self.mediaStateChanged)
        self.mediaPlayer.positionChanged.connect(self.positionChanged)
        self.mediaPlayer.durationChanged.connect(self.durationChanged)

    def openFile(self, fileName):
        if fileName != '' or fileName is not None:
            self.mediaPlayer.setMedia(
                    QMediaContent(QUrl.fromLocalFile(fileName)))

            # set resolution
            res_orig = get_video_resolution(fileName)
            self.aspect_ratio = float(res_orig[0]) / res_orig[1]
            self.videoItem.setSize(QSizeF(WIDTH,
                                          WIDTH / self.aspect_ratio))
            self.setFixedHeight(WIDTH / self.aspect_ratio + 2*WIGGLE)

            self.playButton.setEnabled(True)

            # trick to show screenshot of the first frame of video
            self.mediaPlayer.play()
            self.mediaPlayer.pause()

    def play(self):
        if self.mediaPlayer.state() == QMediaPlayer.PlayingState:
            self.mediaPlayer.pause()
        else:
            self.mediaPlayer.play()

    def mediaStateChanged(self, state):
        if self.mediaPlayer.state() == QMediaPlayer.PlayingState:
            self.playButton.setIcon(
                    self.style().standardIcon(QStyle.SP_MediaPause))
        else:
            self.playButton.setIcon(
                    self.style().standardIcon(QStyle.SP_MediaPlay))

#.........这里部分代码省略.........
开发者ID:santosfamilyfoundation,项目名称:TrafficGUIs,代码行数:103,代码来源:videographicsitem.py


注:本文中的PyQt5.QtWidgets.QPlainTextEdit.setFixedHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。