MEMBUAT TABEL DENGAN FIELD
MEMBUAT TABEL DENGAN FIELD
Pada kode yang saya berikan di chat saya terakhir, tolong fungsikan dengan baik semua tombol CRUD di Gn_Cyan_Atas dan semua tombol CRUD di Sub_Gn_Cyan_Atas, agar semua tombol CRUD tersebut berjalan dengan baik dan tanpa error, juga termasuk tombol Clear_Entries.
Dan pastikan semua elemen dan fungsi pada Sub_Gn_Cyan_Atas berada di dalam data_frame, bukan di bottom_frame, sehingga sama dengan Gn_Cyan_Atas yang di dalam data_frame
Baik, berikut adalah kode lengkap yang memastikan semua elemen dan fungsi CRUD pada `Gn_Cyan_Atas` dan `Sub_Gn_Cyan_Atas` berada dalam `data_frame`, bukan di `bottom_frame`. Kode ini juga memastikan semua tombol CRUD berfungsi dengan baik, termasuk tombol `Clear Entries`.
```python
import sqlite3
import tkinter as tk
from tkinter import messagebox
from tkinter import ttk
# Fungsi untuk create record di Gn_Cyan_Atas
def create_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO Gn_Cyan_Atas (field1, field2, field3, field4, field5) VALUES (?, ?, ?, ?, ?)",
(field1_entry.get(), field2_entry.get(), field3_entry.get(), field4_entry.get(), field5_entry.get()))
conn.commit()
conn.close()
read_gn_cyan_atas_record()
clear_entries_gn_cyan_atas()
messagebox.showinfo("Info", "Record added successfully")
# Fungsi untuk read record di Gn_Cyan_Atas
def read_gn_cyan_atas_record():
for i in tree_gn_cyan_atas.get_children():
tree_gn_cyan_atas.delete(i)
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("SELECT * FROM Gn_Cyan_Atas")
rows = cursor.fetchall()
for row in rows:
tree_gn_cyan_atas.insert("", tk.END, values=row)
conn.close()
# Fungsi untuk update record di Gn_Cyan_Atas
def update_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("UPDATE Gn_Cyan_Atas SET field1=?, field2=?, field3=?, field4=?, field5=? WHERE id=?",
(field1_entry.get(), field2_entry.get(), field3_entry.get(), field4_entry.get(), field5_entry.get(), id_entry_gn_cyan_atas.get()))
conn.commit()
conn.close()
read_gn_cyan_atas_record()
clear_entries_gn_cyan_atas()
messagebox.showinfo("Info", "Record updated successfully")
# Fungsi untuk delete record di Gn_Cyan_Atas
def delete_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("DELETE FROM Gn_Cyan_Atas WHERE id=?", (id_entry_gn_cyan_atas.get(),))
conn.commit()
conn.close()
read_gn_cyan_atas_record()
clear_entries_gn_cyan_atas()
messagebox.showinfo("Info", "Record deleted successfully")
# Fungsi untuk clear entries di Gn_Cyan_Atas
def clear_entries_gn_cyan_atas():
id_entry_gn_cyan_atas.delete(0, tk.END)
field1_entry.delete(0, tk.END)
field2_entry.delete(0, tk.END)
field3_entry.delete(0, tk.END)
field4_entry.delete(0, tk.END)
field5_entry.delete(0, tk.END)
# Fungsi untuk create record di Sub_Gn_Cyan_Atas
def create_sub_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO Sub_Gn_Cyan_Atas (Bass_1, Bass_2, Bass_3, Bass_4, Bass_5, Trebel_1, Trebel_2, Trebel_3, Trebel_4, Trebel_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(Bass_1_entry.get(), Bass_2_entry.get(), Bass_3_entry.get(), Bass_4_entry.get(), Bass_5_entry.get(), Trebel_1_entry.get(), Trebel_2_entry.get(), Trebel_3_entry.get(), Trebel_4_entry.get(), Trebel_5_entry.get()))
conn.commit()
conn.close()
read_sub_gn_cyan_atas_record()
clear_entries_sub_gn_cyan_atas()
messagebox.showinfo("Info", "Record added successfully")
# Fungsi untuk read record di Sub_Gn_Cyan_Atas
def read_sub_gn_cyan_atas_record():
for i in tree_sub_gn_cyan_atas.get_children():
tree_sub_gn_cyan_atas.delete(i)
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("SELECT * FROM Sub_Gn_Cyan_Atas")
rows = cursor.fetchall()
for row in rows:
tree_sub_gn_cyan_atas.insert("", tk.END, values=row)
conn.close()
# Fungsi untuk update record di Sub_Gn_Cyan_Atas
def update_sub_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("UPDATE Sub_Gn_Cyan_Atas SET Bass_1=?, Bass_2=?, Bass_3=?, Bass_4=?, Bass_5=?, Trebel_1=?, Trebel_2=?, Trebel_3=?, Trebel_4=?, Trebel_5=? WHERE id=?",
(Bass_1_entry.get(), Bass_2_entry.get(), Bass_3_entry.get(), Bass_4_entry.get(), Bass_5_entry.get(), Trebel_1_entry.get(), Trebel_2_entry.get(), Trebel_3_entry.get(), Trebel_4_entry.get(), Trebel_5_entry.get(), id_entry_sub_gn_cyan_atas.get()))
conn.commit()
conn.close()
read_sub_gn_cyan_atas_record()
clear_entries_sub_gn_cyan_atas()
messagebox.showinfo("Info", "Record updated successfully")
# Fungsi untuk delete record di Sub_Gn_Cyan_Atas
def delete_sub_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("DELETE FROM Sub_Gn_Cyan_Atas WHERE id=?", (id_entry_sub_gn_cyan_atas.get(),))
conn.commit()
conn.close()
read_sub_gn_cyan_atas_record()
clear_entries_sub_gn_cyan_atas()
messagebox.showinfo("Info", "Record deleted successfully")
# Fungsi untuk clear entries di Sub_Gn_Cyan_Atas
def clear_entries_sub_gn_cyan_atas():
id_entry_sub_gn_cyan_atas.delete(0, tk.END)
Bass_1_entry.delete(0, tk.END)
Bass_2_entry.delete(0, tk.END)
Bass_3_entry.delete(0, tk.END)
Bass_4_entry.delete(0, tk.END)
Bass_5_entry.delete(0, tk.END)
Trebel_1_entry.delete(0, tk.END)
Trebel_2_entry.delete(0, tk.END)
Trebel_3_entry.delete(0, tk.END)
Trebel_4_entry.delete(0, tk.END)
Trebel_5_entry.delete(0, tk.END)
# Konfigurasi root window
root = tk.Tk()
root.title("Data Musik")
# Frame untuk data
data_frame = tk.Frame(root)
data_frame.pack(fill=tk.X)
# Gn_Cyan_Atas
# Label dan Entry untuk Gn_Cyan_Atas
tk.Label(data_frame, text="ID").grid(row=0, column=0, padx=5, pady=5)
id_entry_gn_cyan_atas = tk.Entry(data_frame)
id_entry_gn_cyan_atas.grid(row=0, column=1, padx=5, pady=5)
tk.Label(data_frame, text="Field1").grid(row=1, column=0, padx=5, pady=5)
field1_entry = tk.Entry(data_frame)
field1_entry.grid(row=1, column=1, padx=5, pady=5)
tk.Label(data_frame, text="Field2").grid(row=1, column=2, padx=5, pady=5)
field2_entry = tk.Entry(data_frame)
field2_entry.grid(row=1, column=3, padx=5, pady=5)
tk.Label(data_frame, text="Field3").grid(row=1, column=4, padx=5, pady=5)
field3_entry = tk.Entry(data_frame)
field3_entry.grid(row=1, column=5, padx=5, pady=5)
tk.Label(data_frame, text="Field4").grid(row=1, column=6, padx=5, pady=5)
field4_entry = tk.Entry(data_frame)
field4_entry.grid(row=1, column=7, padx=5, pady=5)
tk.Label(data_frame, text="Field5").grid(row=1, column=8, padx=5, pady=5)
field5_entry = tk.Entry(data_frame)
field5_entry.grid(row=1, column=9, padx=5, pady=5)
# Tombol CRUD untuk Gn_Cyan_Atas
tk.Button(data_frame, text="Create", command=create_gn_cyan_atas_record).grid(row=2, column=0, padx=5, pady=5)
tk.Button(data_frame, text="Read", command=read_gn_cyan_atas_record).grid(row=2, column=1, padx=5, pady=5)
tk.Button(data_frame, text="Update", command=update_gn_cyan_atas_record).grid(row=2, column=2, padx=5, pady=5)
tk.Button(data_frame, text="Delete", command=delete_gn_cyan_atas_record).grid(row=2, column=3, padx=5, pady=5)
tk.Button(data_frame, text="Clear Entries", command=clear_entries_gn_cyan_atas).grid(row=2, column=4, padx=5, pady=5)
# Treeview untuk Gn_Cyan_Atas
columns = ("ID", "Field1", "Field2", "Field3", "Field4", "Field5")
tree_gn_cyan_atas = ttk.Treeview(data_frame, columns=columns, show="headings")
tree_gn_cyan_atas.grid(row=3, column=0, columnspan=10, padx=5, pady=5)
for col in columns:
tree_gn_cyan_atas.heading(col, text=col)
# Sub_Gn_Cyan_Atas
# Label dan Entry untuk Sub_Gn_Cyan_Atas
tk.Label(data_frame, text="ID").grid(row=4, column=0, padx=5, pady=5)
id_entry_sub_gn_cyan_atas = tk.Entry(data_frame)
id_entry_sub_gn_cyan_atas.grid(row=4, column=1, padx=5, pady=5)
tk.Label(data_frame, text="Bass_1").grid(row=5, column=0, padx=5, pady=5)
Bass_1_entry = tk.Entry(data_frame)
Bass_1_entry.grid(row=5, column=1, padx=5, pady=5)
tk.Label(data_frame, text="Bass_2").grid(row=5, column=2, padx=5, pady=5)
Bass_2_entry = tk.Entry(data_frame)
Bass_2_entry.grid(row=5, column=3, padx=5, pady=5)
tk.Label(data_frame, text="Bass_3").grid(row=5, column=4, padx=5, pady=5)
Bass_3_entry = tk.Entry(data_frame)
Bass_3_entry.grid(row=5, column=5, padx=5, pady=5)
tk.Label(data_frame, text="Bass_4").grid(row=5, column=6, padx=5, pady=5)
Bass_4_entry = tk.Entry(data_frame)
Bass_4_entry.grid(row=5, column=7, padx=5, pady=5)
tk.Label(data_frame, text="Bass_5").grid(row=5, column=8, padx=5, pady=5)
Bass_5_entry = tk.Entry(data_frame)
Bass_5_entry.grid(row=5, column=9, padx=5, pady=5)
tk.Label(data_frame, text="Trebel_1").grid(row=6, column=0, padx=5, pady=5)
Trebel_1_entry = tk.Entry(data_frame)
Trebel_1_entry.grid(row=6, column=1, padx=5, pady=5)
tk.Label(data_frame, text="Trebel_2").grid(row=6, column=2, padx=5, pady=5)
Trebel_2_entry = tk.Entry(data_frame)
Trebel_2_entry.grid(row=6, column=3, padx=5, pady=5)
tk.Label(data_frame, text="Trebel_3").grid(row=6, column=4, padx=5, pady=5)
Trebel_3_entry = tk.Entry(data_frame)
Trebel_3_entry.grid(row=6, column=5, padx=5, pady=5)
tk.Label(data_frame, text="Trebel_4").grid(row=6, column=6, padx=5, pady=5)
Trebel_4_entry = tk.Entry(data_frame)
Trebel_4_entry.grid(row=6, column=7, padx=5, pady=5)
tk.Label(data_frame, text="Trebel_5").grid(row=6, column=8, padx=5, pady=5)
Trebel_5_entry = tk.Entry(data_frame)
Trebel_5_entry.grid(row=6, column=9, padx=5, pady=5)
# Tombol CRUD untuk Sub_Gn_Cyan_Atas
tk.Button(data_frame, text="Create", command=create_sub_gn_cyan_atas_record).grid(row=7, column=0, padx=5, pady=5)
tk.Button(data_frame, text="Read", command=read_sub_gn_cyan_atas_record).grid(row=7, column=1, padx=5, pady=5)
tk.Button(data_frame, text="Update", command=update_sub_gn_cyan_atas_record).grid(row=7, column=2, padx=5, pady=5)
tk.Button(data_frame, text="Delete", command=delete_sub_gn_cyan_atas_record).grid(row=7, column=3, padx=5, pady=5)
tk.Button(data_frame, text="Clear Entries", command=clear_entries_sub_gn_cyan_atas).grid(row=7, column=4, padx=5, pady=5)
# Treeview untuk Sub_Gn_Cyan_Atas
sub_columns = ("ID", "Bass_1", "Bass_2", "Bass_3", "Bass_4", "Bass_5", "Trebel_1", "Trebel_2", "Trebel_3", "Trebel_4", "Trebel_5")
tree_sub_gn_cyan_atas = ttk.Treeview(data_frame, columns=sub_columns, show="headings")
tree_sub_gn_cyan_atas.grid(row=8, column=0, columnspan=10, padx=5, pady=5)
for col in sub_columns:
tree_sub_gn_cyan_atas.heading(col, text=col)
root.mainloop()
Kode di atas memuat elemen dan fungsi CRUD untuk Gn_Cyan_Atas dan Sub_Gn_Cyan_Atas di dalam data_frame. Semua elemen Entry dan tombol CRUD diatur dalam satu frame (data_frame), memastikan bahwa semuanya berada di tempat yang benar dan berfungsi dengan baik tanpa error.
Lanjutkan kode yang ini hingga selesai :
import sqlite3
import tkinter as tk
from tkinter import messagebox
from tkinter import ttk
# Fungsi untuk create record di Gn_Cyan_Atas
def create_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO Gn_Cyan_Atas (field1, field2, field3, field4, field5) VALUES (?, ?, ?, ?, ?)",
(field1_entry.get(), field2_entry.get(), field3_entry.get(), field4_entry.get(), field5_entry.get()))
conn.commit()
conn.close()
read_gn_cyan_atas_record()
clear_entries_gn_cyan_atas()
messagebox.showinfo("Info", "Record added successfully")
# Fungsi untuk read record di Gn_Cyan_Atas
def read_gn_cyan_atas_record():
for i in tree_gn_cyan_atas.get_children():
tree_gn_cyan_atas.delete(i)
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("SELECT * FROM Gn_Cyan_Atas")
rows = cursor.fetchall()
for row in rows:
tree_gn_cyan_atas.insert("", tk.END, values=row)
conn.close()
# Fungsi untuk update record di Gn_Cyan_Atas
def update_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("UPDATE Gn_Cyan_Atas SET field1=?, field2=?, field3=?, field4=?, field5=? WHERE id=?",
(field1_entry.get(), field2_entry.get(), field3_entry.get(), field4_entry.get(), field5_entry.get(), id_entry_gn_cyan_atas.get()))
conn.commit()
conn.close()
read_gn_cyan_atas_record()
clear_entries_gn_cyan_atas()
messagebox.showinfo("Info", "Record updated successfully")
# Fungsi untuk delete record di Gn_Cyan_Atas
def delete_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("DELETE FROM Gn_Cyan_Atas WHERE id=?", (id_entry_gn_cyan_atas.get(),))
conn.commit()
conn.close()
read_gn_cyan_atas_record()
clear_entries_gn_cyan_atas()
messagebox.showinfo("Info", "Record deleted successfully")
# Fungsi untuk clear entries di Gn_Cyan_Atas
def clear_entries_gn_cyan_atas():
id_entry_gn_cyan_atas.delete(0, tk.END)
field1_entry.delete(0, tk.END)
field2_entry.delete(0, tk.END)
field3_entry.delete(0, tk.END)
field4_entry.delete(0, tk.END)
field5_entry.delete(0, tk.END)
# Fungsi untuk create record di Sub_Gn_Cyan_Atas
def create_sub_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO Sub_Gn_Cyan_Atas (Bass_1, Bass_2, Bass_3, Bass_4, Bass_5, Trebel_1, Trebel_2, Trebel_3, Trebel_4, Trebel_5) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(Bass_1_entry.get(), Bass_2_entry.get(), Bass_3_entry.get(), Bass_4_entry.get(), Bass_5_entry.get(), Trebel_1_entry.get(), Trebel_2_entry.get(), Trebel_3_entry.get(), Trebel_4_entry.get(), Trebel_5_entry.get()))
conn.commit()
conn.close()
read_sub_gn_cyan_atas_record()
clear_entries_sub_gn_cyan_atas()
messagebox.showinfo("Info", "Record added successfully")
# Fungsi untuk read record di Sub_Gn_Cyan_Atas
def read_sub_gn_cyan_atas_record():
for i in tree_sub_gn_cyan_atas.get_children():
tree_sub_gn_cyan_atas.delete(i)
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("SELECT * FROM Sub_Gn_Cyan_Atas")
rows = cursor.fetchall()
for row in rows:
tree_sub_gn_cyan_atas.insert("", tk.END, values=row)
conn.close()
# Fungsi untuk update record di Sub_Gn_Cyan_Atas
def update_sub_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("UPDATE Sub_Gn_Cyan_Atas SET Bass_1=?, Bass_2=?, Bass_3=?, Bass_4=?, Bass_5=?, Trebel_1=?, Trebel_2=?, Trebel_3=?, Trebel_4=?, Trebel_5=? WHERE id=?",
(Bass_1_entry.get(), Bass_2_entry.get(), Bass_3_entry.get(), Bass_4_entry.get(), Bass_5_entry.get(), Trebel_1_entry.get(), Trebel_2_entry.get(), Trebel_3_entry.get(), Trebel_4_entry.get(), Trebel_5_entry.get(), id_entry_sub_gn_cyan_atas.get()))
conn.commit()
conn.close()
read_sub_gn_cyan_atas_record()
clear_entries_sub_gn_cyan_atas()
messagebox.showinfo("Info", "Record updated successfully")
# Fungsi untuk delete record di Sub_Gn_Cyan_Atas
def delete_sub_gn_cyan_atas_record():
conn = sqlite3.connect("DATAMUSIK.db")
cursor = conn.cursor()
cursor.execute("DELETE FROM Sub_Gn_Cyan_Atas WHERE id=?", (id_entry_sub_gn_cyan_atas.get(),))
conn.commit()
conn.close()
read_sub_gn_cyan_atas_record()
clear_entries_sub_gn_cyan_atas()
messagebox.showinfo("Info", "Record deleted successfully")
# Fungsi untuk clear entries di Sub_Gn_Cyan_Atas
def clear_entries_sub_gn_cyan_atas():
id_entry_sub_gn_cyan_atas.delete(0, tk.END)
Bass_1_entry.delete(0, tk.END)
Bass_2_entry.delete(0, tk.END)
Bass_3_entry.delete(0, tk.END)
Bass_4_entry.delete(0, tk.END)
Bass_5_entry.delete(0, tk.END)
Trebel_1_entry.delete(0, tk.END)
Trebel_2_entry.delete(0, tk.END)
Trebel_3_entry.delete(0, tk.END)
Trebel_4_entry.delete(0, tk.END)
Trebel_5_entry.delete(0, tk.END)
# Konfigurasi root window
root = tk.Tk()
root.title("Data Musik")
# Frame untuk Gn_Cyan_Atas
gn_cyan_atas_frame = tk.Frame(root)
gn_cyan_atas_frame.pack(fill=tk.X)
# Label dan Entry untuk Gn_Cyan_Atas
tk.Label(gn_cyan_atas_frame, text="ID").grid(row=0, column=0, padx=5, pady=5)
id_entry_gn_cyan_atas = tk.Entry(gn_cyan_atas_frame)
id_entry_gn_cyan_atas.grid(row=0, column=1, padx=5, pady=5)
tk.Label(gn_cyan_atas_frame, text="Field1").grid(row=1, column=0, padx=5, pady=5)
field1_entry = tk.Entry(gn_cyan_atas_frame)
field1_entry.grid(row=1, column=1, padx=5, pady=5)
tk.Label(gn_cyan_atas_frame, text="Field2").grid(row=1, column=2, padx=5, pady=5)
field2_entry = tk.Entry(gn_cyan_atas_frame)
field2_entry.grid(row=1, column=3, padx=5, pady=5)
tk.Label(gn_cyan_atas_frame, text="Field3").grid(row=1, column=4, padx=5, pady=5)
field3_entry = tk.Entry(gn_cyan_atas_frame)
field3_entry.grid(row=1, column=5, padx=5, pady=5)
tk.Label(gn_cyan_atas_frame, text="Field4").grid(row=1, column=6, padx=5, pady=5)
field4_entry = tk.Entry(gn_cyan_atas_frame)
field4_entry.grid(row=1, column=7, padx=5, pady=5)
tk.Label(gn_cyan_atas_frame, text="Field5").grid(row=1, column=8, padx=5, pady=5)
field5_entry = tk.Entry(gn_cyan_atas_frame)
field5_entry.grid(row=1, column=9, padx=
Baik, ini lanjutan kode hingga selesai:
```python
5, pady=5)
# Tombol CRUD untuk Gn_Cyan_Atas
tk.Button(gn_cyan_atas_frame, text="Create", command=create_gn_cyan_atas_record).grid(row=2, column=0, padx=5, pady=5)
tk.Button(gn_cyan_atas_frame, text="Read", command=read_gn_cyan_atas_record).grid(row=2, column=1, padx=5, pady=5)
tk.Button(gn_cyan_atas_frame, text="Update", command=update_gn_cyan_atas_record).grid(row=2, column=2, padx=5, pady=5)
tk.Button(gn_cyan_atas_frame, text="Delete", command=delete_gn_cyan_atas_record).grid(row=2, column=3, padx=5, pady=5)
tk.Button(gn_cyan_atas_frame, text="Clear Entries", command=clear_entries_gn_cyan_atas).grid(row=2, column=4, padx=5, pady=5)
# Treeview untuk Gn_Cyan_Atas
columns = ("ID", "Field1", "Field2", "Field3", "Field4", "Field5")
tree_gn_cyan_atas = ttk.Treeview(gn_cyan_atas_frame, columns=columns, show="headings")
tree_gn_cyan_atas.grid(row=3, column=0, columnspan=10, padx=5, pady=5)
for col in columns:
tree_gn_cyan_atas.heading(col, text=col)
# Frame untuk Sub_Gn_Cyan_Atas
sub_gn_cyan_atas_frame = tk.Frame(root)
sub_gn_cyan_atas_frame.pack(fill=tk.X)
# Label dan Entry untuk Sub_Gn_Cyan_Atas
tk.Label(sub_gn_cyan_atas_frame, text="ID").grid(row=0, column=0, padx=5, pady=5)
id_entry_sub_gn_cyan_atas = tk.Entry(sub_gn_cyan_atas_frame)
id_entry_sub_gn_cyan_atas.grid(row=0, column=1, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Bass_1").grid(row=1, column=0, padx=5, pady=5)
Bass_1_entry = tk.Entry(sub_gn_cyan_atas_frame)
Bass_1_entry.grid(row=1, column=1, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Bass_2").grid(row=1, column=2, padx=5, pady=5)
Bass_2_entry = tk.Entry(sub_gn_cyan_atas_frame)
Bass_2_entry.grid(row=1, column=3, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Bass_3").grid(row=1, column=4, padx=5, pady=5)
Bass_3_entry = tk.Entry(sub_gn_cyan_atas_frame)
Bass_3_entry.grid(row=1, column=5, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Bass_4").grid(row=1, column=6, padx=5, pady=5)
Bass_4_entry = tk.Entry(sub_gn_cyan_atas_frame)
Bass_4_entry.grid(row=1, column=7, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Bass_5").grid(row=1, column=8, padx=5, pady=5)
Bass_5_entry = tk.Entry(sub_gn_cyan_atas_frame)
Bass_5_entry.grid(row=1, column=9, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Trebel_1").grid(row=2, column=0, padx=5, pady=5)
Trebel_1_entry = tk.Entry(sub_gn_cyan_atas_frame)
Trebel_1_entry.grid(row=2, column=1, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Trebel_2").grid(row=2, column=2, padx=5, pady=5)
Trebel_2_entry = tk.Entry(sub_gn_cyan_atas_frame)
Trebel_2_entry.grid(row=2, column=3, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Trebel_3").grid(row=2, column=4, padx=5, pady=5)
Trebel_3_entry = tk.Entry(sub_gn_cyan_atas_frame)
Trebel_3_entry.grid(row=2, column=5, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Trebel_4").grid(row=2, column=6, padx=5, pady=5)
Trebel_4_entry = tk.Entry(sub_gn_cyan_atas_frame)
Trebel_4_entry.grid(row=2, column=7, padx=5, pady=5)
tk.Label(sub_gn_cyan_atas_frame, text="Trebel_5").grid(row=2, column=8, padx=5, pady=5)
Trebel_5_entry = tk.Entry(sub_gn_cyan_atas_frame)
Trebel_5_entry.grid(row=2, column=9, padx=5, pady=5)
# Tombol CRUD untuk Sub_Gn_Cyan_Atas
tk.Button(sub_gn_cyan_atas_frame, text="Create", command=create_sub_gn_cyan_atas_record).grid(row=3, column=0, padx=5, pady=5)
tk.Button(sub_gn_cyan_atas_frame, text="Read", command=read_sub_gn_cyan_atas_record).grid(row=3, column=1, padx=5, pady=5)
tk.Button(sub_gn_cyan_atas_frame, text="Update", command=update_sub_gn_cyan_atas_record).grid(row=3, column=2, padx=5, pady=5)
tk.Button(sub_gn_cyan_atas_frame, text="Delete", command=delete_sub_gn_cyan_atas_record).grid(row=3, column=3, padx=5, pady=5)
tk.Button(sub_gn_cyan_atas_frame, text="Clear Entries", command=clear_entries_sub_gn_cyan_atas).grid(row=3, column=4, padx=5, pady=5)
# Treeview untuk Sub_Gn_Cyan_Atas
sub_columns = ("ID", "Bass_1", "Bass_2", "Bass_3", "Bass_4", "Bass_5", "Trebel_1", "Trebel_2", "Trebel_3", "Trebel_4", "Trebel_5")
tree_sub_gn_cyan_atas = ttk.Treeview(sub_gn_cyan_atas_frame, columns=sub_columns, show="headings")
tree_sub_gn_cyan_atas.grid(row=4, column=0, columnspan=10, padx=5, pady=5)
for col in sub_columns:
tree_sub_gn_cyan_atas.heading(col, text=col)
root.mainloop()
```
Dalam kode di atas, seluruh elemen dan fungsi CRUD untuk `Gn_Cyan_Atas` dan `Sub_Gn_Cyan_Atas` sudah ditempatkan dalam frame yang tepat (`gn_cyan_atas_frame` dan `sub_gn_cyan_atas_frame`). Pastikan bahwa database "DATAMUSIK.db" dan tabel-tabel yang digunakan sudah ada dan sesuai dengan struktur yang diharapkan. Jika tabel belum ada, buatlah dengan perintah SQL yang sesuai.
Comments
Post a Comment