#NEWLINE# def CanvasJoin( l ) : #NEWLINE# #INDENT# '\n    Join canvases in l horizontally. Return result.\n\n    :param l: list of (canvas, position, focus, cols) tuples:\n\n              position\n                value that widget.set_focus will accept or None if not allowed\n              focus\n                True if this canvas is the one that would be in focus if\n                the whole widget is in focus\n              cols\n                is the number of screen columns that this widget will require,\n                if larger than the actual canvas.cols() value then this widget\n                will be padded on the right.\n    ' #NEWLINE# l2 = [ ] #NEWLINE# focus_item = 0 #NEWLINE# maxrow = 0 #NEWLINE# n = 0 #NEWLINE# for ( canv , pos , focus , cols ) in l : #NEWLINE# #INDENT# rows = canv . rows ( ) #NEWLINE# pad_right = ( cols - canv . cols ( ) ) #NEWLINE# if focus : #NEWLINE# #INDENT# focus_item = n #NEWLINE# #UNINDENT# if ( rows > maxrow ) : #NEWLINE# #INDENT# maxrow = rows #NEWLINE# #UNINDENT# l2 . append ( ( canv , pos , pad_right , rows ) ) #NEWLINE# n += 1 #NEWLINE# #UNINDENT# shard_lists = [ ] #NEWLINE# children = [ ] #NEWLINE# joined_canvas = CompositeCanvas ( ) #NEWLINE# col = 0 #NEWLINE# for ( canv , pos , pad_right , rows ) in l2 : #NEWLINE# #INDENT# canv = CompositeCanvas ( canv ) #NEWLINE# if pad_right : #NEWLINE# #INDENT# canv . pad_trim_left_right ( 0 , pad_right ) #NEWLINE# #UNINDENT# if ( rows < maxrow ) : #NEWLINE# #INDENT# canv . pad_trim_top_bottom ( 0 , ( maxrow - rows ) ) #NEWLINE# #UNINDENT# joined_canvas . coords . update ( canv . translate_coords ( col , 0 ) ) #NEWLINE# for shortcut in canv . shortcuts . keys ( ) : #NEWLINE# #INDENT# joined_canvas . shortcuts [ shortcut ] = pos #NEWLINE# #UNINDENT# shard_lists . append ( canv . shards ) #NEWLINE# children . append ( ( col , 0 , canv , pos ) ) #NEWLINE# col += canv . cols ( ) #NEWLINE# #UNINDENT# if focus_item : #NEWLINE# #INDENT# children = ( ( [ children [ focus_item ] ] + children [ : focus_item ] ) + children [ ( focus_item + 1 ) : ] ) #NEWLINE# #UNINDENT# joined_canvas . shards = shards_join ( shard_lists ) #NEWLINE# joined_canvas . children = children #NEWLINE# return joined_canvas