Fixed error if file was not select

This commit is contained in:
Sergey Kalinin 2018-07-05 08:41:18 +03:00
parent 9ead049928
commit f1ca27d3e0
6 changed files with 17 additions and 8 deletions

0
errors Normal file
View File

View File

@ -53,13 +53,14 @@ proc scale {w {n 1} node} {
proc ImageBase64Encode {text} { proc ImageBase64Encode {text} {
global env global env
set types { set types {
{"PNG" {.png}}
{"GIF" {.gif}} {"GIF" {.gif}}
{"JPEG" {.jpg}} {"JPEG" {.jpg}}
{"PNG" {.png}}
{"BMP" {.bmp}} {"BMP" {.bmp}}
{"All files" *} {"All files" *}
} }
set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .] set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .]
if {$img ne ""} {
set f [open $img] set f [open $img]
fconfigure $f -translation binary fconfigure $f -translation binary
set data [base64::encode [read $f]] set data [base64::encode [read $f]]
@ -68,5 +69,7 @@ proc ImageBase64Encode {text} {
set name [file root [file tail $img]] set name [file root [file tail $img]]
$text insert [Position] "image create photo $name -data {\n$data\n}" $text insert [Position] "image create photo $name -data {\n$data\n}"
} }
}

View File

@ -381,3 +381,4 @@ if {[info exists workingProject]} {

View File

@ -1012,3 +1012,5 @@ proc InsertTitle {newFile type} {

View File

@ -669,3 +669,4 @@ proc Settings {nBook} {
# Read a config file # # Read a config file #
LoadSettings LoadSettings
} }

View File

@ -176,3 +176,5 @@ option add *Dialog.msg.background $editor(bg)