python写安卓界面_Python编写图形界面Android CTS测试应用

#!/usr/bin/env pythonimportosimportpygtk#pygtk.require('2.0')importgtkimportsysimportshleximportsubprocessfromsubprocessimportPopen, PIPEclassGctsApp:defon_launch(self, widget):

page=self.note.get_current_page()ifpage==7:

cts_stdin.write("start --plan Java\n")elifpage==6:

cts_stdin.write("start --plan AppSecurity\n")elifpage==5:

cts_stdin.write("start --plan Signature\n")elifpage==4:

cts_stdin.write("start --plan Performance\n")elifpage==3:

cts_stdin.write("start --plan CTS\n")elifpage==2:

cts_stdin.write("start --plan RefApp\n")elifpage==1:

cts_stdin.write("start --plan VM\n")elifpage==0:

cts_stdin.write("start --plan Android\n")defdelete(self, widget, event=None):

gtk.main_quit()returnFalsedef__init__(self):

window=gtk.Window(gtk.WINDOW_TOPLEVEL)

window.connect("delete_event", self.delete)

window.set_border_width(20)

window.set_title("Graphic CTS-Testing Demo")

table=gtk.Table(3,6,False)

window.add(table)#Create a new notebook, place the position of the tabsnotebook=gtk.Notebook()

self.note=notebook

notebook.set_tab_pos(gtk.POS_LEFT)

table.attach(notebook, 0,6,0,1)

notebook.show()

self.show_tabs=True

self.show_border=True#Now finally let's prepend pages to the notebookforiinrange(8):

bufferf="Launch Test Plan %d"%(i+1)

bufferl="Plan %d"%(i+1)

frame=gtk.Frame(bufferf)

frame.set_border_width(5)

frame.set_size_request(100,75)

frame.show()

TP={"Plan 1":"Test Plan - Java","Plan 2":"Test Plan - AppSecurity","Plan 3":"Test Plan - Signature","Plan 4":"Test Plan - Performance","Plan 5":"Test Plan - CTS","Plan 6":"Test Plan - RefApp","Plan 7":"Test Plan - VM","Plan 8":"Test Plan - Android"}

label=gtk.Label(TP[bufferl])

frame.add(label)

label.show()

label=gtk.Label(bufferl)

notebook.prepend_page(frame, label)#Set what page to start at (page 7)notebook.set_current_page(7)#create a tooltips objectself.tooltips=gtk.Tooltips()#Create a bunch of buttonsbutton=gtk.Button("Quit")

button.connect("clicked", self.delete)

table.attach(button, 0,1,1,2)

self.tooltips.set_tip(button,"Hello")

button.show()

button=gtk.Button("Next Plan")

button.connect("clicked",lambdaw: notebook.next_page())

table.attach(button,1,2,1,2)

button.show()

button=gtk.Button("Prev Plan")

button.connect("clicked",lambdaw: notebook.prev_page())

table.attach(button,2,3,1,2)

button.show()

button=gtk.Button("Launch")

button.connect("clicked", self.on_launch)

table.attach(button,3,4,1,2)

button.show()

table.show()

window.show()#parsed from cts($T/out/host/$HOST_ARCH/bin/cts) shell script pulished by Googleargs=shlex.split("""java -Xmx512M -cp framework/cts.jar:framework/ddmlib.jar:framework/junit.jar:framework/hosttestlib.jar -DHOST_CONFIG=cts/android-cts/repository/host_config.xml com.android.cts.TestHost""")

p=subprocess.Popen(args, stdin=PIPE, cwd="/home/whu/Android/froyo/out/host/linux-x86/", )

(cts_stdout, cts_stdin)=(p.stdout, p.stdin)defmain():

gtk.main()return0if__name__=="__main__":

GctsApp()

main()#ready to teminate, release resources we holdcts_stdin.write("exit\n");

cts_stdin.close();

p.kill();

p.terminate();

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页