| 1 |
# (C) Copyright 2004-2023 Enthought, Inc., Austin, TX |
| 2 |
# All rights reserved. |
| 3 |
# |
| 4 |
# This software is provided without warranty under the terms of the BSD |
| 5 |
# license included in LICENSE.txt and may be redistributed only under |
| 6 |
# the conditions described in the aforementioned license. The license |
| 7 |
# is also available online at http://www.enthought.com/licenses/BSD.txt |
| 8 |
# |
| 9 |
# Thanks for using Enthought open source! |
| 10 |
|
| 11 |
""" |
| 12 |
**WARNING** |
| 13 |
|
| 14 |
This demo might not work as expected and some documented features might be |
| 15 |
missing. |
| 16 |
|
| 17 |
------------------------------------------------------------------------------- |
| 18 |
|
| 19 |
Implementation of a FileEditor demo plugin for Traits UI demo program. |
| 20 |
|
| 21 |
This demo shows each of the four styles of the FileEditor. |
| 22 |
|
| 23 |
Please refer to the `FileEditor API docs`_ for further information. |
| 24 |
|
| 25 |
.. _FileEditor API docs: https://docs.enthought.com/traitsui/api/traitsui.editors.file_editor.html#traitsui.editors.file_editor.FileEditor |
| 26 |
""" |
| 27 |
# Issue related to the demo warning: enthought/traitsui#889 |
| 28 |
|
| 29 |
|
| 30 |
from traits.api import HasTraits, File |
| 31 |
|
| 32 |
from traitsui.api import Item, Group, View |
| 33 |
|
| 34 |
|
| 35 |
# Define the demo class: |
| 36 |
class FileEditorDemo(HasTraits): |
| 37 |
"""Defines the main FileEditor demo class.""" |
| 38 |
|
| 39 |
# Define a File trait to view: |
| 40 |
file_name = File() |
| 41 |
|
| 42 |
# Display specification (one Item per editor style): |
| 43 |
file_group = Group( |
| 44 |
Item('file_name', style='simple', label='Simple', id='simple_file'), |
| 45 |
Item('_'), |
| 46 |
Item('file_name', style='custom', label='Custom'), |
| 47 |
Item('_'), |
| 48 |
Item('file_name', style='text', label='Text'), |
| 49 |
Item('_'), |
| 50 |
Item('file_name', style='readonly', label='ReadOnly'), |
| 51 |
) |
| 52 |
|
| 53 |
# Demo view: |
| 54 |
traits_view = View( |
| 55 |
file_group, |
| 56 |
title='FileEditor', |
| 57 |
width=400, |
| 58 |
height=600, |
| 59 |
buttons=['OK'], |
| 60 |
resizable=True, |
| 61 |
) |
| 62 |
|
| 63 |
|
| 64 |
# Create the demo: |
| 65 |
demo = FileEditorDemo() |
| 66 |
|
| 67 |
# Run the demo (if invoked from the command line): |
| 68 |
if __name__ == '__main__': |
| 69 |
demo.configure_traits() |