• Add an ImageView to the pyui. Then see https://forum.omz-software.com/topic/4697/pyui-button-image-options/3 for adding custom property with your image file name (which should be saved to the same folder as the pyui)

  • import ui import time from random import choice class myclass(): def __init__(self): #self.v = ui.load_view('UIwithOtherName.pyui') self.v = ui.load_view() self.v.present('sheet') self.v.name = 'goapp' self.intro() self.key() def intro(self): self.v['textfield1'].text = "The Guitar Oracle is listening." time.sleep(2) def key(self): self.v['textfield1'].text = "Good bye." myclass()
  • It would be cleaner if those functions returned the answer, or raise an exception, e.g:

    selected_key=key() selected_tone=tone() selected_level=level()

    level() probably should not be an embedded function, but should live at the same level as key() and tone()

  • def hasdupelems(l): return len(l) != len(set(l)) print(hasdupelems(['ab', 'cd', 'ab', 'ef'])) print(hasdupelems(['ab', 'cd', 'ef']))
  • word = 'python' print('*'.join(word))
  • I think your Vampire init needs to look like

    def __init__(self, *args, **kwargs): super().__init__(self,*args, **kwargs) #now, override defaults with class specific data = { "strength": random.randint(14,18), "speed": random.randint(14,18), "intelligence": random.randint(14,18), "knowledge": random.randint(14,18) } for key,value in data.items(): setattr(self,key,value)

    Your Player class probably isnt doing what you expect -- for instance, you take a named strength argument -- which you ignore. Then, you apply kwargs, such as strength. Then you overwrite it with the default.

    Your approach seems very fragile -- do you want to enforce limits by class? In that case, each class should store the min/max limits, then attributes can be checked against those limits. Then you might simply have a roll() method that goes through each attribute, and randints between the limits -- i.e one loop, not fifty bazillion places where you call randint. less chance of errors.

  • @craigmrock Shift left the two def str and scale_steps, they are inside init

    legal_mode = [ "Ionian", "Dorian", "Phrygian", "Lydian", "Mixolydian", "Aeolian", "Locrian"] 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") print(mode1) print(mode1.scale_steps()) mode2 = Mode("Dorian") print(mode2) print(mode2.scale_steps())
  • @ccc thanks, that cleared up one of the errors I was getting through experimenting.

  • @ccc
    Beauty !

  • dgelessus - Good catch. I missed the missing space at first when I read the first post.

    That is def__init__-ly the problem.

    Sorry, I couldn't resist the bad pun.

    In my defense, I would have tried to help too, but I just got here.

Internal error.

Oops! Looks like something went wrong!