Booè¨èªã®ç°¡åãªããã°ã©ã ä¾(端æ«ã¸ã®åºå®æåååºåã¨Gtkï¼ã®ã¦ã£ã³ãã¦è¡¨ç¤º)
ããã§ã¯Booè¨èªãç¨ããç°¡åãªããã°ã©ã ä¾ã¨ãã¦ã端æ«ã¸ã®åºå®æååã®è¡¨ç¤ºã¨ç©ºã®Gtkï¼ã®ã¦ã£ã³ãã¦è¡¨ç¤ºã®ä¾ãæ±ãã
端æ«ã«åºå®æååã表示ãã
ã¡ã¢
端æ«ã«æååã表示ããã«ã¯çµã¿è¾¼ã¿ã®printæãprint()é¢æ°(ã¨ãã«æ«å°¾ã«æ¹è¡ãä»ã),ãããã¯åºæ¬ã¯ã©ã¹ã©ã¤ãã©ãªã®System.Console.Write()(æ¹è¡ãªã),System.Console.WriteLine()(æ¹è¡ãã)ãç¨ããã
åºæ¬ã¯ã©ã¹ã©ã¤ãã©ãªãå«ãã©ã¤ãã©ãªå
ã®æ©è½ã¯ãã®åå空éãããã©ã£ã¦å¼ã³åºã(ä¾:ãSystem.Console.WriteLine()ã)ãã¨ãã§ããããimportæã§æå®ããåå空éã¯ã³ã¼ãå
ã§çç¥ã§ãã(ä¾:ãimport Systemããè¨è¿°ããå ´åã¯System.Console.WriteLine()ã¯ãConsole.WriteLine()ãã¨æ¸ãã)ãããã¯Cï¼ã®usingæã«è¿ããPythonã®importæã¨ã¯æåã大ããç°ãªãã
ã³ã¼ãä¾
[ä»»æ]ãã¡ã¤ã«å: hello.boo
#! /usr/bin/booi # -*- coding: utf-8 -*- # importæã®æåã¯Pythonã¨ã¯ç°ãªã(Cï¼ã®usingæã«è¿ã) import System # 端æ«ã«æååã表示ããæ print 'Hello, Work !!' # 端æ«ã«æååã表示ããé¢æ° print ('Hello, Boo language !!') # åºæ¬ã¯ã©ã¹ã©ã¤ãã©ãªã®ä½¿ç¨ System.Console.Write ('Hello, ') # Systemåå空éãimportãã¦ããã®ã§ # System.Console.WriteLine -> Console.WriteLine ã¨ãã¦ä½¿ãã Console.WriteLine ('System.Console.WriteLine !!')
ä¸ã¯å®è¡çµæã
Hello, Work !! Hello, Boo language !! Hello, System.Console.WriteLine !!
Gtkï¼ã®ã¦ã£ã³ãã¦è¡¨ç¤º
ã¡ã¢
Mono/.NETåãã®ä¸é¨ã®è¨èªãã¤ã³ãã£ã³ã°ãç¨ããéã«ã¯
import [åå空é] from [ããã±ã¼ã¸å]
ã¨ãã¦ããã±ã¼ã¸å(ä¾:gtk-sharp)ãæå®ããå¿
è¦ãããã
ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã¯ãconstructorãã®ååã¨ãªããPythonã¨ã¯ç°ãªããã¯ã©ã¹ã®ã¡ã³ãé¢æ°ã®æåã®å¼æ°ãselfãã¯è¨è¿°ããå¿
è¦ã¯ãªãã
å種ã¤ãã³ãããã³ãã©ã«é¢é£ä»ããå¦çã¯Cï¼ã¨åæ§ã«ãã¦ã¤ãã³ããã¨ã«ã+=ãã§ãã³ãã©ã«å¯¾å¿ä»ãããdef():ãã§å¿åã®é¢æ°ãè¨è¿°ãããã¨ãã§ããã
Gtkï¼ã§ã¯ãGTK+ã®GObjectã·ã°ãã«ãdelete_eventããçºçããã¨ãã®å¦çã¯DeleteEventã¨ããã¤ãã³ãã«å¯¾ãããã³ãã©ã§è¨è¿°ãã(Cï¼ã§ãåã)ã
ã¦ã£ã³ãã¦ã®ã¿ã¤ãã«ã¯ããããã£Titleã¸ã®ä»£å
¥ã§å¤æ´ããããããã¯Cï¼ã§ã®Gtkï¼ã¨åæ§ã
ã³ã¼ãä¾
ä¸ã®ããã°ã©ã ãå®è¡ããã¨ç©ºã®GTK+ã®ã¦ã£ã³ãã¦ãçæãããã¦ã£ã³ãã¦ããã¼ã¸ã£ã®ãéããããã¿ã³ãæ¼ãã¨çµäºããã
[ä»»æ]ãã¡ã¤ã«å: gtksharptest.boo ã¨ã³ã³ã¼ãã£ã³ã°: UTF-8
#! /usr/bin/booi # -*- coding: utf-8 -*- # Gtkï¼ã§ç©ºã®ã¦ã£ã³ãã¦ãçæã表示ãã import Gtk from 'gtk-sharp' # Gtkï¼ã使ç¨ããããã®è¨è¿° class MainWindow (Gtk.Window): # ç¶æ¿ããã¯ã©ã¹ã®æå®ã¯Pythonã¨åæ§ # ã¡ã³ãé¢æ°ãã³ã³ã¹ãã©ã¯ã¿ã«ã¯å¼æ°ãselfãã®è¨è¿°ã¯ä¸è¦(Pythonã¨ã¯ç°ãªã) def constructor (): # ãªãã¸ã§ã¯ãçææã®å¦ç(Pythonã§ã¯__init__()) # 親ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿å¼æ°ã«Gtk.WindowType.Toplevelãæå® super (Gtk.WindowType.Toplevel) # self.[ã¡ã³ã]ã§åãªãã¸ã§ã¯ã(ã¤ã³ã¹ã¿ã³ã¹)å ã®ã¡ã³ãã«ã¢ã¯ã»ã¹ãã(Pythonã¨åæ§) # ããããã£Titleã¸ã®ä»£å ¥ã§ã¦ã£ã³ãã¦ã¿ã¤ãã«å¤æ´ # é¢é£:PyGObject/PyGTKã§ã®GObjectããããã£ã¯ã[ãªãã¸ã§ã¯ã].props.[GObjectããããã£å]ã self.Title = 'Boo Gtkï¼ test' # ã¤ãã³ãã¨ãã³ãã©ã®é¢é£ä»ãã¯Cï¼ã«è¿ã # ãdef ():ã以ä¸ã¯å¿åé¢æ°(Pythonã¨ã¯ç°ãªãææ³) self.DeleteEvent += def (): # ãéããããã¿ã³ãæ¼ãããã¨ãã®å¦ç # ãéããããã¿ã³ã§ã¡ã¤ã³ã«ã¼ããæãã Application.Quit () Application.Init () # Gtkï¼ã®åæå win = MainWindow () # ã¡ã¤ã³ã¦ã£ã³ãã¦ã®ãªãã¸ã§ã¯ã(ã¤ã³ã¹ã¿ã³ã¹)ãçæ win.ShowAll () # ã¦ã£ã³ãã¦ä»¥ä¸ãå ¨ã¦è¡¨ç¤º Application.Run () # ã¡ã¤ã³ã«ã¼ãéå§
é¢é£è¨äº:
- Pythonのimport文について
- C#言語とVala言語のプロパティについて
- PyGObject/PyGTKにおけるGObjectプロパティの操作について
- Boo言語についてと同言語で書かれたプログラムの実行に関して
使ç¨ãããã¼ã¸ã§ã³:
- Boo 0.9.4.9
- Gtkï¼ 2.12.10