본문 바로가기
Programming/Python_Etc

wxpython 간단한 프레임 예제

by Wilkyway 2020. 6. 16.
반응형

 

간단한 윈도우 생성 후 마우스 버튼 클릭에 따라 색상 변하는 예제

import wx

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, parent=None, title="Window Color")
        self.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLButtonDown)
        self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRButtonDown)

    def OnMouseLButtonDown(self, event):
        self.SetBackgroundColour(wx.Colour(0, 0, 255, 0))
        self.Refresh()

    def OnMouseRButtonDown(self, event):
        self.SetBackgroundColour(wx.Colour(255, 0, 0, 0))
        self.Refresh()

if __name__ == "__main__":
    app = wx.App()
    frame = MyFrame()
    frame.Show()
    
    app.MainLoop()

반응형

'Programming > Python_Etc' 카테고리의 다른 글

wxpython 간단한 프레임 예제(FlexGridSizer)  (0) 2020.06.16
wxpython 간단한 프레임 예제(BoxSizer)  (0) 2020.06.16
Python - GUI에서 DB연결  (0) 2020.02.26
Python-Oracle연동  (0) 2020.02.25
Python GUI - tkinter 예제  (2) 2020.02.25

댓글