TShelby

Untitled

Dec 4th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. class PopupDialog(ui.ScriptWindow):
  2.  
  3. def __init__(self):
  4. ui.ScriptWindow.__init__(self)
  5. self.__LoadDialog()
  6. self.acceptEvent = lambda *arg: None
  7.  
  8. def __del__(self):
  9. ui.ScriptWindow.__del__(self)
  10.  
  11. def __LoadDialog(self):
  12. try:
  13. PythonScriptLoader = ui.PythonScriptLoader()
  14. PythonScriptLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
  15.  
  16. self.board = self.GetChild("board")
  17. self.message = self.GetChild("message")
  18. self.accceptButton = self.GetChild("accept")
  19. self.accceptButton.SetEvent(ui.__mem_func__(self.Close))
  20.  
  21. except:
  22. import exception
  23. exception.Abort("PopupDialog.LoadDialog.BindObject")
  24.  
  25. def Open(self):
  26. self.SetCenterPosition()
  27. self.SetTop()
  28. self.Show()
  29.  
  30. def Close(self):
  31. self.Hide()
  32. self.acceptEvent()
  33.  
  34. def Destroy(self):
  35. self.Close()
  36. self.ClearDictionary()
  37.  
  38. def SetWidth(self, width):
  39. height = self.GetHeight()
  40. self.SetSize(width, height)
  41. self.board.SetSize(width, height)
  42. self.SetCenterPosition()
  43. self.UpdateRect()
  44.  
  45. def SetText(self, text):
  46. self.message.SetText(text)
  47.  
  48. def SetAcceptEvent(self, event):
  49. self.acceptEvent = event
  50.  
  51. def SetButtonName(self, name):
  52. self.accceptButton.SetText(name)
  53.  
  54. def OnPressEscapeKey(self):
  55. self.Close()
  56. return True
  57.  
  58. def OnIMEReturn(self):
  59. self.Close()
  60. return True
  61.  
  62. def GetTextSize(self):
  63. if self.message:
  64. return self.message.GetTextSize()
  65.  
  66. return (0,0)
  67.  
  68. def GetLineHeight(self):
  69. if self.message:
  70. return self.message.GetLineHeight()
  71.  
  72. return 0
  73.  
  74. def SetLineHeight(self, Height):
  75. self.message.SetLineHeight(Height)
  76.  
  77. def GetTextLineCount(self):
  78. return self.message.GetTextLineCount()
  79.  
  80. def AutoResize(self, minWidth = 30):
  81. self.SetWidth(self.message.GetTextSize()[0] + minWidth)
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. EXAMPLE :
  91.  
  92. self.startQuestionDialog = uiCommon.QuestionDialog2()
  93. self.startQuestionDialog.SetText1(startText[0] % (30000, 1))
  94. self.startQuestionDialog.SetText2(startText[1])
  95. self.startQuestionDialog.SetAcceptEvent(ui.__mem_func__(self.__StartAccept))
  96. self.startQuestionDialog.SetCancelEvent(ui.__mem_func__(self.__StartCancel))
  97. self.startQuestionDialog.AutoResize(60)
Advertisement
Add Comment
Please, Sign In to add comment