top of page

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()




 
 
 

最新記事

すべて表示
PythonでYAHOO検索もスクレイピング

前回Google検索結果のTOP100取ったのでYAHOOも追加。 YAHOOは10件ずつしか取れないので注意! #!/usr/bin/env python3 # -*- coding: utf-8 -*- # 指定のURLをブラウザで開く #...

 
 
 

Comments


記事: Blog2_Post

©2021 by 日々Python。Wix.com で作成されました。

bottom of page