page.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. # -*- coding: utf-8 -*-
  2. import pygame
  3. from pygame.locals import *
  4. from sys import exit
  5. import os
  6. import sys
  7. import math
  8. from libs import easing
  9. #import base64
  10. #from beeprint import pp
  11. ### local import
  12. from constants import ALIGN,icon_width,icon_height,Width,Height,ICON_TYPES
  13. from util_funcs import midRect
  14. from keys_def import CurKeys
  15. from icon_pool import MyIconPool
  16. from lang_manager import MyLangManager
  17. from widget import Widget
  18. class PageStack:
  19. def __init__(self):
  20. self.stack = list()
  21. def Push(self,data):
  22. if data not in self.stack:
  23. self.stack.append(data)
  24. return True
  25. return False
  26. def Pop(self):
  27. if len(self.stack)<=0:
  28. return None,False
  29. return self.stack.pop(),True
  30. def Length(self):
  31. return len(self.stack)
  32. class PageSelector(Widget):
  33. _Parent = None
  34. _Alpha = 0
  35. _OnShow = True
  36. _IconSurf = None
  37. def __init__(self):
  38. pass
  39. def Init(self,x,y,w,h,alpha):
  40. self._PosX = x
  41. self._PosY = y
  42. self._Width = w
  43. self._Height = h
  44. self._Alpha = alpha
  45. def Adjust(self,x,y,w,h,alpha):
  46. self._PosX = x
  47. self._PosY = y
  48. self._Width = w
  49. self._Height = h
  50. self._Alpha = alpha
  51. def Draw(self):
  52. canvas = self._Parent._CanvasHWND
  53. idx = self._Parent._PsIndex
  54. iconidx = self._Parent._IconIndex
  55. if idx < len(self._Parent._Icons):
  56. x = self._Parent._Icons[idx]._PosX+self._Parent._PosX
  57. y = self._Parent._Icons[iconidx]._PosY ## only use current icon's PosY
  58. rect = midRect(x,y,self._Width,self._Height,self._Parent._Width,self._Parent._Height)
  59. if rect.width <=0 or rect.height <= 0 :
  60. return
  61. #color = (244,197,66,50)
  62. #pygame.draw.rect(canvas,color,rect,1)
  63. if self._IconSurf != None:
  64. self._Parent._CanvasHWND.blit(self._IconSurf,rect)
  65. class Page(Widget):
  66. _Icons = []
  67. _Ps = None
  68. _PsIndex = 0
  69. _IconNumbers = 0
  70. _IconIndex = 0 ## shows which icon current selected, the Selector can not move here
  71. _PrevIconIndex = 0 ## for remember the Highlighted Icon ,restore it's PosY to average
  72. _Index = 0
  73. _Align = ALIGN["SLeft"]
  74. _CanvasHWND = None #
  75. _HWND = None #
  76. _OnShow = False
  77. _Name = ""
  78. _Screen = None ## Should be the Screen Class
  79. _PageIconMargin = 20
  80. _FootMsg = ["Nav","","","","Enter"] ## Default Page Foot info
  81. _SelectedIconTopOffset=20
  82. _EasingDur = 30
  83. _Padding = pygame.Rect(0,0,0,0)# x,y,w,h
  84. _Margin = pygame.Rect(0,0,0,0)
  85. def __init__(self):
  86. self._Icons = []
  87. def AdjustHLeftAlign(self): ## adjust coordinator and append the PageSelector
  88. self._PosX = self._Index*self._Screen._Width
  89. self._Width = self._Screen._Width
  90. self._Height = self._Screen._Height
  91. cols = int(Width /icon_width)
  92. rows = int( (self._IconNumbers * icon_width)/Width + 1)
  93. if rows < 1:
  94. rows = 1
  95. cnt = 0
  96. for i in range(0,rows):
  97. for j in range(0,cols):
  98. start_x = icon_width/2 + j*icon_width
  99. start_y = icon_height/2 + i*icon_height
  100. icon = self._Icons[cnt]
  101. icon.Adjust(start_x,start_y,icon_width-4,icon_height-4,0)
  102. icon._Index = cnt
  103. icon._Parent = self
  104. if cnt >= (self._IconNumbers -1):
  105. break
  106. cnt+=1
  107. ps = PageSelector()
  108. ps._IconSurf = MyIconPool._Icons["blueselector"]
  109. ps._Parent = self
  110. ps.Init(icon_width/2, TitleBar._BarHeight+icon_height/2,92,92,128)
  111. self._Ps = ps
  112. self._PsIndex = 0
  113. self._OnShow = False
  114. def AdjustSLeftAlign(self): ## adjust coordinator and append the PageSelector
  115. self._PosX = self._Index*self._Screen._Width
  116. self._Width = self._Screen._Width
  117. self._Height = self._Screen._Height
  118. start_x = (self._PageIconMargin + icon_width+self._PageIconMargin) /2
  119. start_y = self._Height/2
  120. for i in range(0,self._IconNumbers):
  121. it = self._Icons[i]
  122. it._Parent = self
  123. it._Index = i
  124. it.Adjust(start_x+i*self._PageIconMargin+i*icon_width,start_y,icon_width-6,icon_height-6,0)
  125. it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
  126. ps = PageSelector()
  127. ps._IconSurf = MyIconPool._Icons["blueselector"]
  128. ps._Parent = self
  129. ps.Init(start_x,start_y,92,92,128)
  130. self._Ps = ps
  131. self._PsIndex = 0
  132. self._OnShow = False
  133. if self._IconNumbers > 1:
  134. self._PsIndex = 1
  135. self._IconIndex = self._PsIndex
  136. self._PrevIconIndex = self._IconIndex
  137. self._Icons[self._IconIndex]._PosY -= self._SelectedIconTopOffset
  138. def AdjustSAutoLeftAlign(self): ## adjust coordinator and append the PageSelector
  139. self._PosX = self._Index*self._Screen._Width
  140. self._Width = self._Screen._Width
  141. self._Height = self._Screen._Height
  142. start_x = (self._PageIconMargin + icon_width+self._PageIconMargin) /2
  143. start_y = self._Height/2
  144. if self._IconNumbers == 1:
  145. start_x = self._Width / 2
  146. start_y = self._Height/2
  147. it = self._Icons[0]
  148. it._Parent = self
  149. it._Index = 0
  150. it.Adjust(start_x,start_y,icon_width,icon_height,0)
  151. #it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
  152. elif self._IconNumbers == 2:
  153. start_x = (self._Width - self._PageIconMargin - self._IconNumbers*icon_width) / 2 + icon_width/2
  154. start_y = self._Height /2
  155. for i in range(0,self._IconNumbers):
  156. it = self._Icons[i]
  157. it._Parent = self
  158. it._Index = i
  159. it.Adjust(start_x+i*self._PageIconMargin + i*icon_width,start_y, icon_width, icon_height,0)
  160. #it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
  161. elif self._IconNumbers > 2:
  162. for i in range(0,self._IconNumbers):
  163. it = self._Icons[i]
  164. it._Parent = self
  165. it._Index = i
  166. it.Adjust(start_x+i*self._PageIconMargin + i*icon_width,start_y,icon_width,icon_height,0)
  167. #it._ImgSurf = pygame.transform.smoothscale(it._ImgSurf,(it._Width,it._Height))
  168. ps = PageSelector()
  169. ps._IconSurf = MyIconPool._Icons["blueselector"]
  170. ps._Parent = self
  171. ps.Init(start_x,start_y,92,92,128)
  172. self._Ps = ps
  173. self._PsIndex = 0
  174. self._OnShow = False
  175. if self._IconNumbers > 1:
  176. self._PsIndex = 1
  177. self._IconIndex = self._PsIndex
  178. self._PrevIconIndex = self._IconIndex
  179. self._Icons[self._IconIndex]._PosY -= self._SelectedIconTopOffset
  180. def InitLeftAlign(self):
  181. self._PosX = self._Index*Width
  182. self._Width = self._Screen._Width
  183. self._Height = self._Screen._Height
  184. cols = int(self._Width /icon_width)
  185. rows = int((self._IconNumbers * icon_width)/self._Width + 1)
  186. if rows < 1:
  187. rows = 1
  188. cnt = 0
  189. for i in range(0,rows):
  190. for j in range(0,cols):
  191. start_x = icon_width/2 + j*icon_width
  192. start_y = TitleBar._BarHeight + icon_height/2 + i*icon_height
  193. icon = IconItem()
  194. icon.Init(start_x,start_y,icon_width-4,icon_height-4,0)
  195. icon._Index = cnt
  196. icon._Parent = self
  197. self._Icons.append(icon)
  198. if cnt >= (self._IconNumbers -1):
  199. break
  200. cnt+=1
  201. ps = PageSelector()
  202. ps._IconSurf = MyIconPool._Icons["blueselector"]
  203. ps._Parent = self
  204. ps.Init(icon_width/2,icon_height/2,92,92,128)
  205. self._Ps = ps
  206. self._PsIndex = 0
  207. self._OnShow = False
  208. def Adjust(self): ## default init way,
  209. self._PosX = self._Index*self._Screen._Width
  210. self._Width = self._Screen._Width ## equal to screen width
  211. self._Height = self._Screen._Height
  212. if self._Align == ALIGN["HLeft"]:
  213. start_x = (self._Width - self._IconNumbers*icon_width)/2 + icon_width/2
  214. start_y = self._Height/2
  215. for i in range(0,self._IconNumbers):
  216. it = self._Icons[i]
  217. it._Parent = self
  218. it._Index = i
  219. it.Adjust(start_x+i*icon_width,start_y,icon_width,icon_height,0)
  220. ps = PageSelector()
  221. ps._IconSurf = MyIconPool._Icons["blueselector"]
  222. ps._Parent = self
  223. ps.Init(start_x,start_y,92,92,128)
  224. self._Ps = ps
  225. self._PsIndex = 0
  226. self._OnShow = False
  227. elif self._Align == ALIGN["SLeft"]:
  228. start_x = (self._PageIconMargin + icon_width+self._PageIconMargin) /2
  229. start_y = self._Height/2
  230. for i in range(0,self._IconNumbers):
  231. it = self._Icons[i]
  232. it._Parent = self
  233. it._Index = i
  234. it.Adjust(start_x+i*self._PageIconMargin+i*icon_width,start_y,icon_width,icon_height,0)
  235. ps = PageSelector()
  236. ps._IconSurf = MyIconPool._Icons["blueselector"]
  237. ps._Parent = self
  238. ps.Init(start_x,start_y-self._SelectedIconTopOffset,92,92,128)
  239. self._Ps = ps
  240. self._PsIndex = 0
  241. self._OnShow = False
  242. if self._IconNumbers > 1:
  243. self._PsIndex = 1
  244. self._IconIndex = self._PsIndex
  245. self._PrevIconIndex = self._IconIndex
  246. self._Icons[self._IconIndex]._PosY -= self._SelectedIconTopOffset
  247. def Init(self): ## default init way,
  248. if self._Screen != None:
  249. if self._Screen._CanvasHWND != None and self._CanvasHWND == None:
  250. self._CanvasHWND = self._Screen._CanvasHWND
  251. self._PosX = self._Index*self._Screen._Width
  252. self._Width = self._Screen._Width ## equal to screen width
  253. self._Height = self._Screen._Height
  254. start_x = (self._Width - self._IconNumbers*icon_width)/2 + icon_width/2
  255. start_y = self._Height/2
  256. for i in range(0,self._IconNumbers):
  257. it = IconItem()
  258. it._Parent = self
  259. it._Index = i
  260. it.Init(start_x+i*icon_width,start_y,icon_width,icon_height,0)
  261. self._Icons.append(it)
  262. if self._IconNumbers > 0:
  263. ps = PageSelector()
  264. ps._IconSurf = MyIconPool._Icons["blueselector"]
  265. ps._Parent = self
  266. ps.Init(start_x,start_y,icon_width+4,icon_height+4,128)
  267. self._Ps = ps
  268. self._PsIndex = 0
  269. self._OnShow = False
  270. def IconStepMoveData(self,icon_eh,cuts):## no Sine,No curve,plain movement steps data
  271. all_pieces = []
  272. piece = icon_eh / cuts
  273. c = 0.0
  274. prev = 0.0
  275. for i in range(0,cuts):
  276. c+=piece
  277. dx = c-prev
  278. if dx < 0.5:
  279. dx = 1.0
  280. all_pieces.append( math.ceil(dx) )
  281. if c >= icon_eh:
  282. break
  283. c = 0
  284. bidx = 0
  285. for i in all_pieces:
  286. c+=i
  287. bidx+=1
  288. if c >= icon_eh:
  289. break
  290. all_pieces = all_pieces[0:bidx]
  291. if len(all_pieces) < cuts:
  292. dff = cuts - len(all_pieces)
  293. diffa = []
  294. for i in range(0,dff):
  295. diffa.append(0)
  296. all_pieces.extend( diffa)
  297. return all_pieces
  298. def EasingData(self,start,distance):##generate easing steps data
  299. current_time = 0.0
  300. start_posx = 0.0
  301. current_posx = start_posx
  302. final_posx = float(distance)
  303. posx_init = start
  304. dur = self._EasingDur
  305. last_posx = 0.0
  306. all_last_posx = []
  307. for i in range(0,distance*dur):
  308. current_posx = easing.SineIn(current_time,start_posx,final_posx-start_posx,float(dur))
  309. if current_posx >= final_posx:
  310. current_posx = final_posx
  311. dx = current_posx - last_posx
  312. all_last_posx.append(int(dx))
  313. current_time+=1
  314. last_posx = current_posx
  315. if current_posx >= final_posx:
  316. break
  317. c = 0
  318. for i in all_last_posx:
  319. c+=i
  320. if c < final_posx -start_posx:
  321. all_last_posx.append(final_posx - c)
  322. return all_last_posx
  323. def IconSmoothUp(self,icon_ew):
  324. data = self.EasingData(self._PosX,icon_ew)
  325. data2 = self.IconStepMoveData(self._SelectedIconTopOffset,len(data))
  326. for i,v in enumerate(data):
  327. self.ClearCanvas()
  328. self._Icons[self._IconIndex]._PosY -= data2[i]
  329. if self._Icons[self._PrevIconIndex]._PosY < self._Height/2:
  330. self._Icons[self._PrevIconIndex]._PosY+=data2[i]
  331. self.DrawIcons()
  332. self._Screen.SwapAndShow()
  333. def IconsEasingLeft(self,icon_ew):
  334. data = self.EasingData(self._PosX,icon_ew)
  335. data2 = self.IconStepMoveData(self._SelectedIconTopOffset,len(data))
  336. for i,v in enumerate(data):
  337. self.ClearCanvas()
  338. self._PosX -= v
  339. self._Icons[self._IconIndex]._PosY -= data2[i]
  340. if self._Icons[self._PrevIconIndex]._PosY < self._Height/2:
  341. self._Icons[self._PrevIconIndex]._PosY+=data2[i]
  342. self.DrawIcons()
  343. self._Screen.SwapAndShow()
  344. def IconsEasingRight(self,icon_ew):
  345. data = self.EasingData(self._PosX,icon_ew)
  346. data2 = self.IconStepMoveData(self._SelectedIconTopOffset,len(data))
  347. for i,v in enumerate(data):
  348. self.ClearCanvas()
  349. self._PosX += v
  350. self._Icons[self._IconIndex]._PosY-=data2[i]
  351. if self._Icons[self._PrevIconIndex]._PosY < self._Height/2:
  352. self._Icons[self._PrevIconIndex]._PosY+=data2[i]
  353. self.DrawIcons()
  354. self._Screen.SwapAndShow()
  355. def EasingLeft(self,ew): #ew int
  356. data = self.EasingData(self._PosX,ew)
  357. for i in data:
  358. self._PosX -=i
  359. self.Draw()
  360. self._Screen.SwapAndShow()
  361. def EasingRight(self,ew):
  362. data = self.EasingData(self._PosX,ew)
  363. for i in data:
  364. self._PosX += i
  365. self.Draw()
  366. self._Screen.SwapAndShow()
  367. def MoveLeft(self,ew):
  368. self._PosX -= ew
  369. def MoveRight(self,ew):
  370. self._PosX += ew
  371. def ResetPageSelector(self):
  372. self._PsIndex = 0
  373. self._IconIndex = 0
  374. self._Ps._OnShow = True
  375. def DrawPageSelector(self):
  376. if self._Ps._OnShow == True:
  377. self._Ps.Draw()
  378. def MoveIconIndexPrev(self):
  379. self._IconIndex-=1
  380. if self._IconIndex < 0:
  381. self._IconIndex = 0
  382. self._PrevIconIndex = self._IconIndex
  383. return False
  384. self._PrevIconIndex = self._IconIndex+1
  385. return True
  386. def MoveIconIndexNext(self):
  387. #True for Moved,False is boundary
  388. self._IconIndex+=1
  389. if self._IconIndex > (self._IconNumbers - 1):
  390. self._IconIndex = self._IconNumbers -1
  391. self._PrevIconIndex = self._IconIndex
  392. return False
  393. self._PrevIconIndex = self._IconIndex-1
  394. return True
  395. def IconClick(self):
  396. if self._IconIndex > (len(self._Icons) -1):
  397. return
  398. cur_icon = self._Icons[self._IconIndex]
  399. if self._Ps._OnShow == False:
  400. return
  401. if cur_icon._MyType == ICON_TYPES["EXE"]:
  402. print("IconClick: %s %d"%(cur_icon._CmdPath,cur_icon._Index))
  403. self._Screen.RunEXE(cur_icon._CmdPath)
  404. elif cur_icon._MyType == ICON_TYPES["DIR"]:
  405. child_page = self._Icons[self._IconIndex]._LinkPage
  406. if child_page != None:
  407. child_page.Draw()
  408. self._Screen._MyPageStack.Push(self._Screen._CurrentPage)
  409. self._Screen._CurrentPage = child_page
  410. elif cur_icon._MyType == ICON_TYPES["FUNC"]:
  411. print("IconClick API: %d"%(cur_icon._Index))
  412. #print("%s"% cur_icon._CmdPath)
  413. api_cb = getattr(cur_icon._CmdPath,"API",None)
  414. if api_cb != None:
  415. if callable(api_cb):
  416. cur_icon._CmdPath.API(self._Screen)
  417. elif cur_icon._MyType == ICON_TYPES["Emulator"] or cur_icon._MyType == ICON_TYPES["Commercial"]:
  418. cur_icon._CmdPath.API(self._Screen)
  419. def ReturnToUpLevelPage(self):
  420. pop_page,ok = self._Screen._MyPageStack.Pop()
  421. if ok == True:
  422. #self._Screen._CurrentPage.ResetPageSelector()
  423. pop_page.Draw()
  424. self._Screen._CurrentPage = pop_page
  425. on_return_back_cb = getattr(self._Screen._CurrentPage,"OnReturnBackCb",None)
  426. if on_return_back_cb != None:
  427. if callable(on_return_back_cb):
  428. self._Screen._CurrentPage.OnReturnBackCb()
  429. else:
  430. if self._Screen._MyPageStack.Length() == 0:
  431. if len(self._Screen._Pages) > 0:
  432. self._Screen._CurrentPage = self._Screen._Pages[self._Screen._PageIndex]
  433. self._Screen._CurrentPage.Draw()
  434. print("OnTopLevel ",self._Screen._PageIndex)
  435. def ClearCanvas(self):
  436. self._CanvasHWND.fill(self._Screen._SkinManager.GiveColor("White"))
  437. def ClearIcons(self):
  438. for i in range(0,self._IconNumbers):
  439. self._Icons[i].Clear()
  440. def DrawIcons(self):
  441. for i in range(0,self._IconNumbers):
  442. self._Icons[i].Draw()
  443. ##make sure the Class has the _MyList
  444. def ScrollDown(self):
  445. if len(self._MyList) == 0:
  446. return
  447. self._PsIndex +=1
  448. if self._PsIndex >= len(self._MyList):
  449. self._PsIndex = len(self._MyList) -1
  450. cur_li = self._MyList[self._PsIndex]
  451. if cur_li._PosY +cur_li._Height > self._Height:
  452. for i in range(0,len(self._MyList)):
  453. self._MyList[i]._PosY -= self._MyList[i]._Height
  454. def ScrollUp(self):
  455. if len(self._MyList) == 0:
  456. return
  457. self._PsIndex -= 1
  458. if self._PsIndex < 0:
  459. self._PsIndex = 0
  460. cur_li = self._MyList[self._PsIndex]
  461. if cur_li._PosY < 0:
  462. for i in range(0, len(self._MyList)):
  463. self._MyList[i]._PosY += self._MyList[i]._Height
  464. def FScrollUp(self,Step=1):
  465. if len(self._MyList) == 0:
  466. return
  467. tmp = self._PsIndex
  468. self._PsIndex -= Step
  469. if self._PsIndex < 0:
  470. self._PsIndex = 0
  471. dy = tmp-self._PsIndex
  472. cur_li = self._MyList[self._PsIndex]
  473. if cur_li._PosY < 0:
  474. for i in range(0, len(self._MyList)):
  475. self._MyList[i]._PosY += self._MyList[i]._Height*dy
  476. def FScrollDown(self,Step=1):
  477. if len(self._MyList) == 0:
  478. return
  479. tmp = self._PsIndex
  480. self._PsIndex +=Step
  481. if self._PsIndex >= len(self._MyList):
  482. self._PsIndex = len(self._MyList) -1
  483. dy = self._PsIndex - tmp
  484. cur_li = self._MyList[self._PsIndex]
  485. if cur_li._PosY +cur_li._Height > self._Height:
  486. for i in range(0,len(self._MyList)):
  487. self._MyList[i]._PosY -= self._MyList[i]._Height*dy
  488. def KeyDown(self,event):##default keydown,every inherited page class should have it's own KeyDown
  489. if event.key == CurKeys["A"]:
  490. if self._FootMsg[3] == "Back":
  491. self.ReturnToUpLevelPage()
  492. self._Screen.Draw()
  493. self._Screen.SwapAndShow()
  494. return
  495. if event.key == CurKeys["Menu"]:
  496. self.ReturnToUpLevelPage()
  497. self._Screen.Draw()
  498. self._Screen.SwapAndShow()
  499. if event.key == CurKeys["Right"]:
  500. if self.MoveIconIndexNext() == True:
  501. if self._IconIndex == (self._IconNumbers -1) or self._PrevIconIndex == 0:
  502. self.IconSmoothUp(icon_width+ self._PageIconMargin) # only move up selected icon,no horizontal translation
  503. else:
  504. self.IconsEasingLeft(icon_width + self._PageIconMargin)
  505. self._PsIndex = self._IconIndex
  506. self._Screen.Draw()
  507. self._Screen.SwapAndShow()
  508. if event.key == CurKeys["Left"]:
  509. if self.MoveIconIndexPrev() == True:
  510. if self._IconIndex == 0 or self._PrevIconIndex == (self._IconNumbers -1):
  511. self.IconSmoothUp(icon_width+ self._PageIconMargin)
  512. else:
  513. self.IconsEasingRight(icon_width + self._PageIconMargin)
  514. self._PsIndex = self._IconIndex
  515. self._Screen.Draw()
  516. self._Screen.SwapAndShow()
  517. if event.key == CurKeys["Enter"]:
  518. self.IconClick()
  519. self._Screen.Draw()
  520. self._Screen.SwapAndShow()
  521. def Draw(self):
  522. self.ClearCanvas()
  523. self.DrawIcons()
  524. self.DrawPageSelector()