Advertisement
Asthard

Untitled

Dec 8th, 2020
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.20 KB | None | 0 0
  1. import ui
  2. import wndMgr
  3. import grp
  4. import item
  5.  
  6. class ExampleTabs(ui.BoardWithTitleBar):
  7.  
  8.     text = [
  9.             'Lorem Ipsum is simply dummy text of the printing and Lorem Ipsum is simply dummy text of the printing and Lorem ',
  10.             'Lorem Ipsum is simply dummy text of the printing and1 Lorem Ipsum is simply dummy text of the printing and ',
  11.             'Lorem Ipsum is simply dummy text of the printing and2 Lorem Ipsum is simply ',
  12.             'Lorem Ipsum is simply dummy text of the printing and3',
  13.             'Lorem Ipsum is simply dummy text of the printing and3',
  14.             'Lorem Ipsum is simply dummy text of the printing and4',
  15.             'Lorem Ipsum is simply dummy text of the printing and65',
  16.             'Lorem Ipsum is simply dummy text of the printing and6',
  17.             '',
  18.             'Lorem Ipsum is simply dummy text of the printing and7',
  19.             'Lorem Ipsum is simply dummy text of the printing and8',
  20.             'Lorem Ipsum is simply dummy text of the printing and9',
  21.             'Lorem Ipsum is simply dummy text of the printing and0',
  22.             'Lorem Ipsum is simply dummy text of the printing and1',
  23.             'Lorem Ipsum is simply dummy text of the printing and1',
  24.             'Lorem Ipsum is simply dummy text of the printing and1',
  25.             'Lorem Ipsum is simply dummy text of the printing and2 Lorem Ipsum is simply dummy text of the printing and',
  26.             'Lorem Ipsum is simply dummy text of the printing and3',
  27.             'Lorem Ipsum is simply dummy text of the printing and4',
  28.             'Lorem Ipsum is simply dummy text of the printing and6',
  29.             'Lorem Ipsum is simply dummy text of the printing and7Lorem Ipsum is simply dummy text of the printing and Lorem ',
  30.             'Lorem Ipsum is simply dummy text of the printing and8',
  31.             'Lorem Ipsum is simply dummy text of the printing and9',
  32.             'Lorem Ipsum is simply dummy text of the printing and0',
  33.             'Lorem Ipsum is simply dummy text of the printing and1',
  34.             'Lorem Ipsum is simply dummy text of the printing and2',
  35.             'Lorem Ipsum is simply dummy text of the printing and3',
  36.             'Lorem Ipsum is simply dummy text of the printing and',
  37.             'Lorem Ipsum is simply dummy text of the printing and744',
  38.             'Lorem Ipsum is simply dummy text of the printing an11d4',
  39.             'Lorem Ipsum is simply dummy text of the printing and4',
  40.             'Lorem Ipsum is simply dummy text of the printing a2nd4',
  41.             'Lorem Ipsum is simply dummy text of the printing and114',
  42.             'Lorem Ipsum is simply dummy text of the printing a2nd4',
  43.             'Lorem Ipsum is simply dummy text of the printing and4',
  44.             'Lorem Ipsum is simply dummy text of the printing 3and4',
  45.             'Lorem Ipsum is simply dummy text of the printing and4',
  46.  
  47.          ]
  48.  
  49.     def __init__(self):
  50.         ui.BoardWithTitleBar.__init__(self)
  51.         self.isLoaded = FALSE
  52.         if FALSE == self.isLoaded:
  53.             self.__LoadMe()
  54.  
  55.     def __del__(self):
  56.         ui.BoardWithTitleBar.__del__(self)
  57.        
  58.     def __LoadMe(self):
  59.         self.SetSize(700, 700)
  60.         self.SetCenterPosition()
  61.         self.AddFlag('movable')
  62.         self.SetTitleName("Przykładowe Okno")
  63.         self.SetCloseEvent(self.Close)
  64.        
  65.         self.textLines = []
  66.        
  67.         thinBoard = ui.ThinBoard()
  68.         thinBoard.SetParent(self)
  69.         thinBoard.SetSize(300-15-15, 50)
  70.         thinBoard.SetPosition(15, 35)
  71.         thinBoard.Show()
  72.         self.thinBoard = thinBoard
  73.        
  74.         ## Okno buttonów
  75.         thinBoard = ui.ThinBoard()
  76.         thinBoard.SetParent(self)
  77.         thinBoard.SetSize(95, 650)
  78.         thinBoard.SetPosition(15, 35)
  79.         thinBoard.Show()
  80.         self.thinBoard = thinBoard
  81.  
  82.         ## Tworzenie 5 kart
  83.         ## Tworzenie 1 karty
  84.         tabOnePage = ui.ThinBoard()
  85.         tabOnePage.SetParent(self)
  86.         tabOnePage.SetSize(550, 650)
  87.         tabOnePage.SetPosition(115, 35)
  88.         tabOnePage.Hide()
  89.         self.tabOnePage = tabOnePage
  90.        
  91.         ## Dodanie buttona do 1 karty
  92.         button = ui.Button()
  93.         button.SetParent(self.tabOnePage)
  94.         button.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  95.         button.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  96.         button.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  97.         button.SetText("Button")
  98.         button.SetPosition(20,20)
  99.         button.Show()
  100.         self.button = button
  101.        
  102.         ## Tworzenie 2 karty
  103.         tabTwoPage = ui.ThinBoard()
  104.         tabTwoPage.SetParent(self)
  105.         tabTwoPage.SetSize(550, 650)
  106.         tabTwoPage.SetPosition(115, 35)
  107.         tabTwoPage.Hide()
  108.         self.tabTwoPage = tabTwoPage
  109.        
  110.         ## Dodanie buttona do 2 karty
  111.         buttonExit = ui.Button()
  112.         buttonExit.SetParent(self.tabTwoPage)
  113.         buttonExit.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  114.         buttonExit.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  115.         buttonExit.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  116.         buttonExit.SetText("Exit")
  117.         buttonExit.SetEvent(self.Close)
  118.         buttonExit.SetPosition(50,50)
  119.         buttonExit.Show()
  120.         self.buttonExit = buttonExit
  121.        
  122.         ## Tworzenie 3 karty
  123.         tabThreePage = ui.ThinBoard()
  124.         tabThreePage.SetParent(self)
  125.         tabThreePage.SetSize(550, 650)
  126.         tabThreePage.SetPosition(115, 35)
  127.         tabThreePage.Hide()
  128.         self.tabThreePage = tabThreePage
  129.        
  130.         ## Dodanie tekstu do 3 karty
  131.         for i in range(15):
  132.             textLine = ui.TextLine()
  133.             textLine.SetParent(self.tabThreePage)
  134.             textLine.SetPosition(15, 35*i)
  135.             textLine.SetSize(20, 20)
  136.             textLine.SetText(self.text[i])
  137.             textLine.Show()
  138.             self.textLines.append(textLine)
  139.        
  140.         ## Tworzenie 4 karty
  141.         tabFourPage = ui.ThinBoard()
  142.         tabFourPage.SetParent(self)
  143.         tabFourPage.SetSize(550, 650)
  144.         tabFourPage.SetPosition(115, 35)
  145.         tabFourPage.Hide()
  146.         self.tabFourPage = tabFourPage
  147.        
  148.         ## Dodanie drag buttona do 4 karty
  149.         dragButton = ui.DragButton()
  150.         dragButton.SetParent(self.tabFourPage)
  151.         dragButton.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
  152.         dragButton.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
  153.         dragButton.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
  154.         dragButton.SetText("Drag me")
  155.         dragButton.SetPosition(0, 0)
  156.         dragButton.SetRestrictMovementArea(0, 0, self.tabFourPage.GetWidth(), self.tabFourPage.GetHeight())
  157.         dragButton.Show()
  158.         self.dragButton = dragButton
  159.        
  160.         ## Tworzenie pustej 5 karty
  161.         tabFivePage = ui.ThinBoard()
  162.         tabFivePage.SetParent(self)
  163.         tabFivePage.SetSize(550, 650)
  164.         tabFivePage.SetPosition(115, 35)
  165.         tabFivePage.Hide()
  166.         self.tabFivePage = tabFivePage
  167.        
  168.         ## Dodanie 5 kart
  169.         self.pages = []
  170.         self.pages.append(self.tabOnePage)
  171.         self.pages.append(self.tabTwoPage)
  172.         self.pages.append(self.tabThreePage)
  173.         self.pages.append(self.tabFourPage)
  174.         self.pages.append(self.tabFivePage)
  175.  
  176.         ## Tworzenie buttonów dla kart
  177.         self.curTab = 0
  178.         tabButtons = []
  179.         for i in xrange(5):
  180.             radioButton = ui.RadioButton()
  181.             radioButton.SetParent(self.thinBoard)
  182.             radioButton.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
  183.             radioButton.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
  184.             radioButton.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
  185.             radioButton.SetText("Tab %d"%i)
  186.             radioButton.SetPosition(2, 10+26*i)
  187.             #radioButton.SetWindowVerticalAlignCenter()
  188.             radioButton.Show()
  189.             tabButtons.append(radioButton)
  190.        
  191.         self.tabButtonGroup = ui.RadioButtonGroup.Create([
  192.         ##  [button, selectEvent, unselectEvent],
  193.             [tabButtons[0], lambda : self._OnClickTabButton(0), None],
  194.             [tabButtons[1], lambda : self._OnClickTabButton(1), None],
  195.             [tabButtons[2], lambda : self._OnClickTabButton(2), None],
  196.             [tabButtons[3], lambda : self._OnClickTabButton(3), None],
  197.             [tabButtons[4], lambda : self._OnClickTabButton(4), None]
  198.         ])
  199.        
  200.         ## Tworzenie Scrollbara
  201.         scrollBar = ui.ScrollBar()
  202.         scrollBar.SetParent(self)
  203.         scrollBar.SetScrollBarSize(650)
  204.         scrollBar.SetPosition(670,35)
  205.         scrollBar.SetScrollEvent(self.__OnScroll)
  206.        
  207.         self.scrollBar = scrollBar
  208.         self.scrollBar.Show()
  209.         self.isLoaded = True
  210.  
  211.  
  212.     def __OnScroll(self):
  213.         pos = int(self.scrollBar.GetPos() * (len(self.text) - 5))
  214.         for i in xrange(15):
  215.             self.textLines[i].SetText(self.text[i+pos])
  216.  
  217.     def _OnClickTabButton(self, id):
  218.         self.SetCurTab(id)
  219.  
  220.     def GetCurTab(self):
  221.         return self.curTab
  222.  
  223.     def SetCurTab(self, tab):
  224.         self.curTab = tab
  225.         self.RefreshTab()
  226.        
  227.     def RefreshTab(self):
  228.         for page in self.pages:
  229.             page.Hide()
  230.         self.pages[self.GetCurTab()].Show()
  231.  
  232.     def Open(self):
  233.         self.Show()
  234.  
  235.     def Close(self):
  236.         self.Hide()
  237.  
  238.     def OnPressEscapeKey(self):
  239.         self.Close()
  240.         return True
  241.  
  242.     def OnPressExitKey(self):
  243.         self.Close()
  244.         return True
  245.  
  246. wnd = ExampleTabs()
  247. wnd.Open()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement