[GTK+] GJS로 'Hello world' 창띄어보기

컴퓨터/Linux 2013.03.18 03:19 Posted by StudioEgo

자바스크립트를 이용하여 GNOME에서 창을 띄어보기


출처: YES! Gnome JS Bindings Documentation is now available! 

#!/usr/bin/gjs

//The previous line is a hash bang which tells how to run the script.
// Note that the script has to be executable (run in terminal in the right folder: chmod +x scriptname)
// Initialize GTK+
var Gtk = imports.gi.Gtk;
Gtk.init(null, 0);
// Create your window, name it, and connect the “click x to quit” function.
// The word “window” is a JavaScript keyword, so we have to
// call it something different.
var mywindow = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
mywindow.title = "Hello World!";
mywindow.connect("destroy", function(){Gtk.main_quit()});
// Add some text to your window
var label = new Gtk.Label({label: "Hello World"});
mywindow.add(label);
// Make the label and the window itself visible to the user
label.show();
mywindow.show();
// Let the user run the app
Gtk.main();


chmod +x helloworld.js

./helloworld.js


Hello World!




Web Developer. My native language is Korean(한국어) My hobby is Learning Language(English,中國語[繁體中文/简体中文],日本語) Interested Mobile & Web #Unicode #CJK #文字 #漢字 #이상한모임
저는 초등학교 3학년때 역삼동 아부지 회사에서 접해보았던 Netscape Browser를 보고 인터넷에 빠져들었습니다. Web에 대해 관심이 많으며 음악을 좋아합니다.
블로그 : http://blog.studioego.info
Twitter: @studioego
이 글은 StudioEgo 가 작성하였습니다.

댓글을 달아 주세요