AOISOMEãªã»ãã&ã³ããããã¾ãã
AOISOMEã®æ¹ã¯ä¸æ¦ã¯ãªã¢ããXRCedã§ä½æãããã¡ã¤ã«ã ãã®ç¶æ ã«ãã¾ãã(Rev.22)ã
ããããã®äºå®ã¨ãã¦ã¯
- ãã¿ã³ã§TreeViewã«ãã¼ã追å ããã¤ãã³ã
- ãã¹ãç¨ãã¡ã¤ã«ã®èªã¿æ¸ã
ãããããã£ã¦ã¿ã¾ãããã®éã«ãAoisoNodeã¯ã©ã¹ã¯æ¢åã®ãã®ã使ãã¾ããã¾ããã¾ããLogicã¯ã©ã¹ãæµç¨ããæçµçã«ã¯PyGtkã¨wxPythonã©ã¡ãã§ãå ±æã§ããã½ã¼ã¹ãã§ããã ãä½ãããã¨æãã¾ãããã¾ãããã°AOISORAã«ç§»æ¤ãæçµçã«ã¯
$ python aoisora.py -gtk
$ python aoisora.py -wx
è¦ããã«èµ·åãªãã·ã§ã³ã§ãã¼ã«ããããé¸ã¹ãã¨ããã¾ãããã¾ã§ãããã©ããã¯æªå®ã§ããã
XRCedã§çæãããã½ã¼ã¹ã«ã¤ãã¦
XRCedã§GUIãä½ã£ãããxrcãã¡ã¤ã«ã¨pythonãã¡ã¤ã«ãä½ãããããã§ããããã®pythonãã¡ã¤ã«ãã©ãããããåé¡ã§ããç´æ¥ç·¨éããã¨æ¬¡åã¸ã§ãã¬ã¼ãããã¨ãã«å°ãã¾ãããããè¯ãè¦ã¦ã¿ãã¨å¤§äºãªãã¨ã¯ã ãããxrcãã¡ã¤ã«ã«æ¸ãã¦ããã®ã§ãGUIãä½ãæ¿ãã¦ãpythonãã¡ã¤ã«ã®æ¹ã¯æ¯åã¸ã§ãã¬ã¼ãããªãã¦ãè¯ãããã§ããã¤ãã³ããã³ãã©ã®é¢é£ä»ããæåã§ãããã¨ã«ãªãã¾ããããã®ç¨åº¦ã§ããã°ç´æ¥ç·¨éã§ããã¡ãªããã®æ¹ã大ããã§ãããã
ã¾ãããã®ãããªä¾¿å©ãªã¦ã¼ãã£ãªãã£ãä½ã£ã¦ããæ¹ããã¾ããã
http://python.matrix.jp/projects/wxPython/helper.html
ããã使ãã°ã¤ãã³ãã¨ã¡ã½ããã®ç´ã¥ãã楽ã«ãªãã¾ãã
ã¨ããããã§ãXRCedã§ã®ç·¨éã§ã¯
- æåã®ä¸åã ãpythonã½ã¼ã¹ãæ¸ãåºãããã®ããã¡ã¤ã³ãã¬ã¼ã ã®ååã¯ãã®æç¹ã§ç¢ºå®ãããã
- ãã®å¾ã®ç·¨éã§ã¯xrcãã¡ã¤ã«ã ãä¿åã
- ä¸è¨ãµã¤ãã®wx_utils.pyã®binderã使ããã¦ãããã
ã¨ããã®ãä¸çªçæ³çãªéçºææ³ã§ã¯ãªããã¨æãã¾ãããã ããã®wx_utils.pyã¯ã©ã¤ã»ã³ã¹ãä¸æã§ãããã使ããã¨ã«ãªã£ããä½è ã«èãã¦ã¿ã¾ãã
ç¶ã»XRCedã§çæãããã½ã¼ã¹ã«ã¤ãã¦
ãªããã¸ã§ãã¬ã¼ããããPythonãã¡ã¤ã«ã¯ãããªããããªæ°ããã¦ããã
Gladeã¨åãããã«XMLãèªã¿è¾¼ãã¨ããããã³ã¼ãã£ã³ã°ãã¦ãå¥ã«æéãããªãããèªåã§æ¸ããã½ã¼ã¹ã®æ¹ãèªã¿ãããã
ã·ã³ãã«ãªFrameãªãxrcãã¡ã¤ã«ã¨Appã¯ã©ã¹ã ãã§ãããã
import sys import wx import wx.xrc as xrc print "aoiso start" print __name__ class AoisoApp(wx.App): def OnInit(self): self.res = xrc.XmlResource('aoisome.xrc') self.init_frame() return True def init_frame(self): self.frame = self.res.LoadFrame(None, 'MainFrame') self.frame.Bind(wx.EVT_MENU, self.OnFileNewClick, id=xrc.XRCID('FILE_NEW')) self.frame.SetSize((700,500)) self.frame.SetPosition((200,200)) self.frame.Show() def OnFileNewClick(self, event): print "file_new" if __name__ == "__main__": print "Execute AOISO" app = AoisoApp(False) app.MainLoop()
MainFrameãã¡ããã¨å®£è¨ãã¦ã¡ã½ããã追å ããããããå ´åã¯ããããªæãã
import sys import wx import wx.xrc as xrc print "aoiso start" print __name__ class MainFrame(wx.Frame): def __init__(self, app, parent=None): pre = wx.PreFrame() app.res.LoadOnFrame(pre, parent, "MainFrame") self.PostCreate(pre) self.Bind(wx.EVT_MENU, app.OnFileNewClick, id=xrc.XRCID('FILE_NEW')) self.SetSize((700,500)) self.SetPosition((200,200)) class AoisoApp(wx.App): def OnInit(self): self.res = xrc.XmlResource('aoisome.xrc') self.frame = MainFrame(self) self.frame.Show() return True def OnFileNewClick(self, event): print "file_new" if __name__ == "__main__": print "Execute AOISO" app = AoisoApp(False) app.MainLoop()
æåã¯Frameã®å¼æ°parentã«Appèªèº«ã渡ãã¦ããã°ããã®ã§ã¯ã¨æã£ãã®ã§ãããparentã¯æ¬æ¥ãããããã®ã§ã¯ãªãã®ã§ãLoadOnFrameã®parentã«Noneã渡ãããã¨ããªããã¼ãªè¨è¿°ãå¿ è¦ã«ãªãã¾ããããã§ã¯__init__ã®å¼æ°ãå¢ããã¾ããã
ãã¨ãåãã£ã¦ãã¾ãã°ãªãã¨ãããã¨ã¯ãªãã®ã§ãããã¤ãã³ããåããªãã¦ã¡ãã£ã¨ãããã¾ãããMenuãToolBarã®ã¤ãã³ãã¯EVT_BUTTONã§ã¯ãªãEVT_MENUãªãã§ããã
ããã¾ã§ã³ããããã¾ãã(Rev.23)ã
TreeViewã«ã¢ã¤ã³ã³è¡¨ç¤º
ãããã¨ã¯ãTreeViewã®çææã«
column = gtk.TreeViewColumn() column.set_title('item') render_pixbuf = gtk.CellRendererPixbuf() column.pack_start(render_pixbuf,expand=False) column.add_attribute(render_pixbuf,'pixbuf',c.COL_ICON) render_text = gtk.CellRendererText() column.pack_start(render_text,expand=True) column.add_attribute(render_text,'text',c.COL_TEXT) self.append_column(column)
ãããªæãã§ããã¹ãã®åã«pixbufã追å ãã¦ããã ãã§ããããã¨ã¯åTreeIterã®ã«ã©ã ã«å¯¾ãã¦pixbufãset_valueãã¦ããã°ã¢ã¤ã³ã³ã表示ããã¾ãã
ã¨ããããã§ãã³ããã(Rev.21)ãã»ã»ã»ãªãã§ãããååã®ã¤ã¥ãã§ã½ã¼ã¹ãæ´çãã¦ãããã¡ã«ãã¡ãã¡ããã£ãã®ã§å¤æ´ç®æã追ãã®ã¯çµæ§å¤§å¤ã§ããã¢ãã«ã«é¢ãã¦ãTreeStoreãç´æ¥ä½¿ãã®ã§ãªãæ´¾çã¯ã©ã¹ã使ããã¨ã«ãã¾ããããããã§ã ãã¶ã¢ãã«ã¨ãã¥ã¼ã¨ãã¸ãã¯ãåé¢ã§ãã¦ããããªã
wxPythonã使ã£ã¦ã¿ãã
ã«ãã´ãªãã¡ãã£ã¨å¤æ´ãã¾ããã
ãã¦ãPyGtkã§ã®éçºã®ãã©ã¯ãã£ããã§ãããpy2exeã®è±è åé¡ã¨ããGtkã®ãã¤ã¢ãã°ã¯Windowsã¦ã¼ã¶ã«ã¯é¦´æããªãã¨ããããããªèª²é¡ãæ®ããã¦ãã¾ããå ã Linuxã§ä½¿ãããã®ã½ããã¨ãã¦éçºããã¦ããããã§ãããé å¸ãå§ããã9å²ãããã¯Windowsã¦ã¼ã¶ãããªããã¨æãã®ã§ããã®è¾ºã¯ã¡ããã¨èããªããã°ãªãã¨ããã¨ããã§ãã
ããã§ãéçºä¸ã®AOISORAã¯ã¡ãã£ã¨ä¸æããAOISOMEã®ã»ãã§ã¯wxPythonã«æµ®æ°ãã¦ã¿ãããã¨æãã¾ããè¦ããã«ããã¾ã§Gtkã§ä½ã£ã¦ãããã®ã¨åããã®ãä¸ããwxWidgetsã§æ¸ãç´ãã¦ã¿ããã¨ããããã§ãã
ãããªãããªã§wxGladeã¨æ ¼éãã¦ããã®ã§ãããsizerç¬ç¹ããã¦ã¯ã«ã³ãã»ã»ã»ãGtkã¨ãããªã«éããªãã¨æã£ã¦ããã®ã§ããçãã£ããwxGladeã®ä½¿ãæ¹ã®åã«wxWidgetsã®ã¬ã¤ã¢ã¦ãã«ã¤ãã¦åå¼·ããå¿ è¦ãããããã§ãã
AOISORA 0.0.4 ãªãªã¼ã¹ãã¾ããã
次ã®ä½æ¥ã«å ¥ãåã«ä¸æ¦ä»ã®ç¶æ (Rev.21)ãAOISORA-0.0.4ã¨ãã¦ãªãªã¼ã¹ãã¾ãã
0.0.3ããã®ç®ã ã£ãå¤æ´ç¹ã¯ããªã¼ä¸ã«ã¢ã¤ã³ã³ã表示ãããããã«ãªã£ããããã§ãããå é¨çã«ã¯ããªãå¤ãã£ã¦ãã¾ããã¾ããä»ã®ã¨ããæååããã¦å®è³ªä½¿ããªãã®ã§ãããWindowsç¨ãã¤ããª(exe)ãä»åããé å¸ãããã¨ã«ãã¾ããã
sizerã¡ã¢
ç»é¢ãªãµã¤ãºã«è¿½éãããã©ããã®æ±ºãæã«ãªããã©ã¡ã¼ã¿ã¯Proportionã¨wxEXPANDã
Sizerã®æ¹åã«é¢ãã¦ã¯Proportionã0ã ã¨åºå®ã1以ä¸ã ã¨ãªãµã¤ãºã«è¿½éãé常ã®2åå²ã®å ´åã¯çæ¹ã0ãããä¸æ¹ã1ã«ãªãã3åå²ä»¥ä¸ã使ãå ´åã¯ãåºããããã¤ã³ã ã1ã«ãããåºããããã¤ã³ãè¤æ°ããå ´åã¯æ¯çãæå®ãããå ¨é¨1ãªãåçã
Sizerã®æ¹åãããªãæ¹ã®é ç½®ã«é¢ãã¦ã¯Alignmentï¼wxHOGEï¼ã使ç¨ãããwxEXPANDã§ãã£ã±ããã£ã±ãã«åºããã
wxGladeã§ã¯ãé ç½®ããWidgetã®Proportionãå ´åã«ãã£ã¦0ã«ãªã£ãã1ã«ãªã£ãããããä¸è¦è¦ªåãªããã ãã©ãã¾ãç確ã§ã¯ãªãã®ã§ãå ¨é¨èª¿ã¹ã¦æä¿®æ£ããã
å¤åãããªæãã
wxGladeãPythonã§ä½¿ãæ¹æ³
Gladeã®å ´åã¯Pythonã®ã¹ã¯ãªãããã*.gladeãã¡ã¤ã«ãç´æ¥èªã¿è¾¼ãã§ä½¿ãããwxGladeã®å ´åã¯wxGladeããPythonãã¡ã¤ã«ãã¸ã§ãã¬ã¼ããã¦ããã使ãããã£ã¡ã®æ¹ãå ¨é¨Pythonã§èªãã¦ä¾¿å©ããã
ããããwxGladeã§GUIããã度ã«ã¸ã§ãã¬ã¼ãããã¨ããã°Pythonã®ã½ã¼ã¹ã¯GUIé¨åã«é¢ãã¦ã¯å ¨ãããããªãããã¸ã§ãã¬ã¼ããããPythonã½ã¼ã¹ãã¬ã³ã¬ã³ãããã¨ããã°wxGladeã®æ©æµã«ãããããã®ã¯éçºã®åæã ãã¨ãããã¨ã«ãªãããã¼ããã©ã£ã¡ããããã ããã
ã¡ãªã¿ã«ã¸ã§ãã¬ã¼ããããPythonã½ã¼ã¹ã«ã¯ã¡ã¤ã³ã«ã¼ããæ¸ããã¦ããã®ã§ããã®ã¾ã¾å®è¡ããã°ã¡ã¤ã³ã¦ã¤ã³ãã¦ãèµ·åãããPythonãä¸è¡ãæ¸ããã«ããã¾ã§ãã©ãçããã¨ããã®ã¯çµæ§ããããããDelphiã¨ãLazarusã§ãã§ãããã ãã©ããGladeã¨ã¯ã ãã¶éããªãã¨ã
XRCedã«ããã
wxGladeã使ã£ã¦ãããããã«åé¡ã«ã¶ã¤ãã£ããwxGladeã§ã¯ããã¿ã³ãªã©ã®ç»åã®æå®ããã¡ã¤ã«åã§ããã§ããªãï¼å¤åï¼ãGladeã®ããã«stockç»åãå¼ã³åºããªããæçµçã«ã¯ãã¹ã¦ã®ç»åã¢ã¤ã³ã³ãèªä½ããäºå®ãªã®ã§ããã¯ããã§ãããã®ãããããªãããéçºéä¸ã«ã¯ã¨ããããä»®ã®ã¢ã¤ã³ã³ãé¸ã¹ãæ¹ã便å©ã ã
ããã§wxWidgetsä»å±ã®XRCedã使ã£ã¦ã¿ããããã¯GUIããã¬ãã¥ã¼ããã¦ä¸è¦RADã£ã½ãããããããªããXMLããªã¼ãç·¨éããããã®GUIã¨ãã£ã¿ã ãæ£ç´è¨ã£ã¦ãã¾ã親åãªãã¼ã«ãããªããç¹ã«ä½ãã¦ã£ã¸ã§ãããééã£ã¦é ç½®ãã¦ããã¨ãã«ã¯ãã¬ãã¥ã¼ããéã«ãããã ãªããã¨è¨ãããã®ãã¦ã¶ãï¼å ã«æãã¦ãããwï¼ãããwxGladeãããè¯ãç¹ãããã¤ããããã¾ããSizerã®è¡(å)ã®è¿½å ãä¸è¦ãªç¹ãSizerä¸ã«ã¦ã£ã¸ã§ãããã¬ã³ã¬ã³è¿½å ãã¦ããããã¨ã§Proportionã¨wxEXPANDã§èª¿æ´ãããSizerã®ç¸¦æ¨ªå¤æ´ããã¡ãã®æ¹ãç´æçãããããæ¬é¡ã®stockç»åã«ã¤ãã¦ã¯ãwxART_HOGEãæå®ã§ãããã»ãã¨ã¯ä¸è¦§è¡¨ã«ç»åãã®ãã®ã表示ããã¦ãã¨ãããã ãã©ãã¾ããããã¬ãã¥ã¼ãããããããã
ã¨ããããã§ãwxGladeã¯ä¸æ¢ãGUIã¨ãã£ã¿ã¯XRCedã«ãã¾ãã
æ¸ãå¿ãã¦ã¾ãããããXRCedã¯æ¥æ¬èªã使ããªããã¨ããæ å ±ãããã¤ããããä¸ã§è¦åãããã¾ãããã¡ããã¨ä½¿ãã¾ãã