Hi,

Im trying to create a canvas as a background
but i can manage to work =/

I create a window with the text and the size of de image, but the image is not there

can someone help me?

thanks.

import Tkinter as tk
import tkMessageBox


class Janela:
    def __init__(self, toplevel):
        toplevel.resizable(width=False, height=False)
        toplevel.title('Calculadora CaféMania v1 (beta)')

        raiz.bind_all("<F1>", self.help)

        fundo = tk.PhotoImage(file="fundo.gif")
        w = fundo.width()
        h = fundo.height()

        toplevel.geometry("%dx%d+0+0" % (w, h))

        painel = tk.Canvas(width=w, height=h)
        painel.pack(side='top', fill='both', expand='yes')
        painel.create_image(0, 0, image=fundo, anchor='nw')

        painel.create_text(10, 10, text='Selecione sua opção.\n'
                           'Aperte F1 para Ajuda.\n', fill='red', anchor='nw')

raiz = tk.Tk()  
Janela(raiz)
raiz.mainloop()

nervermind, I found out ;D

import Tkinter as tk
import tkMessageBox

raiz = tk.Tk()
fundo = tk.PhotoImage(file="fundo.gif")
w = fundo.width()
h = fundo.height()

class Janela:
    def __init__(self, toplevel):
        toplevel.resizable(width=False, height=False)
        toplevel.title('Calculadora CaféMania v1 (beta)')

        raiz.bind_all("<F1>", self.help)

        toplevel.geometry("%dx%d+0+0" % (w, h))

        self.painel = tk.Canvas(toplevel, width=w, height=h)
        self.painel.pack(side='top', fill='both', expand='yes')
        self.painel.create_image(0, 0, image=fundo, anchor='nw')

        self.painel.create_text(10, 10, text='Selecione sua opção.\n'
                           'Aperte F1 para Ajuda.\n', fill='red', anchor='nw')


Janela(raiz)
raiz.mainloop()

Please mark this thread "solved" so the helpful volunteers don't waste their time reading a solved thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.