<s> from __future__ import print_function <EOL> from datetime import date <EOL> from random import randint <EOL> from bokeh . client import push_session <EOL> from bokeh . document import Document <EOL> from bokeh . models . glyphs import Line , Circle <EOL> from bokeh . models import ( <EOL> Plot , ColumnDataSource , DataRange1d , <EOL> LinearAxis , DatetimeAxis , Grid , HoverTool <EOL> ) <EOL> from bokeh . models . widgets import ( <EOL> Button , TableColumn , DataTable , <EOL> DateEditor , DateFormatter , IntEditor ) <EOL> from bokeh . models . layouts import VBox <EOL> document = Document ( ) <EOL> session = push_session ( document ) <EOL> def make_data ( ) : <EOL> n = randint ( <NUM_LIT:5> , <NUM_LIT:10> ) <EOL> return dict ( <EOL> dates = [ date ( <NUM_LIT> , <NUM_LIT:3> , i + <NUM_LIT:1> ) for i in range ( n ) ] , <EOL> downloads = [ randint ( <NUM_LIT:0> , <NUM_LIT:100> ) for i in range ( n ) ] , <EOL> ) <EOL> source = ColumnDataSource ( make_data ( ) ) <EOL> def make_plot ( ) : <EOL> xdr = DataRange1d ( ) <EOL> ydr = DataRange1d ( ) <EOL> plot = Plot ( title = "<STR_LIT>" , x_range = xdr , y_range = ydr , plot_width = <NUM_LIT> , plot_height = <NUM_LIT> ) <EOL> line = Line ( x = "<STR_LIT>" , y = "<STR_LIT>" , line_color = "<STR_LIT>" ) <EOL> plot . add_glyph ( source , line ) <EOL> circle = Circle ( x = "<STR_LIT>" , y = "<STR_LIT>" , fill_color = "<STR_LIT>" ) <EOL> plot . add_glyph ( source , circle ) <EOL> xaxis = DatetimeAxis ( ) <EOL> plot . add_layout ( xaxis , '<STR_LIT>' ) <EOL> yaxis = LinearAxis ( ) <EOL> plot . add_layout ( yaxis , '<STR_LIT:left>' ) <EOL> plot . add_layout ( Grid ( dimension = <NUM_LIT:0> , ticker = xaxis . ticker ) ) <EOL> plot . add_layout ( Grid ( dimension = <NUM_LIT:1> , ticker = yaxis . ticker ) ) <EOL> plot . add_tools ( HoverTool ( tooltips = dict ( downloads = "<STR_LIT>" ) ) ) <EOL> return plot , source <EOL> def click_handler ( ) : <EOL> source . data = make_data ( ) <EOL> def make_layout ( ) : <EOL> plot , source = make_plot ( ) <EOL> columns = [ <EOL> TableColumn ( field = "<STR_LIT>" , title = "<STR_LIT>" , editor = DateEditor ( ) , formatter = DateFormatter ( ) ) , <EOL> TableColumn ( field = "<STR_LIT>" , title = "<STR_LIT>" , editor = IntEditor ( ) ) , <EOL> ] <EOL> data_table = DataTable ( source = source , columns = columns , width = <NUM_LIT> , height = <NUM_LIT> , editable = True ) <EOL> button = Button ( label = "<STR_LIT>" , button_type = "<STR_LIT:success>" ) <EOL> button . on_click ( click_handler ) <EOL> buttons = VBox ( children = [ button ] ) <EOL> vbox = VBox ( children = [ buttons , plot , data_table ] ) <EOL> return vbox <EOL> layout = make_layout ( ) <EOL> document . add_root ( layout ) <EOL> session . show ( layout ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> print ( "<STR_LIT>" ) <EOL> session . loop_until_closed ( ) </s>
