Exemple #1
0
    def down_chess(self, position, color):
        # position 落子位置
        # color 落子颜色

        # 构建一个棋子
        chessman = Chessman(color, self)

        coord = QPoint(*self.reverse_to_coordinate(
            position))  #QPoint 传两个参数,但是position只是一个元组,所以用*展开元组
        # 将位置转换成坐标
        chessman.move(coord)

        chessman.show()
        chessman.raise_()

        # 落子后构造声音
        QSound.play('source/luozisheng.wav')

        # 将棋子放到当前在棋子列表中
        self.chessman_list.append(chessman)
        # 显示棋子标识
        self.focus_point.move(coord.x() - 15,
                              coord.y() - 15)  # 用x()代替 int x,及用() 代替int
        # 显示标识
        self.focus_point.show()
        # 让标识在上层显示
        self.focus_point.raise_()
    def initGuiProperty(self):
        self.oldPos = self.pos()

        self.player_left.setText("")
        self.player_right.setText("")
        self.ai_left.setText("")
        self.ai_right.setText("")
        self.changeAiLeftHandTo(1)
        self.changeAiRightHandTo(1)
        self.changePlayerLeftHandTo(1)
        self.changePlayerRightHandTo(1)

        self.bg_label.setPixmap(QtGui.QPixmap("Assets/Background dll/BG.png"))
        self.logo_label.setPixmap(
            QtGui.QPixmap("Assets/Background dll/Ayo Main.png"))
        # self.logo_label.setScaledContents(True)
        self.logo_label.setText("")

        logo_start = QtGui.QPixmap("Assets/Background dll/Start.png")
        self.start_button.setPixmap(logo_start)
        # self.start_button.setScaledContents(True)
        self.exit_button.setPixmap(
            QtGui.QPixmap("Assets/Background dll/Exit.png"))
        # self.exit_button.setScaledContents(True)

        self.lose_label.setPixmap(QPixmap("Assets/Background dll/YouLose.png"))
        self.lose_label.setAlignment(Qt.AlignHCenter)
        self.menu_label.setPixmap(QPixmap("Assets/Background dll/Exit.png"))
        self.menu_label.setAlignment(Qt.AlignHCenter)
        self.lose_frame.setStyleSheet("background-color:rgba(22,22,22,0.6)")
        self.lose_label.setStyleSheet("background-color:rgba(22,22,22,0)")
        self.menu_label.setStyleSheet("background-color:rgba(22,22,22,0)")
        self.play_again_label.setStyleSheet(
            "background-color:rgba(22,22,22,0)")
        self.play_again_label.hide()
        self.lose_frame.hide()
        # self.moveWidgetTo(self.lose_frame,0,-800)

        self.ingame_frame.hide()
        self.home_frame.raise_()
        self.move_label.raise_()
        # self.ai_left.setText("")
        # self.ai_right.setText("")
        self.moveWidgetTo(self.status_game_label, 400, 0)
        self.exit_button_ingame.setPixmap(
            QPixmap("Assets/Background dll/Exit.png"))
        self.exit_button_ingame.setScaledContents(True)
        self.exit_button_ingame.hide()

        self.audio_main_menu = QSound("Assets/Audio/menu.wav")
        # self.audio_main_menu.
        self.audio_main_menu.setLoops(QSound.Infinite)
        self.audio_main_menu.play()

        self.audio_lose = QSound("Assets/Audio/lose.wav")
        self.audio_lose.setLoops(False)
Exemple #3
0
 def handle_timeout(self):
     minutes_total = self.time // 60
     seconds = self.time % 60
     self.time += self.change
     self.ui.min.display(str(minutes_total))
     self.ui.sec.display(str(seconds))
     if (minutes_total, seconds) <= (0, 0) and self.method == 'dao':
         self.ui.min.setStyleSheet('color: red; border: none;')
         self.ui.sec.setStyleSheet('color: red; border: none;')
         self.handle_stop()
     elif (minutes_total, seconds) == (0, 3) and self.method == 'dao':
         QSound.play('timer.wav')
Exemple #4
0
    def process_machine_message(self):
        '''Shows machine's message and reproduce its voice'''
        if json.loads(self.response.text):
            self.textResponse = json.loads(self.response.text)[0]["text"]
            print(self.textResponse)
            self.sqlConversationModel.send_message("Me", self.textResponse, "machine")

            url = "http://localhost:5002/api/tts?text=" + quote_plus(self.textResponse)
            urlretrieve(url, OUT_FILE)
            logging.debug("Machine message: {self.textResponse}")
            QSound.play(OUT_FILE);
        else:
            logging.error("An error happened in the Rasa Server and there's no message to display.")
Exemple #5
0
    def __init__(self, game):
        super(GameWidget, self).__init__()
        uic.loadUi('UI/GameWidget.ui', self)

        self.m_game = game
        self.labelInfo.setText('Motus de ' +
                               str(self.m_game.options.lettersCount) +
                               " lettres. Nombre maximum d'éssais: " +
                               str(self.m_game.options.maximumTriesCount) +
                               ". Nombre de mots possibles: " +
                               str(len(game.dico) - 1))

        self.lineEditWord.setMaxLength(self.m_game.options.lettersCount)

        self.m_motusTableWidget = MotusTableWidget.MotusTableWidget(game)
        self.progressBar.setMaximum(game.options.duration)

        # Sons
        self.beepSound = QSound("data/sounds/beep-3.wav")
        self.newGameSound = QSound("data/sounds/nouveau_mot.wav")
        self.winSound = QSound("data/sounds/kultur0407.wav")
        self.lostSound = QSound("data/sounds/incorrect.wav")

        self.verticalLayoutGameComponents.addWidget(self.m_motusTableWidget)

        # Connections
        self.toolButtonPlayWord.clicked.connect(self.onPlay)
        self.lineEditWord.textChanged.connect(self.onLineEditTextChanged)

        self.m_game.proposeFirstLetterSignal.connect(
            self.onFirstLetterProposed)
        self.m_game.playedSignal.connect(self.onPlayed)
        self.m_game.progressSignal.connect(self.onDurationChanged)
        self.m_game.gameOverSignal.connect(self.onGameOver)
Exemple #6
0
 def __init__(self):
     super().__init__()
     self.setupUi(self)
     self.state = GameState.SETUP
     self.hook_events()
     self.enable_controls()
     self.question.setAlignment(Qt.AlignRight)
     self.sound_ok = QSound(":/sound/sound/ok.wav")
     self.sound_error = QSound(":/sound/sound/error.wav")
     self.test_timed_out = False
     self.card_stats = CardStatsLoader.load(self.get_stats_file())
     self.apply_selections(SelectionsLoader.load(
         self.get_selections_file()))
     print(self.card_stats)
Exemple #7
0
    def play(self):
        control = self.key_prop.GetControl("Transform")
        prop_transform = self.key_prop.LocalTransform()
        
        prop_transform.R().SetX(0.035)
        prop_transform.R().SetY(0)
        prop_transform.R().SetZ(0)
        prop_transform.R().SetW(1)

        key = RLPy.RTransformKey()
        key.SetTime(RLPy.RGlobal.GetTime())
        key.SetTransform(prop_transform)
        control.AddKey(key, RLPy.RGlobal.GetFps())
        
        QSound.play(self.audio_path)
Exemple #8
0
    def _get_resource_from_key(cls, resource_key, parent=None) -> QSound:
        if resource_key in cls.storage:
            return cls.storage.get(resource_key)

        if resource_key not in Resource.icon_paths.keys():
            return QSound('')

        rsc_path: str = Resource.icon_paths.get(resource_key)

        LOGGER.debug('Creating QSound for resource %s', rsc_path)

        sound_obj = QSound(rsc_path, parent)
        cls.storage[resource_key] = sound_obj

        return sound_obj
    def process_machine_message(self):
        '''Shows machine's message and reproduce its voice'''
        if json.loads(self.response.text):
            self.textResponse = json.loads(self.response.text)[0]["text"]
            print(self.textResponse)
            self.sqlConversationModel.send_message("Me", self.textResponse,
                                                   "machine")

            self.tts.tts_predict(self.model, MODEL_PATH, self.textResponse,
                                 CONFIG, use_cuda, self.ap, OUT_FILE)
            logging.debug("Machine message: {self.textResponse}")
            QSound.play(OUT_FILE)
        else:
            logging.error(
                "An error happened in the Rasa Server and there's no message to display."
            )
Exemple #10
0
    def play(self):
        control = self.key_prop.GetControl("Transform")
        prop_transform = self.key_prop.LocalTransform()

        prop_transform.R().SetX(0.035)
        prop_transform.R().SetY(0)
        prop_transform.R().SetZ(0)
        prop_transform.R().SetW(1)

        key = RLPy.RTransformKey()
        time = RLPy.RGlobal.GetTime()
        key.SetTime(time)
        key.SetTransform(prop_transform)
        control.AddKey(key, RLPy.RGlobal.GetFps())
        control.SetKeyTransition(time, RLPy.ETransitionType_Step, 1.0)

        if (RLPy.RGlobal.IsPlaying()):
            self.key_list.append(time)

        #RLPy.RAudio.LoadAudioToObject(self.key_prop, self.audio_object, time)

        QSound.play(self.audio_path)
Exemple #11
0
def _set_sound_source(alias):
    solution = 2
    if solution == 0:
        # qrc, MediaPlayer()
        sound = QMediaPlayer()
        sound.setMedia(QUrl('qrc:/' + alias))
    elif solution == 1:
        # absoluteFilePath(), MediaPlayer()
        path = QFileInfo('sounds/' + alias + '.wav').absoluteFilePath()
        sound = QMediaPlayer()
        sound.setMedia(QUrl(path))
    elif solution == 2:
        # qrc, QSound()
        sound = QSound('qrc:/' + alias)
    return sound
Exemple #12
0
 def down_chess(self, position, color):
     '''
     落子
     position:落子位置
         x:水平位置 19个位置,0~18
         y:垂直位置 19个位置,0~18
     color:棋子颜色
     '''
     # 构建一个棋子
     chessman = Chessman(color, self)  # 棋子颜色、父窗口
     # 将位置转换成坐标,然后将棋子移动到该位置
     coord = QPoint(*self.reverse_to_coordinate(position))
     chessman.move(coord)
     chessman.show()
     chessman.raise_()  # 确保棋子显示
     # 播放落子声
     QSound.play('source/luozisheng.wav')
     # 将棋子放到当前棋子列表中
     self.chessman_list.append(chessman)
     # 显示棋子标识、
     self.focus_point.move(coord.x() - 15, coord.y() - 15)
     self.focus_point.show()
     # 让标识在上层显示
     self.focus_point.raise_()
Exemple #13
0
 def update_value(self):
     self.frame_no += self.play_pause
     if self.frame_no >= 20:
         self.frame_no = 0
         QSound.play("sounds/rabbit_jump.wav")
Exemple #14
0
class TafelsMainWindow(QMainWindow, Ui_MainWindow):
    test_timed_out: bool
    card_stats: CardStats
    cards_todo: List[Card]
    state: GameState
    test_timer: QTimer
    question_start_time: float
    test_answers: Dict[Card, int]

    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.state = GameState.SETUP
        self.hook_events()
        self.enable_controls()
        self.question.setAlignment(Qt.AlignRight)
        self.sound_ok = QSound(":/sound/sound/ok.wav")
        self.sound_error = QSound(":/sound/sound/error.wav")
        self.test_timed_out = False
        self.card_stats = CardStatsLoader.load(self.get_stats_file())
        self.apply_selections(SelectionsLoader.load(
            self.get_selections_file()))
        print(self.card_stats)

    def hook_events(self):
        for pb in self.numpad_controls():
            pb.clicked.connect(self.numpad_click)
        self.pb_clear.clicked.connect(self.clear_answer)
        self.pb_submit.clicked.connect(self.check_answer)
        self.pb_stop.clicked.connect(self.stop_all)
        self.pb_test.clicked.connect(self.start_test)
        self.pb_practice.clicked.connect(self.start_practice)
        self.answer.returnPressed.connect(self.check_answer)

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

    def numpad_controls(self) -> Iterable[QPushButton]:
        return [
            self.pushButton_1, self.pushButton_2, self.pushButton_3,
            self.pushButton_4, self.pushButton_5, self.pushButton_6,
            self.pushButton_7, self.pushButton_8, self.pushButton_9,
            self.pushButton_0
        ]

    def enable_controls(self):
        for pb in self.numpad_controls():
            pb.setEnabled(self.is_running())
        self.pb_clear.setEnabled(self.is_running())
        self.pb_submit.setEnabled(self.is_running())
        self.answer.setEnabled(self.is_running())
        self.pb_stop.setEnabled(self.is_running())
        self.pb_practice.setEnabled(self.state == GameState.SETUP)
        self.pb_test.setEnabled(self.state == GameState.SETUP)
        self.lst_selection.setEnabled(self.state == GameState.SETUP)

    def is_running(self):
        return self.state == GameState.TESTING or self.state == GameState.PRACTICE

    def get_selection(self) -> Iterable[int]:
        selection = []
        for i in range(0, self.lst_selection.count()):
            item: QListWidgetItem = self.lst_selection.item(i)
            if item.checkState() == Qt.Checked:
                selection.append(int(item.text()))
        return selection

    def apply_selections(self, selection: Iterable[int]):
        for i in range(0, self.lst_selection.count()):
            item: QListWidgetItem = self.lst_selection.item(i)
            if int(item.text()) in selection:
                item.setCheckState(Qt.Checked)
            else:
                item.setCheckState(Qt.Unchecked)

    @Slot()
    def clear_answer(self):
        self.answer.setText("")

    @Slot()
    def numpad_click(self):
        sender = self.sender()
        self.answer.setText(self.answer.text() + sender.text())

    @Slot()
    def start_test(self):
        SelectionsLoader.store(self.get_selections_file(),
                               self.get_selection())
        self.state = GameState.TESTING
        self.test_timed_out = False
        self.enable_controls()
        self.cards_todo = list(
            self.card_stats.select_for_test(TEST_SIZE, self.get_selection()))
        shuffle(self.cards_todo)
        self.show_question_or_feedback()
        self.feedback.setText("")
        self.test_answers = {}

        self.test_timer = QTimer(self)
        self.test_timer.timeout.connect(self.test_timeout)
        self.test_timer.setInterval(TEST_DURATION_MSEC)
        self.test_timer.setSingleShot(True)
        self.test_timer.start()
        self.progressBar.setValue(0)
        self.progressBar.setMaximum(len(self.cards_todo))

    @Slot()
    def start_practice(self):
        print("starting practice")
        SelectionsLoader.store(self.get_selections_file(),
                               self.get_selection())
        self.state = GameState.PRACTICE
        self.test_timed_out = False
        self.enable_controls()
        self.cards_todo = list(Card.generate(self.get_selection()))
        shuffle(self.cards_todo)
        self.show_question_or_feedback()
        self.feedback.setText("")
        self.progressBar.setValue(0)
        self.progressBar.setMaximum(len(self.cards_todo))

    @Slot()
    def stop_all(self):
        print("stopping")
        self.state = GameState.SETUP
        self.enable_controls()
        self.progressBar.setValue(0)
        if self.state == GameState.TESTING:
            self.test_timer.stop()
            del self.test_timer
            self.test_timed_out = False

    @Slot()
    def test_timeout(self):
        self.test_timed_out = True

    def show_test_results(self):
        print(self.test_answers)
        msgBox = QMessageBox()
        msgBox.setTextFormat(Qt.RichText)
        msgBox.setText(self.generate_report())
        msgBox.exec()

    def current_card(self):
        return self.cards_todo[-1]

    @Slot()
    def check_answer(self):
        try:
            answer = int(self.answer.text())
        except ValueError:
            self.clear_answer()
            return
        stop_time = time()
        if answer == self.current_card().answer():
            self.correct_answer(stop_time)
        else:
            self.wrong_answer()

    def correct_answer(self, stop_time):
        time_delta = stop_time - self.question_start_time
        print(" %s took %f" % (self.current_card(), time_delta))
        self.card_stats.add_correct_answer(self.current_card(), time_delta)
        self.save_stats()
        if self.state == GameState.PRACTICE:
            self.sound_ok.play()
            self.next_card()
        elif self.state == GameState.TESTING:
            self.test_answers[self.current_card()] = int(self.answer.text())
            self.next_card()

    def next_card(self):
        self.cards_todo.pop()
        self.progressBar.setValue(1 + self.progressBar.maximum() -
                                  len(self.cards_todo))
        self.show_question_or_feedback()

    def wrong_answer(self):
        self.card_stats.add_error(self.current_card())
        print(" %s wrong answer %s" %
              (str(self.current_card()), self.answer.text()))
        self.save_stats()
        if self.state == GameState.PRACTICE:
            self.sound_error.play()
            self.style_feedback()
            self.feedback.setText(" " + self.answer.text() + " ")
            self.answer.setText("")
        elif self.state == GameState.TESTING:
            self.test_answers[self.current_card()] = int(self.answer.text())
            self.next_card()

    def style_feedback(self, color=Qt.red, strikeout=True):
        font = self.question.font()
        font.setStrikeOut(strikeout)
        self.feedback.setFont(font)
        palette = self.feedback.palette()
        palette.setColor(self.feedback.foregroundRole(), color)
        self.feedback.setPalette(palette)

    def show_question_or_feedback(self):
        if len(self.cards_todo) == 0 or self.test_timed_out:
            if self.state == GameState.PRACTICE:
                self.style_feedback(Qt.green, False)
                self.feedback.setText("Klaar!")
            else:
                self.show_test_results()
            self.question.setText("")
            self.answer.setText("")
            self.stop_all()
        else:
            self.question.setText(str(self.current_card()) + " =")
            self.answer.setText("")
            self.answer.setFocus()
            self.feedback.setText("")
            self.question_start_time = time()

    def generate_report(self) -> str:
        correct_answers = 0
        for (card, my_answer) in self.test_answers.items():
            correct_answer = card.answer()
            if my_answer == correct_answer:
                correct_answers += 1
        report = "<h1>"
        report += "Resultaat toets = %d / %d" % (correct_answers, TEST_SIZE)
        report += "<img src='%s'></img>" % self.get_report_icon(
            correct_answers / TEST_SIZE)
        report += " </h1>\n<br>"
        for (card, my_answer) in self.test_answers.items():
            correct_answer = card.answer()
            if my_answer == correct_answer:
                report += "<font size='6' color='green'>%s = %d</font><br>\n" % (
                    str(card), my_answer)
            else:
                report += "<font size='6' color='red'>%s&nbsp;=&nbsp;<s>%s</s>&nbsp;</font>" \
                          "<font size='6'>%d</font><br>\n" % (str(card), str(my_answer), correct_answer)
        return report

    @staticmethod
    def get_report_icon(score: float) -> str:
        if score == 1.0:
            return ":/icons/icons/emoji/1F3C6.svg"  # prize
        elif score >= 0.9:
            return ":/icons/icons/emoji/1F600.svg"  # :D
        elif score >= 0.8:
            return ":/icons/icons/emoji/1F642.svg"  # :-)
        elif score >= 0.6:
            return ":/icons/icons/emoji/1F610.svg"  # :-|
        else:
            return ":/icons/icons/emoji/1F61F.svg"  # :-(

    @staticmethod
    def get_stats_file() -> Path:
        dir = user_state_dir("tafels")
        return Path(dir, "cardstate.dat")

    @staticmethod
    def get_selections_file() -> Path:
        dir = user_state_dir("tafels")
        return Path(dir, "selections.dat")

    def save_stats(self):
        CardStatsLoader.store(self.get_stats_file(), self.card_stats)
Exemple #15
0
class GameWidget(QtWidgets.QWidget):
    """Cette classe implémente l’IHM du jeu"""
    def __init__(self, game):
        super(GameWidget, self).__init__()
        uic.loadUi('UI/GameWidget.ui', self)

        self.m_game = game
        self.labelInfo.setText('Motus de ' +
                               str(self.m_game.options.lettersCount) +
                               " lettres. Nombre maximum d'éssais: " +
                               str(self.m_game.options.maximumTriesCount) +
                               ". Nombre de mots possibles: " +
                               str(len(game.dico) - 1))

        self.lineEditWord.setMaxLength(self.m_game.options.lettersCount)

        self.m_motusTableWidget = MotusTableWidget.MotusTableWidget(game)
        self.progressBar.setMaximum(game.options.duration)

        # Sons
        self.beepSound = QSound("data/sounds/beep-3.wav")
        self.newGameSound = QSound("data/sounds/nouveau_mot.wav")
        self.winSound = QSound("data/sounds/kultur0407.wav")
        self.lostSound = QSound("data/sounds/incorrect.wav")

        self.verticalLayoutGameComponents.addWidget(self.m_motusTableWidget)

        # Connections
        self.toolButtonPlayWord.clicked.connect(self.onPlay)
        self.lineEditWord.textChanged.connect(self.onLineEditTextChanged)

        self.m_game.proposeFirstLetterSignal.connect(
            self.onFirstLetterProposed)
        self.m_game.playedSignal.connect(self.onPlayed)
        self.m_game.progressSignal.connect(self.onDurationChanged)
        self.m_game.gameOverSignal.connect(self.onGameOver)

    # --- Slots

    # Appelé quand le contenu du mot joué est modifié
    @Slot(str)
    def onLineEditTextChanged(self, word):
        self.lineEditWord.textChanged.disconnect(self.onLineEditTextChanged)
        w = Utils.getNormalizedToUpperCaseWord(word)
        if self.m_game.isWordValid(word):
            self.lineEditWord.setStyleSheet(
                "QLineEdit { background-color: rgb(255, 255, 255, 255); } ")
        else:
            self.lineEditWord.setStyleSheet(
                "QLineEdit { background-color: rgb(255, 0, 0, 127); } ")

        self.lineEditWord.setText(w)
        self.lineEditWord.textChanged.connect(self.onLineEditTextChanged)

    # Appelé quand un on clicque sur le bouton jouer
    @Slot()
    def onPlay(self):
        self.m_game.play(self.lineEditWord.text())

    # Appelé quand la première lettre du mot est proposée par le jeu
    @Slot()
    def onFirstLetterProposed(self, firstLetter):
        self.lineEditWord.setText(firstLetter)
        self.newGameSound.play()

    # Appelé quand un essai a été validé par le jeu
    @Slot(int, str)
    def onPlayed(self, row, word, result):
        for column in range(len(word)):
            self.m_motusTableWidget.setLetter(row, column, str(word[column]),
                                              result[column])

    # Appelé quand le jeu signale une seconde écoulée
    @Slot(int)
    def onDurationChanged(self, duration):
        self.progressBar.setValue(duration)
        self.beepSound.play()

    # Appelé quand le jeu est terminé
    @Slot(bool)
    def onGameOver(self, isWinner):
        self.lineEditWord.setEnabled(False)
        self.toolButtonPlayWord.setEnabled(False)

        if isWinner:
            self.labelResult.setText("Gagné")
            self.winSound.play()
        else:
            self.labelResult.setText("Perdu")
            self.lostSound.play()
Exemple #16
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle('计时器')
        # self.resize(320, 480)
        self.setFixedSize(320, 480)

        # 布局
        layout = QVBoxLayout()

        # 时间显示
        self.show_time = QLabel('00:00')
        self.show_time.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.show_time)

        # 时间控制
        self.setting_time = QSlider(Qt.Horizontal)
        self.setting_time.setRange(0, 60)
        self.setting_time.valueChanged.connect(self.setting_change)
        layout.addWidget(self.setting_time)

        # 开始按钮
        self.start_button = QPushButton('START')
        # 信号和插槽连接
        self.start_button.clicked.connect(self.start_timer)
        layout.addWidget(self.start_button)

        # 停止按钮
        self.stop_button = QPushButton('STOP')
        self.stop_button.clicked.connect(self.stop_timer)
        layout.addWidget(self.stop_button)

        # space
        space = QWidget()
        space.setFixedHeight(10)
        layout.addWidget(space)

        container = QWidget()
        container.setLayout(layout)

        self.setCentralWidget(container)

        # 计时器
        self.timer = QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.refresh_show)

        # 提示音
        self.done_sound = QSound('done.wav')
        self.ticking_sound = QSound('ticking.wav')

        # 自定义的属性
        # 秒
        self.current_time = 0
        # 1 = 计时中...
        self.timer_status = 0

        # QSS
        self.setStyleSheet("""
            QLabel {
                font-size: 80px;
                font-weight: bold;
                border: 1px solid #000;
            }
            
            QSlider {
                margin: 20
            }
            
            QPushButton {
                height: 35px;
                font-weight: bold;
                font-size: 16px;
            }
            
        """)
Exemple #17
0
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('计时器')
        # self.resize(320, 480)
        self.setFixedSize(320, 480)

        # 布局
        layout = QVBoxLayout()

        # 时间显示
        self.show_time = QLabel('00:00')
        self.show_time.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.show_time)

        # 时间控制
        self.setting_time = QSlider(Qt.Horizontal)
        self.setting_time.setRange(0, 60)
        self.setting_time.valueChanged.connect(self.setting_change)
        layout.addWidget(self.setting_time)

        # 开始按钮
        self.start_button = QPushButton('START')
        # 信号和插槽连接
        self.start_button.clicked.connect(self.start_timer)
        layout.addWidget(self.start_button)

        # 停止按钮
        self.stop_button = QPushButton('STOP')
        self.stop_button.clicked.connect(self.stop_timer)
        layout.addWidget(self.stop_button)

        # space
        space = QWidget()
        space.setFixedHeight(10)
        layout.addWidget(space)

        container = QWidget()
        container.setLayout(layout)

        self.setCentralWidget(container)

        # 计时器
        self.timer = QTimer()
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.refresh_show)

        # 提示音
        self.done_sound = QSound('done.wav')
        self.ticking_sound = QSound('ticking.wav')

        # 自定义的属性
        # 秒
        self.current_time = 0
        # 1 = 计时中...
        self.timer_status = 0

        # QSS
        self.setStyleSheet("""
            QLabel {
                font-size: 80px;
                font-weight: bold;
                border: 1px solid #000;
            }
            
            QSlider {
                margin: 20
            }
            
            QPushButton {
                height: 35px;
                font-weight: bold;
                font-size: 16px;
            }
            
        """)

    @Slot()
    def start_timer(self):
        self.timer.start()
        self.timer_status = 1
        self.start_button.setEnabled(False)
        self.start_button.repaint()
        self.setting_time.setEnabled(False)
        self.setting_time.repaint()

    @Slot()
    def stop_timer(self):
        self.timer.stop()
        self.start_button.setEnabled(True)
        self.start_button.repaint()
        self.setting_time.setEnabled(True)
        self.setting_time.repaint()
        self.setting_time.setRange(0, 60)
        self.setting_time.setValue(self.current_time // 60)
        self.timer_status = 0
        self.done_sound.play()

    @Slot()
    def setting_change(self, value):
        if self.timer_status == 1:
            return
        self.current_time = value * 60
        show = format_show(value * 60)
        self.show_time.setText(show)

    @Slot()
    def refresh_show(self):
        self.current_time -= 1
        self.setting_time.setRange(0, 3600)
        self.setting_time.setValue(self.current_time)
        if self.current_time >= 0:
            self.ticking_sound.play()
            show = format_show(self.current_time)
            self.show_time.setText(show)
        else:
            self.stop_timer()
class GameGui(Ui_Form):
    playerTurnSignal = Signal(int)

    def __init__(self):
        super().__init__()
        self.the_game = TheGame()

        self.setupUi(self)
        self.setFixedSize(384, 670)
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        self.connectWidget()
        self.initGuiProperty()

        self.show()
        self.clicked_player = ""

    def connectWidget(self):
        self.move_label.mousePressEvent = self.label_moveClicked
        self.move_label.mouseMoveEvent = self.label_moveMove
        self.move_label.setEnabled(True)
        self.start_button.mousePressEvent = self.startButtonClicked
        self.exit_button.mousePressEvent = self.closeEvent

        self.play_again_label.mousePressEvent = self.playAgainClicked
        self.menu_label.mousePressEvent = self.menuClicked

        self.player_left.mousePressEvent = self.playerLeftClicked
        self.player_right.mousePressEvent = self.playerRightClicked
        self.ai_left.mousePressEvent = self.aiLeftClicked
        self.ai_right.mousePressEvent = self.aiRightClicked

        self.exit_button_ingame.mousePressEvent = self.menuClicked
        # self.player_left.enterEvent = self.hoverPlayerLeft
        # self.player_left.leaveEvent = self.unHoverPLayerLeft

        self.playerTurnSignal.connect(self.the_game.playGame)
        self.the_game.resultStateSignal.connect(self.stateResultCallback)
        self.the_game.resultAiSignal.connect(self.stateResultCallbackAi)
        self.the_game.resultPlayerSignal.connect(
            self.stateResultCallbackPlayer)
        self.the_game.resultLoseSignal.connect(self.playerLose)

        self.move_label.raise_()

    def hoverPlayerLeft(self, event):
        self.scaleWidgetTo(self.player_left, 1.2)
        self.moveWidgetTo(self.player_left, 0, -50)

    def unHoverPLayerLeft(self, event):
        self.scaleWidgetTo(self.player_left, 1 / 1.2)
        self.moveWidgetTo(self.player_left, 0, 50)
        pass

    def initGuiProperty(self):
        self.oldPos = self.pos()

        self.player_left.setText("")
        self.player_right.setText("")
        self.ai_left.setText("")
        self.ai_right.setText("")
        self.changeAiLeftHandTo(1)
        self.changeAiRightHandTo(1)
        self.changePlayerLeftHandTo(1)
        self.changePlayerRightHandTo(1)

        self.bg_label.setPixmap(QtGui.QPixmap("Assets/Background dll/BG.png"))
        self.logo_label.setPixmap(
            QtGui.QPixmap("Assets/Background dll/Ayo Main.png"))
        # self.logo_label.setScaledContents(True)
        self.logo_label.setText("")

        logo_start = QtGui.QPixmap("Assets/Background dll/Start.png")
        self.start_button.setPixmap(logo_start)
        # self.start_button.setScaledContents(True)
        self.exit_button.setPixmap(
            QtGui.QPixmap("Assets/Background dll/Exit.png"))
        # self.exit_button.setScaledContents(True)

        self.lose_label.setPixmap(QPixmap("Assets/Background dll/YouLose.png"))
        self.lose_label.setAlignment(Qt.AlignHCenter)
        self.menu_label.setPixmap(QPixmap("Assets/Background dll/Exit.png"))
        self.menu_label.setAlignment(Qt.AlignHCenter)
        self.lose_frame.setStyleSheet("background-color:rgba(22,22,22,0.6)")
        self.lose_label.setStyleSheet("background-color:rgba(22,22,22,0)")
        self.menu_label.setStyleSheet("background-color:rgba(22,22,22,0)")
        self.play_again_label.setStyleSheet(
            "background-color:rgba(22,22,22,0)")
        self.play_again_label.hide()
        self.lose_frame.hide()
        # self.moveWidgetTo(self.lose_frame,0,-800)

        self.ingame_frame.hide()
        self.home_frame.raise_()
        self.move_label.raise_()
        # self.ai_left.setText("")
        # self.ai_right.setText("")
        self.moveWidgetTo(self.status_game_label, 400, 0)
        self.exit_button_ingame.setPixmap(
            QPixmap("Assets/Background dll/Exit.png"))
        self.exit_button_ingame.setScaledContents(True)
        self.exit_button_ingame.hide()

        self.audio_main_menu = QSound("Assets/Audio/menu.wav")
        # self.audio_main_menu.
        self.audio_main_menu.setLoops(QSound.Infinite)
        self.audio_main_menu.play()

        self.audio_lose = QSound("Assets/Audio/lose.wav")
        self.audio_lose.setLoops(False)
        # self.audio_lose.play()

        # self.move_label.setStyleSheet("background-color:rgb(22,22,22)")

    @Slot(object)
    def stateResultCallback(self, game_state: GameState):
        print("SLOT STATE ")
        # time.sleep(1)
        # game_state.print()
        # self.changeAiLeftHandTo(game_state.values[1][0])
        # self.changeAiRightHandTo(game_state.values[1][1])
        #
        # # time.sleep(2)
        # self.stateResultCallbackAi(game_state)

    def showLoseFrame(self):
        self.lose_frame.show()
        self.lose_frame.raise_()
        # self.animMoveWidget(self.lose_frame,0,800,700,QEasingCurve.InExpo)
        pass

    @Slot(object)
    def playerLose(self, game_state):
        self.audio_main_menu.stop()
        self.audio_lose.play()
        self.changeAiLeftHandTo(game_state.values[1][0])
        self.changeAiRightHandTo(game_state.values[1][1])
        self.changePlayerLeftHandTo(game_state.values[0][0])
        self.changePlayerRightHandTo(game_state.values[0][1])
        self.status_game_label.setText("YOU LOSE!")
        print("KALAH GAME GUI")
        self.status_game_label.setPixmap(None)
        self.showLoseFrame()

    @Slot(object)
    def stateResultCallbackPlayer(self, game_state: GameState):
        print("SLOT STATE ")
        # time.sleep(1)
        game_state.print()
        self.changeAiLeftHandTo(game_state.values[1][0])
        self.changeAiRightHandTo(game_state.values[1][1])
        self.changePlayerLeftHandTo(game_state.values[0][0])
        self.changePlayerRightHandTo(game_state.values[0][1])
        self.turnStatusShow(1)

    def resetAiLeftHand(self):
        self.animMoveWidget(self.ai_left, 0, -175, 300, QEasingCurve.InExpo,
                            self.changeAllHandImage)
        pass

    def resetAiRightHand(self):
        self.animMoveWidget(self.ai_right, 0, -175, 300, QEasingCurve.InExpo,
                            self.changeAllHandImage)
        pass

    def resetAiLeftHand2(self):
        self.animMoveWidget(self.ai_left, -100, -175, 300, QEasingCurve.InExpo,
                            self.changeAllHandImage)

    def resetAiRightHand2(self):
        self.animMoveWidget(self.ai_right, 100, -175, 300, QEasingCurve.InExpo,
                            self.changeAllHandImage)

    def resetDivideAiHand(self):
        self.anim_devide = QtCore.QParallelAnimationGroup()
        self.anim_devide.addAnimation(
            self.animateWidgetMove(self.ai_left, -25, 0, 240,
                                   QEasingCurve.OutExpo))
        self.anim_devide.addAnimation(
            self.animateWidgetMove(self.ai_right, 25, 0, 240,
                                   QEasingCurve.OutExpo))
        self.anim_devide.finished.connect(self.changeAllHandImage)
        self.anim_devide.start()

    def animateAiHand(self, number):
        if number == 0:
            self.animMoveWidget(self.ai_left, 0, 175, 300, QEasingCurve.InExpo,
                                self.resetAiLeftHand)
        elif number == 1:
            self.animMoveWidget(self.ai_left, 100, 175, 300,
                                QEasingCurve.InExpo, self.resetAiLeftHand2)
        elif number == 2:
            self.animMoveWidget(self.ai_right, -100, 175, 300,
                                QEasingCurve.InExpo, self.resetAiRightHand2)
        elif number == 3:
            self.animMoveWidget(self.ai_right, 0, 175, 300,
                                QEasingCurve.InExpo, self.resetAiRightHand)
        elif number == 4:
            self.anim3 = QtCore.QParallelAnimationGroup()
            self.anim3.addAnimation(
                self.animateWidgetMove(self.ai_left, 25, 0, 240,
                                       QEasingCurve.InExpo))
            self.anim3.addAnimation(
                self.animateWidgetMove(self.ai_right, -25, 0, 240,
                                       QEasingCurve.InExpo))
            self.anim3.finished.connect(self.resetDivideAiHand)
            self.anim3.start()

    @Slot(object)
    def stateResultCallbackAi(self, game_state: GameState):
        print("CALLBACKKK AI : ", game_state.values[2][0])
        self.game_state_tmp = game_state
        self.animateAiHand(game_state.values[2][0])
        # self.changeAiLeftHandTo(game_state.values[1][0])
        # self.changeAiRightHandTo(game_state.values[1][1])
        # self.changePlayerLeftHandTo(game_state.values[0][0])
        # self.changePlayerRightHandTo(game_state.values[0][1])
        self.turnStatusShow(0)

    def changeAllHandImage(self):
        game_state = self.game_state_tmp
        self.changeAiLeftHandTo(game_state.values[1][0])
        self.changeAiRightHandTo(game_state.values[1][1])
        self.changePlayerLeftHandTo(game_state.values[0][0])
        self.changePlayerRightHandTo(game_state.values[0][1])
        # self.turnStatusShow(0)

    @Slot(QPixmap)
    def setLeftPlayerHandImage(self, img):
        pass

    @Slot(QPixmap)
    def setRightPlayerHandImage(self, img):
        pass

    @Slot(QPixmap)
    def setLeftAiHandImage(self, img):
        pass

    @Slot(QPixmap)
    def setRightAiHandImage(self, img):
        pass

    def changeAiLeftHandTo(self, number):
        # self.player_left.setPixmap()
        # image_hand = QtGui.QPixmap("Assets/AiPlayer/"+str(number)+"Kiri.png")
        image_hand = QtGui.QPixmap("Assets/AiKiri/akiri0" + str(number) +
                                   "f4.png")
        image_hand = image_hand.transformed(QTransform().scale(1, -1))
        self.ai_left.setPixmap(image_hand)
        # self.ai_left.setScaledContents(True)

    def changeAiRightHandTo(self, number):
        # self.player_left.setPixmap()
        # image_hand = QtGui.QPixmap("Assets/AiPlayer/"+str(number)+"Kanan.png")
        image_hand = QtGui.QPixmap("Assets/AiKanan/akanan0" + str(number) +
                                   "f4.png")
        image_hand = image_hand.transformed(QTransform().scale(1, -1))
        self.ai_right.setPixmap(image_hand)
        self.ai_right.setScaledContents(True)

    def changePlayerLeftHandTo(self, number):
        # self.player_left.setPixmap()
        # image_hand = QtGui.QPixmap("Assets/Player1/"+str(number)+"Kiri.png")
        image_hand = QtGui.QPixmap("Assets/PlayerKiri/pkiri0" + str(number) +
                                   "f4.png")
        self.player_left.setPixmap(image_hand)
        self.player_left.setScaledContents(True)
        pass

    def changePlayerRightHandTo(self, number):
        # self.player_right.setPixmap()
        # image_hand = QtGui.QPixmap("Assets/Player1/" + str(number) + "Kanan.png")
        image_hand = QtGui.QPixmap("Assets/PlayerKanan/pkanan0" + str(number) +
                                   "f4.png")
        self.player_right.setPixmap(image_hand)
        self.player_right.setScaledContents(True)
        pass

    def playerLeftClicked(self, event):

        if self.clicked_player != "" and self.the_game.game_states.values[0][
                0] != self.the_game.game_states.values[0][1]:
            self.animMoveWidget(self.player_right,
                                to_x=0,
                                to_y=25,
                                duration=400,
                                ease=QEasingCurve.OutExpo,
                                finished_=None)
            self.playerTurnSignal.emit(4)
            self.clicked_player = ""

        else:
            # self.player_left.setGeometry()
            # self.hoverPlayerLeft("")
            self.anim = self.animateWidgetMove(self.player_left, 0, -25, 400,
                                               QEasingCurve.OutExpo)
            self.anim.start()
            self.clicked_player = "left"
        print("CLICKED PLAYER ", self.clicked_player)

    def playerRightClicked(self, event):
        if self.clicked_player != "":
            self.animMoveWidget(self.player_left,
                                to_x=0,
                                to_y=25,
                                duration=400,
                                ease=QEasingCurve.OutExpo,
                                finished_=None)
            self.playerTurnSignal.emit(4)
            self.clicked_player = ""
        else:
            self.anim = self.animateWidgetMove(self.player_right, 0, -25, 250,
                                               QEasingCurve.OutExpo)
            self.anim.start()
            self.clicked_player = "right"
        print("CLICKED PLAYER ", self.clicked_player)

    def resetPlayerLeft(self):
        self.anim = self.animateWidgetMove(self.player_left, 0, 175, 350,
                                           QEasingCurve.OutExpo)
        self.anim.start()

    def resetPlayerRight(self):
        self.anim = self.animateWidgetMove(self.player_right, 100, 175, 350,
                                           QEasingCurve.OutExpo)
        self.anim.start()

    def resetPlayerLeft2(self):
        self.anim = self.animateWidgetMove(self.player_left, -100, 175, 350,
                                           QEasingCurve.OutExpo)
        self.anim.start()

    def resetPlayerRight2(self):
        self.anim = self.animateWidgetMove(self.player_right, 0, 175, 350,
                                           QEasingCurve.OutExpo)
        self.anim.start()

    def animMoveWidget(self, widget: QLabel, to_x, to_y, duration,
                       ease: QEasingCurve, finished_):
        self.anim = self.animateWidgetMove(widget, to_x, to_y, duration, ease)
        if finished_ is not None:
            print("sini")
            self.anim.finished.connect(finished_)
        self.anim.start()

    def aiLeftClicked(self, event):
        # self.ai_clicked = "left"
        print("CLICKED AI LEFT")

        if (self.clicked_player == 'left'):
            self.anim = self.animateWidgetMove(self.player_left, 0, -150, 450,
                                               QEasingCurve.OutExpo)
            self.anim.finished.connect(self.resetPlayerLeft)
            self.anim.start()
            self.playerTurnSignal.emit(0)
        elif self.clicked_player == 'right':
            self.anim = self.animateWidgetMove(self.player_right, -100, -150,
                                               450, QEasingCurve.OutExpo)
            self.anim.finished.connect(self.resetPlayerRight)
            self.anim.start()
            self.playerTurnSignal.emit(3)

        self.clicked_player = ""

    def aiRightClicked(self, event):
        print("CLICKED AI RIGHT")
        # self.ai_clicked = "right"
        if (self.clicked_player == 'left'):
            self.anim = self.animateWidgetMove(self.player_left, 100, -150,
                                               450, QEasingCurve.OutExpo)
            self.anim.finished.connect(self.resetPlayerLeft2)
            self.anim.start()
            self.playerTurnSignal.emit(1)
            print("CLICKED AI EMIT 1")
        elif self.clicked_player == 'right':
            self.anim = self.animateWidgetMove(self.player_right, 0, -150, 450,
                                               QEasingCurve.OutExpo)
            self.anim.finished.connect(self.resetPlayerRight2)
            self.anim.start()
            self.playerTurnSignal.emit(2)
        self.clicked_player = ""

    def _animateTurnStatus2(self):
        self.anim_groupstate = QtCore.QParallelAnimationGroup()

        self.anim_groupstate.addAnimation(
            self.animateWidgetMove(self.status_game_label, 400, 0, 1000,
                                   QEasingCurve.InExpo))
        if self.the_game.game_states.player == 1:
            print("MASUK SINI CUIY11")
            self.anim_groupstate.finished.connect(self.the_game.playGameAi)
        else:
            print("MASUK SINI CUIY")
        self.anim_groupstate.start()
        pass

    def animateTurnStatus(self):
        self.anim_groupstatus = QtCore.QParallelAnimationGroup()
        # print("MASUK SINI CUIY")
        self.anim_groupstatus.addAnimation(
            self.animateWidgetMove(self.status_game_label, 400, 0, 300,
                                   QEasingCurve.OutExpo))
        self.anim_groupstatus.finished.connect(self._animateTurnStatus2)
        self.anim_groupstatus.start()
        pass

    @Slot(int)
    def turnStatusShow(self, turn):
        if turn == 1:
            turn_img = QPixmap("Assets/Background dll/AITurn.png")
        else:
            turn_img = QPixmap("Assets/Background dll/YourTurn.png")

        self.moveWidgetTo(self.status_game_label, -800, 0)
        self.status_game_label.setPixmap(turn_img)
        self.status_game_label.setText("")
        self.status_game_label.show()
        self.status_game_label.raise_()

        self.animateTurnStatus()

    def scaleWidgetTo(self, widget: QLabel, to_s):
        widget.setGeometry(
            QRect(widget.x(), widget.y(),
                  widget.width() * to_s,
                  widget.height() * to_s))

    def moveWidgetTo(self, widget: QLabel, to_x, to_y):
        widget.setGeometry(
            QRect(widget.x() + to_x,
                  widget.y() + to_y, widget.width(), widget.height()))

    def showHandAnimation(self):
        self.anim_group = QtCore.QParallelAnimationGroup()
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.player_left, 0, -300, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.player_right, 0, -300, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.ai_left, 0, 300, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.ai_right, 0, 300, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.finished.connect(self.showTurnInit)
        self.anim_group.start()

    def showTurnInit(self):
        self.turnStatusShow(0)

    def showIngameFrame(self):
        self.home_frame.hide()
        self.ingame_frame.show()
        self.ingame_frame.raise_()

        self.moveWidgetTo(self.player_left, 0, 300)
        self.moveWidgetTo(self.player_right, 0, 300)
        self.moveWidgetTo(self.ai_left, 0, -300)
        self.moveWidgetTo(self.ai_right, 0, -300)

        self.showHandAnimation()
        # pass

    def animateWidgetMove(self, widget, to_x, to_y, duration, ease):
        anim = QPropertyAnimation(widget, b"geometry")
        anim.setDuration(duration)
        anim.setStartValue(
            QRect(widget.x(), widget.y(), widget.width(), widget.height()))
        anim.setEndValue(
            QRect(widget.x() + to_x,
                  widget.y() + to_y, widget.width(), widget.height()))
        anim.setEasingCurve(ease)
        # anim.state()
        return anim

    def startButtonAnimation(self):
        # widget.setPixmap
        # self.start_button.setPixmap(QtGui.QPixmap("Assets/Background dll/Start.png")
        #                             .scaledToHeight(75,Qt.TransformationMode.SmoothTransformation))
        # time.sleep(0.1)
        # self.anim.finished.connect(self.showIngameFrame)
        # self.anim.start()
        # self.effect = QGraphicsOpacityEffect()
        # self.start_button.setGraphicsEffect(self.effect)
        #
        # self.anim2 = QPropertyAnimation(self.effect, b"opacity")
        # self.anim2.setDuration(500)
        # # self.anim2.setCurrentTime(-100)
        # self.anim2.setStartValue(1)
        # self.anim2.setEndValue(1)

        self.anim_group = QtCore.QParallelAnimationGroup()
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.start_button, 0, 300, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.exit_button, 0, 100, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.logo_label, 0, -400, 1300,
                                   QEasingCurve.InBounce))
        self.anim_group.finished.connect(self.showIngameFrame)
        self.anim_group.start()

    def startButtonClicked(self, event):
        self.startButtonAnimation()

    def playAgainClicked(self, event):
        pass

    def showAgainHomeAnimation(self):
        self.anim_group = QtCore.QParallelAnimationGroup()
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.start_button, 0, -300, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.exit_button, 0, -100, 1000,
                                   QEasingCurve.InOutExpo))
        self.anim_group.addAnimation(
            self.animateWidgetMove(self.logo_label, 0, 400, 1300,
                                   QEasingCurve.InBounce))
        self.anim_group.start()
        pass

    def menuClicked(self, event):
        self.audio_lose.stop()
        self.audio_main_menu.play()
        print("MENU CLICKED")
        self.changeAiLeftHandTo(1)
        self.changeAiRightHandTo(1)
        self.changePlayerLeftHandTo(1)
        self.changePlayerRightHandTo(1)
        self.the_game.resetState()
        self.lose_frame.hide()
        self.ingame_frame.hide()
        self.home_frame.show()
        self.home_frame.raise_()
        self.clicked_player = ""
        self.showAgainHomeAnimation()

    pass

    def label_moveClicked(self, event):
        # print("EMIT CLICK MOVE")
        self.oldPos = event.globalPos()

    def label_moveMove(self, event):
        # print("EMIT MOVE")
        delta = QPoint(event.globalPos() - self.oldPos)
        # print(delta)
        self.move(self.x() + delta.x(), self.y() + delta.y())
        self.oldPos = event.globalPos()

    def exitPressed(self):
        # self.exit()
        # print("posisi 3", self.start_button.y())
        pass

    def closeEvent(self, event):
        print("QUIT BROOO")
        self.exitPressed()
        # self.close()
        sys.exit()
 def trigger(self):
     QSound.play(self._path)