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} { 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 .]
set f [open $img] if {$img ne ""} {
fconfigure $f -translation binary set f [open $img]
set data [base64::encode [read $f]] fconfigure $f -translation binary
close $f set data [base64::encode [read $f]]
# base name on root name of the image file close $f
set name [file root [file tail $img]] # base name on root name of the image file
$text insert [Position] "image create photo $name -data {\n$data\n}" 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 # # Read a config file #
LoadSettings LoadSettings
} }

View File

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