• craigmrock

    Hi, working on UI layout and want to know how to get a photo from my camera roll or my iCloud Drive to display in the UI grid.

    posted in Pythonista read more
  • craigmrock

    @mikael they aren’t named myInterface, but they are both named the same thing, GOapp.py and GOapp.pyui in the same folder

    posted in Pythonista read more
  • craigmrock

    @cvp I’m not sure how to show that here, I don’t see adding a picture/screenshot option and my UI file only shows the grid layout. I thought I had accessed a code version before, but every button I press in the menu seems to take me everywhere but where the code is (using my iPhone, not a tablet).

    posted in Pythonista read more
  • craigmrock

    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.")
    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)
                elif (levels == 2):
                    question = choice(cmajor),choice(cmajor)
                elif (levels == 3):
                    question = choice(cmajor),choice(cmajor),choice(cmajor)
                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)
                    elif (levels == 2):
                        question = choice(cminor),choice(cminor)
                    elif (levels == 3):
                        question = choice(cminor),choice(cminor),choice(cminor)
    if __name__ == "__main__":
        practicing = True
        while practicing: #prompts the user to keep playing
            viewSelector = myInterface.superview
            textFromTextBox = viewSelector['textview1'].text
            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
    v = ui.load_view()

    posted in Pythonista read more
  • craigmrock

    Trying to build a 3 function program:

    1. What key(music)?
    2. Major or minor?
      3.What level (for practicing)?
      Having trouble with local variables I think. The steps should be: get the key, decide between major or minor scales, then determine how many scales to provide, 1, 2, or 3?
      I have this working properly without functions but believe there’s a cleaner way to write it.
    from random import choice
    def key():
        keys = ['A','B','C','D','E','F','G']
        k1=input('Choose your key: ').upper()
        if k1 in keys:
            print('Ahh,',k1, 'excellent choice.')
            print('I do not understand your choice.')
    def tone():
        major = ['Ionian: W,W,H,W,W,W,H','Lydian: W,W,W,H,W,W,H','Mixolydian: W,W,H,W,W,H']
        minor= ['Dorian: W,H,W,W,W,H,W','Phrygian: H,W,W,W,H,W,W','Aeolian: W,H,W,W,H,W,W','Locrian: H,W,W,H,W,W,W','Harmonic Minor: W,H,W,W,H,W+H,H']
        ask2 = input('Major or Minor: ')
        if (ask2=='major'):
                question = choice(major)
        elif (ask2=='minor'):
                question = choice(minor)
        def level():
            ask = int(input('Choose your level(1, 2, or 3): '))
            if (ask == 1):
                question = choice()
            elif (ask == 2):
                question = choice(),choice()
            elif (ask == 3):
                question = choice(),choice(),choice()
                print('I do not understand your choice.')

    posted in Pythonista read more
  • craigmrock

    Trying to return True if there are duplicate items in a list.
    Not working with numbers, and want to allow the user to make a list as long as they want...suggestions?

    user = input("What's on your list??: ")
    def has_consecutive():
        items = user.split() #trying to split list into items to compare
        if (items[0] == items[+1]): #trying to compare one item to the next to find duplicates
            return True #return true if duplicates are found
            return False #return False if no duplicates are found 

    posted in Pythonista read more
  • craigmrock

    Horrible at math (and probably Python) but trying to make a function that takes a word and adds an asterisk in between the letters. Trying with a 3 letter word, but the formula should handle any size word you give it.
    Here’s what I have:

    word=str(input('Give me a word: '))
    def starry_eyes(str):
        while word == (''):
            return ([],'*',[],'*',[])

    posted in Pythonista read more
  • craigmrock

    Thinking I set up this inheritance structure right, but getting an error that “ init() takes 1 positional argument but 15 were given.” Any thoughts?

    import random
    #Player Info
    class Player:
        def __init__ (self, name, race, subrace, age, subclass,hair, eyes, height, weight, strength, speed, intelligence, knowledge, attack, defense,**kwargs):
            for key,value in kwargs.items():
            self.name = name
            self.race = race
            self.subrace = subrace
            self.age = age
            self.subclass = subclass
            self.hair = hair
            self.eyes = eyes
            self.height = height
            self.weight = weight
            self.strength = random.randint(6,18)
            self.speed = random.randint(6,18)
            self.intelligence = random.randint(6,18)
            self.knowledge = random.randint(6,18)
            self.attack = random.randint(2,6)
            self.defense = random.randint(2,6)
        def __str__ (self):
            return ("Name: {}, Race: {}, Subrace: {}, Age: {}, Subclass: {}, Hair: {}, Eyes: {}, Height: {}, Weight:{}, Strength: {}, Speed: {}, Intelligence: {}, Knowledge: {}, Attack: {}, Defense: {}").format(self.name,self.race,self.subrace,
            self.height,self.weight,self.strength, self.speed,self.intelligence,self.knowledge,
    p1 = Player("Rob", "Human", "Hunter", "25", "none", "Brown", "Green", "72in","185"," "," "," "," "," "," ")
    #Special Classes for Players
    class Vampire(Player):
            def __init__ (self):
                data = {
                    "strength": random.randint(14,18),
                    "speed": random.randint(14,18),
                    "intelligence": random.randint(14,18),
                    "knowledge": random.randint(14,18)
    p2 = Vampire("Jon", "Vampire", "Archaea", "500", "none", "Black", "Red", "84in","225"," "," "," "," "," ")

    posted in Pythonista read more
  • craigmrock

    Getting an error that “mode object has no attribute scale_steps” when I run this, but I think everything is ok. Does anyone see where there is a disconnect??

    legal_mode = [ 
    stepping = [2, 2, 1, 2, 2, 2, 1]
    major_mode = ["Ionian"]
    class Mode():
        def __init__(self,title):
            self.title = title
            self.ismajor = title in major_mode
            tonic = legal_mode.index(title)
            self.stepping = stepping[tonic:]+stepping[:tonic]
            def __str__(self):
                return "Title: {}, Major{}".format(self.title, self.ismajor)
            def scale_steps(self):
                return "Half-steps{}".format(''.join(str(c) for c in self.stepping))
    mode1 = Mode("Ionian")
    mode2 = Mode("Dorian")

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!