Forum Archive

Converting from PyGame into scene or similar

Gadgettyke

Hi All

Have been searching the forum for a solution to pygame conversions, Most of it says use scene but I can't quite find what I need as I'm not quite sure what I'm looking at. Most of my drawing functions I've managed to do successfully and some of the sound output stuff is working already but I'm a bit lost in finding how to replicate an event queue.

The snippets I'm looking at converting are

def start_timer():
    start = pygame.time.get_ticks()
    Qstatus[0] = start
    Qstatus[1] = 1
    Qstatus[2] = 0
    pygame.time.set_timer(USEREVENT + 1, 200) #set timer1 for 0.2 seconds refresh 

def safe_timer():
    pygame.time.set_timer(USEREVENT + 2, 1000) #set timer2 for 1 seconds refresh 
    abandon[2] = 11

for event in pygame.event.get():
    if event.type == pygame.USEREVENT +1:
            timer_symbol()
        if event.type == pygame.USEREVENT +2:
            abandon[2] = abandon[2]-1
            print (abandon)

there's a lot of pointers to threading and/or multiprocessing but no real examples of what I'm aiming at.

Any help or pointers gratefully received.

Gadgettyke

Hi, have managed to code a replacement for the one second tick but have run into another noob difficulty,

I’m trying to update labels from my main() but can’t quite get the call to them right. Try as I might they all come up syntax error or not callable.

The base code (extracted portion to keep it sensible) and the pyui files ive stored here.
https://gist.github.com/0ad93bb91cf9b9694fca28fb8c093e0a

P.S. I can’t just quite get a 0.2 tick to work reliably ( see post above) so if someone is knowledgable on event queues i’d Still be more than interested to hear from you all.

Gadgettyke

Wow, I managed to do it! Bless pythonista's followers for their posts. Just a case of getting it straight in my head as to when to actually invoke the ui.view more than any thing else.

You'll have to forgive my enthusiasm but being a PC bound guy for many years this is the first time I've used my iPad pro for anything other than games, kindle, photos and email!!!

I now have a quiz timer for the league that does what I need. To press I've only had a PC version hoyed out to a TV that we use at cup finals etc.

Now my question changes yet again, How do I get it to other iPhone users in my group as a running piece of software without uploading it to the vaunted APP Store as its not one that I think the general public would use. (a bit too niche I think)

I still have a few bits to sort out that I'd like to add over time (such as the 0.2 interrupt ;-) ) but its in a state that I'd like to share it out.

If any of you guys would be interested to have a look at my really bad brute force - but working code; let me know and I'll set up a gist.

JonB

If everyone installs pythonista, then you can share the code via email, gist, etc, or write a one liner that downloads the code and installs it... But everyone needs to install pythonista unless you are trying to use the app template and submit to app store.

Another option would be to reformulate this as JavaScript, which could be deployed as a web app..

Gadgettyke

Thanks JonB

So we not able to stick it in an executable as a stand-alone like other python systems? Is there no equivalent to pyinstaller for example.

Pythonista is probably beyond most people who I actually want to use this app. Is there a cut down run only environment / compiler version that can be used for testing?

As you can probably tell i’m Newly apple’d having mostly programmed with PC’s, RaspPi’s or PIC’s.

Cheers

JonB

no, due to apple restrictions, you cannot develop apps for others without a developer license.

Gadgettyke

Thanks again Jon

Looks like Apple developer I must become 👼🏼

Good job I’m a quick learner

At least pc and android versions will be easier to pass around

JonB

Be aware that in order to deploy apps you need XCode, which I think still requires a Mac (no PC version)

It sounds to me more like you want a standalone app written in HTML 5/js.
That way you can open it on python, iOS, windows

Gadgettyke

Hmm being from engineering not overly familiar with media coding, can you recommend a good method / editor / compiler to produce your suggested result?

The Mac issue can be sorted as a VM to a degree or if really stuck I can always rent a Mac mini but if there’s an easy port then I’ll give it a try.

dng88

I gave up but given you have done it could there be some example of this. Trying to convert a card game for my own entertainment.

Source is in pygame

project-Simpy+Big+Two-2676-.html

enceladus

Look at the scene section for few simple scene examples. https://github.com/encela95dus/ios_pythonista_examples
stop_watch.py is a small example that illustrates handing time events and touch events.