Problems with a python creation of Grid Tkinter

Asked

Viewed 49 times

-1

I’m creating an app using Python 3 and Tkinter and I’m time a problem overlapping the widgets, I can’t see the error in the code.

import tkinter as tk
from tkinter import ttk

class MainFrame (ttk.Frame):
    def __init__(self,  container):
        super().__init__(container)

        divSearch = ttk.Frame(self)
        searchLabel = ttk.Label(divSearch,  text="Search:")
        searchLabel.grid(row=0, column=0, sticky="W")
        searchEntry = ttk.Entry(divSearch,  text="")
        searchEntry.grid(row=0, column=1, sticky="W")
        divSearch.grid(row=0, column=0, sticky="NSEW")

        divSubjects = ttk.Frame(self)
        subjectsListBox = tk.Listbox(divSubjects)
        subjectsListBox.grid(row=0, column=0, sticky="NSEW", pady=5,  padx=5)
        subjectsCreateButton = ttk.Button(divSubjects, text="Create")
        subjectsCreateButton.grid(row=1, column=0, sticky="EW", pady=5, padx=5)
        subjectsEditButton = ttk.Button(divSubjects, text="Edit")
        subjectsEditButton.grid(row=1, column=0, sticky="EW", pady=5, padx=5)
        subjectsDeleteButton = ttk.Button(divSubjects, text="Delete")
        subjectsDeleteButton.grid(row=1, column=0, sticky="EW", pady=5, padx=5)
        divSubjects.grid(row=1, column=0, sticky="NSEW")

        divNotes= ttk.Frame(self)

        divNotes.grid(row=1, column=1, sticky="NSEW")

Final result inserir a descrição da imagem aqui

1 answer

0

I don’t know if this will solve your problem but you can use instead of grid() you can use the function pack() and inside you can say where you want your containers to be ex

self.nome=Label(self.frame,text='user:')
self.nome.pack(side=LEFT)

this code inside the __init__ and in principle it will be repaired

Browser other questions tagged

You are not signed in. Login or sign up in order to post.