কম্পিউটার

Tkinter ব্যবহার করে কলাম সহ একটি তালিকাবক্স কিভাবে প্রদর্শন করবেন?


যেকোনো অ্যাপ্লিকেশনে প্রচুর ডেটা মোকাবেলা করতে, Tkinter একটি Treeview উইজেট প্রদান করে। এটির বিভিন্ন বৈশিষ্ট্য রয়েছে যেমন সারি এবং কলাম সমন্বিত টেবিলের আকারে ডেটা প্রদর্শন করা।

ট্রিভিউ উইজেট ব্যবহারকারীকে টেবিল যোগ করতে, এতে ডেটা সন্নিবেশ করতে এবং টেবিল থেকে ডেটা ম্যানিপুলেট করতে সক্ষম করে। ট্রিভিউ উইজেটটি ট্রিভিউ(অভিভাবক, কলাম, **বিকল্প) সংজ্ঞায়িত করে তৈরি করা যেতে পারে। কনস্ট্রাক্টর।

উদাহরণ

# Import the required libraries
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame
win = Tk()

# Set the size of the tkinter window
win.geometry("700x350")

s = ttk.Style()
s.theme_use('clam')

# Add a Treeview widget
tree = ttk.Treeview(win, column=("c1", "c2", "c3"), show='headings', height=5)

tree.column("# 1", anchor=CENTER)
tree.heading("# 1", text="ID")
tree.column("# 2", anchor=CENTER)
tree.heading("# 2", text="FName")
tree.column("# 3", anchor=CENTER)
tree.heading("# 3", text="LName")

# Insert the data in Treeview widget
tree.insert('', 'end', text="1", values=('1', 'Joe', 'Nash'))
tree.insert('', 'end', text="2", values=('2', 'Emily', 'Mackmohan'))
tree.insert('', 'end', text="3", values=('3', 'Estilla', 'Roffe'))
tree.insert('', 'end', text="4", values=('4', 'Percy', 'Andrews'))
tree.insert('', 'end', text="5", values=('5', 'Stephan', 'Heyward'))

tree.pack()

win.mainloop()

আউটপুট

যখন আমরা উপরের কোডটি কার্যকর করি, এটি কিছু কলাম সহ আইটেমগুলির একটি তালিকা প্রদর্শন করবে৷

Tkinter ব্যবহার করে কলাম সহ একটি তালিকাবক্স কিভাবে প্রদর্শন করবেন?


  1. কিভাবে Tkinter দিয়ে একটি সম্পূর্ণ Treeview সাফ করবেন?

  2. Tkinter এ ফুল-স্ক্রীন মোড কিভাবে প্রদর্শন করবেন?

  3. Tkinter ব্যবহার করে কিভাবে একটি সাধারণ পর্দা তৈরি করবেন?

  4. Tkinter ব্যবহার করে কিভাবে বহিরাগত প্রোগ্রাম খুলবেন?