Guest User

Untitled

a guest
May 22nd, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. import ui
  2. import dbg
  3. import app
  4.  
  5. class Dialog1(ui.Window):
  6. def __init__(self):
  7. ui.Window.__init__(self)
  8. self.BuildWindow()
  9.  
  10. def __del__(self):
  11. ui.Window.__del__(self)
  12.  
  13. def BuildWindow(self):
  14. self.Board = ui.BoardWithTitleBar()
  15. self.Board.SetSize(170, 170)
  16. self.Board.SetCenterPosition()
  17. self.Board.AddFlag('movable')
  18. self.Board.AddFlag('float')
  19. self.Board.SetTitleName('Window')
  20. self.Board.SetCloseEvent(self.Close)
  21. self.Board.Show()
  22. self.__BuildKeyDict()
  23. self.comp = Component()
  24.  
  25.  
  26. def __BuildKeyDict(self):
  27. onPressKeyDict = {}
  28. onPressKeyDict[app.DIK_F5] = lambda : self.OpenWindow()
  29. self.onPressKeyDict = onPressKeyDict
  30.  
  31. def OnKeyDown(self, key):
  32. try:
  33. self.onPressKeyDict[key]()
  34. except KeyError:
  35. pass
  36. except:
  37. raise
  38. return TRUE
  39.  
  40. def OpenWindow(self):
  41. if self.Board.IsShow():
  42. self.Board.Hide()
  43. else:
  44. self.Board.Show()
  45.  
  46. def Close(self):
  47. self.Board.Hide()
  48.  
  49. class Component:
  50. def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
  51. button = ui.Button()
  52. if parent != None:
  53. button.SetParent(parent)
  54. button.SetPosition(x, y)
  55. button.SetUpVisual(UpVisual)
  56. button.SetOverVisual(OverVisual)
  57. button.SetDownVisual(DownVisual)
  58. button.SetText(buttonName)
  59. button.SetToolTipText(tooltipText)
  60. button.Show()
  61. button.SetEvent(func)
  62. return button
  63.  
  64. def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual):
  65. button = ui.ToggleButton()
  66. if parent != None:
  67. button.SetParent(parent)
  68. button.SetPosition(x, y)
  69. button.SetUpVisual(UpVisual)
  70. button.SetOverVisual(OverVisual)
  71. button.SetDownVisual(DownVisual)
  72. button.SetText(buttonName)
  73. button.SetToolTipText(tooltipText)
  74. button.Show()
  75. button.SetToggleUpEvent(funcUp)
  76. button.SetToggleDownEvent(funcDown)
  77. return button
  78.  
  79. def EditLine(self, parent, editlineText, x, y, width, heigh, max):
  80. SlotBar = ui.SlotBar()
  81. if parent != None:
  82. SlotBar.SetParent(parent)
  83. SlotBar.SetSize(width, heigh)
  84. SlotBar.SetPosition(x, y)
  85. SlotBar.Show()
  86. Value = ui.EditLine()
  87. Value.SetParent(SlotBar)
  88. Value.SetSize(width, heigh)
  89. Value.SetPosition(1, 1)
  90. Value.SetMax(max)
  91. Value.SetLimitWidth(width)
  92. Value.SetMultiLine()
  93. Value.SetText(editlineText)
  94. Value.Show()
  95. return SlotBar, Value
  96.  
  97. def TextLine(self, parent, textlineText, x, y, color):
  98. textline = ui.TextLine()
  99. if parent != None:
  100. textline.SetParent(parent)
  101. textline.SetPosition(x, y)
  102. if color != None:
  103. textline.SetFontColor(color[0], color[1], color[2])
  104. textline.SetText(textlineText)
  105. textline.Show()
  106. return textline
  107.  
  108. def RGB(self, r, g, b):
  109. return (r*255, g*255, b*255)
  110.  
  111. def SliderBar(self, parent, sliderPos, func, x, y):
  112. Slider = ui.SliderBar()
  113. if parent != None:
  114. Slider.SetParent(parent)
  115. Slider.SetPosition(x, y)
  116. Slider.SetSliderPos(sliderPos / 100)
  117. Slider.Show()
  118. Slider.SetEvent(func)
  119. return Slider
  120.  
  121. def ExpandedImage(self, parent, x, y, img):
  122. image = ui.ExpandedImageBox()
  123. if parent != None:
  124. image.SetParent(parent)
  125. image.SetPosition(x, y)
  126. image.LoadImage(img)
  127. image.Show()
  128. return image
  129.  
  130. def ComboBox(self, parent, text, x, y, width):
  131. combo = ui.ComboBox()
  132. if parent != None:
  133. combo.SetParent(parent)
  134. combo.SetPosition(x, y)
  135. combo.SetSize(width, 15)
  136. combo.SetCurrentItem(text)
  137. combo.Show()
  138. return combo
  139.  
  140. def ThinBoard(self, parent, moveable, x, y, width, heigh, center):
  141. thin = ui.ThinBoard()
  142. if parent != None:
  143. thin.SetParent(parent)
  144. if moveable == TRUE:
  145. thin.AddFlag('movable')
  146. thin.AddFlag('float')
  147. thin.SetSize(width, heigh)
  148. thin.SetPosition(x, y)
  149. if center == TRUE:
  150. thin.SetCenterPosition()
  151. thin.Show()
  152. return thin
  153.  
  154. def Gauge(self, parent, width, color, x, y):
  155. gauge = ui.Gauge()
  156. if parent != None:
  157. gauge.SetParent(parent)
  158. gauge.SetPosition(x, y)
  159. gauge.MakeGauge(width, color)
  160. gauge.Show()
  161. return gauge
  162.  
  163. def ListBoxEx(self, parent, x, y, width, heigh):
  164. bar = ui.Bar()
  165. if parent != None:
  166. bar.SetParent(parent)
  167. bar.SetPosition(x, y)
  168. bar.SetSize(width, heigh)
  169. bar.SetColor(0x77000000)
  170. bar.Show()
  171. ListBox=ui.ListBoxEx()
  172. ListBox.SetParent(bar)
  173. ListBox.SetPosition(0, 0)
  174. ListBox.SetSize(width, heigh)
  175. ListBox.Show()
  176. scroll = ui.ScrollBar()
  177. scroll.SetParent(ListBox)
  178. scroll.SetPosition(width-15, 0)
  179. scroll.SetScrollBarSize(heigh)
  180. scroll.Show()
  181. ListBox.SetScrollBar(scroll)
  182. return bar, ListBox
  183.  
  184. Dialog1().Show()
Advertisement
Add Comment
Please, Sign In to add comment