Skip to content

Instantly share code, notes, and snippets.

@jepler
Created July 18, 2025 01:20
Show Gist options
  • Select an option

  • Save jepler/af1e6e56fd2cd1921ef0f3dd56408944 to your computer and use it in GitHub Desktop.

Select an option

Save jepler/af1e6e56fd2cd1921ef0f3dd56408944 to your computer and use it in GitHub Desktop.

Revisions

  1. jepler created this gist Jul 18, 2025.
    42 changes: 42 additions & 0 deletions code.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    # m68k-micropython window creation demo

    import eventmgr
    import mactypes
    import qd
    import uctypes
    import windowmgr

    def let(dst, src):
    memoryview(dst)[:] = memoryview(src)[:]

    def pstr(s):
    b = mactypes.Str255()
    b[0] = len(s)
    for i in range(len(s)):
    b[i+1] = ord(s[i])
    return b

    ev = eventmgr.EventRecord()

    NIL_WINDOW = uctypes.struct(0, qd.GrafPort)
    ABOVE_ALL_WINDOWS = uctypes.struct(-1, qd.GrafPort)

    title = pstr("Hello World")
    r = mactypes.Rect()
    scrn = qd.qdGlobals().screenBits
    let(r, scrn.bounds)
    r.top += 80
    qd.InsetRect(r, 25, 25)

    w = windowmgr.NewWindow(NIL_WINDOW, r, title, True, 0, ABOVE_ALL_WINDOWS, True, 0)
    let(r, w.portRect)
    qd.SetPort(w)

    mid_x = (r.left + r.right) // 2
    mid_y = (r.top + r.bottom) // 2
    for i in range(r.left, r.right, 2):
    qd.MoveTo(mid_x, r.bottom)
    qd.LineTo(i, r.top)

    qd.MoveTo(mid_x, mid_y)
    input("hit enter to exit")