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


Python QScrollArea.setFixedHeight方法代码示例

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


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

示例1: Contacts

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setFixedHeight [as 别名]
class Contacts(QWidget):
    def __init__(self, db):
        self.dic_wind = {}
        self.dic_button = {}
        self.dic_err_win = {}
        self.layout = None
        self.mygroupbox = QGroupBox('Contacts list')
        self.myform = QFormLayout()
        self.scroll = QScrollArea()
        self.db = db
        self.google_api = Google()
        super().__init__()

    def init_ui(self):
        sender = self.sender()
        error = None
        if sender is not None:
            if sender.text() == '&VK':
                if not self.db.db_exists():
                    error = self.db.create(download_data(sender.text()))
                else:
                    error = self.db.update_database(
                        download_data(sender.text()))
            if sender.text() == '&Facebook':
                if not self.db.db_exists():
                    error = self.db.create(download_data(sender.text()))
                else:
                    error = self.db.update_database(
                        download_data(sender.text()))

        if error is not None:
            self.dic_err_win[error] = ErrorWindow(error)
            self.dic_err_win[error].init_ui()
        else:
            for friend in self.db.get_list_users():
                button = self.create_button(friend)
                self.myform.addRow(button)

            self.mygroupbox.setLayout(self.myform)

            self.scroll.setWidget(self.mygroupbox)
            self.scroll.setWidgetResizable(True)
            self.scroll.setFixedHeight(600)
            self.layout = QVBoxLayout(self)
            self.layout.addWidget(self.scroll)

    def create_button(self, friend):
        name = friend
        button = QPushButton(name, self)
        self.dic_button[name] = button
        inf_friend = self.db.get_user_inf(friend)
        if inf_friend['picture'] != '':
            logo = inf_friend['picture']

        self.dic_wind[name] = Window(name, logo,
                                     inf_friend, self, self.google_api)
        button.clicked.connect(lambda: self.dic_wind[name].init_ui())
        return button

    def import_all_contacts(self):
        list_users = self.db.get_list_users()
        if len(list_users) != 0:
            open_new('https://contacts.google.com')
            for contact in list_users:
                contact_data = self.db.get_user_inf(contact)
                self.google_api.create_contact(
                    self.google_api.create_xml(contact_data))

    def redrawing(self):
        self.clear_window()
        self.init_ui()

    def clear_layout(self, layout):
        for i in range(layout.count()):
            if layout.itemAt(i) is not None:
                layout.itemAt(i).widget().setParent(None)

    def clear_window(self):
        for i in range(self.layout.count()):
            if self.layout.itemAt(i) is not None:
                if self.layout.itemAt(i).layout() is not None:
                    self.clear_layout(self.layout.itemAt(i).layout())
                    self.layout.itemAt(i).layout().setParent(None)
                if self.layout.itemAt(i).widget() is not None:
                    self.layout.itemAt(i).widget().setParent(None)
开发者ID:vakyym07,项目名称:export_contacts,代码行数:87,代码来源:export_contacts.py


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