Finished the translators

This commit is contained in:
Lyx committed 2025-03-22 17:38:08 +01:00
1 parent 4d5fa48dc8
commit 69be021863
3 files changed
+98 -88

No files matched your search

+5 -9
View File
@@ -1,12 +1,9 @@
from functions import binarian from submenus import entoBin, binToEn, translateMenu
from functions import unbinarian
from submenus import entoBin
from submenus import binToEn
from functions import clear from functions import clear
import readchar import readchar
def main_menu(): def main_menu():
options = ["Translate from English to Binarian", "Translate from Binarian to English", "Exit"] options = ["Translate from English to Binarian","Translate from Binarian to English","Translate","Exit"]
selected = 0 selected = 0
while True: while True:
@@ -30,11 +27,10 @@ def main_menu():
break break
elif options[selected] == "Translate from English to Binarian": elif options[selected] == "Translate from English to Binarian":
entoBin() entoBin()
elif option[selected == "Translate from Binarian to English"]: elif options[selected] == "Translate from Binarian to English":
binToEn() binToEn()
else: elif options[selected] == "Translate":
print(f"Selected: {options[selected]}") translateMenu()
input("Press Enter to return to menu...")
if __name__ == "__main__": if __name__ == "__main__":
main_menu() main_menu()
+82 -79
View File
@@ -1,85 +1,88 @@
import readchar import readchar
from gamemodes import norToBin from gamemodes import norToBin, binToNor
from gamemodes import binToNor
from functions import clear from functions import clear
def entoBin(): from translate import translateEnToBin, translateBinToEn # Ensure these are correctly imported
options = ["Level 1", "Level 2", "Level 3","Level 4", "Level 5" , "Back to main menu"]
selected = 0
while True: def entoBin():
clear() options = ["Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Back to main menu"]
print("Select a level to start translating!") selected = 0
print("Use arrow keys to navigate and Enter to select:\n")
while True:
for i, option in enumerate(options): clear()
prefix = "> " if i == selected else " " print("Select a level to start translating!")
print(f"{prefix}{option}") print("Use arrow keys to navigate and Enter to select:\n")
key = readchar.readkey() for i, option in enumerate(options):
prefix = "> " if i == selected else " "
if key == readchar.key.UP and selected > 0: print(f"{prefix}{option}")
selected -= 1
elif key == readchar.key.DOWN and selected < len(options) - 1: key = readchar.readkey()
selected += 1
elif key == readchar.key.ENTER: if key == readchar.key.UP and selected > 0:
if options[selected] == "Level 1": selected -= 1
clear() elif key == readchar.key.DOWN and selected < len(options) - 1:
norToBin(1) selected += 1
elif options[selected] == "Level 2": elif key == readchar.key.ENTER:
clear() if selected < 5: # If it's a level
norToBin(2) clear()
elif options[selected] == "Level 3": norToBin(selected + 1)
clear() else: # Back to main menu
norToBin(3) print("Exiting...")
elif options[selected] == "Level 4": break
clear()
norToBin(4)
elif options[selected] == "Level 5":
clear()
norToBin(5)
elif options[selected] == "Back to main menu":
print("Exiting...")
break
else:
print(f"Selected: {options[selected]}")
def binToEn(): def binToEn():
options = ["Level 1", "Level 2", "Level 3","Level 4", "Level 5" , "Back to main menu"] options = ["Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Back to main menu"]
selected = 0 selected = 0
while True: while True:
clear() clear()
print("Select a level to start translating!") print("Select a level to start translating!")
print("Use arrow keys to navigate and Enter to select:\n") print("Use arrow keys to navigate and Enter to select:\n")
for i, option in enumerate(options): for i, option in enumerate(options):
prefix = "> " if i == selected else " " prefix = "> " if i == selected else " "
print(f"{prefix}{option}") print(f"{prefix}{option}")
key = readchar.readkey() key = readchar.readkey()
if key == readchar.key.UP and selected > 0: if key == readchar.key.UP and selected > 0:
selected -= 1 selected -= 1
elif key == readchar.key.DOWN and selected < len(options) - 1: elif key == readchar.key.DOWN and selected < len(options) - 1:
selected += 1 selected += 1
elif key == readchar.key.ENTER: elif key == readchar.key.ENTER:
if options[selected] == "Level 1": if selected < 5:
clear() clear()
binToNor(1) binToNor(selected + 1)
elif options[selected] == "Level 2": else:
clear() print("Exiting...")
binToNor(2) break
elif options[selected] == "Level 3":
clear() def translateMenu():
binToNor(3) options = ["Binarian to English", "English to Binarian", "Back to main menu"]
elif options[selected] == "Level 4": selected = 0
clear()
binToNor(4) while True:
elif options[selected] == "Level 5": clear()
clear() print("Select if you want to translate from or to Binarian!")
binToNor(5) print("Use arrow keys to navigate and Enter to select:\n")
elif options[selected] == "Back to main menu":
print("Exiting...") for i, option in enumerate(options):
break prefix = "> " if i == selected else " "
else: print(f"{prefix}{option}")
print(f"Selected: {options[selected]}")
key = readchar.readkey()
if key == readchar.key.UP and selected > 0:
selected -= 1
elif key == readchar.key.DOWN and selected < len(options) - 1:
selected += 1
elif key == readchar.key.ENTER:
if selected == 0:
clear()
translateBinToEn()
elif selected == 1:
clear()
translateEnToBin()
else:
print("Exiting...")
break
+11
View File
@@ -0,0 +1,11 @@
from functions import *
def translateEnToBin():
userIn = input("Enter english word/sentence\n>")
print(binarian(userIn))
input("Hit ENTER to continue")
def translateBinToEn():
userIn = input("Enter binarian word/sentence\n>")
print(unbinarian(userIn))
input("Hit ENTER to continue")