def showMessageBox(self, xMSF, windowServiceName, windowAttribute, MessageText, peer=None): if MessageText is None: return 0 iMessage = 0 try: # If the peer is null we try to get one from the desktop... if peer is None: xFrame = Desktop.getActiveFrame(xMSF) peer = xFrame.getComponentWindow() xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit") oDescriptor = WindowDescriptor() oDescriptor.WindowServiceName = windowServiceName oDescriptor.Parent = peer oDescriptor.Type = MODALTOP oDescriptor.WindowAttributes = windowAttribute xMsgPeer = xToolkit.createWindow(oDescriptor) xMsgPeer.MessageText = MessageText iMessage = xMsgPeer.execute() xMsgPeer.dispose() except Exception: traceback.print_exc() return iMessage
def MessageBox(Document, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK): ParentWin = Document.CurrentController.Frame.ContainerWindow MsgType = MsgType.lower() # available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if not (MsgType in MsgTypes): MsgType = "messbox" # describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin # aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.MessageText = MsgText if MsgTitle: msgbox.CaptionText = MsgTitle return msgbox.execute()
def createNewPreviewFrame(self, xMSF, listener): xToolkit = None try: xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit") except Exception: # TODO Auto-generated catch block traceback.print_exc() #describe the window and its properties aDescriptor = WindowDescriptor() aDescriptor.Type = TOP aDescriptor.WindowServiceName = "window" aDescriptor.ParentIndex = -1 aDescriptor.Parent = None aDescriptor.Bounds = Rectangle(10, 10, 640, 480) #Set Window Attributes gnDefaultWindowAttributes = \ com_sun_star_awt_WindowAttribute_BORDER + \ com_sun_star_awt_WindowAttribute_MOVEABLE + \ com_sun_star_awt_WindowAttribute_SIZEABLE + \ com_sun_star_awt_VclWindowPeerAttribute_CLIPCHILDREN aDescriptor.WindowAttributes = gnDefaultWindowAttributes #create a new blank container window xPeer = None try: xPeer = xToolkit.createWindow(aDescriptor) except IllegalArgumentException: traceback.print_exc() #define some further properties of the frame window #if it's needed .-) #xPeer->setBackground(...); #create new empty frame and set window on it xFrame = None try: xFrame = xMSF.createInstance("com.sun.star.frame.Frame") except Exception: traceback.print_exc() xFrame.initialize(xPeer) #from now this frame is usable ... #and not part of the desktop tree. #You are alone with him .-) if listener is not None: Desktop.getDesktop(xMSF).addTerminateListener(listener) return xFrame
def createPreviewFrame(self, xmsf, xControl): controlPeer = xControl.Peer r = xControl.PosSize toolkit = xmsf.createInstance("com.sun.star.awt.Toolkit") aDescriptor = WindowDescriptor() aDescriptor.Type = SIMPLE aDescriptor.WindowServiceName = "window" aDescriptor.ParentIndex = -1 aDescriptor.Parent = controlPeer #xWindowPeer; #argument ! aDescriptor.Bounds = Rectangle(0, 0, r.Width, r.Height) aDescriptor.WindowAttributes = CLIPCHILDREN | SHOW self.xWindow = toolkit.createWindow(aDescriptor) self.xFrame = xmsf.createInstance("com.sun.star.frame.Frame") self.xFrame.initialize(self.xWindow) self.xWindow.setVisible(True)
def messageBox(document, message): #doc = XSCRIPTCONTEXT.getDocument() window = document.CurrentController.Frame.ContainerWindow aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = "infobox" aDescriptor.ParentIndex = -1 aDescriptor.Parent = window #aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = OK tk = window.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setCaptionText("Conversion to Unicode") msgbox.setMessageText(message) return msgbox.execute()
def MessageBox(ParentWin, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK): MsgType = MsgType.lower() #available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if MsgType not in MsgTypes: MsgType = "messbox" #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setMessageText(MsgText) if MsgTitle : msgbox.setCaptionText(MsgTitle) return msgbox.execute()
def messagebox(tekst, ctx): desktop = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", ctx) doc = desktop.getCurrentComponent() c = doc.getCurrentController() pw = c.Frame.ContainerWindow d = WindowDescriptor() d.Type = MODALTOP d.WindowServiceName = "messbox" d.ParentIndex = -1 d.Parent = pw d.WindowAttributes = OK tk = pw.getToolkit() mb = tk.createWindow(d) mb.setMessageText(tekst) mb.setCaptionText("Oei") return mb.execute()
def alert(self, msg, title = u'Alert'): """Opens an alert window with a message and title, and requires user to click 'Ok'""" parentWin = self.model.CurrentController.Frame.ContainerWindow aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = 'messbox' aDescriptor.ParentIndex = -1 aDescriptor.Parent = parentWin aDescriptor.WindowAttributes = OK tk = parentWin.getToolkit() box = tk.createWindow(aDescriptor) box.setMessageText(msg) if title: box.setCaptionText(title) box.execute()
def messagebox(tekst, ctx): desktop = ctx.ServiceManager.createInstanceWithContext( 'com.sun.star.frame.Desktop', ctx) doc = desktop.getCurrentComponent() c = doc.getCurrentController() pw = c.Frame.ContainerWindow d = WindowDescriptor() d.Type = MODALTOP d.WindowServiceName = 'messbox' d.ParentIndex = -1 d.Parent = pw d.WindowAttributes = OK tk = pw.getToolkit() mb = tk.createWindow(d) mb.setMessageText(tekst) mb.setCaptionText('Oei') return mb.execute()
def MessageBox(MsgText, MsgTitle="GnuCash to Ooo", MsgType="messbox", MsgButtons=OK, ParentWin=None): global crout crout = 'MessageBox' global last_input_MessageBox ## last_input_MessageBox = str(MsgText) if not ParentWin: doc = XSCRIPTCONTEXT.getDocument() try: ParentWin = doc.CurrentController.Frame.ContainerWindow except AttributeError: ParentWin = doc.Frame.ContainerWindow MsgType = MsgType.lower() #available msg types MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox") if not ( MsgType in MsgTypes ): MsgType = "messbox" #describe window properties. aDescriptor = WindowDescriptor() aDescriptor.Type = MODALTOP aDescriptor.WindowServiceName = MsgType aDescriptor.ParentIndex = -1 aDescriptor.Parent = ParentWin #aDescriptor.Bounds = Rectangle() aDescriptor.WindowAttributes = MsgButtons tk = ParentWin.getToolkit() msgbox = tk.createWindow(aDescriptor) msgbox.setMessageText(MsgText) if MsgTitle : msgbox.setCaptionText(MsgTitle) return msgbox.execute()