Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PopupDialog(ui.ScriptWindow):
- def __init__(self):
- ui.ScriptWindow.__init__(self)
- self.__LoadDialog()
- self.acceptEvent = lambda *arg: None
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- def __LoadDialog(self):
- try:
- PythonScriptLoader = ui.PythonScriptLoader()
- PythonScriptLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
- self.board = self.GetChild("board")
- self.message = self.GetChild("message")
- self.accceptButton = self.GetChild("accept")
- self.accceptButton.SetEvent(ui.__mem_func__(self.Close))
- except:
- import exception
- exception.Abort("PopupDialog.LoadDialog.BindObject")
- def Open(self):
- self.SetCenterPosition()
- self.SetTop()
- self.Show()
- def Close(self):
- self.Hide()
- self.acceptEvent()
- def Destroy(self):
- self.Close()
- self.ClearDictionary()
- def SetWidth(self, width):
- height = self.GetHeight()
- self.SetSize(width, height)
- self.board.SetSize(width, height)
- self.SetCenterPosition()
- self.UpdateRect()
- def SetText(self, text):
- self.message.SetText(text)
- def SetAcceptEvent(self, event):
- self.acceptEvent = event
- def SetButtonName(self, name):
- self.accceptButton.SetText(name)
- def OnPressEscapeKey(self):
- self.Close()
- return True
- def OnIMEReturn(self):
- self.Close()
- return True
- def GetTextSize(self):
- if self.message:
- return self.message.GetTextSize()
- return (0,0)
- def GetLineHeight(self):
- if self.message:
- return self.message.GetLineHeight()
- return 0
- def SetLineHeight(self, Height):
- self.message.SetLineHeight(Height)
- def GetTextLineCount(self):
- return self.message.GetTextLineCount()
- def AutoResize(self, minWidth = 30):
- self.SetWidth(self.message.GetTextSize()[0] + minWidth)
- EXAMPLE :
- self.startQuestionDialog = uiCommon.QuestionDialog2()
- self.startQuestionDialog.SetText1(startText[0] % (30000, 1))
- self.startQuestionDialog.SetText2(startText[1])
- self.startQuestionDialog.SetAcceptEvent(ui.__mem_func__(self.__StartAccept))
- self.startQuestionDialog.SetCancelEvent(ui.__mem_func__(self.__StartCancel))
- self.startQuestionDialog.AutoResize(60)
Advertisement
Add Comment
Please, Sign In to add comment