예제 #1
0
def main():
    # Ask the user for the plugins directory
    dir, ok = macfs.GetDirectory('Where is the PlugIns folder?')
    if not ok: sys.exit(0)
    os.chdir(dir.as_pathname())

    # Remove old .slb aliases and collect a list of .slb files
    if EasyDialogs.AskYesNoCancel('Proceed with removing old aliases?') <= 0:
        sys.exit(0)
    LibFiles = []
    allfiles = os.listdir(':')
    for f in allfiles:
        if f[-4:] == '.slb':
            finfo = macfs.FSSpec(f).GetFInfo()
            if finfo.Flags & 0x8000:
                os.unlink(f)
            else:
                LibFiles.append(f)

    print LibFiles
    # Create the new aliases.
    if EasyDialogs.AskYesNoCancel('Proceed with creating new ones?') <= 0:
        sys.exit(0)
    for dst, src in goals:
        if src in LibFiles:
            macostools.mkalias(src, dst)
        else:
            EasyDialogs.Message(dst + ' not created: ' + src + ' not found')

    EasyDialogs.Message('All done!')
예제 #2
0
	def lowlevelhandler(self, event):
		what, message, when, where, modifiers = event
		h, v = where
		if what == kHighLevelEvent:
			msg = "High Level Event: %s %s" % \
				(`code(message)`, `code(h | (v<<16))`)
			try:
				AE.AEProcessAppleEvent(event)
			except AE.Error, err:
				EasyDialogs.Message(msg + "\015AEProcessAppleEvent error: %s" % str(err))
				traceback.print_exc()
			else:
				EasyDialogs.Message(msg + "\015OK!")
예제 #3
0
파일: TTX.py 프로젝트: FilippiSilva/MEDWEB
    def handle_xml_file(self, path):
        prefs = getprefs()
        makesuitcase = int(prefs.get("makesuitcases", 0))
        dstfolder = prefs.get("ttoutput", DEFAULTTTOUTPUT)
        if not os.path.exists(dstfolder):
            os.mkdir(dstfolder)
        srcfilename = dstfilename = os.path.basename(path)
        if dstfilename[-4:] in (".ttx", ".xml"):
            dstfilename = dstfilename[:-4]
        if dstfilename[-4:] not in (".TTF", ".ttf"):
            dstfilename = dstfilename + ".TTF"
        dst = os.path.join(dstfolder, dstfilename)

        if makesuitcase:
            try:
                # see if the destination file is writable,
                # otherwise we'll get an error waaay at the end of
                # the parse procedure
                testref = Res.FSpOpenResFile(macfs.FSSpec(dst),
                                             3)  # read-write
            except Res.Error, why:
                if why[0] <> -43:  # file not found
                    EasyDialogs.Message(
                        "Can't create '%s'; file already open" % dst)
                    return
            else:
                Res.CloseResFile(testref)
예제 #4
0
def GetType():
    """Ask user for distribution type"""
    while 1:
        d = Dlg.GetNewDialog(ID_DTYPE, -1)
        d.SetDialogDefaultItem(DTYPE_EXIST)
        d.SetDialogCancelItem(DTYPE_CANCEL)
        while 1:
            rv = ModalDialog(None)
            if rv in (DTYPE_EXIST, DTYPE_NEW, DTYPE_CANCEL):
                break
        del d
        if rv == DTYPE_CANCEL:
            sys.exit(0)
        if rv == DTYPE_EXIST:
            ##			macfs.SetFolder(':(MkDistr)')
            fss, ok = macfs.StandardGetFile('TEXT')
            if not ok:
                sys.exit(0)
            path = fss.as_pathname()
            basename = os.path.split(path)[-1]
            if basename[-8:] <> '.include':
                EasyDialogs.Message('That is not a distribution include file')
            else:
                return basename[:-8]
        else:
            name = EasyDialogs.AskString('Distribution name:')
            if name:
                return name
            sys.exit(0)
예제 #5
0
def main():
    try:
        buildapplet()
    except buildtools.BuildError, detail:
        if EasyDialogs is None:
            print detail
        else:
            EasyDialogs.Message(detail)
예제 #6
0
def Message(text):
    import EasyDialogs, string
    from Carbon import Qd
    Qd.InitCursor()
    text = string.replace(text, "\n", "\r")
    if not text:
        text = '<Alert text not specified>'
    EasyDialogs.Message(text)
예제 #7
0
def main():
    pathname = EasyDialogs.AskFileForOpen(message='File to check end-of-lines in:')
    if not pathname:
        sys.exit(0)
    fp = open(pathname, 'rb')
    try:
        data = fp.read()
    except MemoryError:
        EasyDialogs.Message('Sorry, file is too big.')
        sys.exit(0)
    if len(data) == 0:
        EasyDialogs.Message('File is empty.')
        sys.exit(0)
    number_cr = string.count(data, '\r')
    number_lf = string.count(data, '\n')
    if number_cr == number_lf == 0:
        EasyDialogs.Message('File contains no lines.')
    if number_cr == 0:
        EasyDialogs.Message('File has unix-style line endings')
    elif number_lf == 0:
        EasyDialogs.Message('File has mac-style line endings')
    elif number_cr == number_lf:
        EasyDialogs.Message('File probably has MSDOS-style line endings')
    else:
        EasyDialogs.Message('File has no recognizable line endings (binary file?)')
    sys.exit(0)
예제 #8
0
 def opendoc(self, *args):
     pathname = EasyDialogs.AskFileForOpen()  # Any file type
     if not pathname:
         return
     bar = EasyDialogs.ProgressBar('Reading and converting...')
     try:
         rdr = img.reader(imgformat.macrgb16, pathname)
     except img.error, arg:
         EasyDialogs.Message(repr(arg))
         return
예제 #9
0
def showMessage(message=''):
    if len(sys.argv) == 1:
        if myos == 'win32':
            EasyDialogs.Message(message)
            return None
        if myos == 'darwin':
            easygui.msgbox(message)
            return None
    else:
        print(str(message)+"\n")
        return None
예제 #10
0
 def insertfile(self, *args):
     if self.active:
         path = EasyDialogs.AskFileForOpen(typeList=('TEXT', ))
         if not path:
             return
         try:
             fp = open(path, 'rb')  # NOTE binary, we need cr as end-of-line
         except IOError, arg:
             EasyDialogs.Message("IOERROR: %r" % (args, ))
             return
         self.active.menu_insert(fp)
예제 #11
0
 def inserthtml(self, *args):
     if self.active:
         path = EasyDialogs.AskFileForOpen(typeList=('TEXT', ))
         if not path:
             return
         try:
             fp = open(path, 'r')
         except IOError, arg:
             EasyDialogs.Message("IOERROR: %r" % (arg, ))
             return
         self.active.menu_insert_html(fp)
예제 #12
0
 def showmessages(self, messages):
     if messages:
         # To be on the safe side we always show the hidden packages,
         # they may be referred to in the error messages.
         if not self.w.hidden_button.get():
             self.w.hidden_button.set(1)
             self.updatestatus()
         if type(messages) == list:
             messages = '\n'.join(messages)
         if self.w.verbose_button.get():
             sys.stdout.write(messages + '\n')
         EasyDialogs.Message(messages)
예제 #13
0
def Message(message, title='RoboFab'):
    """
	A simple message dialog.
	Availability: FontLab, Macintosh
	"""
    if inFontLab:
        _FontLabDialogMessage(message, title).Run()
    elif MAC:
        import EasyDialogs
        EasyDialogs.Message(message)
    else:
        _raisePlatformError('Message')
예제 #14
0
def mac_version(required):

    import EasyDialogs as ed
    import sys

    if required > _mac_version:

        message = "This version of the Ren'Py launcher is too old to run this game. You have version %d.%d.%d, while the game requires version %d.%d.%d.\n\nPlease go to http://www.bishoujo.us/renpy/mac.html, and download the latest version of the launcher." % \
                  (_mac_version[0], _mac_version[1], _mac_version[2],
                   required[0], required[1], required[2])

        ed.Message(message)
        sys.exit(0)
예제 #15
0
 def _open(self, askfile):
     if askfile:
         path = EasyDialogs.AskFileForOpen(typeList=('TEXT', ))
         if not path:
             return
         name = os.path.split(path)[-1]
         try:
             fp = open(path, 'rb')  # NOTE binary, we need cr as end-of-line
             data = fp.read()
             fp.close()
         except IOError, arg:
             EasyDialogs.Message("IOERROR: %r" % (arg, ))
             return
예제 #16
0
파일: TTX.py 프로젝트: FilippiSilva/MEDWEB
 def mainloop(self, mask=FrameWork.everyEvent, wait=0):
     self.quitting = 0
     while not self.quitting:
         try:
             self.do1event(mask, wait)
         except self.__class__:
             # D'OH! FrameWork tries to quit us on cmd-.!
             pass
         except KeyboardInterrupt:
             pass
         except ttLib.xmlImport.xml_parse_error, why:
             EasyDialogs.Message(
                 "An error occurred while parsing the XML file:\n" + why)
         except:
예제 #17
0
def macGetArgs():
    import EasyDialogs
    EasyDialogs.Message("""\
Use the next dialog to build a command line:

1. Choose an output format from the [Option] list 
2. Click [Add]
3. Choose an input file: [Add existing file...]
4. Save the output: [Add new file...]
5. [OK]""")
    optionlist = [(longopt, description)
                  for (longopt, shortopt, description) in options]
    argv = EasyDialogs.GetArgv(optionlist=optionlist, addfolder=0)
    return posixGetArgs(argv)
예제 #18
0
 def replaceall(self):
     editor = findeditor(self)
     if not editor:
         return
     if self.visible:
         self.getparmsfromwindow()
     W.SetCursor("watch")
     find = self.parms["find"]
     if not find:
         return
     findlen = len(find)
     replace = self.parms["replace"]
     replacelen = len(replace)
     Text = editor.get()
     if not self.parms["casesens"]:
         find = string.lower(find)
         text = string.lower(Text)
     else:
         text = Text
     newtext = ""
     pos = 0
     counter = 0
     while 1:
         if self.parms["wholeword"]:
             wholewordRE = _makewholewordpattern(find)
             match = wholewordRE.search(text, pos)
             if match:
                 pos = match.start(1)
             else:
                 pos = -1
         else:
             pos = string.find(text, find, pos)
         if pos < 0:
             break
         counter = counter + 1
         text = text[:pos] + replace + text[pos + findlen:]
         Text = Text[:pos] + replace + Text[pos + findlen:]
         pos = pos + replacelen
     W.SetCursor("arrow")
     if counter:
         self.hide()
         from Carbon import Res
         editor.textchanged()
         editor.selectionchanged()
         editor.set(Text)
         EasyDialogs.Message("Replaced %d occurrences" % counter)
예제 #19
0
    def lowlevelhandler(self, event):
        what, message, when, where, modifiers = event
        h, v = where
        if what == kHighLevelEvent:
            msg = 'High Level Event: %r %r' % (code(message),
                                               code(h | v << 16))
            try:
                AE.AEProcessAppleEvent(event)
            except AE.Error as err:
                print 'AE error: ', err
                print 'in', msg
                traceback.print_exc()

            return
        if what == keyDown:
            c = chr(message & charCodeMask)
            if modifiers & cmdKey:
                if c == '.':
                    raise KeyboardInterrupt, 'Command-period'
                if c == 'q':
                    if hasattr(MacOS, 'OutputSeen'):
                        MacOS.OutputSeen()
                    self.quitting = 1
                    return
        elif what == mouseDown:
            partcode, window = Win.FindWindow(where)
            if partcode == inMenuBar:
                result = Menu.MenuSelect(where)
                id = result >> 16 & 65535
                item = result & 65535
                if id == self.appleid:
                    if item == 1:
                        EasyDialogs.Message(self.getabouttext())
                    elif item > 1 and hasattr(Menu, 'OpenDeskAcc'):
                        name = self.applemenu.GetMenuItemText(item)
                        Menu.OpenDeskAcc(name)
                elif id == self.quitid and item == 1:
                    if hasattr(MacOS, 'OutputSeen'):
                        MacOS.OutputSeen()
                    self.quitting = 1
                Menu.HiliteMenu(0)
                return
        if hasattr(MacOS, 'HandleEvent'):
            MacOS.HandleEvent(event)
        else:
            print 'Unhandled event:', event
예제 #20
0
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2008 Doug Hellmann All rights reserved.
#
"""
"""

__version__ = "$Id$"
#end_pymotw_header

import EasyDialogs

EasyDialogs.Message('This is a Message dialog')
예제 #21
0
 def selsizesmaller(self, *rest):
     if self.active:
         self.active.menu_incsize(-2)
     else:
         EasyDialogs.Message("No active window?")
예제 #22
0
 def selsize(self, id, item, *rest):
     if self.active:
         size = SIZES[item - 1]
         self.active.menu_setsize(size)
     else:
         EasyDialogs.Message("No active window?")
예제 #23
0
 def selfacenormal(self, *rest):
     if self.active:
         self.active.menu_setface(0)
     else:
         EasyDialogs.Message("No active window?")
예제 #24
0
 def clear(self, *args):
     if self.active:
         self.active.menu_clear()
     else:
         EasyDialogs.Message("No active window?")
예제 #25
0
 def message(self, message):
     return EasyDialogs.Message(message)
예제 #26
0
 def paste(self, *args):
     if self.active:
         self.active.menu_paste()
     else:
         EasyDialogs.Message("No active window?")
예제 #27
0
 def undo(self, *args):
     if self.active:
         self.active.menu_undo()
     else:
         EasyDialogs.Message("No active window?")
예제 #28
0
 def saveas(self, *args):
     if self.active:
         self.active.menu_save_as()
     else:
         EasyDialogs.Message("No active window?")
예제 #29
0
 def closewin(self, *args):
     if self.active:
         self.active.close()
     else:
         EasyDialogs.Message("No active window?")
예제 #30
0
 def do_about(self, id, item, window, event):
     EasyDialogs.Message("A simple single-font text editor based on WASTE")