def ui(self): """ Function that sets up the ui of the widget Override it on new widgets (but always call super) """ self.main_layout = self.get_main_layout() if self._use_scrollbar: layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) self.setLayout(layout) central_widget = QWidget() central_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) scroll = QScrollArea() scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setFocusPolicy(Qt.NoFocus) layout.addWidget(scroll) scroll.setWidget(central_widget) central_widget.setLayout(self.main_layout) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) else: self.setLayout(self.main_layout)
def ui(self): super(InterpolateItView, self).ui() central_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) central_widget = QWidget() central_widget.setLayout(central_layout) central_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) scroll = QScrollArea() scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setFocusPolicy(Qt.NoFocus) self.main_layout.addWidget(scroll) scroll.setWidget(central_widget) self._interpolator_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) self._interpolator_layout.setAlignment(Qt.AlignTop) button_layout = layouts.HorizontalLayout(spacing=2, margins=(0, 0, 0, 0)) self._load_btn = buttons.BaseButton('Load', parent=self) self._save_btn = buttons.BaseButton('Save', parent=self) self._add_btn = buttons.BaseButton('New', parent=self) button_layout.addWidget(self._save_btn) button_layout.addWidget(self._load_btn) button_layout.addStretch() button_layout.addWidget(self._add_btn) central_layout.addLayout(self._interpolator_layout) self.main_layout.addLayout(button_layout)
def ui(self): super(Changelog, self).ui() self.set_logo('changelog_logo') self.main_layout.setAlignment(Qt.AlignTop) self.main_layout.setContentsMargins(0, 0, 0, 0) self.setFixedWidth(600) self.setMaximumHeight(800) scroll_layout = layouts.VerticalLayout(spacing=2, margins=(2, 2, 2, 2)) scroll_layout.setAlignment(Qt.AlignTop) central_widget = QWidget() central_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) scroll = QScrollArea() scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setFocusPolicy(Qt.NoFocus) ok_btn = QPushButton('OK') ok_btn.clicked.connect(self.close) self.main_layout.addWidget(scroll) self.main_layout.setAlignment(Qt.AlignTop) self.main_layout.addWidget(ok_btn) scroll.setWidget(central_widget) central_widget.setLayout(scroll_layout) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.main_layout = scroll_layout # =========================================================================================== self.version_accordion = accordion.AccordionWidget(parent=self) self.version_accordion.rollout_style = accordion.AccordionStyle.MAYA self.main_layout.addWidget(self.version_accordion) # =========================================================================================== changelog_json_file = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'changelog.json') if not os.path.isfile(changelog_json_file): return with open(changelog_json_file, 'r') as f: changelog_data = json.load(f, object_pairs_hook=OrderedDict) if not changelog_data: return changelog_data = OrderedDict( sorted(changelog_data.items(), reverse=True)) for version, elements in changelog_data.items(): self._create_version(version, elements) last_version_item = self.version_accordion.item_at(0) last_version_item.set_collapsed(False)