File: dialog.rst

package info (click to toggle)
neuron 8.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,760 kB
  • sloc: cpp: 149,571; python: 58,465; ansic: 50,329; sh: 3,510; xml: 213; pascal: 51; makefile: 35; sed: 5
file content (93 lines) | stat: -rwxr-xr-x 2,244 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Dialog Boxes
------------

.. function:: boolean_dialog

    Syntax:
    
        .. code-block::
            python
            
            h.boolean_dialog("label", ["accept", "cancel"])

    Description:
        Pops up a dialog window at the center of the screen and blocks
        everything until dealt with.
        Returns 1 or 0.
        
    Example:
    
        .. code-block::
            python
            
            from neuron import h, gui

            if h.boolean_dialog('Do you prefer to code in Python or HOC?', 'Python', 'HOC'):
                print('You prefer Python!')
            else:
                print('You prefer HOC!')

    .. image:: ../../images/boolean_dialog.png
        :align: center

.. seealso::
    :class:`SymChooser`, :meth:`VBox.dialog`

----

.. function:: continue_dialog

    Syntax:
    
        .. code-block::
            python
            
            h.continue_dialog("message")

    Description:
        Provides information to the user.
        Like :func:`boolean_dialog`, blocks everything until dealt with.

    Example:
    
        .. code-block::
            python
            
            from neuron import h, gui
            h.continue_dialog("You are reading a message from a dialog box.")
        
        .. image:: ../../images/continue_dialog.png
            :align: center

----

.. function:: string_dialog

    Syntax:
        .. code-block::
            python
            
            h.string_dialog("message", strref)
        
    Description:
        Prompts the user to enter a string. The initial value of strref is used
        as the default value.
        If canceled, returns 0 and *strref* remains unchanged.
        Otherwise, returns 1 and *strref* is replaced with the entered text.
        Like :func:`boolean_dialog`, blocks everything until dealt with.

    Example:
    
        .. code-block::
            python

            from neuron import h, gui

            my_str = h.ref('')
            if h.string_dialog('Type a string:', my_str):
                print('You typed: %s' % my_str[0])
            else:
                print('You canceled')
                
        .. image:: ../../images/string_dialog.png
            :align: center