Frame Tkinter Python does not stand next to another frame

Asked

Viewed 338 times

1

Well, I’m having a problem assembling my simple graphical interface for a program. I’m doing it with Tkinter using python 3 and a frame just doesn’t sit next to each other! I have tried to put side=LEFT in 2, and more a diversity of things. The problem is simple, but I can’t see where the error is.

The code is as follows::

from tkinter import *
import _thread
import threading


def atualizarInterface(atoa):
    while True:
        root.update_idletasks()
        root.update()


def iniciarThreadAtualizar():
    _thread.start_new_thread(atualizarInterface, tuple([1]))


class InterfaceGrafica:
    def __init__(self, master=None):
        self.corVerde = "color-" + 'green'
        self.corAzul = "color-" + 'blue'
        self.corCinza= "color-" + 'grey'

        self.fontePadrao = ("Arial", "12")
        self.fonteTitulos = ("Arial", "12", "bold")

        self.containerGeral = Frame(master)
        self.containerGeral.pack(fill=BOTH, expand=YES)

        self.containerMenu = Frame(self.containerGeral, bg='#cbccc6', width=100)
        self.containerMenu.pack(side=LEFT, anchor='nw', fill=Y, expand=YES)

        self.containerCanvas = Frame(self.containerGeral, bg='black', width=100, height=100)
        self.containerCanvas.pack(side=LEFT, anchor='nw', fill=BOTH, expand=YES)

        self.containerBotoes = Frame(self.containerMenu, bg='#cbccc6')
        self.containerBotoes.pack(fill=X, anchor='nw')

        self.botaoTranslacao = Button(self.containerBotoes, text="Translação", bd=2, font=self.fonteTitulos)

        self.botaoRotacao = Button(self.containerBotoes, text="Rotação", bd=2, font=self.fonteTitulos)

        self.botaoEscala = Button(self.containerBotoes, text="Escala", bd=2, font=self.fonteTitulos)

        self.botaoReflexao = Button(self.containerBotoes, text="Reflexões", bd=2, font=self.fonteTitulos)

        self.botaoTranslacao.pack(side=LEFT, expand=YES)
        self.botaoRotacao.pack(side=LEFT, expand=YES)
        self.botaoEscala.pack(side=LEFT, expand=YES)
        self.botaoReflexao.pack(side=LEFT, expand=YES)

        self.containerAzul = Frame(self.containerMenu, bg='blue')
        self.containerAzul.pack(anchor='nw', fill=BOTH, expand=YES)


root = Tk()
root.title("Trabalho Computação Gráfica")
root.geometry("800x480")
interface = InterfaceGrafica(root)
root.after(100, iniciarThreadAtualizar)
root.mainloop()

I want this containerCanvas to be right next to it and glued to the other container that is the containerMenu. I will show how the result is coming:

NOTE: The Container with buttons and a blue part is the containerMenu, and the whole black (which is what I want it to look good on the side), is the containerCanvas

Container preto (containerCanvas) não fica do lado do containerMenu

Could someone tell me what’s causing this? I live having problems with this organization of frames, I can’t put on the screen what I really want.

The black container has to fill all the rest of the screen too, I put it with 100 width and height just to test.

  • 1

    remove the container expand

  • Good! It worked! Can explain why?

  • I know, I just think that one conflicts with the other

No answers

Browser other questions tagged

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