Fixed error if file was not select
This commit is contained in:
parent
9ead049928
commit
f1ca27d3e0
|
@ -53,13 +53,14 @@ 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 .]
|
||||
if {$img ne ""} {
|
||||
set f [open $img]
|
||||
fconfigure $f -translation binary
|
||||
set data [base64::encode [read $f]]
|
||||
|
@ -67,6 +68,8 @@ proc ImageBase64Encode {text} {
|
|||
# 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}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -381,3 +381,4 @@ if {[info exists workingProject]} {
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1012,3 +1012,5 @@ proc InsertTitle {newFile type} {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -669,3 +669,4 @@ proc Settings {nBook} {
|
|||
# Read a config file #
|
||||
LoadSettings
|
||||
}
|
||||
|
||||
|
|
|
@ -176,3 +176,5 @@ option add *Dialog.msg.background $editor(bg)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user