先从简单的文本框开始
import ipywidgets as wg
from IPython.display import display
@wg.interact_manual()
def doing_actions(name='',company=''):
df=print(name,'works in',company,'company.')
return df
下拉框及日期选择框
import ipywidgets as wg
import pathlib2 as pl
files=['Alex','Bob','Cherry']
Coms=['ABC','MN','XYZ']
dp=wg.DatePicker(description="EnterDate")
cp=wg.ColorPicker(concise=False,Description='workcloth color')
@wg.interact_manual()
def doing_actions(name=files,company=Coms, ed=dp,wc=cp):
df=print(name,'joined',company,'company on',ed,'.','The color of work cloth is',wc,".")
return df
显示图片
import ipywidgets as wg
# from IPython.display import display
fn=open("d:\\temp\\tmp002.png",'rb')
image=fn.read()
wg.Image(value=image,format='png',width=200,height=300,)