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

UI: Adding FileDialog UI #832

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
93c42af
initial commit
Nibba2018 Aug 19, 2020
87cccc7
add basic methods
Nibba2018 Aug 19, 2020
9a41992
fix slot index exception
Nibba2018 Aug 20, 2020
bb87fe8
add callback to update directory path
Nibba2018 Aug 20, 2020
3fea9f3
add dialog buttons
Nibba2018 Aug 20, 2020
4497347
add user hooks and dialog type
Nibba2018 Aug 22, 2020
b9c9a07
Make dialog draggable
Nibba2018 Aug 22, 2020
5e2b674
add support for file selection
Nibba2018 Aug 22, 2020
905c411
Add methods for save dialog
Nibba2018 Aug 22, 2020
be4e376
add check for non saves
Nibba2018 Aug 23, 2020
302d9f5
fix font issue
Nibba2018 Aug 26, 2020
c18aa88
Add color arguments
Nibba2018 Aug 26, 2020
41facd1
base test for file dialog
Nibba2018 Aug 27, 2020
f32fdff
add file dialog tests
Nibba2018 Aug 27, 2020
824ad75
fix pep8
Nibba2018 Aug 27, 2020
cff8095
update tests
Nibba2018 Aug 27, 2020
6b2d26c
fix tests for travis
Nibba2018 Aug 28, 2020
2ca572a
fix pep8
Nibba2018 Aug 28, 2020
32f8de5
update tests
Nibba2018 Aug 28, 2020
768caa5
Merge remote-tracking branch 'fury-gl/master' into file_dialog
Nibba2018 Jun 15, 2021
6af7084
fix documentation
Nibba2018 Jun 15, 2021
692bb7f
add file dialog tutorial
Nibba2018 Jun 15, 2021
f06f105
fix pep8
Nibba2018 Jun 15, 2021
eb8a9bf
Merge branch 'master' into filedialog
ganimtron-10 Aug 1, 2023
01902af
adding filedialog to magic all variable
ganimtron-10 Aug 1, 2023
0109305
updating textbox size
ganimtron-10 Aug 3, 2023
8152da4
removing reduntant variable
ganimtron-10 Aug 4, 2023
b2dce03
updating tests
ganimtron-10 Aug 4, 2023
d45abae
resolving merge issues
ganimtron-10 Aug 4, 2023
64cd6b7
upating docs
ganimtron-10 Aug 4, 2023
8452111
fixing the clip overflow issue!
ganimtron-10 Aug 14, 2023
437a1c8
fixing ZeroDivisionError
ganimtron-10 Aug 14, 2023
b59fc44
removing text cliping from add to scene
ganimtron-10 Aug 14, 2023
221f4c3
fixing listboxitem positioning issue
ganimtron-10 Aug 15, 2023
e5a3d0d
Merge branch 'master' into filedialog
ganimtron-10 Aug 18, 2023
561e2b9
adding example to valid_example file
ganimtron-10 Aug 18, 2023
b0e6379
updating test line sequence
ganimtron-10 Aug 20, 2023
9c5f0a7
updating tests to use TemporaryDirectory
ganimtron-10 Aug 20, 2023
b95871b
updating directory textblock clipping
ganimtron-10 Aug 20, 2023
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
3 changes: 2 additions & 1 deletion docs/examples/_valid_examples.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ files = [
"viz_ui_slider.py",
"viz_card.py",
"viz_card_sprite_sheet.py",
"viz_spinbox.py"
"viz_spinbox.py",
"viz_file_dialog.py"
]

[animation]
Expand Down
78 changes: 78 additions & 0 deletions docs/examples/viz_file_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""
===========
File Dialog
===========

This example shows how to use the File Dialog UI. We will demonstrate how to
create File Dialogs for browsing the file system and to get the desired file
path.

First, some imports.
"""

import os

from fury import ui, window

########################################################################
# File Dialog
# ================
#
# We create a couple of File Dialogs, one for saving a file and,
# the other for opening a file.
# We also create a TextBlock to display the filenames.

file_dialog_save = ui.FileDialog2D(os.getcwd(), position=(25, 25),
size=(300, 200),
dialog_type="Save")
file_dialog_open = ui.FileDialog2D(os.getcwd(), position=(180, 250),
size=(300, 200),
dialog_type="Open")

tb = ui.TextBlock2D(text="", position=(100, 300))


########################################################################
# Callbacks
# ==================================
#
# Now we create a callback which triggers when a specific action like,
# open, save or close is performed.

def open_(file_dialog):
tb.message = "File:" + file_dialog.current_file


def save_(file_dialog):
tb.message = "File:" + file_dialog.current_file
tb.message += "\nSave File:" + file_dialog.save_filename


def close_(file_dialog):
tb.message = "Exiting..."


# Callbacks are assigned to specific methods.

file_dialog_save.on_accept = save_
file_dialog_save.on_reject = close_

file_dialog_open.on_accept = open_
file_dialog_open.on_reject = close_

###############################################################################
# Show Manager
# ==================================
#
# Now we add the File Dialogs and the TextBlock to the scene.

sm = window.ShowManager(size=(500, 500))
sm.scene.add(file_dialog_open, file_dialog_save, tb)

# To interact with the UI, set interactive = True
interactive = False

if interactive:
sm.start()

window.record(sm.scene, out_path="viz_file_dialog.png", size=(500, 500))
1 change: 1 addition & 0 deletions fury/data/files/test_ui_file_dialog_2d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"CharEvent": 8, "MouseMoveEvent": 831, "KeyPressEvent": 8, "KeyReleaseEvent": 8, "LeftButtonPressEvent": 16, "LeftButtonReleaseEvent": 16, "RightButtonPressEvent": 0, "RightButtonReleaseEvent": 0, "MiddleButtonPressEvent": 0, "MiddleButtonReleaseEvent": 0}
Binary file added fury/data/files/test_ui_file_dialog_2d.log.gz
Binary file not shown.
Loading