Last active
December 24, 2015 21:09
-
-
Save ekd123/6863383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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