Text

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import tkinter as tk

class IPHostApp:
def __init__(self, root):
self.root = root
self.root.title("Tkinter Example")

self.entry_var = tk.StringVar()
self.textbox = tk.Entry(root, textvariable=self.entry_var, width=30)
self.textbox.insert(0, "Enter IP/Host here")

self.text_output = tk.Text(root, height=10, width=40)

self.connect_button = tk.Button(root, text="Connect", command=self.connect)


self.disconnect_button = tk.Button(root, text="Disconnect",
command=self.disconnect)

self.status_label = tk.Label(root, text="", fg="black")

self.bgp_button = tk.Button(root, text="BGP", command=lambda:


self.show_info("BGP Button Pressed", "blue"))
self.routes_button = tk.Button(root, text="Routes", command=lambda:
self.show_info("Routes Button Pressed", "orange"))
self.interfaces_button = tk.Button(root, text="Interfaces", command=lambda:
self.show_info("Interfaces Button Pressed", "purple"))

self.textbox.grid(row=0, column=0, pady=10, padx=10, sticky="n")


self.text_output.grid(row=1, column=0, pady=10, padx=10)
self.connect_button.grid(row=2, column=0, pady=5, padx=10, sticky="w")
self.disconnect_button.grid(row=2, column=0, pady=5, padx=10, sticky="e")
self.status_label.grid(row=3, column=0, pady=5, padx=10)
self.bgp_button.grid(row=4, column=0, pady=5, padx=10, sticky="w")
self.routes_button.grid(row=4, column=0, pady=5, padx=10)
self.interfaces_button.grid(row=4, column=0, pady=5, padx=10, sticky="e")

def connect(self):
self.show_info("Success", "green")

def disconnect(self):
self.show_info("Error", "red")

def show_info(self, message, color):


self.status_label.config(text=message, fg=color)

if __name__ == "__main__":
root = tk.Tk()
app = IPHostApp(root)
root.mainloop()

You might also like