Skip to content

Commit

Permalink
added initial text on entry dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
thanoulis committed Dec 3, 2020
1 parent 3c9df08 commit d22b6c6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tpmg
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ Configuration is done through "--text" option, with comma separated label texts.
options for Entry dialog:
--title="string" set window title [default: "Enter Text"]
--text="csv" set label text [default: "Enter text below:"]
--default="csv" set initial text [no default]
--help this help

returns: entries' list on 'OK', 1 on 'Cancel', 255 on error

example: tpmg --entry --title="Personal Information" --text="First name:,Last name:,email:"
example: tpmg --entry --title="Personal Information" --text="First name:,Last name:,email:" --default=",,email@example.com"
}
variable Scale {
Display a scale dialog.
Expand Down Expand Up @@ -563,8 +564,9 @@ proc tPMG::dialog::Password {args} {
# ENTRY DIALOG
#
proc tPMG::dialog::Entry {args} {
set title "Enter Text"
set text [list "Enter text below:"]
set title "Enter Text"
set text [list "Enter text below:"]
set default ""
foreach option {*}$args {
switch -glob -- $option {
--title=* {
Expand All @@ -574,6 +576,9 @@ proc tPMG::dialog::Entry {args} {
set text [split [string range $option 7 end] ","]
set tPMG::dialog::value [llength $text]
}
--default=* {
set default [split [string range $option 10 end] ","]
}
--help {
tPMG::Help "entry"
exit 0
Expand All @@ -585,13 +590,21 @@ proc tPMG::dialog::Entry {args} {
}
}
}
if {$text eq ""} {
puts stderr "no entries defined"
tPMG::Help "entry" stderr
return $tPMG::Error
}
set i 0
foreach item $text {
set tPMG::dialog::list($i) ""
set entry [string cat "." $i]
set frame [string cat $entry "frame"]
ttk::labelframe $frame -relief flat -text $item
ttk::entry $entry -textvariable tPMG::dialog::list($i)
if {$default ne ""} {
set tPMG::dialog::list($i) [lindex $default $i]
}
pack $entry -in $frame
pack $frame -pady 5
incr i
Expand Down

0 comments on commit d22b6c6

Please sign in to comment.