Пример #1
0
 def ToggleButton(self, x=0, y=0, width=400, height=40, image=button_image, image_highlighted=button_highlighted, caption="Unlabeled", batch=None, group=None, label_group=None, font_name='ChunkFive Roman', on_click=None, on_toggle=None, enabled=True):
     button = ToggleButton(self, x=x, y=y, width=width, height=height, image=resize_button_image(image, 400, width), image_highlighted=resize_button_image(image_highlighted, 400, width), caption=caption, batch=(batch or self.batch), group=(group or self.group), label_group=(label_group or self.labels_group), font_name=font_name, enabled=enabled)
     if on_click:
         button.push_handlers(on_click=on_click)
     if on_toggle:
         button.push_handlers(on_toggle=on_toggle)
     return button
Пример #2
0
 def ToggleButton(self,
                  x=0,
                  y=0,
                  width=400,
                  height=40,
                  image=button_image,
                  image_highlighted=button_highlighted,
                  caption="Unlabeled",
                  batch=None,
                  group=None,
                  label_group=None,
                  font_name='ChunkFive Roman',
                  on_click=None,
                  on_toggle=None,
                  enabled=True):
     button = ToggleButton(self,
                           x=x,
                           y=y,
                           width=width,
                           height=height,
                           image=resize_button_image(image, 400, width),
                           image_highlighted=resize_button_image(
                               image_highlighted, 400, width),
                           caption=caption,
                           batch=(batch or self.batch),
                           group=(group or self.group),
                           label_group=(label_group or self.labels_group),
                           font_name=font_name,
                           enabled=enabled)
     if on_click:
         button.push_handlers(on_click=on_click)
     if on_toggle:
         button.push_handlers(on_toggle=on_toggle)
     return button
Пример #3
0
    def setupUi(self, window):
        window.setObjectName("window")
        window.resize(1388, 664)
        window.setMinimumSize(QtCore.QSize(1024, 480))
        window.setStyleSheet("")
        self.widget_central = QtWidgets.QWidget(window)
        self.widget_central.setObjectName("widget_central")
        self.layout_main = QtWidgets.QGridLayout(self.widget_central)
        self.layout_main.setObjectName("layout_main")
        self.entry_video = QtWidgets.QLineEdit(self.widget_central)
        self.entry_video.setAutoFillBackground(False)
        self.entry_video.setReadOnly(True)
        self.entry_video.setObjectName("entry_video")
        self.layout_main.addWidget(self.entry_video, 1, 1, 1, 1)
        self.list_timestamp = TimestampTableView(self.widget_central)
        self.list_timestamp.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.list_timestamp.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.list_timestamp.setAlternatingRowColors(True)
        self.list_timestamp.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
        self.list_timestamp.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.list_timestamp.setObjectName("list_timestamp")
        self.list_timestamp.horizontalHeader().setHighlightSections(False)
        self.list_timestamp.horizontalHeader().setStretchLastSection(True)
        self.list_timestamp.verticalHeader().setHighlightSections(False)
        self.layout_main.addWidget(self.list_timestamp, 2, 0, 1, 4)
        self.button_video_browse = QtWidgets.QPushButton(self.widget_central)
        self.button_video_browse.setObjectName("button_video_browse")
        self.layout_main.addWidget(self.button_video_browse, 1, 3, 1, 1)
        self.frame_media = QtWidgets.QFrame(self.widget_central)
        self.frame_media.setMinimumSize(QtCore.QSize(500, 0))
        self.frame_media.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_media.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_media.setLineWidth(0)
        self.frame_media.setObjectName("frame_media")
        self.gridLayout = QtWidgets.QGridLayout(self.frame_media)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.media_layout = QtWidgets.QVBoxLayout()
        self.media_layout.setSizeConstraint(QtWidgets.QLayout.SetNoConstraint)
        self.media_layout.setObjectName("media_layout")
        self.frame_video = VideoFrame(self.frame_media)
        self.frame_video.setMinimumSize(QtCore.QSize(0, 0))
        self.frame_video.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.frame_video.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_video.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_video.setLineWidth(0)
        self.frame_video.setObjectName("frame_video")
        self.media_layout.addWidget(self.frame_video)
        self.frame_media_control = QtWidgets.QFrame(self.frame_media)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.frame_media_control.sizePolicy().hasHeightForWidth())
        self.frame_media_control.setSizePolicy(sizePolicy)
        self.frame_media_control.setMaximumSize(QtCore.QSize(16777215, 70))
        self.frame_media_control.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_media_control.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame_media_control.setLineWidth(0)
        self.frame_media_control.setObjectName("frame_media_control")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.frame_media_control)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.button_play_pause = ToggleButton(self.frame_media_control)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.button_play_pause.sizePolicy().hasHeightForWidth())
        self.button_play_pause.setSizePolicy(sizePolicy)
        self.button_play_pause.setCheckable(False)
        self.button_play_pause.setObjectName("button_play_pause")
        self.gridLayout_2.addWidget(self.button_play_pause, 1, 0, 1, 1)
        self.button_mute_toggle = ToggleButton(self.frame_media_control)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.button_mute_toggle.sizePolicy().hasHeightForWidth())
        self.button_mute_toggle.setSizePolicy(sizePolicy)
        self.button_mute_toggle.setObjectName("button_mute_toggle")
        self.gridLayout_2.addWidget(self.button_mute_toggle, 1, 13, 1, 1)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem, 1, 12, 1, 1)
        self.btnRight = QtWidgets.QToolButton(self.frame_media_control)
        self.btnRight.setArrowType(QtCore.Qt.RightArrow)
        self.btnRight.setObjectName("btnRight")
        self.gridLayout_2.addWidget(self.btnRight, 1, 10, 1, 1)
        self.button_slow_down = QtWidgets.QPushButton(self.frame_media_control)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.button_slow_down.sizePolicy().hasHeightForWidth())
        self.button_slow_down.setSizePolicy(sizePolicy)
        self.button_slow_down.setObjectName("button_slow_down")
        self.gridLayout_2.addWidget(self.button_slow_down, 1, 2, 1, 1)
        self.slider_volume = HighlightedJumpSlider(self.frame_media_control)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.slider_volume.sizePolicy().hasHeightForWidth())
        self.slider_volume.setSizePolicy(sizePolicy)
        self.slider_volume.setMaximum(39)
        self.slider_volume.setPageStep(1)
        self.slider_volume.setSliderPosition(20)
        self.slider_volume.setOrientation(QtCore.Qt.Horizontal)
        self.slider_volume.setObjectName("slider_volume")
        self.gridLayout_2.addWidget(self.slider_volume, 1, 14, 1, 1)
        self.btnSkipRight = QtWidgets.QToolButton(self.frame_media_control)
        self.btnSkipRight.setObjectName("btnSkipRight")
        self.gridLayout_2.addWidget(self.btnSkipRight, 1, 11, 1, 1)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.gridLayout_2.addItem(spacerItem1, 1, 6, 1, 1)
        self.btnLeft = QtWidgets.QToolButton(self.frame_media_control)
        self.btnLeft.setArrowType(QtCore.Qt.LeftArrow)
        self.btnLeft.setObjectName("btnLeft")
        self.gridLayout_2.addWidget(self.btnLeft, 1, 8, 1, 1)
        self.button_mark_end = QtWidgets.QPushButton(self.frame_media_control)
        self.button_mark_end.setObjectName("button_mark_end")
        self.gridLayout_2.addWidget(self.button_mark_end, 1, 4, 1, 1)
        self.slider_progress = HighlightedJumpSlider(self.frame_media_control)
        self.slider_progress.setMaximum(9999)
        self.slider_progress.setPageStep(1)
        self.slider_progress.setOrientation(QtCore.Qt.Horizontal)
        self.slider_progress.setTickPosition(QtWidgets.QSlider.NoTicks)
        self.slider_progress.setObjectName("slider_progress")
        self.gridLayout_2.addWidget(self.slider_progress, 0, 0, 1, 15)
        self.button_full_screen = QtWidgets.QPushButton(self.frame_media_control)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.button_full_screen.sizePolicy().hasHeightForWidth())
        self.button_full_screen.setSizePolicy(sizePolicy)
        self.button_full_screen.setObjectName("button_full_screen")
        self.gridLayout_2.addWidget(self.button_full_screen, 1, 5, 1, 1)
        self.button_mark_start = QtWidgets.QPushButton(self.frame_media_control)
        self.button_mark_start.setObjectName("button_mark_start")
        self.gridLayout_2.addWidget(self.button_mark_start, 1, 3, 1, 1)
        self.btnSkipLeft = QtWidgets.QToolButton(self.frame_media_control)
        self.btnSkipLeft.setObjectName("btnSkipLeft")
        self.gridLayout_2.addWidget(self.btnSkipLeft, 1, 7, 1, 1)
        self.button_speed_up = QtWidgets.QPushButton(self.frame_media_control)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.button_speed_up.sizePolicy().hasHeightForWidth())
        self.button_speed_up.setSizePolicy(sizePolicy)
        self.button_speed_up.setObjectName("button_speed_up")
        self.gridLayout_2.addWidget(self.button_speed_up, 1, 1, 1, 1)
        self.spinBoxFrameJumpMultiplier = QtWidgets.QSpinBox(self.frame_media_control)
        self.spinBoxFrameJumpMultiplier.setMinimum(1)
        self.spinBoxFrameJumpMultiplier.setMaximum(1000)
        self.spinBoxFrameJumpMultiplier.setObjectName("spinBoxFrameJumpMultiplier")
        self.gridLayout_2.addWidget(self.spinBoxFrameJumpMultiplier, 1, 9, 1, 1)
        self.media_layout.addWidget(self.frame_media_control)
        self.gridLayout.addLayout(self.media_layout, 1, 0, 1, 1)
        self.layout_main.addWidget(self.frame_media, 2, 5, 3, 1)
        self.frame_timestamp_detail = QtWidgets.QFrame(self.widget_central)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.frame_timestamp_detail.sizePolicy().hasHeightForWidth())
        self.frame_timestamp_detail.setSizePolicy(sizePolicy)
        self.frame_timestamp_detail.setFrameShape(QtWidgets.QFrame.Panel)
        self.frame_timestamp_detail.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_timestamp_detail.setObjectName("frame_timestamp_detail")
        self.formLayout = QtWidgets.QFormLayout(self.frame_timestamp_detail)
        self.formLayout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.formLayout.setObjectName("formLayout")
        self.label_start_time = QtWidgets.QLabel(self.frame_timestamp_detail)
        self.label_start_time.setObjectName("label_start_time")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_start_time)
        self.entry_start_time = QtWidgets.QLineEdit(self.frame_timestamp_detail)
        self.entry_start_time.setEnabled(True)
        self.entry_start_time.setAutoFillBackground(False)
        self.entry_start_time.setReadOnly(True)
        self.entry_start_time.setObjectName("entry_start_time")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.entry_start_time)
        self.label_end_time = QtWidgets.QLabel(self.frame_timestamp_detail)
        self.label_end_time.setObjectName("label_end_time")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_end_time)
        self.entry_end_time = QtWidgets.QLineEdit(self.frame_timestamp_detail)
        self.entry_end_time.setEnabled(True)
        self.entry_end_time.setAutoFillBackground(False)
        self.entry_end_time.setReadOnly(True)
        self.entry_end_time.setObjectName("entry_end_time")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.entry_end_time)
        self.label_description = QtWidgets.QLabel(self.frame_timestamp_detail)
        self.label_description.setObjectName("label_description")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_description)
        self.entry_description = PlainTextEdit(self.frame_timestamp_detail)
        self.entry_description.setEnabled(True)
        self.entry_description.setMaximumSize(QtCore.QSize(16777215, 75))
        self.entry_description.setAutoFillBackground(False)
        self.entry_description.setObjectName("entry_description")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.entry_description)
        self.frame = QtWidgets.QFrame(self.frame_timestamp_detail)
        self.frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame.setFrameShadow(QtWidgets.QFrame.Plain)
        self.frame.setLineWidth(0)
        self.frame.setObjectName("frame")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.frame)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.button_add_entry = QtWidgets.QPushButton(self.frame)
        self.button_add_entry.setObjectName("button_add_entry")
        self.horizontalLayout.addWidget(self.button_add_entry)
        self.button_remove_entry = QtWidgets.QPushButton(self.frame)
        self.button_remove_entry.setEnabled(False)
        self.button_remove_entry.setObjectName("button_remove_entry")
        self.horizontalLayout.addWidget(self.button_remove_entry)
        self.button_save = QtWidgets.QPushButton(self.frame)
        self.button_save.setEnabled(False)
        self.button_save.setObjectName("button_save")
        self.horizontalLayout.addWidget(self.button_save)
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem2)
        self.button_run = QtWidgets.QPushButton(self.frame)
        self.button_run.setObjectName("button_run")
        self.horizontalLayout.addWidget(self.button_run)
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.frame)
        self.layout_main.addWidget(self.frame_timestamp_detail, 3, 0, 1, 4)
        self.button_timestamp_browse = QtWidgets.QPushButton(self.widget_central)
        self.button_timestamp_browse.setObjectName("button_timestamp_browse")
        self.layout_main.addWidget(self.button_timestamp_browse, 0, 3, 1, 1)
        self.entry_timestamp = QtWidgets.QLineEdit(self.widget_central)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.entry_timestamp.sizePolicy().hasHeightForWidth())
        self.entry_timestamp.setSizePolicy(sizePolicy)
        self.entry_timestamp.setAutoFillBackground(False)
        self.entry_timestamp.setStyleSheet("")
        self.entry_timestamp.setReadOnly(True)
        self.entry_timestamp.setObjectName("entry_timestamp")
        self.layout_main.addWidget(self.entry_timestamp, 0, 1, 1, 1)
        self.button_timestamp_create = QtWidgets.QPushButton(self.widget_central)
        self.button_timestamp_create.setObjectName("button_timestamp_create")
        self.layout_main.addWidget(self.button_timestamp_create, 0, 4, 1, 1)
        self.label_video = QtWidgets.QLabel(self.widget_central)
        self.label_video.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.label_video.setObjectName("label_video")
        self.layout_main.addWidget(self.label_video, 1, 0, 1, 1)
        self.label_timestamp = QtWidgets.QLabel(self.widget_central)
        self.label_timestamp.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.label_timestamp.setObjectName("label_timestamp")
        self.layout_main.addWidget(self.label_timestamp, 0, 0, 1, 1)
        self.widget = QtWidgets.QWidget(self.widget_central)
        self.widget.setObjectName("widget")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget)
        self.horizontalLayout_3.setContentsMargins(0, 9, 0, 4)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.lblVideoName = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setPointSize(12)
        self.lblVideoName.setFont(font)
        self.lblVideoName.setObjectName("lblVideoName")
        self.horizontalLayout_3.addWidget(self.lblVideoName)
        self.lblVideoSubtitle = QtWidgets.QLabel(self.widget)
        self.lblVideoSubtitle.setObjectName("lblVideoSubtitle")
        self.horizontalLayout_3.addWidget(self.lblVideoSubtitle)
        spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem3)
        self.dateTimeEdit = QtWidgets.QDateTimeEdit(self.widget)
        self.dateTimeEdit.setEnabled(True)
        self.dateTimeEdit.setObjectName("dateTimeEdit")
        self.horizontalLayout_3.addWidget(self.dateTimeEdit)
        self.layout_main.addWidget(self.widget, 0, 5, 1, 1)
        self.widget_2 = QtWidgets.QWidget(self.widget_central)
        self.widget_2.setObjectName("widget_2")
        self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.widget_2)
        self.horizontalLayout_7.setContentsMargins(0, 2, 0, 0)
        self.horizontalLayout_7.setSpacing(6)
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.groupBox_3 = QtWidgets.QGroupBox(self.widget_2)
        self.groupBox_3.setEnabled(True)
        self.groupBox_3.setObjectName("groupBox_3")
        self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.groupBox_3)
        self.horizontalLayout_6.setContentsMargins(-1, 2, -1, 2)
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.label_2 = QtWidgets.QLabel(self.groupBox_3)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_6.addWidget(self.label_2)
        self.lblFileFPS = QtWidgets.QLabel(self.groupBox_3)
        self.lblFileFPS.setObjectName("lblFileFPS")
        self.horizontalLayout_6.addWidget(self.lblFileFPS)
        self.label_3 = QtWidgets.QLabel(self.groupBox_3)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout_6.addWidget(self.label_3)
        self.lblPlaybackPercent = QtWidgets.QLabel(self.groupBox_3)
        self.lblPlaybackPercent.setObjectName("lblPlaybackPercent")
        self.horizontalLayout_6.addWidget(self.lblPlaybackPercent)
        self.horizontalLayout_7.addWidget(self.groupBox_3)
        self.groupBox_2 = QtWidgets.QGroupBox(self.widget_2)
        self.groupBox_2.setObjectName("groupBox_2")
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.groupBox_2)
        self.horizontalLayout_5.setContentsMargins(-1, 2, -1, 2)
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.lblCurrentTime = QtWidgets.QLabel(self.groupBox_2)
        self.lblCurrentTime.setObjectName("lblCurrentTime")
        self.horizontalLayout_5.addWidget(self.lblCurrentTime)
        self.lblTotalDuration = QtWidgets.QLabel(self.groupBox_2)
        self.lblTotalDuration.setObjectName("lblTotalDuration")
        self.horizontalLayout_5.addWidget(self.lblTotalDuration)
        self.horizontalLayout_7.addWidget(self.groupBox_2)
        self.groupBox = QtWidgets.QGroupBox(self.widget_2)
        self.groupBox.setObjectName("groupBox")
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.groupBox)
        self.horizontalLayout_4.setContentsMargins(-1, 2, -1, 2)
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.lblCurrentFrame = QtWidgets.QLabel(self.groupBox)
        self.lblCurrentFrame.setObjectName("lblCurrentFrame")
        self.horizontalLayout_4.addWidget(self.lblCurrentFrame)
        self.lblTotalFrames = QtWidgets.QLabel(self.groupBox)
        self.lblTotalFrames.setObjectName("lblTotalFrames")
        self.horizontalLayout_4.addWidget(self.lblTotalFrames)
        self.horizontalLayout_7.addWidget(self.groupBox)
        self.layout_main.addWidget(self.widget_2, 1, 5, 1, 1)
        window.setCentralWidget(self.widget_central)
        self.actionExit = QtWidgets.QAction(window)
        self.actionExit.setObjectName("actionExit")
        self.actionTest_Entry = QtWidgets.QAction(window)
        self.actionTest_Entry.setObjectName("actionTest_Entry")

        self.retranslateUi(window)
        QtCore.QMetaObject.connectSlotsByName(window)
Пример #4
0
    def start(self, screen):
        if not self.already_loaded:
            PenData.load_all_pens()

            width = screen.get_width()
            height = screen.get_height()

            self.back_btn = Button(
                pygame.Rect(10, 10, 60, 40), "Back", {
                    Options.BORDER_WIDTH: 0,
                    Options.BACKGROUND: (20, 61, 89),
                    Options.FOREGROUND: (244, 180, 26),
                    Options.HOVERED_BACKGROUND: (10, 30, 45),
                    Options.FONT: pygame.font.SysFont("Comic Sans MS", 15)
                })

            self.header = Label(
                pygame.Rect(width / 2 - 200, 10, 400, 30),
                "Choose your opponent!", {
                    Options.BACKGROUND: (20, 61, 89),
                    Options.FOREGROUND: (244, 180, 26),
                    Options.BORDER_WIDTH: 0,
                })

            self.name_text = Label(
                pygame.Rect(width / 2 - 45, height - 125, 90, 50), "", {
                    Options.BACKGROUND: (82, 173, 200),
                    Options.FOREGROUND: (20, 61, 89),
                    Options.BORDER_WIDTH: 0,
                    Options.FONT: pygame.font.SysFont("Comic Sans MS", 18)
                })

            btn_options = {
                Options.BORDER_WIDTH: 0,
                Options.BACKGROUND: (20, 61, 89),
                Options.FOREGROUND: (244, 180, 26),
                Options.HOVERED_BACKGROUND: (10, 30, 45),
                Options.FONT: pygame.font.SysFont("Comic Sans MS", 25)
            }
            self.left_btn = Button(pygame.Rect(10, height / 2 - 20, 20, 30),
                                   "<", btn_options)
            self.right_btn = Button(
                pygame.Rect(width - 30, height / 2 - 20, 20, 30), ">",
                btn_options)
            self.select_btn = Button(
                pygame.Rect(width / 2 - 45, height - 75, 90, 50), "Select",
                btn_options)

            btn_options[Options.TOGGLED_BACKGROUND] = (5, 20, 30)
            self.random_diff_btn = ToggleButton(
                pygame.Rect(width * 1 / 5 - 50, 100, 100, 30), "Random",
                btn_options)
            self.easy_btn = ToggleButton(
                pygame.Rect(width * 2 / 5 - 50, 100, 100, 30), "Easy",
                btn_options)
            self.normal_btn = ToggleButton(
                pygame.Rect(width * 3 / 5 - 50, 100, 100, 30), "Normal",
                btn_options)
            self.hard_btn = ToggleButton(
                pygame.Rect(width * 4 / 5 - 50, 100, 100, 30), "Hard",
                btn_options)
            toggle_group = [
                self.random_diff_btn, self.easy_btn, self.normal_btn,
                self.hard_btn
            ]
            for elt in toggle_group:
                elt.set_group(toggle_group)
            self.easy_btn.toggle()

            self.center_pos = pygame.Rect(width / 2 - 50, height / 2 - 50, 100,
                                          100)
            self.random_pen_data = PenData.dict_to_pen({
                "name":
                "Random",
                "image_file":
                "random_pen"
            })
            for pen in [self.random_pen_data] + PenData.all_pens:
                self.pen_images.append(
                    Image(self.center_pos, Resources.get(pen.image_file),
                          {Options.BACKGROUND: (82, 173, 200)}))

            self.already_loaded = True

        self.reposition_images()
        self.update_enemy_data()
Пример #5
0
class EnemySelectScene(Scene):
    header = None
    back_btn = None

    select_btn = None
    name_text = None

    random_diff_btn = None
    easy_btn = None
    normal_btn = None
    hard_btn = None
    difficulty = -1

    random_pen_data = None
    pen_images = []
    visible_pen_images = []
    left_btn, right_btn = None, None

    center_pos = None
    pen_index = 0

    def start(self, screen):
        if not self.already_loaded:
            PenData.load_all_pens()

            width = screen.get_width()
            height = screen.get_height()

            self.back_btn = Button(
                pygame.Rect(10, 10, 60, 40), "Back", {
                    Options.BORDER_WIDTH: 0,
                    Options.BACKGROUND: (20, 61, 89),
                    Options.FOREGROUND: (244, 180, 26),
                    Options.HOVERED_BACKGROUND: (10, 30, 45),
                    Options.FONT: pygame.font.SysFont("Comic Sans MS", 15)
                })

            self.header = Label(
                pygame.Rect(width / 2 - 200, 10, 400, 30),
                "Choose your opponent!", {
                    Options.BACKGROUND: (20, 61, 89),
                    Options.FOREGROUND: (244, 180, 26),
                    Options.BORDER_WIDTH: 0,
                })

            self.name_text = Label(
                pygame.Rect(width / 2 - 45, height - 125, 90, 50), "", {
                    Options.BACKGROUND: (82, 173, 200),
                    Options.FOREGROUND: (20, 61, 89),
                    Options.BORDER_WIDTH: 0,
                    Options.FONT: pygame.font.SysFont("Comic Sans MS", 18)
                })

            btn_options = {
                Options.BORDER_WIDTH: 0,
                Options.BACKGROUND: (20, 61, 89),
                Options.FOREGROUND: (244, 180, 26),
                Options.HOVERED_BACKGROUND: (10, 30, 45),
                Options.FONT: pygame.font.SysFont("Comic Sans MS", 25)
            }
            self.left_btn = Button(pygame.Rect(10, height / 2 - 20, 20, 30),
                                   "<", btn_options)
            self.right_btn = Button(
                pygame.Rect(width - 30, height / 2 - 20, 20, 30), ">",
                btn_options)
            self.select_btn = Button(
                pygame.Rect(width / 2 - 45, height - 75, 90, 50), "Select",
                btn_options)

            btn_options[Options.TOGGLED_BACKGROUND] = (5, 20, 30)
            self.random_diff_btn = ToggleButton(
                pygame.Rect(width * 1 / 5 - 50, 100, 100, 30), "Random",
                btn_options)
            self.easy_btn = ToggleButton(
                pygame.Rect(width * 2 / 5 - 50, 100, 100, 30), "Easy",
                btn_options)
            self.normal_btn = ToggleButton(
                pygame.Rect(width * 3 / 5 - 50, 100, 100, 30), "Normal",
                btn_options)
            self.hard_btn = ToggleButton(
                pygame.Rect(width * 4 / 5 - 50, 100, 100, 30), "Hard",
                btn_options)
            toggle_group = [
                self.random_diff_btn, self.easy_btn, self.normal_btn,
                self.hard_btn
            ]
            for elt in toggle_group:
                elt.set_group(toggle_group)
            self.easy_btn.toggle()

            self.center_pos = pygame.Rect(width / 2 - 50, height / 2 - 50, 100,
                                          100)
            self.random_pen_data = PenData.dict_to_pen({
                "name":
                "Random",
                "image_file":
                "random_pen"
            })
            for pen in [self.random_pen_data] + PenData.all_pens:
                self.pen_images.append(
                    Image(self.center_pos, Resources.get(pen.image_file),
                          {Options.BACKGROUND: (82, 173, 200)}))

            self.already_loaded = True

        self.reposition_images()
        self.update_enemy_data()

    def update(self, event):
        for elt in (self.back_btn, self.left_btn, self.right_btn,
                    self.select_btn, self.random_diff_btn, self.easy_btn,
                    self.normal_btn, self.hard_btn):
            elt.update(event)

        if self.select_btn.clicked:
            PenData.current_enemy_pen = \
                random.choice(PenData.all_pens) if self.pen_index == 0 else \
                PenData.all_pens[self.pen_index - 1]

            PenData.current_enemy_difficulty = \
                AIDifficulty.EASY if self.easy_btn.toggled else \
                AIDifficulty.NORMAL if self.normal_btn.toggled else \
                AIDifficulty.HARD if self.hard_btn.toggled else \
                random.choice(list(AIDifficulty))

            Scene.push_scene(7)

        if self.back_btn.clicked:
            Scene.pop_scene()

        if self.left_btn.clicked or self.right_btn.clicked:
            if self.left_btn.clicked:
                self.pen_index -= 1
                self.reposition_images()
            elif self.right_btn.clicked:
                self.pen_index += 1
                self.reposition_images()
            self.update_enemy_data()

    def reposition_images(self):
        self.visible_pen_images.clear()

        if self.pen_index > 0:
            img = self.pen_images[self.pen_index - 1]
            self.visible_pen_images.append(img)
            img.rect = self.center_pos.copy().move(-300, 40)

        self.visible_pen_images.append(self.pen_images[self.pen_index])
        self.pen_images[self.pen_index].rect = self.center_pos

        if self.pen_index < len(self.pen_images) - 1:
            img = self.pen_images[self.pen_index + 1]
            self.visible_pen_images.append(img)
            img.rect = self.center_pos.copy().move(300, 40)

        self.left_btn.set_enabled(self.pen_index > 0)
        self.right_btn.set_enabled(self.pen_index < len(self.pen_images) - 1)

    def update_enemy_data(self):
        self.name_text.text = self.random_pen_data.name if self.pen_index == 0 else \
            PenData.all_pens[self.pen_index - 1].name
        self.name_text.recreate()

    def draw(self, screen):
        screen.fill((82, 173, 200))

        for elt in (self.header, self.back_btn, self.left_btn, self.right_btn,
                    self.name_text, self.select_btn, self.easy_btn,
                    self.normal_btn, self.hard_btn, self.random_diff_btn):
            elt.draw(screen)

        for img in self.visible_pen_images:
            img.draw(screen)