Skip to content

Instantly share code, notes, and snippets.

@ekd123
Last active December 24, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekd123/6863383 to your computer and use it in GitHub Desktop.
Save ekd123/6863383 to your computer and use it in GitHub Desktop.
package require Tk
package require tkdnd
pack [ttk::label .drop -text "拖放到此處"] -fill both -expand 1
pack [ttk::button .browse -text "或選擇文件" -command chooseFileToUpload]
tkdnd::drop_target register .drop *
bind .drop <<Drop>> {
upload %D
}
proc upload {fn} {
set ret [exec curl -s -F name=@$fn http://dimg.vim-cn.com/]
clipboard clear; clipboard append $ret
tk_messageBox -message $ret
}
proc chooseFileToUpload {} {
set fn [tk_getOpenFile]
if {$fn == ""} return
upload $fn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment