• Use the time rather than the count

    import scene from math import sin, pi class MyScene (scene.Scene): def update(self): scene.translate(self.size.w/2, self.size.h/2) freq = 15.2 weight = (1+sin(2*pi*freq*self.t))/2 scene.fill((weight,weight,weight)) scene.rect(-80, -80, 160, 160) scene.run(MyScene(),show_fps=True,frame_interval=1)
  • Thanks a lot! I am very impressed and I had no idea it was possible!

    Just in case, as I mentioned real time image in my post, I actually coded a smudge tool in Pythonista and it is kind of real time but still laggy.

    Basically I use a 2D-numpy array representation of my image and constantly “blend” the portion around the cursor’s prev_location on the portion around the cursor’s location. Then, at a given rate, I update the image of my ImageView by converting the numpy array to an ui.image.

    From what I tested the lag seems to mostly come from the conversion.

    I tried doing that with PIL Images instead of numpy but it wasn’t really faster. I also tried directly doing it in an ImageContext and it was actually slower.

    My question is, is there a way to use Metal (or some other gpu computing API) with objc_utils and ctypes to do that? And will it be faster?

  • I think its just a wrapper of UiKit

  • i think what your doing is possible but the way you're doing it isn't. for one apple and the Xbox remote have there Bluetooth locked down.

    but if you use sockets and a pc to forward it instead it might work. you will need a pc and a library to spoof the Xbox remote but it, in theory, should work

  • @twinsant Hi, I use Pythonista as a general programming tool that expands the ios capabilities in a single app (math, graphics, file/folder management, ... with a powerful language as Python).

    About your task (teaching coding) it is not very easy to answer you precisely because it involves complex topics like teaching (teaching is not easy) and coding (a huge world). I think nowadays a lot of students want to know practical problems because they are immersed in a strongly digital world without knowing the hystory and the complexity about programming.

    Anyway I try to list a series of general ideas or questions:

    Would you use Pythonista alone or your students can use Pythonista to test or write codes? Would you use Pythonista (with your iPad or iPhone) linked to a big display in order to show in classroom what you want to teach? A way could be share your lessons by linking your idevice with a big display in front of students (I don't know if it is possible with any TV/LCD display), perform dynamic lessons with questions, wait for answers from students, create different situations about the problem you want to solve with a programming approach, give students opportunities to do exercises about your lessons (all based on your creativity): if they have not Pythonista on their devices (Android?) you could ask them to write, after your lesson, some little pieces of code by hand at home that perform a specific task and that can be add in the main program. The next day you could add students's solutions to the main program and show the effects by running or debugging the main code with students solutions. I think it is better to start with practical problems (in real world) that can be solved or studied with a programming approach. It is better if you start with simple problems like for example: find with programming if a number is prime number, or simulate the dices throwing to perform statistics about number of times the number N comes out and compare it with probability theory (if the students have studied something about probability). Then you could try to solve/study with programming approach something more difficult like for example the simulation of how the rest is calculated and returned in a snacks or drinks distributor with a certain amount of coins inside with minimization of number of coins returned (for example if I want a CNY 8.35 snack and I put inside the machine one coin CNY 10, how to calculate the rest with the minimum number of coins knowing that inside the machine there are X CNY 0.01, Y CNY 0.02, etc...): the problem could be studied in a theoretical way or with a programming approach. The best thing for me is that every student has the ability to program with his device when he/she wants, if you use Pythonista then all students should have Pythonista (it is better, but not required in my opinion). And it would be better to have a way for sharing jobs and codes or projects in classroom or at home that is easy to use: I don't know if there are some pure-python libraries that creates a platform for sharing pieces of code for teaching purposes and that can run in Pythonista.

    Best luck for you intentions.

  • @victordomingos @victordomingos But python 3.6.0 or python 3.7.0 or python 2.7.0 is not stable, while others like python 2.7.15 should be more stable than python 2.7.12.

  • That's exactly what I was looking for - thank you! :)

    Note: After I changed the color in shruntime.py, I had to restart pythonista (swipe up in the task switcher). The changes didn't take effect only by closing and relaunching StaSh.

  • @shinya.ta You are too kind. Really, I'm not a genius at all.
    Happy to have helped you and your wife with this marvelous app.

  • This bug append sometimes, don’t know exactly why. For resolving it just restart Pythonista and everything should go well

  • I’m gonna try it out this night or tomorrow, i’ll keep you in touch; but is there an easy way to convert python 3.7 code to 2.7 ? Cause there is a 2 to 3 option in Pythonista, but I didn’t find the reverse.
    Oh, and thank you for helping me making my dream come true ^^

  • @cvp: Great, you made my day.

  • @cvp Thanks! It works. Here’s my code:

    import sound
    import os

    path = os.path.expanduser('~/Documents/hello.mp3')
    mp3 = sound.Player(path)

  • It looks like the iPad is running Synchronator v1.8 (works) and iPhone has v1.11 (crashes).

  • @RoninSage, some suggestions:

    You do not need to compile the whole list of fonts every time - you can just set the font by the name you find in the font picker ('+' above the keyboard, on the right). You do not need to include the whole code for gestures, you can just import it. Again, you do not really need gestures for the most part, just for the edge swipe to proceed. For tapping the answers I would simplify the code a lot by just using ui.Buttons, all with action set to the same handler function that distinguishes which button was tapped by the name of the center. For saving the answers, do you have a distinct need for CSV, instead of something slighly more robust?
  • @gurunpa I have to add that on my iPhone too, this settIng does not exit. I think it has disappeared with an iOS version but I don't remember which one

  • it needs tkinter, so it won't work on pythonista

  • @JonB that's ok, thanks for @iOSBrett

Internal error.

Oops! Looks like something went wrong!