Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- SwiftUI
- MAC
- MacOS
- Fine Tuning
- 파인튜닝
- 양자화
- 정보관리기술사
- OSX
- IOS
- Llama
- ai 모델 학습시키기
- vibe coding
- Xcode
- 클로드
- persona
- php
- finetuning
- apple gpu
- ollama
- AI
- Claude
- swift
- WWDC
- VirtualBox
- Quantization
- HTTP
- apache
- MCP
- LLM
- python
Archives
- Today
- Total
Project Jo
파이썬 UI 개발 wxPython 본문
| wxPython은 Python 프로그래밍 언어를 위한 크로스 플랫폼 GUI 툴킷입니다. Mac OS, Windows, Linux 및 Unix 기반 시스템과 같은 다양한 플랫폼에서 작동합니다. |
1. 설치
pip install wxpython
2. 화면 표시
import wx
class MainWindow(wx.Frame):
def __init__(self):
super().__init__(parent=None, title='TEST', size=wx.Size(500, 200))
base_sizer = wx.BoxSizer(orient=wx.VERTICAL)
self.SetSizer(base_sizer)
app = wx.App()
window = MainWindow()
window.Show()
app.MainLoop()
wx.Frame 을 상속받은 MainWindow 를 생성하고 보여준다.
초기화에서 parent 는 부모 윈도우, title 는 창의 제목, size 는 윈도우의 크기이다.
BoxSizer 의 orient 는 내부 화면의 정렬 방향 으로 VERTICAL 와 HORIZONTAL 이 있다.
3. 버튼 설정
self.button1 = wx.Button(self, label='메시지박스 띄우기')
self.button2 = wx.Button(self, label='끝내기')
base_sizer.Add(self.button1, proportion=1, flag=wx.ALL|wx.EXPAND)
base_sizer.Add(self.button2, proportion=1, flag=wx.ALL|wx.EXPAND)
self.button1.Bind(wx.EVT_BUTTON, self. OnButton1Click)
self.button2.Bind(wx.EVT_BUTTON, self. OnButton2Click)
def OnButton1Click(self, event):
wx.MessageBox('텍스트')
def OnButton2Click(self, event):
self.Close()
base_sizer 에 2개의 버튼을 생성해서 넣고, 버튼 호출 함수를 연결 하였다.
4. 최종 코드
import wx
class MainWindow(wx.Frame):
def __init__(self):
super().__init__(parent=None, title='TEST', size=wx.Size(500, 200))
base_sizer = wx.BoxSizer(orient=wx.VERTICAL)
self.SetSizer(base_sizer)
self.button1 = wx.Button(self, label='메시지박스 띄우기')
self.button2 = wx.Button(self, label='끝내기')
base_sizer.Add(self.button1, proportion=1, flag=wx.ALL|wx.EXPAND)
base_sizer.Add(self.button2, proportion=1, flag=wx.ALL|wx.EXPAND)
self.button1.Bind(wx.EVT_BUTTON, self. OnButton1Click)
self.button2.Bind(wx.EVT_BUTTON, self. OnButton2Click)
def OnButton1Click(self, event):
wx.MessageBox('텍스트:' + self.text_box.GetValue())
def OnButton2Click(self, event):
self.Close()
app = wx.App()
window = MainWindow()
window.Show()
app.MainLoop()'Developer' 카테고리의 다른 글
| WSL (Windows Subsystem for Linux) (0) | 2025.05.20 |
|---|---|
| Xcode 용량 확보 (0) | 2025.05.07 |
| compiling for java version '1.7' is no longer supported. minimal supported version is '1.8' eclipse (0) | 2025.04.04 |
| MAC + Python + VS Code (0) | 2025.02.28 |
| MAC OS 클린 설치 (0) | 2025.02.28 |