• PeterG

    Letter to Ole about a new turtle.py is not meaningful, because the version uses uses tkinter NOT available on an iphone. Read about it just 11.6.2921.

    For other systems it seams to be much more in speed with two nice examples included..
    Have a nice day
    Peter ( or PKHG ...)

    posted in Editorial read more
  • PeterG

    Problem solved, new phone has below left either abc or 123 button and that is start first too other 123 cides shows a lot of other signs

    Thanks

    posted in Pythonista read more
  • PeterG

    Hi on my ipone old iphon 6 new iohone mini with (old?) pythonista 3 no multipov
    Cation star avalable??? How to get it /(1/x) is annoying ...

    posted in Pythonista read more
  • PeterG

    In the overview all posts are 5 years old,
    No users anymore?

    posted in Editorial read more
  • PeterG

    @ccc, just something I need , very nice indeed! I import a game, that for grand-son and daughter, and run it before the background cardimages are shown, meeaning I am on the way for an 4-level game ...
    Next try, just using one of the marvallous available games , as next levels ..
    .. Topscore files will be used for further interaction ..

    Thanks to your example ... Helps a lot 😊 , happy OpaPeter

    posted in Pythonista read more
  • PeterG

    @ccc very nice example.
    What and why flex=name ? Can't find the meaning of it

    posted in Pythonista read more
  • PeterG

    @ccc THAT was the real timesaver, thanks a lot 😉

    posted in Pythonista read more
  • PeterG

    #! python2
    # Piano
    # 
    # A simple multi-touch piano.
    
    from scene import *
    import sound
    from itertools import chain
    
    class Key (object):
        def __init__(self, frame):
            self.frame = frame
            self.name = None
            self.touch = None
            self.color = Color(1, 1, 1)
            self.highlight_color = Color(0.9, 0.9, 0.9)
            
        def hit_test(self, touch):
            return touch.location in self.frame
    
    class Piano (Scene):
        def setup(self):
            self.white_keys = []
            self.black_keys = []
            white_key_names = ['Piano_C3','Piano_D3', 'Piano_E3',
                               'Piano_F3', 'Piano_G3', 'Piano_A3', 
                               'Piano_B3', 'Piano_C4', 'Piano_D4',
                               'Piano_E4', 'Piano_F4', 'Piano_G4']
            #white_key_names_nogniiet = #['Piano_02','Piano_D2','Piano_E2','Piano_F2','Piano_G2','Piano_A2','Piano_B2','Piano_C3']
            black_key_names = ['Piano_C3#', 'Piano_D3#', 'Piano_F3#', 
                               'Piano_G3#', 'Piano_A3#', 'piano:C4#',
                               'Piano_D4#', 'Piano_F4#']
            for key_name in chain(white_key_names, black_key_names):
                sound.load_effect(key_name)
            white_positions = range(12)
            black_positions = [0.5, 1.5, 3.5, 4.5, 5.5, 7.5, 8.5, 10.5]
            key_w = self.size.w / 2# pkhg factor 0.5 
            key_h = self.size.h / 8 /2
            for i in range(len(white_key_names)):
                pos = white_positions[i]
                key = Key(Rect(0, pos * key_h, key_w, key_h))
                key.name = white_key_names[i]
                self.white_keys.append(key)
            for i in range(len(black_key_names)):
                pos = black_positions[i]
                key = Key(Rect(0, pos * key_h + 10, key_w * 0.6, key_h - 20))
                key.name = black_key_names[i]
                key.color = Color(0, 0, 0)
                key.highlight_color = Color(0.2, 0.2, 0.2)
                self.black_keys.append(key)
            
        def draw(self):
            stroke_weight(1)
            stroke(0.5, 0.5, 0.5)
            for key in chain(self.white_keys, self.black_keys):
                if key.touch is not None:
                    fill(*key.highlight_color.as_tuple())
                else:
                    fill(*key.color.as_tuple())
                rect(*key.frame.as_tuple())
        
        def touch_began(self, touch):
            for key in chain(self.black_keys, self.white_keys):
                if key.hit_test(touch):
                    key.touch = touch
                    sound.play_effect(key.name)
                    return
        
        def touch_moved(self, touch):
            hit_key = None
            for key in chain(self.black_keys, self.white_keys):
                hit = key.hit_test(touch)
                if hit and hit_key is None:
                    hit_key = key
                    if key.touch is None:
                        key.touch = touch
                        sound.play_effect(key.name)
                if key.touch == touch and key is not hit_key:
                    key.touch = None
                    
        def touch_ended(self, touch):
            for key in chain(self.black_keys, self.white_keys):
                if key.touch == touch:
                    key.touch = None
    
    run(Piano(), PORTRAIT)
    

    Append the Piano till G4

    posted in Pythonista read more
  • PeterG

    Yes PeterG and PKHG are the same. Asking as PKHG for the forgotton password did not work 2-3 times, therfore a new account...

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!