본문 바로가기

Language/Python

[wxPython] wx.StaticText를 이용한 문자열 출력

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

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


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





[wxPython] wx.StaticText를 이용한 문자열 출력



# -*- coding: cp949 -*-
#!/usr/bin/python

# statictext.py

import wx


class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(320, 350))

        lyrics1 = '''I'm giving up the ghost of love
                    in the shadows cast on devotion
                    She is the one that I adore
                    creed of my silent suffocation
                    Break this bittersweet spell on me
                    lost in the arms of destiny'''

        lyrics2 = '''There is something in the way
                    You're always somewhere else
                    Feelings have deserted me
                    To a point of no return
                    I don't believe in God
                    But I pray for you'''

        panel = wx.Panel(self, -1)
        
        # StaticText를 이용한 문자열 출력
        wx.StaticText(panel, -1, lyrics1, (45, 25), style=wx.ALIGN_CENTRE)
        wx.StaticText(panel, -1, lyrics2, (45, 190), style=wx.ALIGN_CENTRE)
        self.Centre()

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, 'statictext.py')
        frame.Show(True)
        self.SetTopWindow(frame)
        return True


app = MyApp(0)
app.MainLoop()

[실행 화면]