diff --git a/component/modal.py b/component/modal.py index d36c357..a6aaa5c 100644 --- a/component/modal.py +++ b/component/modal.py @@ -1,4 +1,4 @@ -from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout, QDialog, QHBoxLayout, QLabel +from PyQt6.QtWidgets import QPushButton, QDialog, QHBoxLayout class ConfirmDialog(QDialog): def __init__(self, parent=None): @@ -21,7 +21,7 @@ def initUI(self): self.setLayout(layout) def confirm(self): - self.accept() # Closes the dialog and returns QDialog.Accepted + self.accept() def cancel(self): - self.reject() # Closes the dialog and returns QDialog.Rejected \ No newline at end of file + self.reject() \ No newline at end of file diff --git a/component/screen/end_screen.py b/component/screen/end_screen.py index 7376b7f..c9bfef4 100644 --- a/component/screen/end_screen.py +++ b/component/screen/end_screen.py @@ -15,7 +15,8 @@ def __init__(self,navigator,screen_height,screen_width, result): self.result = result self.initUI() - self.saveResult(result) + if(result is not None): + self.saveResult(result) def initUI(self): layout = QVBoxLayout(self) diff --git a/component/screen/test_screen.py b/component/screen/test_screen.py index a7995c7..1327a45 100644 --- a/component/screen/test_screen.py +++ b/component/screen/test_screen.py @@ -8,6 +8,7 @@ from pydub.playback import play from config.dir import audio_dir from config.constant import pofomopo_consonants,similarity_list +from pydub import AudioSegment # TestScreen @@ -129,7 +130,6 @@ def update_button_states(self): def handling_submit_button(self): self.submit_test() self.navigator.navigate_to_end_screen() - self.navigate_end_screen() def submit_test(self): for question in self.answerList: diff --git a/component/screen/user_information_screen.py b/component/screen/user_information_screen.py index 9a19fd5..ac85737 100644 --- a/component/screen/user_information_screen.py +++ b/component/screen/user_information_screen.py @@ -44,12 +44,6 @@ def initUI(self)->None: def save_data(self): user_info = {label: edit.text() for label, edit in self.fields.items()} print("User Info Saved:", user_info) - - def navigate_test_screen(self): - logging.info("Open the TestScreen") - self.test_screen = TestScreen(self.screen_height,self.screen_width) - self.test_screen.show() - self.close() def show_confirm_dialog(self): dialog = ConfirmDialog(self) @@ -58,7 +52,6 @@ def show_confirm_dialog(self): if result == QDialog.DialogCode.Accepted: print("Save confirmed") self.save_data() - # self.navigator - self.navigate_test_screen() + self.navigator.navigate_to_test_screen() else: print("Save cancelled") \ No newline at end of file diff --git a/component/text.py b/component/text.py deleted file mode 100644 index 82ec5d6..0000000 --- a/component/text.py +++ /dev/null @@ -1,13 +0,0 @@ -from psychopy.visual import TextStim -from config.dir import font_dir - - -class TextElement: - def __init__(self, win, text, pos, color=(1, 1, 1)): - self.text = TextStim(win, text=text, pos=pos, color=color,colorSpace='rgb',font='Noto Sans TC',fontFiles=[font_dir]) - def set_text(self,text): - self.text.setText(text) - def set_color(self,color): - self.text.setColor(color=color) - def draw(self): - self.text.draw() \ No newline at end of file diff --git a/main.py b/main.py index 4022a48..95f9c2a 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,11 @@ from controller import Navigator import logging -if __name__ == "__main__": - try: - navigator = Navigator() - navigator.start() - except Exception as e: - logging.error("An error occurred: %s", str(e)) \ No newline at end of file +# if __name__ == "__main__": +# try: +# navigator = Navigator() +# navigator.start() +# except Exception as e: +# logging.error("An error occurred: %s", str(e)) +navigator = Navigator() +navigator.start() \ No newline at end of file