PythonでGUI
- hiro2studio
- 2021年2月6日
- 読了時間: 1分
wxPythonを使ったGUIアプリ作成
とりあえずボタン押したらOKを表示するだけ
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import wx
class TestGUI(wx.Frame):
def __init__(self, parent, id=-1, title='TEST GUI'):
wx.Frame.__init__(self, parent, id, title)
self.SetTitle('TEST GUI')
self.SetSize((300, 200))
panel = wx.Panel(self)
# ボタンの作成
self.Btn = wx.Button(panel, label="push", pos=(130, 10), size=(60, 20))
# ラベルの作成
self.label = wx.StaticText(panel, -1, ' ', pos=(130, 50))
# ボタンを割り当て
self.Bind(wx.EVT_BUTTON, self.push, self.Btn)
self.Show(True)
def push(self, event):
self.label.SetLabel('OK')
#-------------------------------------------------
## main ###
#-------------------------------------------------
if __name__=='__main__':
app=wx.App()
TestGUI(None, wx.ID_ANY, "Btn")
app.MainLoop()

Comments