#================================================================
#================================================================
# API-DIO(WDM)
# Multi-port/multi-bit I/O Sample
# main UI file
#                                                CONTEC Co., Ltd.
#================================================================
#================================================================
#----------------------------------------
# Import modules
#----------------------------------------
import tkinter as tk
from tkinter import messagebox


#========================================
# MultiIOUI class
#========================================
class MultiIOUI:
    #========================================
    # Initialization function
    #========================================
    def __init__(self):
        #----------------------------------------
        # Start creating main screen
        #----------------------------------------
        self.root = tk.Tk()
        #----------------------------------------
        # Title
        #----------------------------------------
        self.root.title('Multi-port/multi-bit I/O')
        self.root.minsize(475,490)
        #----------------------------------------
        # Set the font for controls
        #----------------------------------------
        self.root.option_add("*Font", ("MS Gothic", 9))
        #----------------------------------------
        # Start creating the UI
        #----------------------------------------
        self._create_ui()

    #========================================
    # UI creation function
    #========================================
    def _create_ui(self):
        #----------------------------------------
        # Initialize
        #----------------------------------------
        #--------------------
        # Create Label for Device Name
        #--------------------
        tk.Label(self.root, text='Device Name : ', anchor='nw').place(x=20, y=20, width=90, height=19)
        #--------------------
        # Create Entry for Device Name
        #--------------------
        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)
        #--------------------
        # Create Button for DioInit
        #--------------------
        self.button_dio_init = tk.Button(self.root, text='DioInit')
        self.button_dio_init.place(x=342, y=20, width=110, height=19)
        #----------------------------------------
        # Create LabelFrame for I/O Set
        #----------------------------------------
        self.groupbox_dir_settings = tk.LabelFrame(self.root, text="I/O Set")
        self.groupbox_dir_settings.place(x=15, y=60, width=450, height=62)
        #--------------------
        # Create Label for I/O Direction
        #--------------------
        tk.Label(self.groupbox_dir_settings, text='I/O Direction : ', anchor='nw').place(x=5, y=10, width=90, height=19)
        #--------------------
        # Create Entry for I/O Direction
        #--------------------
        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)
        #--------------------
        # Create Button for DioSetIoDirection
        #--------------------
        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)
        #----------------------------------------
        # Create LabelFrame for MultiPort Input
        #----------------------------------------
        self.groupbox_inp_port = tk.LabelFrame(self.root, text="MultiPort Input")
        self.groupbox_inp_port.place(x=15, y=130, width=450, height=65)
        #--------------------
        # Create Label for Port Data
        #--------------------
        tk.Label(self.groupbox_inp_port, text='Port Data : ', anchor='nw').place(x=5, y=20, width=90, height=19)
        #--------------------
        # Create Label for Port0
        #--------------------
        tk.Label(self.groupbox_inp_port, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port0
        #--------------------
        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)
        #--------------------
        # Create Label for Port1
        #--------------------
        tk.Label(self.groupbox_inp_port, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port1
        #--------------------
        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)
        #--------------------
        # Create Label for Port2
        #--------------------
        tk.Label(self.groupbox_inp_port, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port2
        #--------------------
        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)
        #--------------------
        # Create Label for Port3
        #--------------------
        tk.Label(self.groupbox_inp_port, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port3
        #--------------------
        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)
        #--------------------
        # Create Label for Port4
        #--------------------
        tk.Label(self.groupbox_inp_port, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port4
        #--------------------
        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)
        #--------------------
        # Create Label for Port5
        #--------------------
        tk.Label(self.groupbox_inp_port, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port5
        #--------------------
        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)
        #--------------------
        # Create Label for Port6
        #--------------------
        tk.Label(self.groupbox_inp_port, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port6
        #--------------------
        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)
        #--------------------
        # Create Label for Port7
        #--------------------
        tk.Label(self.groupbox_inp_port, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port7
        #--------------------
        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)
        #--------------------
        # Create Button for DioInpMultiByte
        #--------------------
        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)
        #----------------------------------------
        # Create LabelFrame for MultiBit Input
        #----------------------------------------
        self.groupbox_inp_bit = tk.LabelFrame(self.root, text="MultiBit Input")
        self.groupbox_inp_bit.place(x=15, y=200, width=450, height=65)
        #--------------------
        # Create Label for Bit Data
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='Bit Data : ', anchor='nw').place(x=5, y=20, width=90, height=19)
        #--------------------
        # Create Label for Bit0
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit0
        #--------------------
        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)
        #--------------------
        # Create Label for Bit1
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit1
        #--------------------
        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)
        #--------------------
        # Create Label for Bit2
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit2
        #--------------------
        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)
        #--------------------
        # Create Label for Bit3
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit3
        #--------------------
        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)
        #--------------------
        # Create Label for Bit4
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit4
        #--------------------
        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)
        #--------------------
        # Create Label for Bit5
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit5
        #--------------------
        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)
        #--------------------
        # Create Label for Bit6
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit6
        #--------------------
        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)
        #--------------------
        # Create Label for Bit7
        #--------------------
        tk.Label(self.groupbox_inp_bit, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit7
        #--------------------
        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)
        #--------------------
        # Create Button for DioInpMultiBit
        #--------------------
        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)
        #----------------------------------------
        # Create LabelFrame for MultiPort Output
        #----------------------------------------
        self.groupbox_out_port = tk.LabelFrame(self.root, text="MultiPort Output")
        self.groupbox_out_port.place(x=15, y=270, width=450, height=65)
        #--------------------
        # Create Label for Port Data
        #--------------------
        tk.Label(self.groupbox_out_port, text='Port Data : ', anchor='nw').place(x=5, y=20, width=90, height=19)
        #--------------------
        # Create Label for Port0
        #--------------------
        tk.Label(self.groupbox_out_port, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port0
        #--------------------
        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)
        #--------------------
        # Create Label for Port1
        #--------------------
        tk.Label(self.groupbox_out_port, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port1
        #--------------------
        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)
        #--------------------
        # Create Label for Port2
        #--------------------
        tk.Label(self.groupbox_out_port, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port2
        #--------------------
        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)
        #--------------------
        # Create Label for Port3
        #--------------------
        tk.Label(self.groupbox_out_port, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port3
        #--------------------
        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)
        #--------------------
        # Create Label for Port4
        #--------------------
        tk.Label(self.groupbox_out_port, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port4
        #--------------------
        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)
        #--------------------
        # Create Label for Port5
        #--------------------
        tk.Label(self.groupbox_out_port, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port5
        #--------------------
        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)
        #--------------------
        # Create Label for Port6
        #--------------------
        tk.Label(self.groupbox_out_port, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port6
        #--------------------
        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)
        #--------------------
        # Create Label for Port7
        #--------------------
        tk.Label(self.groupbox_out_port, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Port7
        #--------------------
        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)
        #--------------------
        # Create Button for DioOutMultiByte
        #--------------------
        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)
        #----------------------------------------
        # Create LabelFrame for MultiBit Output
        #----------------------------------------
        self.groupbox_out_bit = tk.LabelFrame(self.root, text="MultiBit Output")
        self.groupbox_out_bit.place(x=15, y=340, width=450, height=65)
        #--------------------
        # Create Label for Bit Data
        #--------------------
        tk.Label(self.groupbox_out_bit, text='Bit Data : ', anchor='nw').place(x=5, y=20, width=90, height=19)
        #--------------------
        # Create Label for Bit0
        #--------------------
        tk.Label(self.groupbox_out_bit, text='0', anchor='nw').place(x=107, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit0
        #--------------------
        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)
        #--------------------
        # Create Label for Bit1
        #--------------------
        tk.Label(self.groupbox_out_bit, text='1', anchor='nw').place(x=134, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit1
        #--------------------
        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)
        #--------------------
        # Create Label for Bit2
        #--------------------
        tk.Label(self.groupbox_out_bit, text='2', anchor='nw').place(x=161, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit2
        #--------------------
        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)
        #--------------------
        # Create Label for Bit3
        #--------------------
        tk.Label(self.groupbox_out_bit, text='3', anchor='nw').place(x=188, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit3
        #--------------------
        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)
        #--------------------
        # Create Label for Bit4
        #--------------------
        tk.Label(self.groupbox_out_bit, text='4', anchor='nw').place(x=215, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit4
        #--------------------
        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)
        #--------------------
        # Create Label for Bit5
        #--------------------
        tk.Label(self.groupbox_out_bit, text='5', anchor='nw').place(x=242, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit5
        #--------------------
        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)
        #--------------------
        # Create Label for Bit6
        #--------------------
        tk.Label(self.groupbox_out_bit, text='6', anchor='nw').place(x=269, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit6
        #--------------------
        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)
        #--------------------
        # Create Label for Bit7
        #--------------------
        tk.Label(self.groupbox_out_bit, text='7', anchor='nw').place(x=296, y=1, width=10, height=19)
        #--------------------
        # Create Entry for Bit7
        #--------------------
        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)
        #--------------------
        # Create Button for DioOutMultiBit
        #--------------------
        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)
        #----------------------------------------
        # Exit
        #----------------------------------------
        #--------------------
        # Create Label for Return Code
        #--------------------
        tk.Label(self.root, text='Return Code : ', anchor='nw').place(x=20, y=420, width=90, height=19)
        #--------------------
        # Create Entry for Return Code
        #--------------------
        self.textbox_return_string_var= tk.StringVar(self.root)
        tk.Entry(self.root, textvariable=self.textbox_return_string_var).place(x=105, y=420, width=225, height=19)
        #--------------------
        # Create Button for DioExit
        #--------------------
        self.button_dio_exit = tk.Button(self.root, text='DioExit')
        self.button_dio_exit.place(x=342, y=420, width=110, height=19)
        #--------------------
        # Create Button for Exit
        #--------------------
        self.button_exit = tk.Button(self.root, text='Exit')
        self.button_exit.place(x=342, y=450, width=110, height=19)

    #========================================
    # Function that sets the callback function for the UI controls
    #========================================
    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):
        #----------------------------------------
        # Set the callback function for the [DioInit] button
        #----------------------------------------
        self.button_dio_init.configure(command=command_dio_init)
        #----------------------------------------
        # Set the callback function for the [DioSetIoDirection] button
        #----------------------------------------
        self.button_dio_set_io_direction.configure(command=command_dio_set_io_direction)
        #----------------------------------------
        # Set the callback function for the [DioInpMultiByte] button
        #----------------------------------------
        self.button_dio_inp_multi_byte.configure(command=command_dio_inp_multi_byte)
        #----------------------------------------
        # Set the callback function for the [DioInpMultiBit] button
        #----------------------------------------
        self.button_dio_inp_multi_bit.configure(command=command_dio_inp_multi_bit)
        #----------------------------------------
        # Set the callback function for the [DioOutMultiByte] button
        #----------------------------------------
        self.button_dio_out_multi_byte.configure(command=command_dio_out_multi_byte)
        #----------------------------------------
        # Set the callback function for the [DioOutMultiBit] button
        #----------------------------------------
        self.button_dio_out_multi_bit.configure(command=command_dio_out_multi_bit)
        #----------------------------------------
        # Set the callback function for the [DioExit] button
        #----------------------------------------
        self.button_dio_exit.configure(command=command_dio_exit)
        #----------------------------------------
        # Set the callback function for the [Exit] button
        #----------------------------------------
        self.button_exit.configure(command=command_exit)
 
    #========================================
    # Display the error in a message box
    #========================================
    def show_error(self, caption, error):
        messagebox.showerror(caption, error, parent=self.root)

    #========================================
    # Run the main event loop
    #========================================
    def run(self):
        self.root.mainloop()