• adrius42

    I have tried searching the manual for a simple action...

    I want to store variables in an array, I found and implemented many ways of doing this
    Creating the array
    Creating the first elements is easy with variablesarray.append(list)

    I can even read them back with variablesarray[x][y]

    But I cannot for the life of me figure out how to change an element in the array

    In my old basic world it was very simple variablesarray[x][y]=newvalue

    How can I achieve this simple variable change in Python, what am I missing.

    I am confident it will be something simple... but I have yet to discover it.

    Pointers gratefully received...

    posted in Pythonista read more
  • adrius42

    Spotted your pointer to the GitHub humberry UI Tutorial, excitedly skipped over to GitHub
    As I really do want to “get” using pyui’s....
    Aargh! New Brick Walls!

    It may sound simple but how do I get a GitHub resident PYUI file to my iPad.
    You cannot imagine what I have tried so far, including forking the Tutorial!

    Yours incompetently

    posted in Pythonista read more
  • adrius42

    Well restart fixed it.... for now! Something funky going on....

    posted in Pythonista read more
  • adrius42

    @omz Having downloaded the beta, the Calculator example now bombs with:

    Traceback (most recent call last):
    File "/var/containers/Bundle/Application/AA2AD925-136B-48E0-80AA-xxxxxxxxxxx/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/ui.py", line 412, in load_view
    return load_view_str(json_str, bindings, stackframe, verbose=verbose)
    File "/var/containers/Bundle/Application/AA2AD925-136B-48E0-80AA-Xxxxxxxxxxx/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/ui.py", line 398, in load_view_str
    return _view_from_dict(root_view_dict, g, l, verbose=verbose)
    File "/var/containers/Bundle/Application/AA2AD925-136B-48E0-80AA-xxxxxxxxxxxx/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/ui.py", line 379, in _view_from_dict
    subview = _view_from_dict(d, f_globals, f_locals, verbose=verbose)
    File "/var/containers/Bundle/Application/AA2AD925-136B-48E0-80AA-xxxxxxxxxxxx/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/ui.py", line 321, in _view_from_dict
    _bind_action(v, attrs.get('action'), f_globals, f_locals, verbose=verbose)
    TypeError: my_bind_action() got an unexpected keyword argument 'verbose'

    (I xxxxxx’d out a part of my iPad I’d, I am that paranoid!)

    I tried copying the calculator.pyui file from my non upgraded iPhone into my iPad in case I had corrupted the pyui file, I got the same error.

    In my own very simple coding activities I have yet to bump into a beta error.

    I posted here as I cannot find instructions on how to report beta problems. sorry...

    posted in Pythonista read more
  • adrius42

    OMG why did I try a read the manual, I found a part in the manual that showed me that *100 would not work!?

    And yet it all did!


    Btw I wasn’t trying to do a sort that was just a historical side comment, but thanks for the pointer, stored for future reference.


    posted in Pythonista read more
  • adrius42

    I wish to create a blank array of 100 elements
    Where blank is either Integer 0 or Empty string ‘“” (two different use cases)
    Then I wish to write to specific elements in the array
    Either replacing the elements or adding/appending to them
    Having read and re read the documents

    I have not been able fathom how to accomplish these tasks.
    I recall in Algol that this was a trivial task, it was how I ”cheated” doing a sort task,
    According to my professor in doing a sort. He wanted a bubble sort.
    I simply wrote the numbers into an array where n= array element, and then read them out

    How!? In Python?

    Is a command missing from the documentation?

    posted in Pythonista read more
  • adrius42

    @JonB have finally sussed the some of the mysteryies of Stash, not least how to run it!
    How would I have discovered the existence of the -la extension to ls without your kind help?
    I have tried ‘man ls’ with no joy...

    posted in Pythonista read more
  • adrius42

    .... love your blog comments.

    Presumably someone sad thought they were clever writing a python script to Spam this forum.
    Well done you’ve proved you can do it...

    Otherwise I would appreciate if someone else with admin rights wrote a script to expunge these posts.
    I’ll keep flagging them for moderation in the interim.

    @omz ??

    posted in Pythonista read more
  • adrius42

    @JonB you are just amazing Thankyou!

    posted in Pythonista read more
  • adrius42

    So more, properly any ideas on changing a character to an image?

    posted in Pythonista read more
  • adrius42

    I have attempted to search this forum via Google, to answer the question.
    No joy apart from some old posts stating that it is not possible.

    Has anyone come up with a method for resolving this?

    I can call a menu but have not figured out how to get text input.....

    Ideas anyone?

    posted in Pythonista read more
  • adrius42

    In a <Scene> script that places a series of emojis on the Node, it seems that even after I have removed the images, their ghost still remained.

    I have solved the issue by the use of z-position.

    But I can’t figure out why something that is removed and not visible, can be found on the node?
    Any ideas?

    Also any one know how I can access the iPads emojis?

    # coding: utf-8
    from scene import *
    from random import choice, uniform, shuffle
    import sound
    from itertools import product
    from math import sqrt, pi
    A = Action
    ROWS = 3
    COLS = 14
    screen_size = min(get_screen_size())/2 
    center = (683,512)
    class ButtonNode (SpriteNode):
        def __init__(self, title, *args, **kwargs):
            SpriteNode.__init__(self, 'pzl:Button1', *args, **kwargs)
            button_font = ('Avenir Next', 20)
            self.title_label = LabelNode(title, font=button_font, color='black', position=(0, 1), parent=self)
            self.title = title
            return self.title_label
    class Object (SpriteNode):
        def __init__(self, img, col=0, row=0):
            SpriteNode.__init__(self, img, position=((col-0.5*col)*190+60, (row-0.5*row)*152+200))
            self.img_name = img            # image name
            self.title = img[4:]           # img with 'emj:' stripped from name
            self.grid_pos = (col, row)     # not used in this app
            self.i = col + (row * COLS)    # not used in this app
    class MyScene (Scene):
        def setup(self):
            self.space = Node(parent=self)
            self.background_color = '#004f82'
            #self.center = self.size/2
            self.img = [] # List of 38 emoji picture names, eg 'emj:Alien'
            self.emojis = [] # stores the emoji id's
            self.emoji_names = [] # List of  emoji names sripped of 'emj:' , not used to read emoji names
            self.emoji_original = [] # Alpha list of the emoji names
            self.namesis = [] # stores the label id's
            self.names_title = []
            self.touchdisabled = False
            post = (650, 970)
            self.show_title_label = self.show_message("Drag each emoji to it's correct title",  pos = post, font = 48)
            self.img = ('emj:Alien', 'emj:Angry', 'emj:Confounded', 'emj:Cold_Sweat_1', 'emj:Cold_Sweat_2', 'emj:Crying_1', 'emj:Crying_2', 'emj:Disappointed', 'emj:Dizzy', 'emj:Fear_1', 'emj:Fear_2', 'emj:Flushed', 'emj:Grinning', 'emj:Imp', 'emj:Kissing_1', 'emj:Kissing_2', 'emj:Look_Of_Triumph', 'emj:Medical_Mask', 'emj:Relieved', 'emj:Pensive', 'emj:Pouting', 'emj:Relieved', 'emj:Sleepy', 'emj:Smiling_1', 'emj:Smiling_2', 'emj:Smiling_3', 'emj:Smiling_4', 'emj:Smiling_5', 'emj:Smiling_6', 'emj:Smirking', 'emj:Stuck-Out_Tongue_1', 'emj:Stuck-Out_Tongue_2', 'emj:Stuck-Out_Tongue_3', 'emj:Tears_Of_Joy', 'emj:Tired', 'emj:Unamused', 'emj:Weary', 'emj:Winking')
            # print(len(self.img))
            for i, t in enumerate(self.img): # populates self.emoji_names
                self.emoji_names.append (t[4:])
            self.emoji_original = self.emoji_names.copy() # creates the original alphabetic copy
            shuffle(self.emoji_names) # shuffled values of emojis
            for row, col in product(range(ROWS), range(COLS)): # paints emojis and populates list of 'emojis' id
                i = (row*COLS+col)
                if i > len(self.img)-1: break
                self.emojis.append(Object(self.img[i],col,row)) # emojis id's'
            for r, c in product(range(10), range(4)):
                i = (r*4+c)
                if i > len(self.img)-1: break
                post = ((c-0.5*2)*350 + 500, 900-(r*50))
                self.label=self.show_message(self.emoji_names[i], pos=post, font = 24)
                # print('namesis', self.namesis)
        def show_message(self, message, pos = (200, 600), font = 24):
            self.label = LabelNode(message, font=('American Typewriter', 24),position=pos)
            self.label.blend_mode = BLEND_ADD
            #print('namesis in show message', self.namesis)
            return self.label
        def touch_began(self, touch):
            # print('touch began')
            self.touched_emoji = self.emojitouched(touch) # returns touched emoji id
            # print(self.touched_emoji.title) # prints title of emoji created in class Object
        def touch_moved(self, touch):
            if not self.touched_emoji: # ('no emoji near')
                print ('touched background')
                if self.touchdisabled == True:
                    self.touched_emoji.position = touch.location
                    # print(self.touched_emoji.position)
        def emojitouched(self, touch): # Returns touched emoji
            touch_pos = self.space.point_from_scene(touch.location)
            for touched_emoji in self.emojis:
                if touched_emoji.frame.contains_point(touch_pos):
                    # print('et', touched_emoji, touched_emoji.title, len(self.emojis), touch_pos)
                    return touched_emoji
        def check_item_collisions(self):
            #print('collision check')
            for i, item in enumerate(self.namesis):
                item.z_position = 0.1
                if item.frame.intersects(self.touched_emoji.frame):
                    if self.touched_emoji.title == self.emoji_names[i]:
                        self.touchdisabled = True
                        self.emoji_names[i] = '' # why did I do this?
                        self.touched_emoji.z_position = 0.5 
                        item.z_position = 0.5
                        #self.touchdisabled = True
                        # print ('collision detected')
                        item.run_action(A.sequence(A.move_to(700,100), A.scale_to(5, 0.1, TIMING_EASE_OUT_2), A.wait(2), A.fade_to(0.0, 0.15),A.remove()))
                        self.touched_emoji.run_action(A.sequence(A.move_to(700,725), A.scale_to(9, 0.1, TIMING_EASE_OUT_2), A.wait(2), A.fade_to(0.0, 0.15), A.remove()))
                        self.touched_emoji.z_position = 0.2 # This "hides" the emoji ghosts, not sure why they exist?
                        # print('got  one!')
        def restart_touch(self):
            self.touchdisabled = False
    run(MyScene(), show_fps=True)

    posted in Pythonista read more
  • adrius42

    @bennr01 Thank you muchly for taking the time to answer my musings.

    I assure you, that your English is not the problem, in my comprehension of these concepts, it is much more my lack of understanding!

    I will spend the time to extract the wisdom from your response. Thankyou!

    posted in Pythonista read more
  • adrius42

    Much older! Algol then, Basic. More recently Arduino and Sphero!
    I am restarting my coding activities and try to keep my brain active!
    And to get ahead of my grandchildren for a millisecond or two!

    posted in Pythonista read more
  • adrius42

    Aargh, this may explain some other faux pas I have been making.

    Why??! This feels very counter-intuitive changing the meaning of equals in this way.
    I guess way back in the mists of time the original Python developer had a reason!
    So actually the operator was the time traveller! (Or rather the temporal cloner!)

    I had previously declared self.emoji.original = [ ] so I was confident it had its own object id

    I am getting ever more convinced that I do not understand the operation of “self”
    Can you point me to some text that would help me... it feels like self is not always self, and often self is “not defined’ when I know it had been!?

    I would have preferred
    B = A transferred contents of A to B just thus once
    B == A results in B becoming the same as A for all time

    But then I am just wishing that the Python Language understood me, rather than me having to understand it!

    To be clear this only applies to lists right?

    A = 1
    B = A
    A = 2
    Won’t change B to 2

    So, are there any other types of variables where the operators change what they do?

    It would be useful to know now! Rather than be struggling with coding issues ;-)

    posted in Pythonista read more
  • adrius42

    From my early stumblings, I had come to the conclusion that ‘t’ was a Scene variable that correlates to elapsed time. The other related variable is dt.

    The scene documentation confirms this:
    The time (in seconds) that has passed since the last invocation of update(). You can use this to calculate the progress of custom animations.

    The time (in seconds) that has passed since the scene was started. You can use this to calculate the progress of custom animations.

    posted in Pythonista read more
  • adrius42

    These four lines are in a def setup function

    self.emoji_original = self.emoji_names
    print(self.emoji_original)  # result is alphabetic as expected
    print(self.emoji_names, self.emoji_original)```
    Why does the second print  show that both arrays have been shuffled?

    posted in Pythonista read more
  • adrius42

    Have you tried using Google to search the forum? The forum search function is not as effective as Google. Just a thought...

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!