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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
|
##########################################################################
# TEPAM - Tcl's Enhanced Procedure and Argument Manager
##########################################################################
#
# 1b_procedure_interactive_widgets.demo: This file is part of the TEPAM demo
#
# Copyright (C) 2009, 2010 Andreas Drollinger
#
# Id: 1b_procedure_interactive_widgets.demo
##########################################################################
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
##########################################################################
#### Initialization ####
DemoControl(Initialization) 1
DemoControl(IsExecutable) {0}
# This demo shows how the interactive procedure calls open the argument entry form
# with the different available widget types.
package require Tk
package require tepam
namespace import -force tepam::*; # Import tepam::procedure and tepam::argument_dialogbox
#### Entry ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides simply entry widgets for the arguments that meet the
# following criterias:
# 1) No argument specific widget types are available
# 2) No choice lists are defined for the arguments.
procedure entry_example {
-args {
{str -description "String argument"}
{val -type integer -default 0 -description "Integer argument"}
}
} {
return "str:'$str' val:'$val'"
}
entry_example -interactive
#### Text ####
DemoControl(IsExecutable) {1}
# A multi line text widget is used for arguments that that have the type 'text'.
procedure text_example {
-args {
{txt -type text -description "Text argument"}
}
} {
return "txt:'$txt'"
}
text_example -interactive
#### Checkbox ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides checkboxes for the arguments that meet the
# following criterias:
# 1) A tiny choice list is provided (with less or equal than 4 elements)
# 2) No multiple selections are allowed
procedure checkbox_example {
-args {
{FontStyle -description "Font sytle"
-multiple -choices {bold italic underline}
-choicelabels {Bold Italic Underline} -default italic}
}
} {
return "FontStyle: $FontStyle"
}
checkbox_example -interactive
#### Radiobox ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides radioboxes for the arguments that meet the
# following criterias:
# 1) A tiny choice list is provided (with less or equal than 4 elements)
# 2) Multiple selections are allowed
procedure radiobox_example {
-args {
{Adjustment -description "Text adjustment"
-choices {left center right}
-choicelabels {Left Center Right} -default left}
}
} {
return "Adjustment: $Adjustment"
}
radiobox_example -interactive
#### Checkbutton ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides checkbuttons for the arguments that meet the
# following criterias:
# 1) The argument is a flag/switch, e.g. the argument type is 'none'.
procedure checkbutton_example {
-args {
{-Capitalize -type none -description "Capitalize" -default 1}
}
} {
return "Capitalize: $Capitalize"
}
checkbutton_example -interactive
#### Listbox ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides listboxes for the arguments that meet the
# following criterias:
# 1) A large choice list is provided (with more than 4 elements)
# 2) No multiple selections are allowed
procedure listbox_example {
-args {
{Location -description "Picture location"
-choices {top left center right buttom}
-choicelabels {Top Left Center Right Buttom} -default center}
}
} {
return "Location: $Location"
}
listbox_example -interactive
#### Disjoint listbox ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides disjoint listboxes for the arguments that meet the
# following criterias:
# 1) A large choice list is provided (with more than 4 elements)
# 2) Multiple selections are allowed
procedure listbox_example {
-args {
{FontStyle -description "Font sytle" -multiple
-choices {bold italic underline overstrike capitalized superscript subscript}
-choicelabels {Bold Italic Underline Overstrike Capitalized Superscript Subscript}
-default {italic bold}}
}
} {
return "FontStyle: '$FontStyle'"
}
listbox_example -interactive
#### Files ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides file selection widgets for the arguments that meet the
# following criterias:
# 1) The argument type is 'file' or 'existingfile'.
procedure file_example {
-return -
-short_description "File copy"
-description "This procedure allows copying a file."
-args {
{-source -type existingfile -description "Existing file"
-auxargs {-filetypes {{"Log files" *.log} {"All files" *.*}}}}
{-dest -type file -description "Archived new file"}
}
} {
return "source: '$source', dest: '$dest'"
}
file_example -interactive
#### Directories ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides directory selection widgets for the arguments that meet the
# following criterias:
# 1) The argument type is 'directory' or 'existingdirectory'.
procedure directory_example {
-return -
-short_description "File copy"
-description "This procedure allows copying a file."
-args {
{-source -type existingdirectory -description "Source directory"}
{-dest -type directory -description "Destination directory"}
}
} {
return "source: '$source', dest: '$dest'"
}
directory_example -interactive
#### Color ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides color selection widgets for the arguments that meet the
# following criterias:
# 1) The argument type is 'color'.
procedure color_example {
-args {
{color -type color -description "Color" -default red}
}
} {
return "color:'$color'"
}
color_example -interactive
#### Font ####
DemoControl(IsExecutable) {1}
# The interactive entry form provides font selection widgets for the arguments that meet the
# following criterias:
# 1) The argument type is 'font'.
procedure font_example {
-args {
{font -type font -description "Font" -default {Arial 12 italic}}
}
} {
return "font:'$font'"
}
font_example -interactive
##########################################################################
# Id: 1b_procedure_interactive_widgets.demo
# Modifications:
#
# Revision 1.3 2012/05/07 20:27:26 droll
# * TEPAM version 0.4.0
# * Add the new text procedure argument type and the text multi line data
# entry widget.
#
# Revision 1.2 2011/01/21 16:00:49 droll
# * TEPAM version 0.2.0
#
# Revision 1.1 2010/02/11 21:54:38 droll
# * TEPAM module checkin
##########################################################################
|