Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: python icons example #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
14 changes: 7 additions & 7 deletions src/python/example_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import nanogui
from nanogui import Screen, Window, Widget, GridLayout, VScrollPanel, Button
from nanogui import entypo
from nanogui import icons

if __name__ == "__main__":
nanogui.init()
Expand All @@ -41,12 +41,12 @@
wrapper.set_fixed_size((width, height))
wrapper.set_layout(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_"):
b = Button(wrapper, "entypo.{0}".format(key), entypo.__dict__[key])
# NOTE: using `dir` as done below is not good practice.
# It is used here because it is convenient for enumerating all available
# icons -- see 'example_icons.cpp' for an alternative way.
for name in dir(icons):
if name.startswith("FA_"):
b = Button(wrapper, "icons.{0}".format(name), getattr(icons, name))
b.set_icon_position(Button.IconPosition.Left)
b.set_fixed_width(half_width)

Expand Down