2013-08-15 2 views
0

X를 클릭하면 창을 숨기고, 도크 아이콘을 누르면 창을 나타낼 수 있도록 빈 프레임을 얻으려고합니다. 그것은 내가 예상했던 것보다 더 많은 도전이 될 것입니다. 나는 http://wiki.wxpython.org/Optimizing%20for%20Mac%20OS%20X/을 사용했지만 끝낼 수는 없습니다.Mac에서 WxPython으로 도크 아이콘을 활성화하십시오.

여기 내 코드입니다 :

import wx 

class Frame(wx.Frame): 
    def __init__(self): 
     wx.Frame.__init__(self, None, -1, "title",style=wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.CAPTION, size=(300,300)) 
    panel = wx.Panel(self) 


    def MacReopenApp(self, event): 
     print "Attempting to reveal the window." 

    def MacHideApp(self, event): 
     print "Attempting to hide the window." 


if __name__ == '__main__': 
    app = wx.App() 
    frame = Frame() 
    frame.Show() 
    app.MainLoop() 

답변

0

당신이 응용 프로그램에 그 이벤트 핸들러를 추가해야합니다 상태로 연결 문서. 현재 프레임에 정의했습니다. 따라서 wx.App을 확장하고 해당 이벤트 처리기를 정의하고 wx.App 대신 자신의 App을 인스턴스화해야합니다.

그래서 (단축 예 your link에서 복사)

:

class MyApp(wx.App): 
    def __init__(self, *args, **kwargs): 
     wx.App.__init__(self, *args, **kwargs) 

     # This catches events when the app is asked to activate by some other 
     # process 
     self.Bind(wx.EVT_ACTIVATE_APP, self.OnActivate) 

    #..... 

    def MacReopenApp(self): 
     """Called when the doc icon is clicked, and ???""" 
     self.BringWindowToFront() 

app = MyApp(False) 
app.MainLoop() 
관련 문제