Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import ttk
- from tkinter import *
- import mysql.connector
- def show():
- mysqldb = mysql.connector.connect(host="IP", user="User", password="User", database="pran")
- mycursor = mysqldb.cursor()
- mycursor.execute("Select Node, OM_Adress, OM_gateway, CPUP_Adress, CPUP_gateway From TX_address")
- records = mycursor.fetchall()
- print(records)
- for i, (Node, OM_Adress, OM_gateway, CPUP_Adress, CPUP_gateway) in enumerate(records, start=1):
- listBox.insert("", "end", values=(Node, OM_Adress, OM_gateway, CPUP_Adress, CPUP_gateway))
- mysqldb.close()
- root = tk.Tk()
- root.geometry("1200x600")
- root.title("IPnodes")
- label = tk.Label(root, text="IPnodes", font=("Arial",30)).grid(row=0, columnspan=3)
- cols = ('Node', 'OM_Adress', 'OM_gateway','CPUP_Adress', 'CPUP_gateway')
- scrolled_listbox = tk.Frame(root)
- scrolled_listbox.columnconfigure(0, weight=1)
- scrolled_listbox.rowconfigure(0, weight=1)
- scroll = ttk.Scrollbar(scrolled_listbox)
- scroll.grid(row=0, column=1, sticky="ns")
- listBox = ttk.Treeview(scrolled_listbox, columns=cols, show='headings')
- listBox.grid(row=0, column=0, sticky="nsew")
- scroll.configure(command=listBox.yview)
- listBox.configure(yscrollcommand=scroll.set)
- scrolled_listbox.grid(row=2, column=0, columnspan=4, sticky="nsew")
- root.columnconfigure(1, weight=1)
- root.rowconfigure(1, weight=1)
- for col in cols:
- listBox.heading(col, text=col)
- tk.Button(root, text="Close", width=15, command=exit).grid(row=4, column=1)
- show()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement