def __init__(self): #初始化主程序 self.CheckSrc() #检查资源文件 #kum_start.ShowStartFrame() #显示软件启动界面 appuifw.app.screen = 'full' appuifw.app.body = self.mainUI = appuifw.Canvas() #主程序主界面 self.InitMainFrame()
def __init__(self): self.canvas = None appuifw.app.body = self.canvas = \ appuifw.Canvas(redraw_callback=self.refresh, resize_callback=self.refresh) appuifw.app.exit_key_handler = self.quit self.canvas.clear(0x1234567) self.running = True self.count = 0 self.prev_key = -1 self.canvas.bind(EKeyLeftArrow, lambda: self.event_called(0)) self.canvas.bind(EKeyRightArrow, lambda: self.event_called(1)) self.canvas.bind(EKeyUpArrow, lambda: self.event_called(2)) self.canvas.bind(EKeyDownArrow, lambda: self.event_called(3)) self.canvas.bind(EKeySelect, lambda: self.event_called(4)) appuifw.app.focus = self.refresh appuifw.app.menu = [ (u"Screen Area", ((u"Large", lambda: self.screen_area("large")), (u"Full", lambda: self.screen_area("full")), (u"Normal", lambda: self.screen_area("normal")))), (u"Orientation", ((u'Landscape', lambda: self.orientation("landscape")), (u'Portrait', lambda: self.orientation("portrait")), (u'Automatic', lambda: self.orientation("automatic")))), (u"UI Controls", ((u"Text", lambda: self.text_control()), (u"ListBox", lambda: self.listbox_control()), (u"Canvas", lambda: self.canvas_control()))), (u"Direction pad", ((u"On", lambda: self.directional_pad(True)), (u"Off", lambda: self.directional_pad(False)))) ]
def videocamera(): global keyboard i = len(os.listdir("E:\\Videos\\")) video_savepath = u"E:\\Videos\\vid%d.mp4" % i canvas = appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=None) appuifw.app.body = canvas camera.stop_finder() camera.start_finder(vf, size=(240, 196)) recording = False running = True while running: if keyboard.pressed(EScancodeSelect): if not recording: vid = camera.start_record( video_savepath, video_callback) #Start recording the video recording = True else: camera.stop_record() #Stop recording videocamera() #Restart the camera in video mode if keyboard.pressed(EScancodeRightSoftkey) and recording: camera.stop_record() quit() appuifw.app.menu = [(u"Exit", quit)] e32.ao_yield()
def __init__(self): appuifw.app.exit_key_handler = self.quit self.running = True appuifw.app.directional_pad = False self.erase_mode = False self.saving_file = False self.orientation_changed = False self.bind_palette = True self.about_active = False self.is_about_active = False self.about_timer = None self.pen_width = 4 self.x_max = 0 self.y_max = 0 self.canvas = appuifw.Canvas(event_callback=self.event_callback, redraw_callback=self.redraw_callback) if self.canvas.size[0] > self.canvas.size[1]: self.orientation = 'landscape' else: self.orientation = 'portrait' self.drive = unicode(os.getcwd()[0]) self.old_body = appuifw.app.body appuifw.app.body = self.canvas appuifw.app.screen = 'full' appuifw.app.focus = self.focus_monitor self.canvas.clear() self.draw = self.canvas self.draw_img = Image.new((self.canvas.size[0], self.canvas.size[1])) self.draw_buttons() self.bind_buttons()
def __init__(self): self.direction = 0 self.step = 5 self.color = (0, 128, 0) self.fillarray = {} self.exitflag = 0 self.score = 0 self.wormlocs = [] self.wormlength = 10 self.foodloc = None self.fieldcolor = (192, 192, 128) self.state = 'init' self.old_body = appuifw.app.body self.canvas = appuifw.Canvas(redraw_callback=self.redraw) self.draw = Draw(self.canvas) appuifw.app.body = self.canvas self.fieldsize = (self.canvas.size[0] / self.step, (self.canvas.size[1] - 16) / self.step) self.canvas.bind(EKeyRightArrow, lambda: self.turnto(0)) self.canvas.bind(EKeyUpArrow, lambda: self.turnto(1)) self.canvas.bind(EKeyLeftArrow, lambda: self.turnto(2)) self.canvas.bind(EKeyDownArrow, lambda: self.turnto(3)) self.loc = [self.fieldsize[0] / 2, self.fieldsize[1] / 2] self.place_food() self.state = 'playing' self.redraw(())
def __init__(self): self.canvas = appuifw.Canvas(redraw_callback=self.redraw, event_callback=self.paint_table) self.img = Image.new(self.canvas.size) self.w_unit = self.canvas.size[0] / 9 self.h_unit = self.canvas.size[1] / 9 self.fontsize = 20 self.border_color = (0,100,255) self.row = 0 # a keret kiindulasi pozicioja, es kesobb az aktualis pozicioja self.coll = 0 self.blankcells = 51 self.b = Board() self.b.generate(9*9 - self.blankcells) # meglegyen az eredeti peldany, az osszehasonlitasok miatt self.ref_list = copy.deepcopy(self.b.partialboardlist) appuifw.app.title = u"Sudoku" appuifw.app.screen = "normal" self.menu = [ (u"New", self.generateboard), (u"Check", self.check), (u"Difficulty", self.change_difficulty), (u"About", self.about) ] appuifw.app.menu = self.menu appuifw.app.body = self.canvas appuifw.app.exit_key_handler = self.quit self.app_lock = e32.Ao_lock() self.app_lock.wait()
def test_key_codes(): """ Test for various key codes associated with keys of a particular device. The codes for the respective keys are provided in the key_codes module. """ def up(): appuifw.note(u"Arrow up was pressed") def two(): appuifw.note(u"Key 2 was pressed") def yes(): appuifw.note(u"Call key is pressed") def no(): appuifw.note(u"Call end") def menu(): appuifw.note(u"Menu key") canvas = appuifw.Canvas() appuifw.app.body = canvas canvas.text((0, 24), u'These keys are being tested for press :') canvas.text((0, 48), u'Up, Yes, No, Menu, Key2') canvas.bind(key_codes.EKeyUpArrow, up) canvas.bind(key_codes.EKey2, two) canvas.bind(key_codes.EKeyMenu, menu) canvas.bind(key_codes.EKeyYes, yes) canvas.bind(key_codes.EKeyNo, no)
def __init__(s,path=None,waitTime=0): s.screenSize=appuifw.app.layout(appuifw.EScreen)[0] s.maxLines=[5,8][s.screenSize[1]>240] s.__doc__=__doc__ s.__canvas=appuifw.Canvas(s.__redraw,s.__events) appuifw.app.body=s.__canvas try: s.blit(Image.open(path)) e32.ao_sleep(waitTime) except:pass del path,waitTime appuifw.app.exit_key_handler=s.__exit s.__imgOld=Image.new(s.screenSize) s.__img=s.__imgOld s.__mask=Image.new(s.screenSize,"L") s.__mask.clear(0x888888) s.__imgBlack=Image.new(s.screenSize) s.index=0 s.super=0 s.selectType=0 s.keyType=0 s.keyList=[[16,50,63497],[17,56,63498],[14,52,63495],[15,54,63496],[167,53,63557],[196,63586]] s.TitleName="BingyiApp模块".decode("u8") s.__lock=e32.Ao_lock() s.__timer=e32.Ao_timer()
def __init__(self): WhileLoopApp.__init__(self) self.canvas = appuifw.Canvas(event_callback=self.event_callback, redraw_callback=self.redraw_callback) self.old_body = appuifw.app.body appuifw.app.body = self.canvas appuifw.app.screen = 'full' appuifw.app.focus = self.focus_monitor self.img = Image.new(self.canvas.size) self.y_max = self.canvas.size[1] self.box_width = self.canvas.size[0] / 4 self.box_height = self.canvas.size[1] - 40 self.clear_button = ((0, self.box_height), (self.box_width, self.y_max)) self.check1_button = ((self.box_width, self.box_height), (self.box_width * 2, self.y_max)) self.check2_button = ((self.box_width * 2, self.box_height), (self.box_width * 3, self.y_max)) self.quit_button = ((self.box_width * 3 - 25, self.box_height), (self.box_width * 4, self.y_max)) self.canvas.bind(EKeyMenu, self.keyevent_callback, \ ((0, 100), (0, 100))) self.canvas.bind(EButton1Up, self.check2_button_callback, self.check2_button) self.canvas.bind(EButton1Up, self.check1_callback, self.check1_button) self.canvas.bind(EButton1Up, self.reset_canvas, self.clear_button) self.reset_canvas() self.counter = 1
def test_start_record(self): def video_cb(err, code): self.failIf(err, "Error while recording") if self.counter: self.failUnlessEqual(code, camera.EPrepareComplete, "State is not proper") else: self.failUnlessEqual(code, camera.EOpenComplete, "State is not proper") self.counter += 1 def finder_cb(im): appuifw.app.body.blit(im) self.counter = 0 video_filename = 'test_video.3gp' appuifw.app.body = appuifw.Canvas() self.delete_files_if_exist([video_filename], save_path) try: camera.start_finder(finder_cb) camera.start_record(save_path + video_filename, video_cb) e32.ao_sleep(5) camera.stop_record() camera.stop_finder() except RuntimeError, e: print >> sys.stderr, "Error recording a video :", e raise
def test_bind_keyevent(self): """Passing co-ordinates for key events should ignore coordinates""" canvas2 = appuifw.Canvas(redraw_callback=self.redraw_callback) try: canvas2.bind(EKeyUpArrow, self.event_callback, \ ((0, 100), (0, 100))) except: self.fail("Check passing coordinates to key events")
def test_event_callback(self): """ Passing a non callable parameter should raise an exception""" try: event_noncallable = "Just an event" canvas3 = appuifw.Canvas(event_callback=event_noncallable, redraw_callback=self.redraw_callback) except Exception, err: print "Exception: ", err
def run(self): if self.__class__ != Window: return None Window.WalkChilds(self, self) self._Window__canvas = ui.Canvas(redraw_callback=self.redraw, event_callback=self.event) ui.app.screen = 'full' ui.app.body = self._Window__canvas
def view_picture_filename(self): self.img = Image.new((400, 400)) self.screen_picture = Image.open(self.picture_filename) self.canvas = appuifw.Canvas(redraw_callback=self.handle_redraw) self.old_body = appuifw.app.body appuifw.app.title = u'Image' appuifw.app.menu = [(u"Close", self.close_picture)] appuifw.app.body = self.canvas self.handle_redraw(())
def refresh(self): appuifw.app.title = u"Viewfinder" appuifw.app.menu = [(u"Start", self.start_finder), (u"Stop", self.stop_finder), (u"Exit", self.do_exit)] appuifw.app.exit_key_handler = self.exit_key_handler appuifw.app.body = self.canvas = appuifw.Canvas() self.start_finder() self.finder_on = 1
def __init__(self): self.save_picture_flag = 0 self.keyboard = Keyboard() self.screen_picture = camera.take_photo(size=(640, 480)) self.img = Image.new((176, 208)) self.canvas = appuifw.Canvas(event_callback=self.keyboard.handle_event, redraw_callback=self.handle_redraw) self.filename_prefix = u'e:\\Images\obs_' self.filename = u''
def displayTxt(self,txt): appuifw.app.body=canvas=appuifw.Canvas(event_callback=self.handle_event) canvas.clear(0x0099cc) canvas.text((57,20),u'PyUtilS60 v1.00',font=(u'Nokia Sans S60',20,1),fill=0x000000) canvas.text((20,40),u'Utility Program for Symbian Phones',font=(u'Nokia Sans S60',12,1),fill=0x000069) canvas.text((35,220),u'http://s60python.blogspot.com',font=(u'Nokia Sans S60',12,1),fill=0x00ff0ff) if nerr == 0: canvas.text((50,100),u'Capps Off Enabled',font=(u'Nokia Sans S60',14,1),fill=0x33ff33) else: canvas.text((50,100),u'Please enable Capps Off',font=(u'Nokia Sans S60',14,1),fill=0xff3366)
def lab3():#画布界面 from graphics import Image appuifw.app.body=canvas=appuifw.Canvas() img=Image.new((240,320)) img.clear(0x0000ff) def redraw(): canvas.blit(img) while True: redraw()#借循环语句使redraw函数不断执行,比米饭的简单吧 e32.Ao_yield()#监控退出命令,使程序能退出
def splash_screen(): appuifw.app.body = c = appuifw.Canvas() im = graphics.Image.open('E:\\Python\\splash.jpg') c.blit(im, target=(5, 23), scale=0) #sf = audio.Sound.open('E:\\Sounds\\gb.m4a') #sf.play() #e32.ao_sleep(16) c.bind(EKeySelect, init_app)
def __init__(self): self.canvas = None self.img = None self.canvas = appuifw.Canvas(redraw_callback=self.redraw) self.img = graphics.Image.new(self.canvas.size) self.screen_width = self.canvas.size[0] self.screen_height = self.canvas.size[1] self.focus_x = self.screen_width / 3. self.focus_y = self.screen_height / 2.
def __init__(self): self.canvas=appuifw.Canvas() self.old_body=appuifw.app.body self.old_screen=appuifw.app.screen appuifw.app.body=self.canvas appuifw.app.screen='full' self.max = 32 self.w, self.h = self.canvas.size self.palette() self.lock = e32.Ao_lock() appuifw.app.exit_key_handler = self.quit
def start(): image= camera.take_photo() appuifw.app.body=c=appuifw.Canvas() c.blit(image,scale=1) file=(u'e:\\Images\\picture1.jpg') image.save(file) device=socket.bt_obex_discover() address=device[0] channel=device[1][u'OBEX Object Push'] socket.bt_obex_send_file(address,channel,file) appuifw.note(u"Picture sent","info")
def tabs_criar(self): "Cria as páginas do SW." self.img = graphics.Image.open(UI_L) self.canvas = appuifw.Canvas(redraw_callback=self.img_redraw) self.tab2 = appuifw.Text(u"Esta é a Tab2") appuifw.app.set_tabs([u"Um", u"Dois"], self.tab_handler) appuifw.app.body = self.canvas return self.canvas
def __init__(self, exit_cb, captureORM): self.captureORM = captureORM self.filename = u'' if self.captureORM.audio_filename != None: self.filename = self.captureORM.audio_filename self.S = None self.body = appuifw.Canvas() #self.body = appuifw.Text(u'Audio Mode') appuifw.app.title = u'Audio Mode' self.filename_prefix = u'e:\\Sounds\obs_' self.exit_cb = exit_cb
def __init__(self, bg_color=(0, 0, 0)): """ Constructor Args: bg_color (tuple): RGB color """ self.bg_color = bg_color # self.old_body = appuifw.app.body self.canvas = appuifw.Canvas(redraw_callback=self.redraw) self.screen_size = self.canvas.size self.buf = graphics.Draw(self.canvas) appuifw.app.body = self.canvas
def __init__(self, methodName='runTest'): unittest.TestCase.__init__(self, methodName=methodName) self.canvas = appuifw.Canvas(event_callback=self.event_callback, redraw_callback=self.redraw_callback) self.old_body = appuifw.app.body appuifw.app.body = self.canvas appuifw.app.focus = self.focus_monitor self.img = Image.new(self.canvas.size) self.scenario_one = ((20, 20), (75, 80), [25, 50]) self.scenario_two = ([10, 20], [30, 50]) self.scenario_three = [(20, 20), (40, 40)] self.scenario_four = ((100, 100))
def __init__(self): ''' Default values ''' self.my_time = "hh:mm:ss" self.user_set = MySettings(FILE_SET) #self.t_timer = e32.Ao_timer() # Helper variables to position digits on-screen self.dx = 0 self.dy = 0 self.loc = [] # Graphics mask by JOM, derivate work from original graphics tmp = graphics.Image.open(FILE_PATH + u"nix_mask100.jpg") self.mask = graphics.Image.new((XX, YY), mode='L') self.mask.blit(tmp) # Digit graphics self.digit = [ None, None, None, None, None, None, None, None, None, None ] for i in range(10): self.digit[i] = graphics.Image.new((XX, YY)) self.change_color(self.user_set.color()) #appuifw.app.orientation = 'portrait' appuifw.app.screen = 'full' appuifw.app.title = u'Nixie Watch' appuifw.app.exit_key_handler = self.cb_quit appuifw.app.focus = cb_focus appuifw.app.menu = [(u"Change Color", self.menu_settings), (u"About", self.menu_about), (u"Exit", self.cb_quit)] if e32.pys60_version_info > (1, 9): # Hide annoying virtual keypad # HOX: seems like must be before creating canvas appuifw.app.directional_pad = False global canvas canvas = appuifw.Canvas(resize_callback=cb_resize, redraw_callback=cb_redraw) appuifw.app.body = canvas if e32.pys60_version_info > (1, 9): if appuifw.touch_enabled(): # Full screen, even when rotated a = max(canvas.size) canvas.bind(key_codes.EButton1Down, self.cb_touch, ((0, 0), (a, a))) # Disable screensaver handle_screensaver()
def __init__(self): self.canvas = appuifw.Canvas(redraw_callback=self.handle_redraw) Total_x, Total_y = self.canvas.size self.cdraw = Draw(self.canvas) appuifw.app.body = self.canvas self.backup_img = Image.new((Total_x, Total_y)) self._draw = Draw(self.backup_img) self.gcnt = 0 self.gcol = 0 self.gr = 25 self.NOC = 6 self.cnames = [ u"red", u"green", u"blue", u"yellow", u"purple", u"black" ] self.g = [[self.NOC, self.NOC, self.NOC, self.NOC]] * 9 self.colors = [ 0xff0000, 0x00c000, 0x0000ff, 0xff9900, 0xcc0099, 0x000000, 0xffffff ] self.c = [(0, 0)] * self.NOC self.rect = [((0, 0), (0, 0))] * self.NOC appuifw.body = self._draw self.d = Total_x / self.NOC - 4 self.r = self.d / 2 self.sx = 2 self.sy = Total_y - self.d - 60 methods = [ self.red, self.green, self.blue, self.yellow, self.purple, self.black ] # Calculates coordinates for the circles and bind their functions for i in range(self.NOC): x, y = self.sx + (self.d + 4) * i, self.sy self.c[i] = (x + self.r, y + self.r) self.rect[i] = ((x, y), (x + self.d, y + self.d)) self.canvas.bind(key_codes.EButton1Down, methods[i], self.rect[i]) self._draw.ellipse(self.rect[i], fill=self.colors[i]) bw, bh, xl, yl, dl = Total_x / 2 - 10, 40, self.sx, self.sy + 10, self.d button1 = ((xl, yl + dl), (xl + bw, yl + dl + bh)) self._draw.rectangle(button1, fill=0x555555) self._draw.text((xl + bw / 2 - 5, yl + dl + 30), u'OK', 0x10bdff) self.canvas.bind(key_codes.EButton1Down, self.evaluateGuess, button1) ox = xl + bw + 10 button2 = ((ox, yl + dl), (ox + bw, yl + dl + bh)) self._draw.rectangle(button2, fill=0x555555) self._draw.text((ox + bw / 2 - 5, yl + dl + 30), u'<-', 0x10bdff) self.canvas.bind(key_codes.EButton1Down, self.removeGuess, button2) self.createSecret() app_lock = e32.Ao_lock() self.handle_redraw(()) app_lock.wait()
def OnRun(self): appuifw.app.title = unicode('Image push') appuifw.app.body = self._canvas = appuifw.Canvas( redraw_callback=self.OnUpdate) self.OnUpdate(None) appuifw.app.menu = [(u'Pusher...', ((u'Start Push...', self.OnStartPhonePc), (u'Stop Push...', self.OnStopPhonePc))), (u'Exit...', self.OnExit)] appuifw.app.exit_key_handler = self.OnExit self._eventKey() self._threadUI(1)
def initial(): global img, canvas, con, color, cur_x, cur_y, turn, pos1, pos2, pos appuifw.app.screen = 'full' appuifw.app.body = canvas = appuifw.Canvas() img = Image.new((240, 320)) img.clear(color["bg"]) cur_x = 7 cur_y = 7 turn = 1 pos1 = [] pos2 = [] pos = [] for i in range(con["n"] * con["n"]): pos.append(0)