steps.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import sys, string, os
  2. from Tkinter import *
  3. # define class step
  4. class step:
  5. stepFrame = None
  6. def initStep(self, root):
  7. return
  8. def checkStep(self):
  9. return None
  10. # define class step1
  11. class step1(step):
  12. step_entry = None
  13. def initStep(self, root):
  14. self.stepFrame = Frame(root)
  15. step_tip = Label(self.stepFrame, text="Input the android project path of your game:")
  16. step_tip.pack(anchor='nw', padx=30)
  17. step_tip2 = Label(self.stepFrame, text="(Pleasd avoid using spaces in your project path)")
  18. step_tip2.pack(anchor='nw', padx=30)
  19. self.step_entry = Entry(self.stepFrame)
  20. self.step_entry.pack(anchor='nw', fill=X, padx=30)
  21. return
  22. def checkStep(self):
  23. tipStr = None
  24. projPath = self.step_entry.get()
  25. haveDir = os.path.exists(projPath)
  26. isPorj = os.path.exists(projPath + '/AndroidManifest.xml')
  27. if projPath == None or len(projPath) == 0 or haveDir == False or isPorj == False:
  28. tipStr = 'The project path is wrong'
  29. return tipStr
  30. def getPath(self):
  31. return self.step_entry.get()
  32. # define class step2
  33. class step2(step):
  34. checkBtns = []
  35. checkValues = []
  36. def initStep(self, root, pluginList):
  37. self.stepFrame = Frame(root)
  38. step_tip = Label(self.stepFrame, text="Select plugins you needed:")
  39. step_tip.pack(anchor='nw', padx=30)
  40. for plugin in pluginList:
  41. var = StringVar()
  42. self.checkValues.append(var)
  43. btn = Checkbutton(self.stepFrame, text=plugin, variable=var, onvalue=plugin, offvalue='')
  44. btn.pack(anchor='nw', padx=50)
  45. self.checkBtns.append(btn)
  46. return
  47. def checkStep(self):
  48. tipStr = None
  49. num = 0
  50. for var in self.checkValues:
  51. if len(var.get()) != 0:
  52. num += 1
  53. break
  54. if num == 0:
  55. tipStr = 'At least select one plugin'
  56. return tipStr
  57. def getSelectedPlugins(self):
  58. selectPlugins = []
  59. for var in self.checkValues:
  60. if len(var.get()) != 0:
  61. plugin = var.get()
  62. selectPlugins.append(plugin)
  63. return selectPlugins