Exemplo n.º 1
0

def readlines(path):
    with open(path, "r", encoding="ascii") as f:
        data = f.read()
    return data.splitlines()


def writelines(path, lines, sep='\r'):
    with open(path, "w", encoding="ascii", newline=sep) as f:
        f.write("\n".join(lines) + "\n")


if __name__ == "__main__":
    import EasyDialogs
    path = EasyDialogs.AskFileForOpen()
    if path:
        afm = AFM(path)
        char = 'A'
        if afm.has_char(char):
            print(afm[char])  # print charnum, width and boundingbox
        pair = ('A', 'V')
        if afm.has_kernpair(pair):
            print(afm[pair])  # print kerning value for pair
        print(afm.Version)  # various other afm entries have become attributes
        print(afm.Weight)
        # afm.comments() returns a list of all Comment lines found in the AFM
        print(afm.comments())
        #print afm.chars()
        #print afm.kernpairs()
        print(afm)
Exemplo n.º 2
0
def main():
    print 'hello world'  # XXXX
    # skip the toolbox initializations, already done
    # XXXX Should use gestalt here to check for quicktime version
    Qt.EnterMovies()

    # Get the movie file
    fss = EasyDialogs.AskFileForOpen(
        wanted=File.FSSpec)  # Was: QuickTime.MovieFileType
    if not fss:
        sys.exit(0)

    # Open the window
    bounds = (175, 75, 175 + 160, 75 + 120)
    theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0)
    # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
    Qd.SetPort(theWindow)

    # Get the movie
    theMovie = loadMovie(fss)

    # Relocate to (0, 0)
    bounds = theMovie.GetMovieBox()
    bounds = 0, 0, bounds[2] - bounds[0], bounds[3] - bounds[1]
    theMovie.SetMovieBox(bounds)

    # Create a controller
    theController = theMovie.NewMovieController(bounds,
                                                QuickTime.mcTopLeftMovie)

    # Get movie size and update window parameters
    rv, bounds = theController.MCGetControllerBoundsRect()
    theWindow.SizeWindow(bounds[2], bounds[3], 0)  # XXXX or [3] [2]?
    Qt.AlignWindow(theWindow, 0)
    theWindow.ShowWindow()

    # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds)
    theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1')

    # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow)

    done = 0
    while not done:
        gotone, evt = Evt.WaitNextEvent(0xffff, 0)
        (what, message, when, where, modifiers) = evt
        ##              print what, message, when, where, modifiers # XXXX

        if theController.MCIsPlayerEvent(evt):
            continue

        if what == Events.mouseDown:
            part, whichWindow = Win.FindWindow(where)
            if part == Windows.inGoAway:
                done = whichWindow.TrackGoAway(where)
            elif part == Windows.inDrag:
                Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000))
        elif what == Events.updateEvt:
            whichWindow = Win.WhichWindow(message)
            if not whichWindow:
                # Probably the console window. Print something, hope it helps.
                print 'update'
            else:
                Qd.SetPort(whichWindow)
                whichWindow.BeginUpdate()
                Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds())
                whichWindow.EndUpdate()