私はosxプログラミングが初めてです。pyobjc を使用してアラートを作成しています。モーダル ウィンドウまたはダイアログについての私の理解では、モーダル ウィンドウは続行する前にユーザーのアクションを必要とします。ただし、NSAlert の runModal を使用すると、アラートがまだ表示されている間でも他のアプリに移動できます。モーダル ダイアログに対する私の理解は間違っていますか。
class Alert(object):
def __init__(self, messageText):
super(Alert, self).__init__()
self.messageText = messageText
self.informativeText = ""
self.buttons = []
def displayAlert(self):
alert = NSAlert.alloc().init()
alert.setMessageText_(self.messageText)
alert.setInformativeText_(self.informativeText)
# alert.setAlertStyle_(NSInformationalAlertStyle)
alert.setAlertStyle_(NSCriticalAlertStyle)
for button in self.buttons:
alert.addButtonWithTitle_(button)
NSApp.activateIgnoringOtherApps_(True)
self.buttonPressed = alert.runModal()
def alert(message="Default Message", info_text="", buttons=["OK"]):
ap = Alert(message)
ap.informativeText = info_text
ap.buttons = buttons
ap.displayAlert()
return ap.buttonPressed