top of page

PythonでGUI開発:grid設置

  • hiro2studio
  • 2021年2月10日
  • 読了時間: 1分

とりあえずグリッド設置しただけ。

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


import wx
import wx.grid


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, 300))

        panel = wx.Panel(self)

        # ボタンの作成
        self.Btn = wx.Button(panel, label="push", pos=(120, 10), size=(60, 20))

        # ラベルの作成
        self.label = wx.StaticText(panel, -1, ' ', pos=(130, 50))

        # ボタンを割り当て
        self.Bind(wx.EVT_BUTTON, self.push, self.Btn)

        # コンボボックス
        self.cmb01 = wx.ComboBox(panel, wx.ID_ANY, 'select', choices=[], style=wx.CB_SIMPLE, pos=(60,80), size=(180,24))
        self.cmb01.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))

        self.cmb01.Append('FW', 1)
        self.cmb01.Append('MF', 2)
        self.cmb01.Append('DF', 3)

        # Grid
        self.grid = wx.grid.Grid(panel, pos=(30,120), size=(240,100))
        self.grid.CreateGrid(2, 2)
        self.grid.SetColLabelValue(0, "No")
        self.grid.SetColLabelValue(1, "Name")

        self.grid.SetCellValue(0,0,"7")
        self.grid.SetCellValue(0,1,"TEST")
        self.grid.SetCellValue(1,0,"10")
        self.grid.SetCellValue(1,1,"TET")
        self.Show(True)

        # コンボボックスイベント
        self.Bind(wx.EVT_COMBOBOX, self.cmb01select, self.cmb01)


    def push(self, event):
        self.label.SetLabel('OK')

    def cmb01select(self, event):
        print('Position:{}'.format(self.cmb01.GetValue()))
        self.label.SetLabel(self.cmb01.GetValue())


#-------------------------------------------------
## main ###
#-------------------------------------------------
if __name__=='__main__':

    app=wx.App()
    TestGUI(None, wx.ID_ANY, "Btn")
    app.MainLoop()

Grid操作を実装したいところ

 
 
 

最新記事

すべて表示
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