Advertisement
Guest User

add dynamically

a guest
Jul 18th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.04 KB | None | 0 0
  1. # .py Code:
  2.  
  3. class RcGUIApp(App):
  4. def build(self):
  5. Window.clearcolor = (0, 0, 0.35, 1)
  6. sm = ScreenManager()
  7. sm.add_widget(IntroPage(name="intro_page"))
  8. sm.add_widget(NewJobPage(name="new_job_page"))
  9. sm.add_widget(IPMConfirmPage(name = "ipm_confirm_page"))
  10. return sm
  11.  
  12. class IntroPage(Screen):
  13.  
  14. def returnCDPath(self):
  15. global rc
  16. return str(rc.cd_path)
  17.  
  18. def locateDatabase(self):
  19. global rc
  20. self.data_label.text = rc.retrieveDatabase()
  21.  
  22. def openJob(self):
  23. #Go to open job page
  24. pass
  25.  
  26. class NewJobPage(Screen):
  27.  
  28.  
  29. def newJob(self):
  30. global rc
  31. self.ipm_label.text = "IPM file path: " + str(rc.openIPM())
  32. rc.makePartList()
  33. rc.makePoleList()
  34.  
  35. def returnCDPath(self):
  36. global rc
  37. return str(rc.cd_path)
  38.  
  39. def locateDatabase(self):
  40. global rc
  41. self.data_label.text = rc.retrieveDatabase()
  42.  
  43. def retrieve(self):
  44. global rc
  45. rc.getIPM(self.ipm_header.text.upper())
  46. rc.buildIPM(self.pole_header.text.upper(), self.cd_header.text.upper(), self.conductor_header.text.upper())
  47. IPMConfirmPage().displayIPM()
  48.  
  49. class OpenJobPage(Screen):
  50. pass
  51.  
  52.  
  53. class IPMConfirmPage(Screen):
  54. def displayIPM(self):
  55. for i in range(25):
  56. self.grid.add_widget(Button(text="you did it!"))
  57.  
  58. #.kv Code:
  59.  
  60. <IntroPage>:
  61.  
  62. data_label: database_label
  63.  
  64. BoxLayout:
  65.  
  66. orientation: "vertical"
  67. padding: 10
  68. spacing: 10
  69.  
  70. BoxLayout:
  71.  
  72. orientation: "horizontal"
  73. size_hint: (1, .10)
  74.  
  75. Button:
  76. text: "Locate Database"
  77. color: (1,1,1,1)
  78. on_press:
  79. root.locateDatabase()
  80. root.data_label.color= (0,1,0,1)
  81. size_hint_x: (0.05)
  82.  
  83. Label:
  84. id: database_label
  85. text: root.returnCDPath()
  86. color: (1,0,0,1)
  87. size_hint_x: (0.2)
  88. pos: (.5, .5)
  89.  
  90.  
  91.  
  92. BoxLayout:
  93. orientation: "horizontal"
  94.  
  95. Button:
  96. text: "NEW JOB"
  97. color: (1,1,1,1)
  98. size_hint: (.45, .10)
  99. on_press:
  100. root.manager.transition.direction = "up"
  101. root.manager.transition.duration = .8
  102. root.manager.current = "new_job_page"
  103. Button:
  104. text: "OPEN JOB"
  105. color: (1,1,1,1)
  106. size_hint: (.45, .10)
  107. pos: (0.5, 0.5)
  108. on_press: root.openJob()
  109.  
  110. <NewJobPage>:
  111.  
  112. data_label: database_label
  113. ipm_label: ipm_name_label
  114. pole_header: pole_col
  115. cd_header: cd_col
  116. conductor_header: conductor_col
  117. ipm_header: ipm_col
  118.  
  119. BoxLayout:
  120.  
  121. orientation: "vertical"
  122. padding: 10
  123. spacing: 10
  124.  
  125. BoxLayout:
  126.  
  127. orientation: "horizontal"
  128. size_hint: (1, .10)
  129.  
  130. Button:
  131. text: "Locate Database"
  132. color: (1,1,1,1)
  133. on_press:
  134. root.locateDatabase()
  135. root.data_label.color= (0,1,0,1)
  136. size_hint_x: (0.05)
  137.  
  138. Label:
  139. id: database_label
  140. text: root.returnCDPath()
  141. color: (1,0,0,1)
  142. size_hint_x: (0.2)
  143. pos: (.5, .5)
  144. BoxLayout:
  145.  
  146. orientation: "horizontal"
  147. size_hint: (1, .20)
  148.  
  149. Button:
  150. text: "Load IPM"
  151. color: (1,1,1,1)
  152. size_hint: (.05, 0.5)
  153. on_press:
  154. root.newJob()
  155.  
  156. Label:
  157. id: ipm_name_label
  158. text: ""
  159. size_hint: (.2, 0.5)
  160.  
  161. BoxLayout:
  162.  
  163. orientation: "vertical"
  164. size_hint: (1, .35)
  165.  
  166. Label:
  167. text: "Enter your Pole, CD# and Conductor column names below:"
  168. pos_hint: {' center_x': 0.5, 'bottom': 1}
  169.  
  170. BoxLayout:
  171. orientation: "horizontal"
  172. spacing: 30
  173. size_hint: (1, 0.35)
  174.  
  175. TextInput:
  176. id: ipm_col
  177. text: "IPM"
  178.  
  179. TextInput:
  180. id: pole_col
  181. text: "POLE"
  182.  
  183. TextInput:
  184. id: cd_col
  185. text: "CD#"
  186.  
  187. TextInput:
  188. id: conductor_col
  189. text: "CONDUCTOR"
  190.  
  191. BoxLayout:
  192. orientation: "horizontal"
  193. size_hint: (1, .35)
  194.  
  195. Button:
  196. text: "RETRIEVE"
  197. pos_hint: {"center_x": .5, "center_y": .5}
  198. size_hint: (.33, .33)
  199. color: (1,1,1,1)
  200. on_press:
  201. root.retrieve()
  202. root.manager.transition.direction = "left"
  203. root.manager.transition.duration = .8
  204. root.manager.current = "ipm_confirm_page"
  205.  
  206. <IPMConfirmPage>:
  207. grid: Grid
  208. GridLayout:
  209. cols: 1
  210. size_hint_x: 1
  211. padding: 10
  212. spacing: 10
  213.  
  214. BoxLayout:
  215.  
  216. size_hint: (1, 0.1)
  217.  
  218. Label:
  219. text: "IPM"
  220. Label:
  221. text: "CD#"
  222. Label:
  223. text: "CONDUCTOR"
  224.  
  225. ScrollView:
  226.  
  227. GridLayout:
  228. id: Grid
  229. cols: 3
  230. height: self.minimum_height
  231. size_hint: 1, None
  232. spacing: 50
  233. padding: 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement