How to add a button to prompt the user to open a file using KeyCallback function
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
### Checklist
- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).
### My Question
I want to start with basic example of adding a button inside my GUI which will have Keycallback function to load different
geometry types
### My Code
```
import open3d as o3d
def load_geometry(vis_Button):
file_path = o3d.utility.FileDialog.get_open_file_name("Select a geometry file.")
if file_path:
ext = file_path.split(".")[-1]
if ext == "ply":
geometry = o3d.io.read_point_cloud(file_path)
elif ext == "txt":
geometry = o3d.io.read_point_cloud(file_path, format="xyz")
elif ext == "stl":
geometry = o3d.io.read_triangle_mesh(file_path)
elif ext == "obj":
geometry = o3d.io.read_triangle_mesh(file_path)
else:
print("Unsupported geometry file format!")
return
vis_Button.add_geometry(geometry)
vis = o3d.visualization.VisualizerWithKeyCallback()
vis.create_window()
vis.register_key_callback(ord('a'), lambda vis: load_geometry(vis))
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.