#================================================================
#================================================================
# API-DIO(WDM)
# デジタル入力カウンタサンプル
# main UIファイル
#                                                CONTEC Co., Ltd.
#================================================================
#================================================================
#----------------------------------------
# インポートモジュール
#----------------------------------------
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox


#========================================
# DiCounterUI クラス
#========================================
class DiCounterUI:
    #========================================
    # 初期化関数
    #========================================
    def __init__(self):
        #----------------------------------------
        # メイン画面の作成開始
        #----------------------------------------
        self.root = tk.Tk()
        #----------------------------------------
        # タイトル
        #----------------------------------------
        self.root.title('デジタル入力カウンタ')
        self.root.minsize(660,330)
        #----------------------------------------
        # コントロールのフォントを設定
        #----------------------------------------
        self.root.option_add("*Font", ("MS Gothic", 9))
        #----------------------------------------
        # UIの作成を開始
        #----------------------------------------
        self._create_ui()

    #========================================
    # UIの作成関数
    #========================================
    def _create_ui(self):
        #----------------------------------------
        # 初期化処理
        #----------------------------------------
        #--------------------
        # デバイス名のLabelを作成
        #--------------------
        tk.Label(self.root, text='デバイス名 : ', anchor='nw').place(x=45, y=20, width=90, height=19)
        #--------------------
        # デバイス名のEntryを作成
        #--------------------
        self.textbox_device_name_var = tk.StringVar(self.root)
        self.textbox_device_name_var.set('DIO000')
        tk.Entry(self.root, textvariable=self.textbox_device_name_var).place(x=125, y=20, width=90, height=19)
        #--------------------
        # DioInitのButtonを作成
        #--------------------
        self.button_dio_init = tk.Button(self.root, text='DioInit')
        self.button_dio_init.place(x=520, y=20, width=130, height=19)
        #----------------------------------------
        # 設定値のLabelFrameを作成
        #----------------------------------------
        self.groupbox_setting_value = tk.LabelFrame(self.root, text="設定値")
        self.groupbox_setting_value.place(x=45, y=50, width=275, height=225)
        #--------------------
        # カウントエッジのLabelを作成
        #--------------------
        tk.Label(self.groupbox_setting_value, text='カウントエッジ', anchor='nw').place(x=5, y=1, width=90, height=19)
        #--------------------
        # 比較レジスタ値のLabelを作成
        #--------------------
        tk.Label(self.groupbox_setting_value, text='比較レジスタ値\n[Dec]', anchor='nw', justify=tk.RIGHT).place(x=95, y=1, width=90, height=29)
        #--------------------
        # プリセット値のLabelを作成
        #--------------------
        tk.Label(self.groupbox_setting_value, text='プリセット値\n[Dec]', anchor='nw', justify=tk.RIGHT).place(x=190, y=1, width=80, height=29)
        #----------------------------------------
        # 取得値のLabelFrameを作成
        #----------------------------------------
        self.groupbox_getting_value = tk.LabelFrame(self.root, text="取得値")
        self.groupbox_getting_value.place(x=330, y=50, width=185, height=225)
        #--------------------
        # カウント値のLabelを作成
        #--------------------
        tk.Label(self.groupbox_getting_value, text='カウント値\n[Dec]', anchor='nw', justify=tk.RIGHT).place(x=25, y=1, width=90, height=29)
        #--------------------
        # ステータスのLabelを作成
        #--------------------
        tk.Label(self.groupbox_getting_value, text='ステータス\n[Hex]', anchor='nw', justify=tk.RIGHT).place(x=115, y=1, width=60, height=29)
        #--------------------
        # Ch0のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 0:', anchor='nw').place(x=10, y=95, width=30, height=19)
        #--------------------
        # Ch0のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge0 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge0.place(x=5, y=30, width=80, height=20)
        self.combobox_count_edge0['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge0['state'] = 'readonly'
        self.combobox_count_edge0.current(0)
        #--------------------
        # Ch0の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value0_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value0_var.set("100")
        self.textbox_compare_count_value0 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value0_var, justify=tk.RIGHT)
        self.textbox_compare_count_value0.place(x=95, y=30, width=80, height=19)
        #--------------------
        # Ch0のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value0_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value0_var.set("0")
        self.textbox_preset_value0 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value0_var, justify=tk.RIGHT)
        self.textbox_preset_value0.place(x=185, y=30, width=80, height=19)
        #--------------------
        # Ch0のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value0_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value0_var.set("-")
        self.textbox_count_value0 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value0_var, justify=tk.RIGHT)
        self.textbox_count_value0.place(x=5, y=30, width=80, height=19)
        #--------------------
        # Ch0のステータスのEntryを作成
        #--------------------
        self.textbox_count_status0_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status0_var.set("-")
        self.textbox_count_status0 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status0_var, justify=tk.RIGHT)
        self.textbox_count_status0.place(x=95, y=30, width=80, height=19)
        #--------------------
        # Ch1のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 1:', anchor='nw').place(x=10, y=117, width=30, height=19)
        #--------------------
        # Ch1のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge1 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge1.place(x=5, y=52, width=80, height=20)
        self.combobox_count_edge1['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge1['state'] = 'readonly'
        self.combobox_count_edge1.current(0)
        #--------------------
        # Ch1の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value1_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value1_var.set("200")
        self.textbox_compare_count_value1 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value1_var, justify=tk.RIGHT)
        self.textbox_compare_count_value1.place(x=95, y=52, width=80, height=19)
        #--------------------
        # Ch1のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value1_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value1_var.set("100")
        self.textbox_preset_value1 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value1_var, justify=tk.RIGHT)
        self.textbox_preset_value1.place(x=185, y=52, width=80, height=19)
        #--------------------
        # Ch1のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value1_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value1_var.set("-")
        self.textbox_count_value1 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value1_var, justify=tk.RIGHT)
        self.textbox_count_value1.place(x=5, y=52, width=80, height=19)
        #--------------------
        # Ch1のステータスのEntryを作成
        #--------------------
        self.textbox_count_status1_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status1_var.set("-")
        self.textbox_count_status1 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status1_var, justify=tk.RIGHT)
        self.textbox_count_status1.place(x=95, y=52, width=80, height=19)
        #--------------------
        # Ch2のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 2:', anchor='nw').place(x=10, y=139, width=30, height=19)
        #--------------------
        # Ch2のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge2 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge2.place(x=5, y=74, width=80, height=20)
        self.combobox_count_edge2['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge2['state'] = 'readonly'
        self.combobox_count_edge2.current(0)
        #--------------------
        # Ch2の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value2_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value2_var.set("300")
        self.textbox_compare_count_value2 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value2_var, justify=tk.RIGHT)
        self.textbox_compare_count_value2.place(x=95, y=74, width=80, height=19)
        #--------------------
        # Ch2のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value2_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value2_var.set("200")
        self.textbox_preset_value2 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value2_var, justify=tk.RIGHT)
        self.textbox_preset_value2.place(x=185, y=74, width=80, height=19)
        #--------------------
        # Ch2のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value2_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value2_var.set("-")
        self.textbox_count_value2 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value2_var, justify=tk.RIGHT)
        self.textbox_count_value2.place(x=5, y=74, width=80, height=19)
        #--------------------
        # Ch2のステータスのEntryを作成
        #--------------------
        self.textbox_count_status2_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status2_var.set("-")
        self.textbox_count_status2 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status2_var, justify=tk.RIGHT)
        self.textbox_count_status2.place(x=95, y=74, width=80, height=19)
        #--------------------
        # Ch3のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 3:', anchor='nw').place(x=10, y=161, width=30, height=19)
        #--------------------
        # Ch3のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge3 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge3.place(x=5, y=96, width=80, height=20)
        self.combobox_count_edge3['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge3['state'] = 'readonly'
        self.combobox_count_edge3.current(0)
        #--------------------
        # Ch3の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value3_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value3_var.set("400")
        self.textbox_compare_count_value3 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value3_var, justify=tk.RIGHT)
        self.textbox_compare_count_value3.place(x=95, y=96, width=80, height=19)
        #--------------------
        # Ch3のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value3_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value3_var.set("300")
        self.textbox_preset_value3 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value3_var, justify=tk.RIGHT)
        self.textbox_preset_value3.place(x=185, y=96, width=80, height=19)
        #--------------------
        # Ch3のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value3_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value3_var.set("-")
        self.textbox_count_value3 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value3_var, justify=tk.RIGHT)
        self.textbox_count_value3.place(x=5, y=96, width=80, height=19)
        #--------------------
        # Ch3のステータスのEntryを作成
        #--------------------
        self.textbox_count_status3_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status3_var.set("-")
        self.textbox_count_status3 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status3_var, justify=tk.RIGHT)
        self.textbox_count_status3.place(x=95, y=96, width=80, height=19)
        #--------------------
        # Ch4のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 4:', anchor='nw').place(x=10, y=183, width=30, height=19)
        #--------------------
        # Ch4のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge4 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge4.place(x=5, y=118, width=80, height=20)
        self.combobox_count_edge4['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge4['state'] = 'readonly'
        self.combobox_count_edge4.current(0)
        #--------------------
        # Ch4の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value4_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value4_var.set("500")
        self.textbox_compare_count_value4 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value4_var, justify=tk.RIGHT)
        self.textbox_compare_count_value4.place(x=95, y=118, width=80, height=19)
        #--------------------
        # Ch4のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value4_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value4_var.set("400")
        self.textbox_preset_value4 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value4_var, justify=tk.RIGHT)
        self.textbox_preset_value4.place(x=185, y=118, width=80, height=19)
        #--------------------
        # Ch4のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value4_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value4_var.set("-")
        self.textbox_count_value4 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value4_var, justify=tk.RIGHT)
        self.textbox_count_value4.place(x=5, y=118, width=80, height=19)
        #--------------------
        # Ch4のステータスのEntryを作成
        #--------------------
        self.textbox_count_status4_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status4_var.set("-")
        self.textbox_count_status4 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status4_var, justify=tk.RIGHT)
        self.textbox_count_status4.place(x=95, y=118, width=80, height=19)
        #--------------------
        # Ch5のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 5:', anchor='nw').place(x=10, y=205, width=30, height=19)
        #--------------------
        # Ch5のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge5 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge5.place(x=5, y=140, width=80, height=20)
        self.combobox_count_edge5['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge5['state'] = 'readonly'
        self.combobox_count_edge5.current(0)
        #--------------------
        # Ch5の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value5_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value5_var.set("600")
        self.textbox_compare_count_value5 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value5_var, justify=tk.RIGHT)
        self.textbox_compare_count_value5.place(x=95, y=140, width=80, height=19)
        #--------------------
        # Ch5のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value5_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value5_var.set("500")
        self.textbox_preset_value5 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value5_var, justify=tk.RIGHT)
        self.textbox_preset_value5.place(x=185, y=140, width=80, height=19)
        #--------------------
        # Ch5のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value5_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value5_var.set("-")
        self.textbox_count_value5 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value5_var, justify=tk.RIGHT)
        self.textbox_count_value5.place(x=5, y=140, width=80, height=19)
        #--------------------
        # Ch5のステータスのEntryを作成
        #--------------------
        self.textbox_count_status5_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status5_var.set("-")
        self.textbox_count_status5 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status5_var, justify=tk.RIGHT)
        self.textbox_count_status5.place(x=95, y=140, width=80, height=19)
        #--------------------
        # Ch6のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 6:', anchor='nw').place(x=10, y=227, width=30, height=19)
        #--------------------
        # Ch6のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge6 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge6.place(x=5, y=162, width=80, height=20)
        self.combobox_count_edge6['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge6['state'] = 'readonly'
        self.combobox_count_edge6.current(0)
        #--------------------
        # Ch6の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value6_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value6_var.set("700")
        self.textbox_compare_count_value6 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value6_var, justify=tk.RIGHT)
        self.textbox_compare_count_value6.place(x=95, y=162, width=80, height=19)
        #--------------------
        # Ch6のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value6_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value6_var.set("600")
        self.textbox_preset_value6 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value6_var, justify=tk.RIGHT)
        self.textbox_preset_value6.place(x=185, y=162, width=80, height=19)
        #--------------------
        # Ch6のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value6_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value6_var.set("-")
        self.textbox_count_value6 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value6_var, justify=tk.RIGHT)
        self.textbox_count_value6.place(x=5, y=162, width=80, height=19)
        #--------------------
        # Ch6のステータスのEntryを作成
        #--------------------
        self.textbox_count_status6_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status6_var.set("-")
        self.textbox_count_status6 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status6_var, justify=tk.RIGHT)
        self.textbox_count_status6.place(x=95, y=162, width=80, height=19)
        #--------------------
        # Ch7のLabelを作成
        #--------------------
        tk.Label(self.root, text='Ch 7:', anchor='nw').place(x=10, y=249, width=30, height=19)
        #--------------------
        # Ch7のカウントエッジのComboboxを作成
        #--------------------
        self.combobox_count_edge7 = ttk.Combobox(self.groupbox_setting_value)
        self.combobox_count_edge7.place(x=5, y=184, width=80, height=20)
        self.combobox_count_edge7['value'] = ('立上り', '立下り', '両方')
        self.combobox_count_edge7['state'] = 'readonly'
        self.combobox_count_edge7.current(0)
        #--------------------
        # Ch7の比較レジスタ値のEntryを作成
        #--------------------
        self.textbox_compare_count_value7_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_compare_count_value7_var.set("800")
        self.textbox_compare_count_value7 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_compare_count_value7_var, justify=tk.RIGHT)
        self.textbox_compare_count_value7.place(x=95, y=184, width=80, height=19)
        #--------------------
        # Ch7のプリセット値のEntryを作成
        #--------------------
        self.textbox_preset_value7_var = tk.StringVar(self.groupbox_setting_value)
        self.textbox_preset_value7_var.set("700")
        self.textbox_preset_value7 = tk.Entry(self.groupbox_setting_value, textvariable=self.textbox_preset_value7_var, justify=tk.RIGHT)
        self.textbox_preset_value7.place(x=185, y=184, width=80, height=19)
        #--------------------
        # Ch7のカウント値のEntryを作成
        #--------------------
        self.textbox_count_value7_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_value7_var.set("-")
        self.textbox_count_value7 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_value7_var, justify=tk.RIGHT)
        self.textbox_count_value7.place(x=5, y=184, width=80, height=19)
        #--------------------
        # Ch7のステータスのEntryを作成
        #--------------------
        self.textbox_count_status7_var = tk.StringVar(self.groupbox_getting_value)
        self.textbox_count_status7_var.set("-")
        self.textbox_count_status7 = tk.Entry(self.groupbox_getting_value, textvariable=self.textbox_count_status7_var, justify=tk.RIGHT)
        self.textbox_count_status7.place(x=95, y=184, width=80, height=19)
        #--------------------
        # DioSetCountEdgeのButtonを作成
        #--------------------
        self.button_dio_set_count_edge = tk.Button(self.root, text='DioSetCountEdge')
        self.button_dio_set_count_edge.place(x=520, y=50, width=130, height=19)
        #--------------------
        # DioSetCountMatchValueのButtonを作成
        #--------------------
        self.button_dio_set_count_match_value = tk.Button(self.root, text='DioSetCountMatchValue')
        self.button_dio_set_count_match_value.place(x=520, y=80, width=130, height=19)
        #--------------------
        # DioStartCountのButtonを作成
        #--------------------
        self.button_dio_start_count = tk.Button(self.root, text='DioStartCount')
        self.button_dio_start_count.place(x=520, y=110, width=130, height=19)
        #--------------------
        # DioReadCountのButtonを作成
        #--------------------
        self.button_dio_read_count = tk.Button(self.root, text='DioReadCount')
        self.button_dio_read_count.place(x=520, y=140, width=130, height=19)
        #--------------------
        # DioGetCountStatusのButtonを作成
        #--------------------
        self.button_dio_get_count_status = tk.Button(self.root, text='DioGetCountStatus')
        self.button_dio_get_count_status.place(x=520, y=170, width=130, height=19)
        #--------------------
        # DioCountPresetのButtonを作成
        #--------------------
        self.button_dio_count_preset = tk.Button(self.root, text='DioCountPreset')
        self.button_dio_count_preset.place(x=520, y=200, width=130, height=19)
        #--------------------
        # DioStopCountのButtonを作成
        #--------------------
        self.button_dio_stop_count = tk.Button(self.root, text='DioStopCount')
        self.button_dio_stop_count.place(x=520, y=230, width=130, height=19)
        #----------------------------------------
        # 終了
        #----------------------------------------
        #--------------------
        # 戻り値のLabelを作成
        #--------------------
        tk.Label(self.root, text='戻り値 : ', anchor='nw').place(x=10, y=290, width=90, height=19)
        #--------------------
        # 戻り値のEntryを作成
        #--------------------
        self.textbox_return_string_var= tk.StringVar(self.root)
        tk.Entry(self.root, textvariable=self.textbox_return_string_var).place(x=70, y=290, width=443, height=19)
        #--------------------
        # DioExitのButtonを作成
        #--------------------
        self.button_dio_exit = tk.Button(self.root, text='DioExit')
        self.button_dio_exit.place(x=520, y=260, width=130, height=19)
        #--------------------
        # ExitのButtonを作成
        #--------------------
        self.button_exit = tk.Button(self.root, text='Exit')
        self.button_exit.place(x=520, y=290, width=130, height=19)

    #========================================
    # UIコントロールのコールバック関数を設定する関数
    #========================================
    def setup_commands(self,
                       command_dio_init,
                       command_dio_set_count_edge,
                       command_dio_set_count_match_value,
                       command_dio_start_count,
                       command_dio_read_count,
                       command_dio_get_count_status,
                       command_dio_count_preset,
                       command_dio_stop_count,
                       command_dio_exit,
                       command_exit):
        #----------------------------------------
        # 「DioInit」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_init.configure(command=command_dio_init)
        #----------------------------------------
        # 「DioSetCountEdge」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_set_count_edge.configure(command=command_dio_set_count_edge)
        #----------------------------------------
        # 「DioSetCountMatchValue」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_set_count_match_value.configure(command=command_dio_set_count_match_value)
        #----------------------------------------
        # 「DioStartCount」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_start_count.configure(command=command_dio_start_count)
        #----------------------------------------
        # 「DioReadCount」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_read_count.configure(command=command_dio_read_count)
        #----------------------------------------
        # 「DioGetCountStatus」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_get_count_status.configure(command=command_dio_get_count_status)
        #----------------------------------------
        # 「DioCountPreset」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_count_preset.configure(command=command_dio_count_preset)
        #----------------------------------------
        # 「DioStopCount」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_stop_count.configure(command=command_dio_stop_count)
        #----------------------------------------
        # 「DioExit」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_exit.configure(command=command_dio_exit)
        #----------------------------------------
        # 「Exit」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_exit.configure(command=command_exit)

    #========================================
    # メッセージボックスにエラーを表示
    #========================================
    def show_error(self, caption, error):
        messagebox.showerror(caption, error, parent=self.root)

    #========================================
    # メインイベントループを実行
    #========================================
    def run(self):
        self.root.mainloop()