Ejemplo n.º 1
0
class FloatingWindow():
    def __init__(self, parent_window, position):
        # The parent window is the main window for floating windows
        self.pw = parent_window

        # Default properties
        default_height = 250
        default_height_min = 30
        default_width = 200

        # Initialize the floating window
        self.window = Window(self.pw, "alpha")
        self.window.setFixedSize((default_width * self.pw.pixelRatio(),
                                  default_height * self.pw.pixelRatio()))
        self.window.setPosition(position)
        self.window.setLayout(GroupLayout())

        # Add window control buttons (min/max, close, etc)
        buttons = self.window.buttonPanel()

        # Minimize/Maximize
        b_minmax = Button(buttons, "", icon=entypo.ICON_CHEVRON_DOWN)

        def cb():
            if self.window.height() == default_height_min:
                self.window.setHeight(default_height)
            else:
                self.window.setHeight(default_height_min)
            b_minmax.setPushed(not b_minmax.pushed())

        b_minmax.setCallback(cb)

        # Close
        b_close = Button(buttons, "", icon=entypo.ICON_CIRCLE_WITH_CROSS)

        def cb():
            self.window.dispose()

        b_close.setCallback(cb)
Ejemplo n.º 2
0
import nanogui
from nanogui import Screen, Window, Widget, GridLayout, VScrollPanel, Button
from nanogui import entypo

if __name__ == "__main__":
    nanogui.init()

    width = 1000
    half_width = width // 2
    height = 800

    # create a fixed size screen with one window
    screen = Screen((width, height), "NanoGUI Icons", False)
    window = Window(screen, "All Icons")
    window.setPosition((0, 0))
    window.setFixedSize((width, height))

    # attach a vertical scroll panel
    vscroll = VScrollPanel(window)
    vscroll.setFixedSize((width, height))

    # vscroll should only have *ONE* child. this is what `wrapper` is for
    wrapper = Widget(vscroll)
    wrapper.setFixedSize((width, height))
    wrapper.setLayout(GridLayout())  # defaults: 2 columns

    # NOTE: don't __dict__ crawl in real code!
    # this is just because it's more convenient to do this for enumerating all
    # of the icons -- see cpp example for alternative...
    for key in entypo.__dict__.keys():
        if key.startswith("ICON_"):