0% found this document useful (0 votes)
2 views4 pages

My Code

The document outlines a Python method for creating a main layout using Tkinter, featuring a scrollable canvas and a notebook with multiple tabs. It includes configurations for vertical and horizontal scrolling, as well as mouse wheel support. The method also initializes various tabs for different functionalities such as Dashboard, Courses, and Payments, and sets up the content within each tab.

Uploaded by

alexanderyusra9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

My Code

The document outlines a Python method for creating a main layout using Tkinter, featuring a scrollable canvas and a notebook with multiple tabs. It includes configurations for vertical and horizontal scrolling, as well as mouse wheel support. The method also initializes various tabs for different functionalities such as Dashboard, Courses, and Payments, and sets up the content within each tab.

Uploaded by

alexanderyusra9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

def create_main_layout(self):

from tkinter import Canvas

# Main container that takes full window

main_container = [Link](self)

main_container.pack(fill="both", expand=True)

# Canvas for vertical scrolling

canvas = Canvas(main_container, background="#f8f9fa", highlightthickness=0)

scrollbar = [Link](main_container, orient="vertical", command=[Link])

self.scrollable_frame = [Link](canvas)

# Horizontal scrollbar

h_scrollbar = [Link](main_container, orient="horizontal", command=[Link])

# Scrollable frame

self.scrollable_frame = [Link](canvas)

# Configure scrolling

self.scrollable_frame.bind(

"<Configure>",

lambda e: [Link](scrollregion=[Link]("all"))

canvas.create_window((0, 0), window=self.scrollable_frame, anchor="nw",


width=main_container.winfo_screenwidth())

[Link](yscrollcommand=[Link])

# Pack scrollbar and canvas

[Link](side="right", fill="y")
[Link](side="left", fill="both", expand=True)

# Mouse wheel scrolling

def _on_mousewheel(event):

canvas.yview_scroll(int(-1*([Link]/120)), "units")

canvas.bind_all("<MouseWheel>", _on_mousewheel)

canvas.bind_all("<Button-4>", lambda e: canvas.yview_scroll(-1, "units"))

canvas.bind_all("<Button-5>", lambda e: canvas.yview_scroll(1, "units"))

# === NOTEBOOK — NOW PERFECTLY FITTED ===

self.tab_control = [Link](self.scrollable_frame)

# This is the key: make notebook fill available width with padding

self.tab_control.pack(fill="x", padx=30, pady=15) # left/right padding for beauty

# Optional: make tabs stretch to fill width

[Link]('[Link]', padding=[20, 10])

[Link]('[Link]',

padding=[('selected', [25, 12]), ('active', [20, 10])])

# Create all tabs

[Link] = {

"Dashboard": [Link](self.tab_control),

"Courses": [Link](self.tab_control),

"Teachers": [Link](self.tab_control),

"Students": [Link](self.tab_control),

"Payments": [Link](self.tab_control),

"Search": [Link](self.tab_control),

"Expenses": [Link](self.tab_control),

"Defaulters": [Link](self.tab_control),

"Teacher Pay": [Link](self.tab_control),


"Balance": [Link](self.tab_control),

"Monthly Profit": [Link](self.tab_control),

"Left Students": [Link](self.tab_control),

"Database": [Link](self.tab_control),

"Users": [Link](self.tab_control),

for name, frame in [Link]():

self.tab_control.add(frame, text=name)

# Build content inside each tab frame

self.setup_function_key_shortcuts()

self._build_dashboard()

self._build_courses_tab()

self._build_teachers_tab()

self._build_students_tab()

self._build_payments_tab()

self._build_search_tab()

self._build_expenses_tab()

self._build_defaulters_tab()

self._build_teacher_pay_tab()

self._build_balance_tab()

self._create_monthly_profit_tab()

self._build_left_students_tab()

self._build_database_tab()

self._build_users_tab()

# Final

self.tab_control.select([Link]["Dashboard"])
self._refresh_dashboard()

self.tab_control.bind("<<NotebookTabChanged>>", self._on_tab_changed)

[Link]("WM_DELETE_WINDOW", [Link])

self.student_names = []

self.name_to_id = {}

self.print_counts = {}

You might also like