Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/python/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import math
import time
import gc
from os.path import dirname, join

import numpy as np

from nanogui import Color, ColorPicker, Screen, Window, GroupLayout, \
Expand All @@ -27,6 +29,8 @@

# A simple counter, used for dynamic tab creation with TabWidget callback
counter = 1
# Directory where icons are located
ICONS_DIR = join(dirname(dirname(dirname(__file__))), "resources", "icons")


class TestApp(Screen):
Expand Down Expand Up @@ -128,17 +132,7 @@ def cb():
dlg.set_callback(cb2)
b.set_callback(cb)

import os
import sys
os.chdir(sys.path[0])
try:
icons_data = nanogui.load_image_directory(self.nvg_context(), "icons")
except:
try:
icons_data = nanogui.load_image_directory(self.nvg_context(), "../icons")
except:
icons_data = nanogui.load_image_directory(self.nvg_context(), "../resources/icons")

icons_data = nanogui.load_image_directory(self.nvg_context(), ICONS_DIR)

Label(window, "Image panel & scroll panel", "sans-bold")
image_panel_btn = PopupButton(window, "Image Panel")
Expand Down Expand Up @@ -364,6 +358,9 @@ def cp_final_cb(color):
alpha_int_box = IntBox(window)

def cp_fast_cb(color):
if math.isnan(color.r) or math.isnan(color.g) or math.isnan(color.b):
return

b.set_background_color(color)
b.set_text_color(color.contrasting_color())
red = int(color.r * 255.0)
Expand Down