{"id":2359,"date":"2019-11-26T15:16:38","date_gmt":"2019-11-26T06:16:38","guid":{"rendered":"https:\/\/julialang.kr\/?p=2359"},"modified":"2019-11-26T17:24:06","modified_gmt":"2019-11-26T08:24:06","slug":"julia-ui-framework-gtk-%eb%a7%9b%eb%b3%b4%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/julialang.kr\/?p=2359","title":{"rendered":"[Julia] UI Framework &#8220;Gtk&#8221; \ub9db\ubcf4\uae30"},"content":{"rendered":"\n<p>Julia UI Framework\ub85c &#8220;Gtk&#8221;\ub97c \uc0ac\uc6a9 \ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<p>Gtk \ud328\ud0a4\uc9c0\ub97c \uba3c\uc800 \uc124\uce58 \ud55c\ub2e4.<br>Pkg&gt;add Gtk<\/p>\n\n\n<p>using Gtk<\/p>\n<p>win = GtkWindow(&#8220;My First Gtk.jl Program&#8221;, 400, 200)<br \/>\nb = GtkButton(&#8220;Click Me \ud55c\uae00&#8221;)<br \/>\npush!(win,b)<br \/>\nshowall(win)<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/julialang.kr\/wp-content\/uploads\/2019\/11\/image-2.png\" alt=\"\" class=\"wp-image-2360\" width=\"636\" height=\"468\" srcset=\"https:\/\/julialang.kr\/wp-content\/uploads\/2019\/11\/image-2.png 939w, https:\/\/julialang.kr\/wp-content\/uploads\/2019\/11\/image-2-300x221.png 300w, https:\/\/julialang.kr\/wp-content\/uploads\/2019\/11\/image-2-768x565.png 768w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/figure><\/div>\n\n\n\n<p>\uc2e4\ud589\ud658\uacbd <br> &#8211; \ubc31\uc5d4\ub4dc : Ubuntu 18.04 \/ Jupyter noteboo<br> &#8211; Windows 10, Xming<\/p>\n\n\n<p>using Gtk<br \/>\nusing Gtk.GConstants<\/p>\n<p>function resize_event(widget::Gtk.GtkGLArea, width::Int32, height::Int32)<br \/>\n\tprintln(&#8220;resize_event: &#8220;, &#8220;w=&#8221;, width, &#8221; h=&#8221;, height)<br \/>\nend<\/p>\n<p>function scroll_event(widget::Gtk.GtkGLArea, event::Gtk.GdkEventScroll)<br \/>\n\tprintln(&#8220;scroll_event&#8221;)<br \/>\n\treturn true<br \/>\nend<\/p>\n<p>function motion_notify_event(widget::Gtk.GtkGLArea, event::Gtk.GdkEventMotion)<br \/>\n\tprintln(&#8220;motion_notify_event&#8221;)<br \/>\n\treturn true<br \/>\nend<\/p>\n<p>function button_press_event(widget::Gtk.GtkGLArea, event::Gtk.GdkEventButton)<br \/>\n\tprintln(&#8220;button_press_event&#8221;)<br \/>\n\treturn true<br \/>\nend<\/p>\n<p>function button_release_event(widget::Gtk.GtkGLArea, event::Gtk.GdkEventButton)<br \/>\n\tprintln(&#8220;button_release_event&#8221;)<br \/>\n\treturn true<br \/>\nend<\/p>\n<p>area = Gtk.GLArea()<br \/>\nadd_events(area,<br \/>\n\t\t\tGConstants.GdkEventMask.SCROLL |<br \/>\n\t\t\tGConstants.GdkEventMask.BUTTON_PRESS |<br \/>\n\t\t\tGConstants.GdkEventMask.BUTTON_RELEASE |<br \/>\n\t\t\tGConstants.GdkEventMask.BUTTON1_MOTION |<br \/>\n\t\t\tGConstants.GdkEventMask.BUTTON3_MOTION)<br \/>\nsignal_connect(resize_event, area, &#8220;resize&#8221;)<br \/>\nsignal_connect(scroll_event, area, &#8220;scroll-event&#8221;)<br \/>\nsignal_connect(motion_notify_event, area, &#8220;motion-notify-event&#8221;)<br \/>\nsignal_connect(button_press_event, area, &#8220;button-press-event&#8221;)<br \/>\nsignal_connect(button_release_event, area, &#8220;button-release-event&#8221;)<\/p>\n<p>win = Gtk.Window(&#8220;Hello Gtk.jl&#8221;)<br \/>\npush!(win, area)<br \/>\nshowall(win)<\/p>\n<p># https:\/\/stackoverflow.com\/a\/33571506\/1500988<br \/>\nsignal_connect(win, :destroy) do widget<br \/>\n    Gtk.gtk_quit()<br \/>\nend<br \/>\nGtk.gtk_main()<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/julialang.kr\/wp-content\/uploads\/2019\/11\/image-3.png\" alt=\"\" class=\"wp-image-2364\" width=\"537\" height=\"333\" srcset=\"https:\/\/julialang.kr\/wp-content\/uploads\/2019\/11\/image-3.png 659w, https:\/\/julialang.kr\/wp-content\/uploads\/2019\/11\/image-3-300x186.png 300w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Julia UI Framework\ub85c &#8220;Gtk&#8221;\ub97c \uc0ac\uc6a9 \ud560 \uc218 \uc788\ub2e4. Gtk \ud328\ud0a4\uc9c0\ub97c \uba3c\uc800 \uc124\uce58 \ud55c\ub2e4.Pkg&gt;add Gtk \uc2e4\ud589\ud658\uacbd &#8211; \ubc31\uc5d4\ub4dc : Ubuntu 18.04 \/ Jupyter noteboo &#8211; Windows 10, Xming<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/julialang.kr\/index.php?rest_route=\/wp\/v2\/posts\/2359"}],"collection":[{"href":"https:\/\/julialang.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/julialang.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/julialang.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/julialang.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2359"}],"version-history":[{"count":3,"href":"https:\/\/julialang.kr\/index.php?rest_route=\/wp\/v2\/posts\/2359\/revisions"}],"predecessor-version":[{"id":2365,"href":"https:\/\/julialang.kr\/index.php?rest_route=\/wp\/v2\/posts\/2359\/revisions\/2365"}],"wp:attachment":[{"href":"https:\/\/julialang.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/julialang.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/julialang.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}