1
# -*- coding: UTF-8 -*-
3
__revision__ = '$Id: macutils.py 1519 2011-02-05 15:32:36Z iznogoud $'
5
# Copyright (c) 2005-2011 Vasco Nunes, Piotr Ożarowski
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Library General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21
# You may use and distribute this software under the terms of the
22
# GNU General Public License, version 2 or later
30
def saveDialog(filetypes=[]):
31
panel = NSSavePanel.savePanel()
32
panel.setCanCreateDirectories_(True)
33
panel.setCanChooseDirectories_(False)
34
panel.setCanChooseFiles_(True)
35
panel.setAllowsOtherFileTypes_(False)
36
result = panel.runModalForDirectory_file_types_(
37
NSHomeDirectory() + '/Desktop',None,filetypes)
39
return True, panel.filename(), panel.directory()
41
return False, None, None
48
def openDialog(filetypes=[]):
49
panel = NSOpenPanel.openPanel()
50
panel.setCanCreateDirectories_(False)
51
panel.setCanChooseDirectories_(False)
52
panel.setCanChooseFiles_(True)
53
result = panel.runModalForDirectory_file_types_(
54
NSHomeDirectory() + '/Desktop',None,filetypes)
56
return True, panel.filename(), panel.directory()
58
return False, None, None
66
alert = NSAlert.alloc().init()
67
alert.setMessageText_(msg)
68
alert.setInformativeText_("")
69
alert.setAlertStyle_(NSInformationalAlertStyle)
76
def question(msg, window=None):
77
alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
78
msg, "Yes", "No", None, "")
79
buttonPressed=alert.runModal()
80
if buttonPressed == 0:
b'\\ No newline at end of file'