#!/usr/bin/python3.11
import tkinter as tk
from tkinter import ttk
from tkinter import *

class StatusBar(tk.Frame):   
    def __init__(self, owner):
        tk.Frame.__init__(self, owner)
        self.variable=tk.StringVar()        
        self.label=tk.Label(self, bd=1, relief=tk.SUNKEN, anchor=tk.W, textvariable=self.variable,font=('arial',12,'normal'))
        self.variable.set('')
        self.label.pack(fill=tk.X)        
        self.pack(side = BOTTOM, fill=tk.X)
    def set(self, text):
        self.variable.set(text)

class MyApp:
    def __init__(self, owner):

        # Create  the main window
        owner.geometry('540x650')
        owner.configure(background='#FFFACD')
        owner.title('HTC debug tool')

        # variable associated with the radio button group
        self.debugRadioButtonVar = tk.StringVar(value="DEBUG_NONE")        

        # Create label for IP address
        Label(owner, text='HTC IP address:', bg='#FFFACD', font=('arial', 12, 'normal')).place(x=8, y=15)

        # Create entry box for IP address
        self.HTC_address_entry=Entry(owner)
        self.HTC_address_entry.place(x=148, y=15)

        # Create label for debug type radio button
        Label(owner, text='Debug type:', bg='#FFFACD', font=('arial', 12, 'normal')).place(x=8, y=55)

        # Create  a group of radio buttons
        radioButtonFrame=Frame(owner, width=0, height=0, bg='#FFFACD')
        radioButtonFrame.place(x=138, y=65)
        debug_values=['DEBUG_NONE', 'DEBUG_FATAL','DEBUG_ERROR','DEBUG_WARN', 'DEBUG_NOTICE''DEBUG_INFO', 'DEBUG_TRACE']
        for text in debug_values:
            rbGroupOne=Radiobutton(radioButtonFrame, text=text, variable=self.debugRadioButtonVar, value=text, bg='#FFFACD', font=('arial', 12, 'normal')).pack(side='top', anchor = 'w')

        # Create label for module list
        Label(owner, text='Module:', bg='#FFFACD', font=('arial', 12, 'normal')).place(x=18, y=255)

        # Create a listbox and associated scrollbar
        listBoxFrame=Frame(owner, width=0, height=0, bg='#FFFACD')
        listBoxFrame.place(x=138, y=255)
        self.moduleListBox=Listbox(listBoxFrame, bg='#FFFACD', font=('arial', 12, 'normal'), width=25, height=15)
        self.moduleListBox.pack(side="left", fill="y")
        self.moduleListBox.insert('0', 'CONTROLLER')
        self.moduleListBox.insert('1', 'ERIC')
        self.moduleListBox.insert('2', 'PRESENTATION MANAGER')
        self.moduleListBox.insert('3', 'PRESENTATION AUDIO')
        self.moduleListBox.insert('4', 'PRESENTATION LED')

        # Creating a Scrollbar
        scrollbar = Scrollbar(listBoxFrame, orient="vertical")
        scrollbar.config(command=self.moduleListBox.yview)
        scrollbar.pack(side="right", fill="y")
        self.moduleListBox.config(yscrollcommand=scrollbar.set) 

        # Create  a button
        Button(owner, text='Find modules', bg='#9ACD32', font=('arial', 12, 'normal'), command=self.btnClickFind).place(x=400, y=11)

        # Create  a button
        Button(owner, text='Apply', bg='#9ACD32', font=('arial', 12, 'normal'), command=self.btnClickApply).place(x=400, y=255)

        # Create  a button
        Button(owner, text='Exit', bg='#FF0000', font=('arial', 12, 'normal'), command=self.btnClickExit).place(x=400, y=290)

        # Add a status bar
        self.myStatusBar=StatusBar(owner)
        self.myStatusBar.set("Hi!")

    # Set status bar text
    def setStausBarText(self, text):
        self.myStatusBar.set(text)

    # get the user input from the text input box
    def getInputBoxValue(self):
        userInput = self.HTC_address_entry.get()
        return userInput

    # get the selected radio button value
    def getRadioButtonValue(self):
        buttonSelected = self.debugRadioButtonVar.get()
        return buttonSelected

    # get the selected list box value
    def getListboxValue(self):
        itemSelected = self.moduleListBox.curselection()
        return itemSelected

    # call when the Find button is clicked
    def btnClickFind(self):
        print('Find clicked')

    # call when the apply button is clicked
    def btnClickApply(self):
        print('Apply clicked')

    # call when the exit button is clicked
    def btnClickExit(self):
        print('Exit clicked')

root = Tk()
app = MyApp(root)
app.setStausBarText("Hey!")
root.mainloop()

