Fixed error if file was not select

0.4.6
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 100644
View File

View File

@ -53,20 +53,23 @@ proc scale {w {n 1} node} {
proc ImageBase64Encode {text} {
global env
set types {
{"PNG" {.png}}
{"GIF" {.gif}}
{"JPEG" {.jpg}}
{"PNG" {.png}}
{"BMP" {.bmp}}
{"All files" *}
}
set img [tk_getOpenFile -initialdir $env(HOME) -filetypes $types -parent .]
set f [open $img]
fconfigure $f -translation binary
set data [base64::encode [read $f]]
close $f
# base name on root name of the image file
set name [file root [file tail $img]]
$text insert [Position] "image create photo $name -data {\n$data\n}"
if {$img ne ""} {
set f [open $img]
fconfigure $f -translation binary
set data [base64::encode [read $f]]
close $f
# base name on root name of the image file
set name [file root [file tail $img]]
$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 #
LoadSettings
}

View File

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