#================================================================
#================================================================
# API-DIO(WDM)
# 複数ポート／ビット I/O サンプル
# main UIファイル
#                                                CONTEC Co., Ltd.
#================================================================
#================================================================
#----------------------------------------
# インポートモジュール
#----------------------------------------
import tkinter as tk
from tkinter import messagebox


#========================================
# MultiIOUI クラス
#========================================
class MultiIOUI:
    #========================================
    # 初期化関数
    #========================================
    def __init__(self):
        #----------------------------------------
        # メイン画面の作成開始
        #----------------------------------------
        self.root = tk.Tk()
        #----------------------------------------
        # タイトル
        #----------------------------------------
        self.root.title('複数ポート／ビット I/O')
        self.root.minsize(475,490)
        #----------------------------------------
        # コントロールのフォントを設定
        #----------------------------------------
        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=20, 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=110, y=20, width=90, height=19)
        #--------------------
        # DioInitのButtonを作成
        #--------------------
        self.button_dio_init = tk.Button(self.root, text='DioInit')
        self.button_dio_init.place(x=342, y=20, width=110, height=19)
        #----------------------------------------
        # 入出力設定のLabelFrameを作成
        #----------------------------------------
        self.groupbox_dir_settings = tk.LabelFrame(self.root, text="入出力設定")
        self.groupbox_dir_settings.place(x=15, y=60, width=450, height=62)
        #--------------------
        # 入出力方向のLabelを作成
        #--------------------
        tk.Label(self.groupbox_dir_settings, text='入出力方向 : ', anchor='nw').place(x=10, y=10, width=90, height=19)
        #--------------------
        # 入出力方向のEntryを作成
        #--------------------
        self.textbox_dir_var = tk.StringVar(self.groupbox_dir_settings)
        tk.Entry(self.groupbox_dir_settings, textvariable=self.textbox_dir_var, justify=tk.RIGHT).place(x=103, y=10, width=60, height=19)
        #--------------------
        # DioSetIoDirectionのButtonを作成
        #--------------------
        self.button_dio_set_io_direction = tk.Button(self.groupbox_dir_settings, text='DioSetIoDirection')
        self.button_dio_set_io_direction.place(x=325, y=10, width=110, height=19)
        #----------------------------------------
        # 複数ポート入力のLabelFrameを作成
        #----------------------------------------
        self.groupbox_inp_port = tk.LabelFrame(self.root, text="複数ポート入力")
        self.groupbox_inp_port.place(x=15, y=130, width=450, height=65)
        #--------------------
        # ポートデータのLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='ポートデータ : ', anchor='nw').place(x=10, y=20, width=90, height=19)
        #--------------------
        # ポート0のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # ポート0のEntryを作成
        #--------------------
        self.textbox_inp_port_data0_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data0 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data0_var, justify=tk.RIGHT)
        self.textbox_inp_port_data0.place(x=103, y=20, width=20, height=19)
        #--------------------
        # ポート1のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # ポート1のEntryを作成
        #--------------------
        self.textbox_inp_port_data1_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data1 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data1_var, justify=tk.RIGHT)
        self.textbox_inp_port_data1.place(x=130, y=20, width=20, height=19)
        #--------------------
        # ポート2のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # ポート2のEntryを作成
        #--------------------
        self.textbox_inp_port_data2_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data2 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data2_var, justify=tk.RIGHT)
        self.textbox_inp_port_data2.place(x=157, y=20, width=20, height=19)
        #--------------------
        # ポート3のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # ポート3のEntryを作成
        #--------------------
        self.textbox_inp_port_data3_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data3 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data3_var, justify=tk.RIGHT)
        self.textbox_inp_port_data3.place(x=184, y=20, width=20, height=19)
        #--------------------
        # ポート4のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # ポート4のEntryを作成
        #--------------------
        self.textbox_inp_port_data4_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data4 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data4_var, justify=tk.RIGHT)
        self.textbox_inp_port_data4.place(x=211, y=20, width=20, height=19)
        #--------------------
        # ポート5のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # ポート5のEntryを作成
        #--------------------
        self.textbox_inp_port_data5_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data5 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data5_var, justify=tk.RIGHT)
        self.textbox_inp_port_data5.place(x=238, y=20, width=20, height=19)
        #--------------------
        # ポート6のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # ポート6のEntryを作成
        #--------------------
        self.textbox_inp_port_data6_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data6 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data6_var, justify=tk.RIGHT)
        self.textbox_inp_port_data6.place(x=265, y=20, width=20, height=19)
        #--------------------
        # ポート7のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_port, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # ポート7のEntryを作成
        #--------------------
        self.textbox_inp_port_data7_var = tk.StringVar(self.groupbox_inp_port)
        self.textbox_inp_port_data7 = tk.Entry(self.groupbox_inp_port, textvariable=self.textbox_inp_port_data7_var, justify=tk.RIGHT)
        self.textbox_inp_port_data7.place(x=292, y=20, width=20, height=19)
        #--------------------
        # DioInpMultiByteのButtonを作成
        #--------------------
        self.button_dio_inp_multi_byte = tk.Button(self.groupbox_inp_port, text='DioInpMultiByte')
        self.button_dio_inp_multi_byte.place(x=325, y=10, width=110, height=19)
        #----------------------------------------
        # 複数ビット入力のLabelFrameを作成
        #----------------------------------------
        self.groupbox_inp_bit = tk.LabelFrame(self.root, text="複数ビット入力")
        self.groupbox_inp_bit.place(x=15, y=200, width=450, height=65)
        #--------------------
        # ビットデータのLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='ビットデータ : ', anchor='nw').place(x=10, y=20, width=90, height=19)
        #--------------------
        # ビット0のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # ビット0のEntryを作成
        #--------------------
        self.textbox_inp_bit_data0_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data0 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data0_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data0.place(x=103, y=20, width=20, height=19)
        #--------------------
        # ビット1のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # ビット1のEntryを作成
        #--------------------
        self.textbox_inp_bit_data1_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data1 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data1_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data1.place(x=130, y=20, width=20, height=19)
        #--------------------
        # ビット2のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # ビット2のEntryを作成
        #--------------------
        self.textbox_inp_bit_data2_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data2 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data2_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data2.place(x=157, y=20, width=20, height=19)
        #--------------------
        # ビット3のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # ビット3のEntryを作成
        #--------------------
        self.textbox_inp_bit_data3_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data3 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data3_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data3.place(x=184, y=20, width=20, height=19)
        #--------------------
        # ビット4のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # ビット4のEntryを作成
        #--------------------
        self.textbox_inp_bit_data4_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data4 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data4_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data4.place(x=211, y=20, width=20, height=19)
        #--------------------
        # ビット5のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # ビット5のEntryを作成
        #--------------------
        self.textbox_inp_bit_data5_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data5 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data5_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data5.place(x=238, y=20, width=20, height=19)
        #--------------------
        # ビット6のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # ビット6のEntryを作成
        #--------------------
        self.textbox_inp_bit_data6_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data6 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data6_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data6.place(x=265, y=20, width=20, height=19)
        #--------------------
        # ビット7のLabelを作成
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # ビット7のEntryを作成
        #--------------------
        self.textbox_inp_bit_data7_var = tk.StringVar(self.groupbox_inp_bit)
        self.textbox_inp_bit_data7 = tk.Entry(self.groupbox_inp_bit, textvariable=self.textbox_inp_bit_data7_var, justify=tk.RIGHT)
        self.textbox_inp_bit_data7.place(x=292, y=20, width=20, height=19)
        #--------------------
        # DioInpMultiBitのButtonを作成
        #--------------------
        self.button_dio_inp_multi_bit = tk.Button(self.groupbox_inp_bit, text='DioInpMultiBit')
        self.button_dio_inp_multi_bit.place(x=325, y=10, width=110, height=19)
        #----------------------------------------
        # 複数ポート出力のLabelFrameを作成
        #----------------------------------------
        self.groupbox_out_port = tk.LabelFrame(self.root, text="複数ポート出力")
        self.groupbox_out_port.place(x=15, y=270, width=450, height=65)
        #--------------------
        # ポートデータのLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='ポートデータ : ', anchor='nw').place(x=10, y=20, width=90, height=19)
        #--------------------
        # ポート0のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # ポート0のEntryを作成
        #--------------------
        self.textbox_out_port_data0_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data0_var.set("11")
        self.textbox_out_port_data0 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data0_var, justify=tk.RIGHT)
        self.textbox_out_port_data0.place(x=103, y=20, width=20, height=19)
        #--------------------
        # ポート1のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # ポート1のEntryを作成
        #--------------------
        self.textbox_out_port_data1_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data1_var.set("22")
        self.textbox_out_port_data1 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data1_var, justify=tk.RIGHT)
        self.textbox_out_port_data1.place(x=130, y=20, width=20, height=19)
        #--------------------
        # ポート2のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # ポート2のEntryを作成
        #--------------------
        self.textbox_out_port_data2_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data2_var.set("33")
        self.textbox_out_port_data2 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data2_var, justify=tk.RIGHT)
        self.textbox_out_port_data2.place(x=157, y=20, width=20, height=19)
        #--------------------
        # ポート3のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # ポート3のEntryを作成
        #--------------------
        self.textbox_out_port_data3_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data3_var.set("44")
        self.textbox_out_port_data3 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data3_var, justify=tk.RIGHT)
        self.textbox_out_port_data3.place(x=184, y=20, width=20, height=19)
        #--------------------
        # ポート4のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # ポート4のEntryを作成
        #--------------------
        self.textbox_out_port_data4_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data4_var.set("55")
        self.textbox_out_port_data4 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data4_var, justify=tk.RIGHT)
        self.textbox_out_port_data4.place(x=211, y=20, width=20, height=19)
        #--------------------
        # ポート5のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # ポート5のEntryを作成
        #--------------------
        self.textbox_out_port_data5_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data5_var.set("66")
        self.textbox_out_port_data5 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data5_var, justify=tk.RIGHT)
        self.textbox_out_port_data5.place(x=238, y=20, width=20, height=19)
        #--------------------
        # ポート6のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # ポート6のEntryを作成
        #--------------------
        self.textbox_out_port_data6_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data6_var.set("77")
        self.textbox_out_port_data6 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data6_var, justify=tk.RIGHT)
        self.textbox_out_port_data6.place(x=265, y=20, width=20, height=19)
        #--------------------
        # ポート7のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_port, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # ポート7のEntryを作成
        #--------------------
        self.textbox_out_port_data7_var = tk.StringVar(self.groupbox_out_port)
        self.textbox_out_port_data7_var.set("88")
        self.textbox_out_port_data7 = tk.Entry(self.groupbox_out_port, textvariable=self.textbox_out_port_data7_var, justify=tk.RIGHT)
        self.textbox_out_port_data7.place(x=292, y=20, width=20, height=19)
        #--------------------
        # DioOutMultiByteのButtonを作成
        #--------------------
        self.button_dio_out_multi_byte = tk.Button(self.groupbox_out_port, text='DioOutMultiByte')
        self.button_dio_out_multi_byte.place(x=325, y=10, width=110, height=19)
        #----------------------------------------
        # 複数ビット出力のLabelFrameを作成
        #----------------------------------------
        self.groupbox_out_bit = tk.LabelFrame(self.root, text="複数ビット出力")
        self.groupbox_out_bit.place(x=15, y=340, width=450, height=65)
        #--------------------
        # ビットデータのLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='ビットデータ : ', anchor='nw').place(x=10, y=20, width=90, height=19)
        #--------------------
        # ビット0のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # ビット0のEntryを作成
        #--------------------
        self.textbox_out_bit_data0_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data0_var.set("1")
        self.textbox_out_bit_data0 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data0_var, justify=tk.RIGHT)
        self.textbox_out_bit_data0.place(x=103, y=20, width=20, height=19)
        #--------------------
        # ビット1のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # ビット1のEntryを作成
        #--------------------
        self.textbox_out_bit_data1_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data1_var.set("0")
        self.textbox_out_bit_data1 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data1_var, justify=tk.RIGHT)
        self.textbox_out_bit_data1.place(x=130, y=20, width=20, height=19)
        #--------------------
        # ビット2のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # ビット2のEntryを作成
        #--------------------
        self.textbox_out_bit_data2_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data2_var.set("1")
        self.textbox_out_bit_data2 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data2_var, justify=tk.RIGHT)
        self.textbox_out_bit_data2.place(x=157, y=20, width=20, height=19)
        #--------------------
        # ビット3のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # ビット3のEntryを作成
        #--------------------
        self.textbox_out_bit_data3_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data3_var.set("0")
        self.textbox_out_bit_data3 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data3_var, justify=tk.RIGHT)
        self.textbox_out_bit_data3.place(x=184, y=20, width=20, height=19)
        #--------------------
        # ビット4のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # ビット4のEntryを作成
        #--------------------
        self.textbox_out_bit_data4_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data4_var.set("1")
        self.textbox_out_bit_data4 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data4_var, justify=tk.RIGHT)
        self.textbox_out_bit_data4.place(x=211, y=20, width=20, height=19)
        #--------------------
        # ビット5のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # ビット5のEntryを作成
        #--------------------
        self.textbox_out_bit_data5_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data5_var.set("0")
        self.textbox_out_bit_data5 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data5_var, justify=tk.RIGHT)
        self.textbox_out_bit_data5.place(x=238, y=20, width=20, height=19)
        #--------------------
        # ビット6のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # ビット6のEntryを作成
        #--------------------
        self.textbox_out_bit_data6_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data6_var.set("1")
        self.textbox_out_bit_data6 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data6_var, justify=tk.RIGHT)
        self.textbox_out_bit_data6.place(x=265, y=20, width=20, height=19)
        #--------------------
        # ビット7のLabelを作成
        #--------------------
        tk.Label(self.groupbox_out_bit, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # ビット7のEntryを作成
        #--------------------
        self.textbox_out_bit_data7_var = tk.StringVar(self.groupbox_out_bit)
        self.textbox_out_bit_data7_var.set("0")
        self.textbox_out_bit_data7 = tk.Entry(self.groupbox_out_bit, textvariable=self.textbox_out_bit_data7_var, justify=tk.RIGHT)
        self.textbox_out_bit_data7.place(x=292, y=20, width=20, height=19)
        #--------------------
        # DioOutMultiBitのButtonを作成
        #--------------------
        self.button_dio_out_multi_bit = tk.Button(self.groupbox_out_bit, text='DioOutMultiBit')
        self.button_dio_out_multi_bit.place(x=325, y=10, width=110, height=19)
        #----------------------------------------
        # 終了
        #----------------------------------------
        #--------------------
        # 戻り値のLabelを作成
        #--------------------
        tk.Label(self.root, text='戻り値 : ', anchor='nw').place(x=20, y=420, 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=75, y=420, width=250, height=19)
        #--------------------
        # DioExitのButtonを作成
        #--------------------
        self.button_dio_exit = tk.Button(self.root, text='DioExit')
        self.button_dio_exit.place(x=342, y=420, width=110, height=19)
        #--------------------
        # ExitのButtonを作成
        #--------------------
        self.button_exit = tk.Button(self.root, text='Exit')
        self.button_exit.place(x=342, y=450, width=110, height=19)

    #========================================
    # UIコントロールのコールバック関数を設定する関数
    #========================================
    def setup_commands(self,
                       command_dio_init,
                       command_dio_set_io_direction,
                       command_dio_inp_multi_byte,
                       command_dio_inp_multi_bit,
                       command_dio_out_multi_byte,
                       command_dio_out_multi_bit,
                       command_dio_exit,
                       command_exit):
        #----------------------------------------
        # 「DioInit」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_init.configure(command=command_dio_init)
        #----------------------------------------
        # 「DioSetIoDirection」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_set_io_direction.configure(command=command_dio_set_io_direction)
        #----------------------------------------
        # 「DioInpMultiByte」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_inp_multi_byte.configure(command=command_dio_inp_multi_byte)
        #----------------------------------------
        # 「DioInpMultiBit」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_inp_multi_bit.configure(command=command_dio_inp_multi_bit)
        #----------------------------------------
        # 「DioOutMultiByte」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_out_multi_byte.configure(command=command_dio_out_multi_byte)
        #----------------------------------------
        # 「DioOutMultiBit」ボタンのコールバック関数を設定
        #----------------------------------------
        self.button_dio_out_multi_bit.configure(command=command_dio_out_multi_bit)
        #----------------------------------------
        # 「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()