本文整理匯總了Python中ipywidgets.widgets.HBox方法的典型用法代碼示例。如果您正苦於以下問題:Python widgets.HBox方法的具體用法?Python widgets.HBox怎麽用?Python widgets.HBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ipywidgets.widgets
的用法示例。
在下文中一共展示了widgets.HBox方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: DrawDecisionTree
# 需要導入模塊: from ipywidgets import widgets [as 別名]
# 或者: from ipywidgets.widgets import HBox [as 別名]
def DrawDecisionTree(fac, datasetName, methodName):
m = GetMethodObject(fac, datasetName, methodName)
if m==None:
return None
tr = TreeReader(str(m.GetWeightFileName()))
variables = tr.getVariables();
def clicked(b):
if treeSelector.value>tr.getNTrees():
treeSelector.value = tr.getNTrees()
clear_output()
toJs = {
"variables": variables,
"tree": tr.getTree(treeSelector.value)
}
json_str = json.dumps(toJs)
JPyInterface.JsDraw.Draw(json_str, "drawDecisionTree", True)
mx = str(tr.getNTrees()-1)
treeSelector = widgets.IntText(value=0, font_weight="bold")
drawTree = widgets.Button(description="Draw", font_weight="bold")
label = widgets.HTML("<div style='padding: 6px;font-weight:bold;color:#333;'>Decision Tree [0-"+mx+"]:</div>")
drawTree.on_click(clicked)
container = widgets.HBox([label,treeSelector, drawTree])
display(container)
## This function puts the main thread to sleep until data points for tracking plots appear.
# @param m Method object
# @param sleep_time default sleeping time
示例2: DrawDNNWeights
# 需要導入模塊: from ipywidgets import widgets [as 別名]
# 或者: from ipywidgets.widgets import HBox [as 別名]
def DrawDNNWeights(fac, datasetName, methodName="DNN"):
m = GetMethodObject(fac, datasetName, methodName)
if m == None:
return None
try:
net = GetDeepNetwork(str(m.GetWeightFileName()), True)
except AttributeError:
print("STANDARD architecture not supported! If you want to use this function you must use CPU or GPU architecture")
numOfLayers = len(net["layers"])
options = []
vals=[]
for layer in xrange(numOfLayers):
options.append(str(layer)+"->"+str(layer+1))
vals.append(layer)
selectLayer=widgets.Dropdown(
options=options,
value=options[0],
description='Layer'
)
def drawWrapper(e):
CreateWeightHist(net, selectLayer.value)
pass
button = widgets.Button(description="Draw", font_weight="bold", font_size="16")
button.on_click(drawWrapper)
box = widgets.HBox([selectLayer, button])
display(box)
示例3: create_widget
# 需要導入模塊: from ipywidgets import widgets [as 別名]
# 或者: from ipywidgets.widgets import HBox [as 別名]
def create_widget(self):
self.id_widget = widgets.HTML("")
self.question_widget = widgets.HTML("")
self.choice_widgets = []
self.choice_row_list = []
for count in range(1, 5 + 1):
self.choice_widgets.append(widgets.HTML(""))
self.choice_row_list.append(widgets.HBox([widgets.HTML("<b>%s</b>) " % count),
self.choice_widgets[-1]]))
self.buttons = []
for i in range(1, 5 + 1):
button = widgets.Button(description = str(i))
button.on_click(self.handle_submit)
button.layout.margin = "20px"
self.buttons.append(button)
self.respond_row_widgets = widgets.HBox([widgets.HTML("""<br/><br clear="all"/><b>Respond</b>: """)] + self.buttons)
self.next_button = widgets.Button(description="Next")
self.next_button.on_click(self.handle_next)
self.results_button = widgets.Button(description="Results")
self.results_button.on_click(self.handle_results)
self.prev_button = widgets.Button(description="Previous")
self.prev_button.on_click(self.handle_prev)
self.results_html = widgets.HTML("")
self.top_margin = widgets.HTML("")
#self.top_margin.layout.height = "100px"
right_stack = widgets.VBox([self.top_margin, self.results_html])
self.stack = widgets.VBox([self.id_widget, self.question_widget] + self.choice_row_list +
[self.respond_row_widgets,
widgets.HBox([self.prev_button, self.results_button, self.next_button])])
self.output = widgets.Output()
self.top_level = widgets.VBox([widgets.HBox([self.stack, right_stack]),
self.output])