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


Python QUiLoader.resize方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PySide.QtUiTools import QUiLoader [as 别名]
# 或者: from PySide.QtUiTools.QUiLoader import resize [as 别名]
class NiconvertQt:

    def __init__(self):
        ui_file_path = os.path.join(__folder__, 'niconvert_qt.ui')
        self.main_window = QUiLoader().load(ui_file_path)
        for widget in self.main_window.findChildren(QObject):
            name = widget.objectName()
            if name == '' or name.startswith('qt_') or name.startswith('_'):
                continue
            setattr(self, name, widget)

        self.init_widgets_status()
        self.bind_signals()

        self.website = None

    def init_widgets_status(self):
        if sys.platform == 'win32':
            self.font_pushButton.setText(u'微软雅黑 | 36')
        else:
            self.font_pushButton.setText('WenQuanYi Micro Hei | 36')
        self.move_to_screen_center()
        self.main_window.resize(480, 0)

    def move_to_screen_center(self):
        cp = QDesktopWidget().availableGeometry().center()
        qr = self.main_window.frameGeometry()
        qr.moveCenter(cp)
        self.main_window.move(qr.topLeft())

    def bind_signals(self):
        self.quit_menuitem.triggered.connect(
            self.quit_menuitem_triggered_slot)
        self.about_menuitem.triggered.connect(
            self.about_menuitem_triggered_slot)
        self.fetch_pushButton.clicked.connect(
            self.fetch_pushButton_clicked_slot)
        self.font_pushButton.clicked.connect(
            self.font_pushButton_clicked_slot)
        self.output_lineEdit.editingFinished.connect(
            self.output_lineEdit_editingFinished_slot)
        self.output_pushButton.clicked.connect(
            self.output_pushButton_clicked_slot)
        self.convert_pushButton.clicked.connect(
            self.convert_pushButton_clicked_slot)

    def alert(self, message_type, message_text):
        dialog = QMessageBox()
        dialog.setIcon(message_type)
        dialog.setText('%s' % message_text)
        dialog.exec_()

    def fetch_pushButton_clicked_slot(self):
        url = self.url_lineEdit.text().strip()
        if not url.startswith('http://'):
            return

        try:
            self.website = create_website(url)
        except StandardError as error:
            self.video_title_label.setText('')
            self.comment_url_label.setText('')
            self.website = None
            self.alert(QMessageBox.Critical, error)
            return

        if self.website is None:
            self.alert(QMessageBox.Critical, u'不支持的网站')
            return

        title = self.website.downloader.title
        url = self.website.downloader.comment_url
        markup = '<a href="%s">%s</a>' % (url, url)

        self.video_title_label.setText(title)
        self.comment_url_label.setText(markup)
        if self.output_lineEdit.text().strip() == '':
            self.output_lineEdit.setText(title + '.ass')

    def font_pushButton_clicked_slot(self):
        font_name, font_size =  self.font_pushButton.text().split(' | ')
        font_size = int(font_size)
        font, respose = QFontDialog.getFont(
            QFont(font_name, font_size), self.main_window)

        if respose:
            font_label = '%s | %d' % (
                font.family(), font.pointSize())
            self.font_pushButton.setText(font_label)

    def output_lineEdit_editingFinished_slot(self):
        text = self.output_lineEdit.text().strip()
        if text != '' and not text.endswith('.ass'):
            text += '.ass'
        self.output_lineEdit.setText(text)

    def output_pushButton_clicked_slot(self):
        filename = 'output.ass'
        output = self.output_lineEdit.text().strip()
        if output == '':
#.........这里部分代码省略.........
开发者ID:ccxuy,项目名称:niconvert,代码行数:103,代码来源:niconvert_qt.py


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