2012-02-19 19 views

答えて

1

これは簡単な例です。 self.buttonは、画像を含むディレクトリを選択します。任意のサムネイルのダブルクリックで、選択された親指に関する情報を含むメッセージボックスが表示されます。

import wx 
from wx.lib.agw import thumbnailctrl as tn 

class MyFrame(wx.Frame): 
    def __init__(self, *args, **kwds): 
     wx.Frame.__init__(self, *args, style=wx.DEFAULT_FRAME_STYLE) 
     self.button = wx.Button(self, -1, "Select dir") 
     self.Bind(wx.EVT_BUTTON, self.ButtonPress, self.button) 
     self.tn = tn.ThumbnailCtrl(self)  
     self.tn.Bind(tn.EVT_THUMBNAILS_DCLICK, self.TnClick) 

     box = wx.BoxSizer(wx.VERTICAL) 
     box.Add(self.tn, 1, wx.EXPAND, 0) 
     box.Add(self.button, 0, wx.ADJUST_MINSIZE, 0) 
     self.SetSizer(box) 
     box.Fit(self) 
     self.Layout() 

    def ButtonPress(self, evt): 
     dlg = wx.DirDialog(self, 'Get dir') 
     if dlg.ShowModal() == wx.ID_OK: 
     path = dlg.GetPath() 
     dlg.Destroy() 
     self.tn.ShowDir(path) 

    def TnClick(self, evt): 
     sel = self.tn.GetSelection() 
     wx.MessageBox(self.tn.GetThumbInfo(sel)) 

if __name__ == "__main__": 
    app = wx.PySimpleApp(0) 
    frame = MyFrame(None, -1, "") 
    frame.Show() 
    app.MainLoop() 
+0

非常にいい!!!!、。 – thelost

関連する問題