Skip to content

Commit

Permalink
update __init__.py
Browse files Browse the repository at this point in the history
added _msgBox() and alertOkCancel() functions
  • Loading branch information
tudstlennkozh authored Feb 28, 2020
1 parent 523519b commit bae72a2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions oosheet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,23 @@ def dispatch(self, cmd, *args):
self.dispatcher.executeDispatch(self.model.getCurrentController(),
'.uno:%s' % cmd, '', 0, args)

def alert(self, msg, title = u'Alert'):
"""Opens an alert window with a message and title, and requires user to click 'Ok'"""
def _msgBox(self, msg, title, box_type, button_type):
"""call to uno API to display a messageBox"""
ctx = self.get_context()
toolkit = ctx.ServiceManager.createInstanceWithContext('com.sun.star.awt.Toolkit', ctx)
parentWin = toolkit.getDesktopWindow()
box = toolkit.createMessageBox(parentWin, MESSAGEBOX, MSG_BUTTONS.BUTTONS_OK, title, str(msg))
box = toolkit.createMessageBox(parentWin, box_type, button_type, title, msg)

return box.execute()

box.execute()
def alert(self, msg, title = u'Alert'):
"""Opens an alert window with a message and title, and requires user to click 'Ok'"""
self._msgBox(str(msg), title, MESSAGEBOX, MSG_BUTTONS.BUTTONS_OK)

def alertOkCancel(self, msg, title = u'Alert'):
"""Opens an alert window and allows user to choose between ok or cancel"""
return self._msgBox(str(msg), title, MESSAGEBOX, MSG_BUTTONS.BUTTONS_OK_CANCEL)

def undo(self):
"""Undo the last action"""
self.dispatch('.uno:Undo')
Expand Down

0 comments on commit bae72a2

Please sign in to comment.