Hi,
I’m looking to get my pythonista code into app mode, and I’m looking for some advice from others. I created the UI folder so I have a UI file and a Python file. The only tutorials I can find are for different types of games.
I need to figure out how to incorporate my code into the UI layout. Thoughts?
This is my code, the console says I haven’t defined myInterface, so I need help with that.
import ui
import time
from random import choice
def intro():
print("The Guitar Oracle is listening.")
time.sleep(2)
def key (myInterface):
viewSelector = myInterface.superview
textFromTextBox = viewSelector['textview1'].text
keys = ['C','F','Bb','Eb','Ab','Db','Gb', 'Cb','G','D','A','E','B','F#','C#']
key = input("Choose your key: ").capitalize()
if (key == 'C'):
print('You chose C, excellent')
ask=input('Major or Minor?: ').lower()
if (ask=='major'):
cmajor = ['C Ionian: C – D – E – F – G – A – B','C Lydian: C - D - E - F# - G - A - B','C Mixolydian: C - D - E - F - G - A - Bb', 'C Maj Pentatonic: C - D - E - G - A']
levels= input('Choose your level (1, 2, or 3): ')
validLevel = range(1,4) #provides range for acceptable levels 1, 2, or 3
if (levels.isnumeric()):
levels = int(levels)
if (levels == 1):
question = choice(cmajor)
print(question)
elif (levels == 2):
question = choice(cmajor),choice(cmajor)
print(question)
elif (levels == 3):
question = choice(cmajor),choice(cmajor),choice(cmajor)
print(question)
if (ask=='minor'):
cminor = ['C Dorian: C - D - Eb - F - G - A - Bb','C Phrygian: C - Db - Eb - F - G - Ab - Bb', 'C Aeolian: C - D - Eb - F - G - Ab - Bb','C Locrian: C - Db - Eb - F - Gb - Ab - Bb', 'C Harmonic Minor: C - D - Eb - F - G - Ab - B','C Melodic Minor: C - D - Eb - F - G - A - B','C Min Pentatonic: C - Eb - F - G - Bb']
levels= input('Choose your level (1, 2, or 3): ')
validLevel = range(1,4) #provides range for acceptable levels 1, 2, or 3
if (levels.isnumeric()):
levels = int(levels)
if (levels == 1):
question = choice(cminor)
print(question)
elif (levels == 2):
question = choice(cminor),choice(cminor)
print(question)
elif (levels == 3):
question = choice(cminor),choice(cminor),choice(cminor)
print(question)
if __name__ == "__main__":
intro()
practicing = True
while practicing: #prompts the user to keep playing
key(myInterface)
viewSelector = myInterface.superview
textFromTextBox = viewSelector['textview1'].text
time.sleep(2)
keepPracticing = input('Do you want to keep practicing (yes or no)? ')
validUser = ['yes', 'y','sure','ok','k','okay'] #acceptable answers for keepPracticing
if (keepPracticing not in validUser): practicing = False #terminates program/loop
print('Goodbye')
v = ui.load_view()
v.present('sheet')