Пример #1
0
 def _add_ticket(self, ticket_model: TicketModel, ticket_counter: int,
                 layout: QtWidgets.QLayout) -> None:
     ticket_widget = TicketInfoWidget.create_ticket_info_widget(
         self, ticket_model)
     layout.addWidget(ticket_widget)
     ticket_widget.set_title(f"Ticket {ticket_counter}")
     if ticket_model == self.ticket_clicked:
         ticket_widget.highlight()
Пример #2
0
 def clear_layout(self, layout: QtWidgets.QLayout):
     self._parameter_widgets = {}
     while layout.count():
         child = layout.itemAt(0)
         if isinstance(child, QtWidgets.QSpacerItem):
             layout.removeItem(child)
         elif child.widget() is not None:
             child.widget().setParent(None)
         elif child.layout() is not None:
             self.clear_layout(child.layout())
Пример #3
0
 def _add_preview_color_square_to_layout(self, layout: QLayout,
                                         default_color: tuple[int, int,
                                                              int]):
     color_square = QFrame(self.game_changes_box)
     color_square.setMinimumSize(QSize(22, 22))
     color_square.setSizePolicy(
         QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
     color_square.setStyleSheet(
         'background-color: rgb({},{},{})'.format(*default_color))
     layout.addWidget(color_square)
     return color_square
Пример #4
0
 def _add_to_widget(
     self,
     my_object: Union[ProjectModel, importer.ProjectModification],
     widget_class: Type[QtWidgets.QWidget],
     description: str,
     layout: QtWidgets.QLayout,
 ) -> None:
     widget = widget_class(self)
     widget.my_object = my_object
     widget.setText(description)
     layout.addWidget(widget)
Пример #5
0
def get_widget_from_layout(layout: QLayout, widget_name: str) -> QWidget:
    """Find a widget in a QLayout via the widget name
    Arg - layout (QLayout): A QLayout to search for the widget name
    Arg - widget_name (str): The name of the QWidget to search for
    Returns (QWidget | None): Returns the QWidget with the given name, if found. else
        returns None
    """
    for i in range(layout.count()):
        widget = layout.itemAt(i).widget()
        if widget.objectName() == widget_name:
            return widget
    return None
Пример #6
0
def clear_widgets(layout: QLayout = None):
    if layout is not None:
        for i in range(layout.count()):
            layout.itemAt(i).widget().deleteLater()