Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
popup.setLayout(GroupLayout())
Label(popup, "Arbitrary widgets can be placed here")
CheckBox(popup, "A check box")
# popup right
popupBtn = PopupButton(popup, "Recursive popup", entypo.ICON_FLASH)
popupRight = popupBtn.popup()
popupRight.setLayout(GroupLayout())
CheckBox(popupRight, "Another check box")
# popup left
popupBtn = PopupButton(popup, "Recursive popup", entypo.ICON_FLASH)
popupBtn.setSide(Popup.Side.Left)
popupLeft = popupBtn.popup()
popupLeft.setLayout(GroupLayout())
CheckBox(popupLeft, "Another check box");
window = Window(self, "Basic widgets")
window.setPosition((200, 15))
window.setLayout(GroupLayout())
Label(window, "Message dialog", "sans-bold")
tools = Widget(window)
tools.setLayout(BoxLayout(Orientation.Horizontal,
Alignment.Middle, 0, 6))
def cb2(result):
print("Dialog result: %i" % result)
b = Button(tools, "Info")
def cb():
dlg = MessageDialog(self, MessageDialog.Type.Information, "Title",
"This is an information message")
graphDyn.setFooter("Iteration {0}".format(index*counter))
valuesDyn = [0.5 * abs((0.5 * math.sin(i / 10.0 + counter)) +
(0.5 * math.cos(i / 23.0 + 1 + counter)))
for i in range(100)]
graphDyn.setValues(valuesDyn)
counter += 1
# We must invoke perform layout from the screen instance to keep everything in order.
# This is essential when creating tabs dynamically.
self.performLayout()
# Ensure that the newly added header is visible on screen
tabWidget.ensureTabVisible(index)
tabWidget.setCallback(tab_cb)
tabWidget.setActiveTab(0);
window = Window(self, "Grid of small widgets")
window.setPosition((425, 300))
layout = GridLayout(Orientation.Horizontal, 2,
Alignment.Middle, 15, 5)
layout.setColAlignment(
[Alignment.Maximum, Alignment.Fill])
layout.setSpacing(0, 10)
window.setLayout(layout)
Label(window, "Floating point :", "sans-bold")
floatBox = TextBox(window)
floatBox.setEditable(True)
floatBox.setFixedSize((100, 20))
floatBox.setValue("50")
floatBox.setUnits("GiB")
floatBox.setDefaultValue("0.0")
floatBox.setFontSize(16)
def __init__(self):
super(TestApp, self).__init__((1024, 768), "NanoGUI Test")
window = Window(self, "Button demo")
window.setPosition((15, 15))
window.setLayout(GroupLayout())
Label(window, "Push buttons", "sans-bold")
b = Button(window, "Plain button")
def cb():
print("pushed!")
b.setCallback(cb)
b = Button(window, "Styled", entypo.ICON_ROCKET)
b.setBackgroundColor(Color(0, 0, 1.0, 0.1))
b.setCallback(cb)
Label(window, "Toggle buttons", "sans-bold")
b = Button(window, "Toggle me")
try:
icons = nanogui.loadImageDirectory(self.nvgContext(), "../icons")
except:
icons = nanogui.loadImageDirectory(self.nvgContext(), "../resources/icons")
Label(window, "Image panel & scroll panel", "sans-bold")
imagePanelBtn = PopupButton(window, "Image Panel")
imagePanelBtn.setIcon(entypo.ICON_FOLDER)
popup = imagePanelBtn.popup()
vscroll = VScrollPanel(popup)
imgPanel = ImagePanel(vscroll)
imgPanel.setImages(icons)
popup.setFixedSize((245, 150))
img_window = Window(self, "Selected image")
img_window.setPosition((710, 15))
img_window.setLayout(GroupLayout())
imgView = ImageView(img_window, icons[0][0])
def cb(i):
print("Selected item %i" % i)
imgView.bindImage(icons[i][0])
imgPanel.setCallback(cb)
imgView.setGridThreshold(3)
Label(window, "File dialog", "sans-bold")
tools = Widget(window)
tools.setLayout(BoxLayout(Orientation.Horizontal,
Alignment.Middle, 0, 6))
textBox = TextBox(panel)
textBox.setFixedSize((60, 25))
textBox.setValue("50")
textBox.setUnits("%")
textBox.setFontSize(20)
textBox.setAlignment(TextBox.Alignment.Right)
def cb(value):
textBox.setValue("%i" % int(value * 100))
slider.setCallback(cb)
def cb(value):
print("Final slider value: %i" % int(value * 100))
slider.setFinalCallback(cb)
window = Window(self, "Misc. widgets")
window.setPosition((425, 15))
window.setLayout(GroupLayout())
tabWidget = TabWidget(window)
layer = tabWidget.createTab("Color Wheel")
layer.setLayout(GroupLayout())
Label(layer, "Color wheel widget", "sans-bold")
ColorWheel(layer)
layer = tabWidget.createTab("Function Graph")
layer.setLayout(GroupLayout())
Label(layer, "Function graph widget", "sans-bold")
graph = Graph(layer, "Some function")
graph.setHeader("E = 2.35e-3")
try:
icons = nanogui.loadImageDirectory(self.nvgContext(), "../icons")
except:
icons = nanogui.loadImageDirectory(self.nvgContext(), "../resources/icons")
Label(window, "Image panel & scroll panel", "sans-bold")
imagePanelBtn = PopupButton(window, "Image Panel")
imagePanelBtn.setIcon(entypo.ICON_FOLDER)
popup = imagePanelBtn.popup()
vscroll = VScrollPanel(popup)
imgPanel = ImagePanel(vscroll)
imgPanel.setImages(icons)
popup.setFixedSize((245, 150))
img_window = Window(self, "Selected image")
img_window.setPosition((710, 15))
img_window.setLayout(GroupLayout())
imgView = ImageView(img_window, icons[0][0])
def cb(i):
if i < len(icons):
print("Selected item %i" % i)
imgView.bindImage(icons[i][0])
imgPanel.setCallback(cb)
imgView.setGridThreshold(3)
Label(window, "File dialog", "sans-bold")
tools = Widget(window)
tools.setLayout(BoxLayout(Orientation.Horizontal,
def __init__(self):
super(TestApp, self).__init__((1024, 768), "NanoGUI Test")
window = Window(self, "Button demo")
window.setPosition((15, 15))
window.setLayout(GroupLayout())
Label(window, "Push buttons", "sans-bold")
b = Button(window, "Plain button")
def cb():
print("pushed!")
b.setCallback(cb)
b = Button(window, "Styled", entypo.ICON_ROCKET)
b.setBackgroundColor(Color(0, 0, 1.0, 0.1))
b.setCallback(cb)
Label(window, "Toggle buttons", "sans-bold")
b = Button(window, "Toggle me")
def __init__(self):
super(TestApp, self).__init__((800, 600), "NanoGUI Test", False)
window = Window(self, "GLCanvas Demo")
window.setPosition((15, 15))
window.setLayout(GroupLayout())
self.canvas = MyGLCanvas(window)
self.canvas.setBackgroundColor(Color(0.5, 0.5, 0.5, 1.0))
self.canvas.setSize((400, 400))
self.canvas.rotation = [0.25, 0.5, 0.33]
tools = Widget(window)
tools.setLayout(BoxLayout(Orientation.Horizontal,
Alignment.Middle, 0, 5))
b0 = Button(tools, "Random Color")
def cb0():
self.canvas.setBackgroundColor(Color(random.random(), random.random(), random.random(), 1.0))
graphDyn.setFooter("Iteration {0}".format(index*counter))
valuesDyn = [0.5 * abs((0.5 * math.sin(i / 10.0 + counter)) +
(0.5 * math.cos(i / 23.0 + 1 + counter)))
for i in range(100)]
graphDyn.setValues(valuesDyn)
counter += 1
# We must invoke perform layout from the screen instance to keep everything in order.
# This is essential when creating tabs dynamically.
self.performLayout()
# Ensure that the newly added header is visible on screen
tabWidget.ensureTabVisible(index)
tabWidget.setCallback(tab_cb)
tabWidget.setActiveTab(0);
window = Window(self, "Grid of small widgets")
window.setPosition((425, 300))
layout = GridLayout(Orientation.Horizontal, 2,
Alignment.Middle, 15, 5)
layout.setColAlignment(
[Alignment.Maximum, Alignment.Fill])
layout.setSpacing(0, 10)
window.setLayout(layout)
Label(window, "Floating point :", "sans-bold")
floatBox = TextBox(window)
floatBox.setEditable(True)
floatBox.setFixedSize((100, 20))
floatBox.setValue("50")
floatBox.setUnits("GiB")
floatBox.setDefaultValue("0.0")
floatBox.setFontSize(16)
cp = ColorPicker(window, Color(255, 120, 0, 255));
cp.setFixedSize((100, 20));
def cp_final_cb(color):
print(
"ColorPicker Final Callback: [{0}, {1}, {2}, {3}]".format(color.r,
color.g,
color.b,
color.w)
)
cp.setFinalCallback(cp_final_cb)
# setup a fast callback for the color picker widget on a new window
# for demonstrative purposes
window = Window(self, "Color Picker Fast Callback")
window.setPosition((425, 300))
layout = GridLayout(Orientation.Horizontal, 2,
Alignment.Middle, 15, 5)
layout.setColAlignment(
[Alignment.Maximum, Alignment.Fill])
layout.setSpacing(0, 10)
window.setLayout(layout)
window.setPosition((425, 500))
Label(window, "Combined: ");
b = Button(window, "ColorWheel", entypo.ICON_500PX)
Label(window, "Red: ")
redIntBox = IntBox(window)
redIntBox.setEditable(False)
Label(window, "Green: ")
greenIntBox = IntBox(window)
greenIntBox.setEditable(False)