Skip to content

Commit

Permalink
Fixed a bug
Browse files Browse the repository at this point in the history
Fixed the bug that crashes program when you clicked "Surf Words" without a word data.
  • Loading branch information
DolphyWind committed Sep 29, 2022
1 parent ec85483 commit 5f65508
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def switchMenu(self, menu: Menu, wordData: word.Word = None):
if menu == Menu.PLAY_GAME:
return

if menu == Menu.SURF_WORDS:
if len(self.wordData) == 0:
QtWidgets.QMessageBox.warning(self, 'Error!', 'You Have to add some words to your dictionary!', QtWidgets.QMessageBox.Ok)
return

if menu == self.previousMenu:
self.menuList.pop(-1)

Expand Down Expand Up @@ -586,6 +591,8 @@ def changeWord(index, step):
def getRandomWord():
new_word = word.Word()
keys_list = list(self.wordData.keys())
if len(keys_list) <= 1:
return
randomWord = random.choice(keys_list)
while randomWord == currentWord.word:
randomWord = random.choice(keys_list)
Expand Down

0 comments on commit 5f65508

Please sign in to comment.