Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
b.setFlags(Button.Flags.ToggleButton)
def change_cb(state):
print("Toggle button state: %s" % str(state))
b.setChangeCallback(change_cb)
Label(window, "Radio buttons", "sans-bold")
b = Button(window, "Radio button 1")
b.setFlags(Button.Flags.RadioButton)
b = Button(window, "Radio button 2")
b.setFlags(Button.Flags.RadioButton)
Label(window, "A tool palette", "sans-bold")
tools = Widget(window)
tools.setLayout(BoxLayout(Orientation.Horizontal,
Alignment.Middle, 0, 6))
ToolButton(tools, entypo.ICON_CLOUD)
ToolButton(tools, entypo.ICON_CONTROLLER_FAST_FORWARD)
ToolButton(tools, entypo.ICON_COMPASS)
ToolButton(tools, entypo.ICON_INSTALL)
Label(window, "Popup buttons", "sans-bold")
popupBtn = PopupButton(window, "Popup", entypo.ICON_EXPORT)
popup = popupBtn.popup()
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())
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))
b0.setCallback(cb0)
b1 = Button(tools, "Random Rotation")
def cb1():
self.canvas.rotation = [random.random(), random.random(), random.random()]
b1.setCallback(cb1)
self.performLayout()
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)
floatBox.setFormat("[-]?[0-9]*\\.?[0-9]+")
Label(window, "Positive integer :", "sans-bold")
b.setFlags(Button.Flags.ToggleButton)
def change_cb(state):
print("Toggle button state: %s" % str(state))
b.setChangeCallback(change_cb)
Label(window, "Radio buttons", "sans-bold")
b = Button(window, "Radio button 1")
b.setFlags(Button.Flags.RadioButton)
b = Button(window, "Radio button 2")
b.setFlags(Button.Flags.RadioButton)
Label(window, "A tool palette", "sans-bold")
tools = Widget(window)
tools.setLayout(BoxLayout(Orientation.Horizontal,
Alignment.Middle, 0, 6))
ToolButton(tools, entypo.ICON_CLOUD)
ToolButton(tools, entypo.ICON_CONTROLLER_FAST_FORWARD)
ToolButton(tools, entypo.ICON_COMPASS)
ToolButton(tools, entypo.ICON_INSTALL)
Label(window, "Popup buttons", "sans-bold")
popupBtn = PopupButton(window, "Popup", entypo.ICON_EXPORT)
popup = popupBtn.popup()
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())
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))
b = Button(tools, "Open")
valid = [("png", "Portable Network Graphics"), ("txt", "Text file")]
def cb():
result = nanogui.file_dialog(valid, False)
print("File dialog result = %s" % result)
b.setCallback(cb)
b = Button(tools, "Save")
def cb():
result = nanogui.file_dialog(valid, True)
print("File dialog result = %s" % result)
b.setCallback(cb)