Skip to content

Commit

Permalink
Update Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalarico committed Sep 27, 2017
1 parent ff45204 commit 9050196
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 102 deletions.
Binary file modified docs/_static/forms/taskdialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions rpw/ui/forms/taskdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@ class TaskDialog(BaseObjectWrapper):
"""
Task Dialog Wrapper
>>> commands= [
... CommandLink('Open Dialog', return_value='Open'),
... CommandLink('Another Command', return_value=call_back_func)
... ]
>>> dialog = TaskDialog(command_links=commands, buttons='Yes')
>>> result = dialog.show()
>>> commands= [CommandLink('Open Dialog', return_value='Open'),
>>> ... CommandLink('Command', return_value=lambda: True)]
>>> ...
>>> dialog = TaskDialog('This TaskDialog has Buttons ',
>>> ... title_prefix=False,
>>> ... content="Further Instructions",
>>> ... commands=commands,
>>> ... buttons=['Cancel', 'OK', 'RETRY'],
>>> ... footer='It has a footer',
>>> ... # verification_text='Add Verification Checkbox',
>>> ... # expanded_content='Add Expanded Content',
>>> ... show_close=True)
>>> dialog.show()
'Open'
Wrapped Element:
self._revit_object = `Revit.UI.TaskDialog`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,104 +28,108 @@

class TaskDialogTests(unittest.TestCase):

def test_basic(self):
commands = [CommandLink('Select This Option', return_value='XXX',
subtext='Subtext 1'),
CommandLink('Option 2 - Should see subtext',
subtext='Subtext 2')
]

dialog = TaskDialog('Test 1 - Full',
title='My Title - Footer is ON. No Close Btn',
content='X Close IS SHOWING',
footer='Foot Text',
verification_text='Check This',
show_close=True,
commands=commands)
result = dialog.show()
self.assertEqual(result, 'XXX')
self.assertEqual(dialog.Title, 'My Title - Footer is ON. No Close Btn')
self.assertEqual(dialog.MainInstruction, 'Test 1 - Full')
self.assertEqual(dialog.MainContent, 'X Close IS SHOWING')
self.assertEqual(dialog.FooterText, 'Foot Text')
self.assertEqual(dialog.verification_checked, True)

def test_func_return_value(self):
commands = [CommandLink('Select This Option',
return_value=lambda: 'ZZZ',
subtext='Subtext 1'),
CommandLink('Option 2', subtext='Subtext 2')
]
dialog = TaskDialog('Test 2 - Simple',
verification_text='Leave this off',
commands=commands,
content='X Close Should NOT be Showing',
show_close=False)
result = dialog.show()
self.assertEqual(result(), 'ZZZ')
self.assertEqual(dialog.verification_checked, False)

def test_func_defaultvalue_button(self):
commands = [CommandLink('Press This Button')]
dialog = TaskDialog('Test 3',
content='Press Button Below',
# def test_basic(self):
# commands = [CommandLink('Select This Option', return_value='XXX',
# subtext='Subtext 1'),
# CommandLink('Option 2 - Should see subtext',
# subtext='Subtext 2')
# ]

# dialog = TaskDialog('Test 1 - Full',
# title='My Title - Footer is ON. No Close Btn',
# content='X Close IS SHOWING',
# footer='Foot Text',
# verification_text='Check This',
# show_close=True,
# commands=commands)
# result = dialog.show()
# self.assertEqual(result, 'XXX')
# self.assertEqual(dialog.Title, 'My Title - Footer is ON. No Close Btn')
# self.assertEqual(dialog.MainInstruction, 'Test 1 - Full')
# self.assertEqual(dialog.MainContent, 'X Close IS SHOWING')
# self.assertEqual(dialog.FooterText, 'Foot Text')
# self.assertEqual(dialog.verification_checked, True)

# def test_func_return_value(self):
# commands = [CommandLink('Select This Option',
# return_value=lambda: 'ZZZ',
# subtext='Subtext 1'),
# CommandLink('Option 2', subtext='Subtext 2')
# ]
# dialog = TaskDialog('Test 2 - Simple',
# verification_text='Leave this off',
# commands=commands,
# content='X Close Should NOT be Showing',
# show_close=False)
# result = dialog.show()
# self.assertEqual(result(), 'ZZZ')
# self.assertEqual(dialog.verification_checked, False)

# def test_func_defaultvalue_button(self):
# commands = [CommandLink('Press This Button')]
# dialog = TaskDialog('Test 3',
# content='Press Button Below',
# commands=commands,
# buttons=['Cancel'])
# result = dialog.show()
# self.assertEqual(result, 'Press This Button')
# self.assertEqual(dialog.verification_checked, None)

# def test_func_all_buttons_retry(self):
# dialog = TaskDialog('Test 4',
# content='Press Retry',
# buttons=['Ok', 'Yes', 'No',
# 'Cancel', 'Retry', 'Close'])
# result = dialog.show()
# self.assertEqual(result, 'Retry')

# def test_func_all_buttons_close(self):
# dialog = TaskDialog('Test 5',
# content='Press Close',
# buttons=['Ok', 'Yes', 'No',
# 'Cancel', 'Retry', 'Close'])
# result = dialog.show()
# self.assertEqual(result, 'Close')

# def test_func_all_buttons_cancel(self):
# dialog = TaskDialog('Test 6',
# content='Press Cancel',
# buttons=['Ok', 'Yes', 'No',
# 'Cancel', 'Retry', 'Close'])
# result = dialog.show()
# self.assertEqual(result, None)

# def test_close(self):
# dialog = TaskDialog('Test 7 - Exit',
# content="Close Using X",
# buttons=[],
# show_close=True)
# with self.assertRaises(SystemExit):
# result = dialog.show(exit=True)

# def test_close_cancel(self):
# dialog = TaskDialog('Test 8 - Exit',
# content="Close Using Cancel",
# buttons=['Cancel'],
# show_close=False)
# with self.assertRaises(SystemExit):
# result = dialog.show(exit=True)


def test_close_for_docs(self):
commands= [CommandLink('Open Dialog', return_value='Open'),
CommandLink('Command', return_value=lambda: True)]

dialog = TaskDialog('This TaskDialog has Buttons ',
title_prefix=False,
content="Further Instructions",
commands=commands,
buttons=['Cancel'])
result = dialog.show()
self.assertEqual(result, 'Press This Button')
self.assertEqual(dialog.verification_checked, None)

def test_func_all_buttons_retry(self):
dialog = TaskDialog('Test 4',
content='Press Retry',
buttons=['Ok', 'Yes', 'No',
'Cancel', 'Retry', 'Close'])
result = dialog.show()
self.assertEqual(result, 'Retry')

def test_func_all_buttons_close(self):
dialog = TaskDialog('Test 5',
content='Press Close',
buttons=['Ok', 'Yes', 'No',
'Cancel', 'Retry', 'Close'])
result = dialog.show()
self.assertEqual(result, 'Close')

def test_func_all_buttons_cancel(self):
dialog = TaskDialog('Test 6',
content='Press Cancel',
buttons=['Ok', 'Yes', 'No',
'Cancel', 'Retry', 'Close'])
result = dialog.show()
self.assertEqual(result, None)

def test_close(self):
dialog = TaskDialog('Test 7 - Exit',
content="Close Using X",
buttons=[],
buttons=['Cancel', 'OK', 'RETRY'],
footer='It has a footer',
# verification_text='And Verification Text',
# expanded_content='And Expanded Content',
show_close=True)
with self.assertRaises(SystemExit):
result = dialog.show(exit=True)

def test_close_cancel(self):
dialog = TaskDialog('Test 8 - Exit',
content="Close Using Cancel",
buttons=['Cancel'],
show_close=False)
with self.assertRaises(SystemExit):
result = dialog.show(exit=True)


# def test_close_for_docs(self):
# dialog = TaskDialog('This TaskDialog has Buttons ',
# title_prefix=False,
# content="Further Instructions",
# buttons=['Cancel', 'OK', 'RETRY'],
# footer='It has a footer',
# # verification_text='And Verification Text',
# # expanded_content='And Expanded Content',
# show_close=True)
# dialog.show()
dialog.show()

class AlertTests(unittest.TestCase):

Expand Down

0 comments on commit 9050196

Please sign in to comment.