You Are Here:

Community: Developer Discussion Boards

#1 Old Graphics and Threads - 2006-06-15, 06:04

Join Date: May 2006
Posts: 17
nibss
Offline
Registered User
There is a good example of graphics ball movement with arrowkeys on
http://www.mobilenin.com/pys60/resou...ics_drawing.py

the user can move the ball with arrow keys
I added some more code into it basically a start thread code to snd a sms message but i cannot send the sms while user is pressing the keys

so my question is does the thread.start( ) method work while the screen is being continuiously updated ??
should we use thread when the main UI thread is continuously doing something else i.e, in a loop ??

here is the code
[code]# Copyright (c) 2005 Jurgen Scheible
# Graphics drawing
# use button Arrow up,down,left,right, to move the colour point
import sys
import inbox
import messaging
import time
import thread
import appuifw
from appuifw import *
import e32
from key_codes import *
from graphics import *


## ----- Here is my addition to the code --------------------

def run():

messaging.sms_send(u'+6421368740',u'hello there')


def cb(id_cb):
thread.start_new_thread(run,())
#messaging.sms_send(u'+6421368740',u'ki hal v')

i = inbox.Inbox()
i.bind(cb)


##----------------------------------------------------------


class Keyboard(object):
def __init__(self,onevent=lambda:None):
self._keyboard_state={}
self._downs={}
self._onevent=onevent
def handle_event(self,event):
if event['type'] == appuifw.EEventKeyDown:
code=event['scancode']
if not self.is_down(code):
self._downs[code]=self._downs.get(code,0)+1
self._keyboard_state
Code:
=1
        elif event['type'] == appuifw.EEventKeyUp:
            self._keyboard_state[event['scancode']]=0
        self._onevent()
    def is_down(self,scancode):
        return self._keyboard_state.get(scancode,0)
    def pressed(self,scancode):
        if self._downs.get(scancode,0):
            self._downs[scancode]-=1
            return True
        return False

keyboard=Keyboard()



def quit():
    global running
    running=0
    appuifw.app.set_exit()


appuifw.app.screen='full'
img=Image.new((176,208))
blobsize=30
location_x = 100.
location_y = 100.

def handle_redraw(rect):
    canvas.blit(img)

running=1

canvas=appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=handle_redraw)
appuifw.app.body=canvas

app.exit_key_handler=quit

while running:

    img.clear(0x0000ff)
    img.point((location_x + blobsize/2,location_y + blobsize/2),0xff0000,width=blobsize)

    handle_redraw(())
    e32.ao_yield()

    if keyboard.is_down(EScancodeLeftArrow):
        location_x = location_x - 1

    if keyboard.is_down(EScancodeRightArrow):
        location_x = location_x + 1


    if keyboard.is_down(EScancodeDownArrow):
        location_y = location_y + 1


    if keyboard.is_down(EScancodeUpArrow):
        location_y = location_y - 1
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Exchange bitmap between threads stopin General Symbian C++ 10 2005-03-16 20:47
Question about threads Pelops Mobile Java General 2 2004-08-10 09:56
smooth graphics 3hrguy Mobile Java Media (Graphics & Sounds) 7 2003-08-19 10:45
Realtime graphics on 7650 suckho General Symbian C++ 2 2002-09-18 12:14
9210 graphics -> slow! Nokia_Archive Mobile Java General 1 2002-05-24 15:39

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ