commit de92b1f7101277d987f14aaea84b26059fba92e7 Author: David Ashby Date: Sat Feb 22 00:14:55 2025 -0500 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b3a757 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +why \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e413132 --- /dev/null +++ b/go.mod @@ -0,0 +1,51 @@ +module git.yetaga.in/alazyreader/why + +go 1.24.0 + +require modernc.org/tk9.0 v0.62.0 + +require ( + github.com/adrg/xdg v0.5.3 // indirect + github.com/disintegration/imaging v1.6.2 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/ebitengine/purego v0.8.0 // indirect + github.com/evilsocket/islazy v1.11.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect + github.com/mat/besticon/v3 v3.18.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect + golang.org/x/image v0.20.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sys v0.28.0 // indirect + modernc.org/fileutil v1.3.0 // indirect + modernc.org/fsm v1.2.1 // indirect + modernc.org/gc/v3 v3.0.0-20230512134359-466b49aa80e0 // indirect + modernc.org/knuth v0.5.4 // indirect + modernc.org/libX11 v0.11.2 // indirect + modernc.org/libXau v0.9.2 // indirect + modernc.org/libXdmcp v0.12.0 // indirect + modernc.org/libXft v0.10.0 // indirect + modernc.org/libXrender v0.9.0 // indirect + modernc.org/libbsd v0.11.1 // indirect + modernc.org/libc v1.61.13 // indirect + modernc.org/libexpat v0.10.2 // indirect + modernc.org/libfontconfig v0.8.2 // indirect + modernc.org/libfreetype v0.9.1 // indirect + modernc.org/libmd v0.12.0 // indirect + modernc.org/libtcl9.0 v0.15.1 // indirect + modernc.org/libtk9.0 v0.14.0 // indirect + modernc.org/libxcb v0.11.0 // indirect + modernc.org/libz v0.16.10 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/memory v1.8.2 // indirect + modernc.org/ngrab v0.1.0 // indirect + modernc.org/rec v0.2.0 // indirect + modernc.org/regexp v1.7.3 // indirect + modernc.org/sortutil v1.2.1 // indirect + modernc.org/strutil v1.2.1 // indirect + modernc.org/tcl9.0 v0.15.25 // indirect + modernc.org/token v1.1.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..bc146fc --- /dev/null +++ b/go.sum @@ -0,0 +1,115 @@ +github.com/adrg/xdg v0.5.3 h1:xRnxJXne7+oWDatRhR1JLnvuccuIeCoBu2rtuLqQB78= +github.com/adrg/xdg v0.5.3/go.mod h1:nlTsY+NNiCBGCK2tpm09vRqfVzrc2fLmXGpBLF0zlTQ= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= +github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE= +github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= +github.com/evilsocket/islazy v1.11.0 h1:B5w6uuS6ki6iDG+aH/RFeoMb8ijQh/pGabewqp2UeJ0= +github.com/evilsocket/islazy v1.11.0/go.mod h1:muYH4x5MB5YRdkxnrOtrXLIBX6LySj1uFIqys94LKdo= +github.com/expr-lang/expr v1.16.9 h1:WUAzmR0JNI9JCiF0/ewwHB1gmcGw5wW7nWt8gc6PpCI= +github.com/expr-lang/expr v1.16.9/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4= +github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/mat/besticon/v3 v3.18.0 h1:dEDT5cXp8s/UH4Gh2uWEmguxGexU7q22MKjBzZmfd70= +github.com/mat/besticon/v3 v3.18.0/go.mod h1:J8y+A9X0Oxxsq5+gaeIzn5/6XcJe1rsnhpFOXsq9/6A= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 h1:pVgRXcIictcr+lBQIFeiwuwtDIs4eL21OuM9nyAADmo= +golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw= +golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +modernc.org/cc/v4 v4.24.4 h1:TFkx1s6dCkQpd6dKurBNmpo+G8Zl4Sq/ztJ+2+DEsh0= +modernc.org/cc/v4 v4.24.4/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= +modernc.org/ccgo/v4 v4.23.16 h1:Z2N+kk38b7SfySC1ZkpGLN2vthNJP1+ZzGZIlH7uBxo= +modernc.org/ccgo/v4 v4.23.16/go.mod h1:nNma8goMTY7aQZQNTyN9AIoJfxav4nvTnvKThAeMDdo= +modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= +modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= +modernc.org/fsm v1.2.1 h1:HbM58bXxL5O2lcZV2MLunCelmbcx0pfEABx5MiBdVcU= +modernc.org/fsm v1.2.1/go.mod h1:EDGRSaPWy3qP70XVpUVVqkUplm0myW+jAohuM5RajEs= +modernc.org/gc/v2 v2.6.3 h1:aJVhcqAte49LF+mGveZ5KPlsp4tdGdAOT4sipJXADjw= +modernc.org/gc/v2 v2.6.3/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v3 v3.0.0-20230512134359-466b49aa80e0 h1:Iox2PD9TaVKyyCdDn7A3KuDd4ELb9TcrsA/2iXzRRtU= +modernc.org/gc/v3 v3.0.0-20230512134359-466b49aa80e0/go.mod h1:1hU1kIUddpAm7byqo+bfUr4X6PwhHSjb3cNv5yXlzEs= +modernc.org/knuth v0.5.4 h1:F8mDs7ME3oN9eyx01n6/xVmJ4F5U/qEhSYPnPXaZrps= +modernc.org/knuth v0.5.4/go.mod h1:e5SBb35HQBj2aFwbBO3ClPcViLY3Wi0LzaOd7c/3qMk= +modernc.org/libX11 v0.11.2 h1:tAqv1KVQEDhBqQ/1gfSmEAQtAoOjteOTHZZoiB7AfUQ= +modernc.org/libX11 v0.11.2/go.mod h1:3AuhC2yIZnqs345bgkN09wZkQxftMkh0VxzG5hlGMHU= +modernc.org/libXau v0.9.2 h1:zvsrhQm4LZxp9s+PmH4cU3bHtwx8D2N1ZosdOGFgAIw= +modernc.org/libXau v0.9.2/go.mod h1:W7rrXkzskKX3CCFdNkoBoj1MIIxbLLG3zyO7uOdKT1o= +modernc.org/libXdmcp v0.12.0 h1:ZjEkqq0oMPJLSIHf3sGTyWZAaN3pufx1FxieH8ahujA= +modernc.org/libXdmcp v0.12.0/go.mod h1:vGEvyhpeH8Tq8t813RNeyMRODJ0Wxlwg9Avy1TC3DK4= +modernc.org/libXft v0.10.0 h1:CtttMuQsmLbXg+IPYVxQHJXsGVLMn3WsKIXr8e/TDKo= +modernc.org/libXft v0.10.0/go.mod h1:z+VNTTc3Lmtzn4FcpueZkoHGlhXkMReyLcfTFfERxCE= +modernc.org/libXrender v0.9.0 h1:JDLYImH30B2f1HYM0gMN+RArkyL37I4/3PkgE40dMGY= +modernc.org/libXrender v0.9.0/go.mod h1:b41LOnUnhzdqU0Nn5b/HL6F+JvIS5rD58FOQXDgNQBY= +modernc.org/libbsd v0.11.1 h1:fitxx6pR7qCmKiyguiaSd3sNluE3Upb5CqoSQKWAfo4= +modernc.org/libbsd v0.11.1/go.mod h1:FEVwPCCWsF7E3aZ5r7r4VeRullGyYucA6aTgk5HNTRY= +modernc.org/libc v1.61.13 h1:3LRd6ZO1ezsFiX1y+bHd1ipyEHIJKvuprv0sLTBwLW8= +modernc.org/libc v1.61.13/go.mod h1:8F/uJWL/3nNil0Lgt1Dpz+GgkApWh04N3el3hxJcA6E= +modernc.org/libexpat v0.10.2 h1:apvlWGtS3cn61Z24isCvCLU4t1NWAUOBWTA2KMNvVzc= +modernc.org/libexpat v0.10.2/go.mod h1:OJbzff11GOxEfSSy3ofxGn0vrkpAWN0YLvTTLthe4Lw= +modernc.org/libfontconfig v0.8.2 h1:OvllZZfoE/7WrtzO8HHaQn9YS6JZlSUdkAY3nL+od6Y= +modernc.org/libfontconfig v0.8.2/go.mod h1:xQ59wWxiqkxaAIg+hH+6u+b9B0uu7njWDV4UnoXrDYE= +modernc.org/libfreetype v0.9.1 h1:OS57DE3q1dSTAfOz2O0dw2w5zDx3oax8BUNaHQB0DGU= +modernc.org/libfreetype v0.9.1/go.mod h1:7MEdxlU7xIIQ1k5MQYGe0C7BfKuXwVW1i5G9fQDbRSE= +modernc.org/libmd v0.12.0 h1:aAvpjpr7FJUrO14hghEB5QK7Prvl6Cbf7D8vSswxojE= +modernc.org/libmd v0.12.0/go.mod h1:QQBOHm77lZsemt1VbO7fQhDUYO0/dy5KR1nLVm5YvLY= +modernc.org/libtcl9.0 v0.15.1 h1:DM9nzm+VPFeEpPYYSLfRif9vneEklR9/OCkrabMdrbw= +modernc.org/libtcl9.0 v0.15.1/go.mod h1:WVZziJEB6DHMOG7nTfRXKzOzFF9dfdI6aA/GkpffgXg= +modernc.org/libtk9.0 v0.14.0 h1:X2cLLoObDTlXwf0c6fwmSWP48tfABIuvqUBfsLySUmM= +modernc.org/libtk9.0 v0.14.0/go.mod h1:D6csINNOuk5lLMab20kjhCK0JxQfL02IaAPa9vnj2G4= +modernc.org/libxcb v0.11.0 h1:MzVt6ETBHfAjQeZYH3J5vKzHn7HihZd3FSKbQb9mK1Y= +modernc.org/libxcb v0.11.0/go.mod h1:Wht2E7ngaJG36GguDTdXkHXItBFPFVXAcN7w8pJW9ug= +modernc.org/libz v0.16.10 h1:EzVXcQypULQaMZvYCTaUrifHI3w+qJC32tVHhIJME6w= +modernc.org/libz v0.16.10/go.mod h1:aFCUCpH+9uJvjLJfN98nhQz1ibdhZrZG8Pe6ZJeBSIA= +modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= +modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= +modernc.org/memory v1.8.2 h1:cL9L4bcoAObu4NkxOlKWBWtNHIsnnACGF/TbqQ6sbcI= +modernc.org/memory v1.8.2/go.mod h1:ZbjSvMO5NQ1A2i3bWeDiVMxIorXwdClKE/0SZ+BMotU= +modernc.org/ngrab v0.1.0 h1:21cX4tAIfLNjR4ax7JMfHTz2ztnjVGcCSsztoG6EFMk= +modernc.org/ngrab v0.1.0/go.mod h1:dDGjUip6IXmb5Y5M8RPYD7Sg4S/VdfG5akxK34uYtOE= +modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= +modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= +modernc.org/rec v0.2.0 h1:bvKWh/hNdAkdcUxWXAmyBQ1htADn5n5ad5G8boPp4Og= +modernc.org/rec v0.2.0/go.mod h1:SoaswcFNRf7GmLiMHK1672ac60D2KmUFmu5rRrZDBPo= +modernc.org/regexp v1.7.3 h1:XOyVuWwhINI1jwwEkEKBNXAgfdYKOJ7iRgQH1zYlol0= +modernc.org/regexp v1.7.3/go.mod h1:w871IJbq9BwRr+ZtUZ9D7+p7qPAFWTN47ESu46YcGjI= +modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= +modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= +modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= +modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= +modernc.org/tcl9.0 v0.15.25 h1:3xNx26D+vYmSY3K9FaNdPmlHd8Hcz39YGiqsBFCYx5c= +modernc.org/tcl9.0 v0.15.25/go.mod h1:hCbqZz0GQRzN3Xnfn4dKpMCwvA9sfEb+Go++cw1cJ3A= +modernc.org/tk9.0 v0.62.0 h1:V4lyYhCRSXZKn+txvjZCyUnWodAFVJRYFDpFuLldGlk= +modernc.org/tk9.0 v0.62.0/go.mod h1:vzTmvDro5F7yCnusSheZrF8VXXOzmY9RxH2c5M3YFqc= +modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/gopher.png b/gopher.png new file mode 100644 index 0000000..7213edb Binary files /dev/null and b/gopher.png differ diff --git a/main.go b/main.go new file mode 100644 index 0000000..0bdf59b --- /dev/null +++ b/main.go @@ -0,0 +1,138 @@ +package main + +import ( + "bytes" + _ "embed" + "fmt" + "image" + "image/draw" + "image/jpeg" + "image/png" + "io" + "log" + "os" + "slices" + "strings" + "time" + + tk "modernc.org/tk9.0" +) + +//go:embed gopher.png +var gopher []byte + +var validFileTypes = []tk.FileType{ + { + TypeName: "JPEG", + Extensions: []string{".jpg", ".jpeg"}, + }, + { + TypeName: "GIF", + Extensions: []string{".gif"}, + }, + { + TypeName: "PNG", + Extensions: []string{".png"}, + }, + { + TypeName: "SVG", + Extensions: []string{".svg"}, + }, +} + +var metaPressed bool + +func isType(filename string, desired string) bool { + splode := strings.Split(filename, ".") + if len(splode) < 2 { + return false + } + ext := fmt.Sprintf(".%s", splode[len(splode)-1]) + for _, ft := range validFileTypes { + if slices.Contains(ft.Extensions, ext) && ft.TypeName == desired { + return true + } + } + return false +} + +func jpegToPng(in io.Reader) (*bytes.Buffer, error) { + start := time.Now() + buf := new(bytes.Buffer) + + img, err := jpeg.Decode(in) + if err != nil { + return nil, fmt.Errorf("unable to decode jpeg: %w", err) + } + + b := img.Bounds() + dst := image.NewNRGBA(image.Rect(0, 0, b.Dx(), b.Dy())) + draw.Draw(dst, dst.Bounds(), img, b.Min, draw.Src) + + if err := (&png.Encoder{ + CompressionLevel: -2, + }).Encode(buf, dst); err != nil { + return nil, fmt.Errorf("unable to encode png: %w", err) + } + end := time.Now() + log.Printf("jpeg to png took %v", end.Sub(start)) + return buf, nil +} + +func loadImage(img *tk.LabelWidget) func() { + return func() { + files := tk.GetOpenFile(tk.Filetypes(validFileTypes)) + if len(files) > 0 { + f, err := os.Open(files[0]) + if err != nil { + log.Println(err.Error()) + return + } + var r io.Reader + if isType(files[0], "JPEG") { + r, err = jpegToPng(f) + if err != nil { + log.Println(err.Error()) + return + } + } else { + r = f + } + i, err := io.ReadAll(r) + if err != nil { + log.Println(err.Error()) + return + } + img.Configure(tk.Image(tk.NewPhoto(tk.Data(i)))) + } + } +} + +func main() { + img := tk.Label(tk.Image(tk.NewPhoto(tk.Data(gopher)))) + + menubar := tk.Menu() + fileMenu := menubar.Menu() + fileMenu.AddCommand(tk.Lbl("Open"), tk.Underline(0), tk.Accelerator("Meta+O"), tk.Command(loadImage(img))) + menubar.AddCascade(tk.Lbl("File"), tk.Underline(0), tk.Mnu(fileMenu)) + + tk.Bind(tk.App, "", tk.Command(func(e *tk.Event) { + if e.Keysym == "Meta_L" || e.Keysym == "Meta_R" { + metaPressed = true + } + if e.Keysym == "o" && metaPressed { + loadImage(img)() + } + })) + tk.Bind(tk.App, "", tk.Command(func(e *tk.Event) { + if e.Keysym == "Meta_L" || e.Keysym == "Meta_R" { + metaPressed = false + } + })) + tk.Bind(tk.App, "", tk.Command(func(e *tk.Event) { + log.Println(e) + })) + + tk.Pack(img) + tk.App.Configure(tk.Mnu(menubar)).Center().Wait() +}