Exemplo n.º 1
0
def open(title, data):  # Public function to open a table window
    #
    # Set geometry parameters (one day, these may be changeable)
    #
    margin = stdwin.textwidth('  ')
    lineheight = stdwin.lineheight()
    #
    # Geometry calculations
    #
    colstarts = [0]
    totwidth = 0
    maxrows = 0
    for coldata in data:
        # Height calculations
        rows = len(coldata)
        if rows > maxrows: maxrows = rows
        # Width calculations
        width = colwidth(coldata) + margin
        totwidth = totwidth + width
        colstarts.append(totwidth)
    #
    # Calculate document and window height
    #
    docwidth, docheight = totwidth, maxrows * lineheight
    winwidth, winheight = docwidth, docheight
    if winwidth > stdwin.textwidth('n') * 100: winwidth = 0
    if winheight > stdwin.lineheight() * 30: winheight = 0
    #
    # Create the window
    #
    stdwin.setdefwinsize(winwidth, winheight)
    w = gwin.open(title)
    #
    # Set properties and override methods
    #
    w.data = data
    w.margin = margin
    w.lineheight = lineheight
    w.colstarts = colstarts
    w.totwidth = totwidth
    w.maxrows = maxrows
    w.selection = (-1, -1)
    w.lastselection = (-1, -1)
    w.selshown = 0
    w.setdocsize(docwidth, docheight)
    w.draw = draw
    w.mup = mup
    w.arrow = arrow
    #
    # Return
    #
    return w
Exemplo n.º 2
0
def open(title, data): # Public function to open a table window
	#
	# Set geometry parameters (one day, these may be changeable)
	#
	margin = stdwin.textwidth('  ')
	lineheight = stdwin.lineheight()
	#
	# Geometry calculations
	#
	colstarts = [0]
	totwidth = 0
	maxrows = 0
	for coldata in data:
		# Height calculations
		rows = len(coldata)
		if rows > maxrows: maxrows = rows
		# Width calculations
		width = colwidth(coldata) + margin
		totwidth = totwidth + width
		colstarts.append(totwidth)
	#
	# Calculate document and window height
	#
	docwidth, docheight = totwidth, maxrows*lineheight
	winwidth, winheight = docwidth, docheight
	if winwidth > stdwin.textwidth('n')*100: winwidth = 0
	if winheight > stdwin.lineheight()*30: winheight = 0
	#
	# Create the window
	#
	stdwin.setdefwinsize(winwidth, winheight)
	w = gwin.open(title)
	#
	# Set properties and override methods
	#
	w.data = data
	w.margin = margin
	w.lineheight = lineheight
	w.colstarts = colstarts
	w.totwidth = totwidth
	w.maxrows = maxrows
	w.selection = (-1, -1)
	w.lastselection = (-1, -1)
	w.selshown = 0
	w.setdocsize(docwidth, docheight)
	w.draw = draw
	w.mup = mup
	w.arrow = arrow
	#
	# Return
	#
	return w
Exemplo n.º 3
0
def open(title, data):  # Display a list of texts in a window
    lineheight = stdwin.lineheight()
    h, v = maxlinewidth(data), len(data) * lineheight
    h0, v0 = h + stdwin.textwidth(' '), v + lineheight
    if h0 > stdwin.textwidth(' ') * 80: h0 = 0
    if v0 > stdwin.lineheight() * 24: v0 = 0
    stdwin.setdefwinsize(h0, v0)
    w = gwin.open(title)
    w.setdocsize(h, v)
    w.lineheight = lineheight
    w.data = data
    w.draw = draw
    w.action = action
    w.mup = mup
    return w
Exemplo n.º 4
0
def open(title, data): # Display a list of texts in a window
       lineheight = stdwin.lineheight()
       h, v = maxlinewidth(data), len(data)*lineheight
       h0, v0 = h + stdwin.textwidth(' '), v + lineheight
       if h0 > stdwin.textwidth(' ')*80: h0 = 0
       if v0 > stdwin.lineheight()*24: v0 = 0
       stdwin.setdefwinsize(h0, v0)
       w = gwin.open(title)
       w.setdocsize(h, v)
       w.lineheight = lineheight
       w.data = data
       w.draw = draw
       w.action = action
       w.mup = mup
       return w
Exemplo n.º 5
0
def open(title, str):  # Display a string in a window
    w = gwin.open(title)
    w.readonly = 0
    w.text = w.textcreate((0, 0), w.getwinsize())
    w.text.replace(str)
    w.text.setfocus(0, 0)
    addeditmenu(w)
    fixsize(w)
    w.draw = draw
    w.size = size
    w.close = close
    w.mdown = mdown
    w.mmove = mmove
    w.mup = mup
    w.char = char
    w.backspace = backspace
    w.arrow = arrow
    w.activate = activate
    return w
Exemplo n.º 6
0
def open(title, str):                  # Display a string in a window
       w = gwin.open(title)
       w.readonly = 0
       w.text = w.textcreate((0, 0), w.getwinsize())
       w.text.replace(str)
       w.text.setfocus(0, 0)
       addeditmenu(w)
       fixsize(w)
       w.draw = draw
       w.size = size
       w.close = close
       w.mdown = mdown
       w.mmove = mmove
       w.mup = mup
       w.char = char
       w.backspace = backspace
       w.arrow = arrow
       w.activate = activate
       return w