當前位置: 首頁>>代碼示例>>Python>>正文


Python NSAlert.alloc方法代碼示例

本文整理匯總了Python中AppKit.NSAlert.alloc方法的典型用法代碼示例。如果您正苦於以下問題:Python NSAlert.alloc方法的具體用法?Python NSAlert.alloc怎麽用?Python NSAlert.alloc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppKit.NSAlert的用法示例。


在下文中一共展示了NSAlert.alloc方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: displayAlert

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alloc [as 別名]
def displayAlert(message, info, buttons):
	alert = NSAlert.alloc().init()
	alert.setMessageText_(message)
	alert.setInformativeText_(info)
	alert.setAlertStyle_(NSInformationalAlertStyle)
	for button in buttons:
		alert.addButtonWithTitle_(button)
	NSApp.activateIgnoringOtherApps_(True)	
	buttonPressed = alert.runModal()
	return buttonPressed
開發者ID:benwiggy,項目名稱:PDFsuite,代碼行數:12,代碼來源:countpages.py

示例2: display_alert

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alloc [as 別名]
def display_alert(title, message):
    """Display a warning alert with the given ``title`` and ``message``.

    :param str title: the big bold title
    :param str message: the body of the alert
    """
    alert = NSAlert.alloc().init()
    alert.setAlertStyle_(NSWarningAlertStyle)
    alert.setMessageText_(title)
    alert.setInformativeText_(message)
    NSApp.activateIgnoringOtherApps_(True)
    alert.runModal()
開發者ID:kennydo,項目名稱:rename-archive-extension,代碼行數:14,代碼來源:RenameArchiveService.py

示例3: log_std

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alloc [as 別名]
def log_std(msg):
	from AppKit import NSAlert, NSInformationalAlertStyle, NSRunningApplication, NSApplicationActivateIgnoringOtherApps

	# initialize
	# tip from: http://graphicsnotes.blogspot.fr/2010/01/programmatically-creating-window-in-mac.html
	NSApplication.sharedApplication()
	NSRunningApplication.currentApplication().activateWithOptions_(NSApplicationActivateIgnoringOtherApps);

	alert = NSAlert.alloc().init()
	alert.autorelease()
	alert.setAlertStyle_(NSInformationalAlertStyle)
	alert.setMessageText_(msg)
	alert.runModal()
開發者ID:ChennyBaBy,項目名稱:bin-scripts,代碼行數:15,代碼來源:export-current-omnigraffle-canvas.py

示例4: __init__

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alloc [as 別名]
    def __init__(self):
        ''' initializes an alert with custom view containing username and
            password fields with a save to keychain checkbox'''
        # Create an dialog with ok and cancel buttons
        self.alert = NSAlert.alloc().init()
        self.alert.setMessageText_('Please enter your username and password!')
        self.alert.addButtonWithTitle_('Ok')
        self.alert.addButtonWithTitle_('Cancel')

        # create the view for username and password fields
        accessory_view = NSView.alloc().initWithFrame_(NSMakeRect(0, 114, 250, 110))

        # setup username field and label
        self.username_field = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 70, 250, 22))
        username_label = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 94, 250, 20))
        username_label.setStringValue_('Username:')
        username_label.setBezeled_(False)
        username_label.setDrawsBackground_(False)
        username_label.setEditable_(False)
        username_label.setSelectable_(False)

        # setup password field and label
        self.password_field = NSSecureTextField.alloc().initWithFrame_(NSMakeRect(0, 24, 250, 22))
        password_label = NSTextField.alloc().initWithFrame_(NSMakeRect(0, 48, 250, 20))
        password_label.setStringValue_('Password:')
        password_label.setBezeled_(False)
        password_label.setDrawsBackground_(False)
        password_label.setEditable_(False)
        password_label.setSelectable_(False)

        # setup keychain checkbox and label
        self.keychain_checkbox = NSButton.alloc().initWithFrame_(NSMakeRect(0, 0, 200, 20))
        self.keychain_checkbox.setButtonType_(NSSwitchButton)
        self.keychain_checkbox.cell().setTitle_('Save to Keychain')
        self.keychain_checkbox.cell().setBordered_(False)
        self.keychain_checkbox.cell().setEnabled_(True)
        self.keychain_checkbox.cell().setState_(True)

        # add various objects as subviews
        accessory_view.addSubview_(self.keychain_checkbox)
        accessory_view.addSubview_(username_label)
        accessory_view.addSubview_(self.username_field)
        accessory_view.addSubview_(password_label)
        accessory_view.addSubview_(self.password_field)

        # add custom view to alert dialog
        self.alert.setAccessoryView_(accessory_view)
開發者ID:kylecrawshaw,項目名稱:ShareMounter,代碼行數:49,代碼來源:PyDialog.py

示例5: initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alloc [as 別名]
    def initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_(self,
        messageText="", informativeText="", alertStyle=NSInformationalAlertStyle, buttonTitlesValues=[], parentWindow=None, resultCallback=None):

        self = super(BaseMessageDialog, self).init()
        self.retain()
        self._resultCallback = resultCallback
        self._buttonTitlesValues = buttonTitlesValues
        #
        alert = NSAlert.alloc().init()
        alert.setMessageText_(messageText)
        alert.setInformativeText_(informativeText)
        alert.setAlertStyle_(alertStyle)
        for buttonTitle, value in buttonTitlesValues:
            alert.addButtonWithTitle_(buttonTitle)
        self._value = None
        if parentWindow is None:
            code = alert.runModal()
            self._translateValue(code)
        else:
            alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(parentWindow, self, "alertDidEnd:returnCode:contextInfo:", 0)
        return self
開發者ID:schriftgestalt,項目名稱:vanilla,代碼行數:23,代碼來源:dialogs.py

示例6: initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alloc [as 別名]
 def initWithMessageText_informativeText_alertStyle_buttonTitlesValues_window_resultCallback_(self,
         messageText="",
         informativeText="", 
         alertStyle=NSInformationalAlertStyle,
         buttonTitlesValues=None,
         parentWindow=None,
         resultCallback=None):
     if buttonTitlesValues is None:
         buttonTitlesValues = []
     self = super(BaseMessageDialog, self).init()
     self.retain()
     self._resultCallback = resultCallback
     self._buttonTitlesValues = buttonTitlesValues
     #
     alert = NSAlert.alloc().init()
     alert.setMessageText_(messageText)
     alert.setInformativeText_(informativeText)
     alert.setAlertStyle_(alertStyle)
     for buttonTitle, value in buttonTitlesValues:
         alert.addButtonWithTitle_(buttonTitle)
     self._value = None
     code = alert.runModal()
     self._translateValue(code)
     return self
開發者ID:anthrotype,項目名稱:robofab,代碼行數:26,代碼來源:dialogs_fontlab_legacy2.py

示例7: __init__

# 需要導入模塊: from AppKit import NSAlert [as 別名]
# 或者: from AppKit.NSAlert import alloc [as 別名]
 def __init__(self, title, message):
     self.nsalert = NSAlert.alloc().init()
     self.nsalert.setAlertStyle_(NSInformationalAlertStyle)
     self.nsalert.setMessageText_(title)
     self.nsalert.setInformativeText_(message)
開發者ID:xoconusco,項目名稱:verano16,代碼行數:7,代碼來源:osx_panel.py


注:本文中的AppKit.NSAlert.alloc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。