본문 바로가기

Language/Python

[wxPython] 이벤트04 (사이즈 이벤트 예제 : wx.EVT_PAINT)

본 내용의 출처는 이글루 블로그의 '하린아빠' 라는 네임을 쓰시는 분의 블로그입니다.

[출처] - http://pythondev.egloos.com/104069


행여나 이글루 블로그가 없어지면 참고할 곳이 사라지기에 주인장님께 댓글을 남기고 퍼 옵니다.



[wxPython] 이벤트04 (사이즈 이벤트 예제 : wx.EVT_PAINT)



# -*- coding: cp949 -*-

#!/usr/bin/python
# paintevent.py

import wx

class PaintEvent(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title)
        # Paint 이벤트 함수와 연결
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Centre()

    # Paint 이벤트 처리함수
    def OnPaint(self, event):
        # 벨 울리기
        wx.Bell()


class MyApp(wx.App):
    def OnInit(self):
        pe = PaintEvent(None, -1, 'paintevent.py')
        pe.Show(True)
        return True

app = MyApp(0)
app.MainLoop()



[실행화면]


마우스로 창의 크기를 변경할 때 마다 벨 소리가 발생한다.