コード例 #1
0
def testStdwin():
    import stdwin, fmt
    from stdwinevents import *
    if sys.argv[1:]: file = sys.argv[1]
    else: file = 'test.html'
    data = open(file, 'r').read()
    window = stdwin.open('testStdwin')
    b = None
    while 1:
        etype, ewin, edetail = stdwin.getevent()
        if etype == WE_CLOSE:
            break
        if etype == WE_SIZE:
            window.setdocsize(0, 0)
            window.setorigin(0, 0)
            window.change((0, 0), (10000, 30000))  # XXX
        if etype == WE_DRAW:
            if not b:
                b = fmt.StdwinBackEnd(window, 1)
                f = fmt.BaseFormatter(b.d, b)
                p = FormattingParser(f, \
                       MacStylesheet)
                p.feed(data)
                p.close()
                b.finish()
            else:
                b.redraw(edetail)
    window.close()
コード例 #2
0
ファイル: wwww.py プロジェクト: olympu/ancient-pythons
 def setrawdata(self, addr, data):
     if '#' in addr:
         i = string.index(addr, '#')
         addr, anchor = addr[:i], addr[i + 1:]
     else:
         anchor = ''
     self.cur_addr = addr
     self.cur_data = data
     #
     self.window.settitle('Formatting ' + addr + ' ...')
     self.window.setorigin(0, 0)
     self.window.setdocsize(0, 0)
     self.window.change((0, 0), (10000, 30000))  # XXX
     #
     # XXX The X11 version here assumes that setdocsize()
     # generates a WE_DRAW event
     b = fmt.StdwinBackEnd(self.window, 0)
     b.d.setfont(htmllib.StdwinStylesheet.stdfontset[0])
     ##b = fmt.StdwinBackEnd(self.window, 1) # Mac version
     f = fmt.BaseFormatter(b.d, b)
     p = htmllib.AnchoringParser(f, htmllib.StdwinStylesheet)
     p.feed(self.cur_data)
     p.close()
     b.finish()
     #
     self.cur_backend = b
     self.cur_anchors = p.anchors
     self.cur_anchornames = p.anchornames
     self.cur_anchortypes = p.anchortypes
     self.cur_isindex = p.isindex
     #
     if not places.has_key(self.cur_addr):
         exits = []
     else:
         exits = places[self.cur_addr][1]
     places[self.cur_addr] = (p.title, exits)
     #
     self.command_menu.enable(self.find_index, self.cur_isindex)
     self.make_title()
     self.make_anchors_menu()
     self.window.setwincursor(READYCURSOR)
     #
     if anchor:
         if anchor not in self.cur_anchornames:
             stdwin.fleep()  # Anchor not found
             return
         id = 1 + self.cur_anchornames.index(anchor)
         self.cur_backend.showanchor(id)
         return
コード例 #3
0
def testGL():
    import gl, GL, fmt
    if sys.argv[1:]: file = sys.argv[1]
    else: file = 'test.html'
    data = open(file, 'r').read()
    W, H = 600, 600
    gl.foreground()
    gl.prefsize(W, H)
    wid = gl.winopen('testGL')
    gl.ortho2(0, W, H, 0)
    gl.color(GL.WHITE)
    gl.clear()
    gl.color(GL.BLACK)
    b = fmt.GLBackEnd(wid)
    f = fmt.BaseFormatter(b.d, b)
    p = FormattingParser(f, GLStylesheet)
    p.feed(data)
    p.close()
    b.finish()
    #
    import time
    time.sleep(5)