首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian >> Symbian开发 >> 正文
S60 Python 编程指南——如何创建pys60应用程序
作者:佚名    文章来源:本站原创    更新时间:2006-12-16 11:29:57
.Listbox(entries,shout)
示例代码:
------------------------------------------------
import appuifw
import e32
def exit_key_handler():
    app_lock.signal()
# define a callback function
def shout():
    index = lb.current()
    print index
    print entries[index]
# create your content list of your listbox including the icons to be used for each entry
entries = [u"Signal",u"Battery"]
lb = appuifw.Listbox(entries,shout)
# create an Active Object
app_lock = e32.Ao_lock()
# create an instance of appuifw.Listbox(), include the content list "entries" and the callback function "shout"
# and set the instance of Listbox now as the application body
appuifw.app.body = lb
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()
--------------------------------------
  1. # body as Text:
  2. appuifw.app.body = appuifw.Text(u'hello')
示例代码:
------------------------------------
import appuifw
import e32
def exit_key_handler():
    app_lock.signal()
# create an instance of appuifw.Text()
round = appuifw.Text()
# change the style of the text
round.style = appuifw.STYLE_UNDERLINE
# set the text to 'hello'
round.set(u'hello')
# put the screen size to full screen
appuifw.app.screen='full'
# create an Active Object
app_lock = e32.Ao_lock()
# set the application body to Text
# by handing over "round" which is an instance of appuifw.Text() as definded above
appuifw.app.body = round
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()
---------------------------------------------
  1. # body as Canvas:
  2. appuifw.app.body=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
示例代码:
---------------------------------------------
# Copyright (c) 2005 Jurgen Scheible
# This script draws different shapes and text to the canvas
import appuifw
from appuifw import *
import e32
# import graphics
from graphics import *
# create an exit handler
def quit():
    global running
    running=0
    appuifw.app.set_exit()
# set the screen size to large
appuifw.app.screen='large'
# define an initial image (white)
img=Image.new((176,208))
# add different shapes and text to the image
# coord. sequence x1,x2,y1,y2
img.line((20,20,20,120),0xff00ee)
img.rectangle((40,60,50,80),0xff0000)
img.point((50.,150.),0xff0000,width=40)
img.ellipse((100,150,150,180),0x0000ff)
img.text((100,80), u'hello')
# define your redraw function (that redraws the picture on and on)
# in this case we redraw the image named img using the blit function
def handle_redraw(rect):
    canvas.blit(img)
running=1
# define the canvas, include the redraw callback function
canvas=appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
# set the app.body to canvas
appuifw.app.body=canvas
app.exit_key_handler=quit
# create a loop to redraw the the screen again and again until the exit button is pressed
while running:
    # redraw the screen
    handle_redraw(())
    # yield needs to be here in order that key pressings can be noticed
    e32.ao_yield()
------------------------------------------------
9.   如何创建一个主循环?
把主循环放置在需要反复运行的代码位置
1.   running = 1 
2.   while running:
3.        # #e.g. redraw the screen:
4.        handle_redraw(())

这里有2个我常用的程序骨架示例

  1. no main loop because the application logic works without
    示例代码:
    -

    上一页  [1] [2] [3] [4] 下一页

相关文章:
小试Python for Symbian
为什么recognizer 导致lock up
S60 Python 编程指南——程序菜单练习(2)
S60 Python 编程指南——程序菜单练习(1)
S60 Python 编程指南——信息标签
在程序启动后先弹出确定使用文字页面,然后确定后继续运行,怎么做?
编写异常安全的C++代码
OPL 速成教程(二)
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号