Advertisement
Guest User

component.py

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