Hello everybody,

I've a somewhat odd issue displaying a .png image onto a Tkinter canvas.
The image is surrounded by a grey frame.
Here below an excerpt of the relevant code and by the way I'm running under windows xp.
The same thing happens with the menu of the gui, it stays grey whatever colour I set.
Any suggestion about this issue?

self.frameCanvas = Frame(master, bg="white", bd=0, relief=FLAT)
self.frameCanvas.grid(column=1, row=0, rowspan=2, sticky=NE, padx=10, pady=5)
#
self.logo = Canvas(self.frameCanvas, width=70, height=70, bg="white", bd=0)
self.logo.create_image(36, 36, image=self.Logo_TCTK)
self.logo.grid()
self.logo.image = self.Logo_TCTK

Thank you all

Attachments canvas.JPG 6.21 KB

I can indeed give you the full code of the app infrastructure which is the one creating the gui's aspect and common widgets. This part then call the various modules which I don't include here as I don't think they're useful to solve the problem.
Be warned that the code is rude and not at all smooth and clean

Thanks to all again.

Gab

Attachments
import os
import win32com.client
from Tkinter import *
from tkMessageBox import * #import the standard popup modules native on the OS
from PIL import Image, ImageTk
import tkFileDialog
import shutil
import tempfile
# import tkFileDialog #to import open file etc.. functions

root = Tk()
root.iconbitmap("NetConnections.ico")
root.title("Tecnocryo Products - Price List")
#w, h = root.winfo_screenwidth(), root.winfo_screenheight()
#root.geometry("%dx%d+0+0" % (w, h))
root.config(bg="white")
root.geometry("+0+0")

class App:
    import RecPS
    from RecPS import *
    #import PPC
    #from PPC import *
    

    def __init__(self, master):
        self.PSv = master
        self.PSprod = master
        self.SumAcc = master
        self.accessoryLAB = master
        self.ASQv = master
        self.SumTOT = master
        self.AccVal = master
        self.component = master
        self.CSF_entry = master
        self.TCJob_entry = master
        self.TCSn_entry = master
        self.Remks01 = master
        self.Remks02 = master
        self.Remks03 = master
        self.Remks04 = master
        self.Remks05 = master
        self.Remks06 = master
        self.Remks07 = master
        self.frameListOption = master
        self.frameLabelPriceList = master
        
        
        ########################################################################################################################################
        # create a pulldown menu, and add it to the menu bar
        self.menubar = Menu(root, background="LightSteelBlue2")
        self.filemenu = Menu(self.menubar, tearoff=0)
        self.filemenu.add_command(label="Print", command=self.printGen)
        self.filemenu.add_command(label="Open", command=self.open_it)
        self.filemenu.add_command(label="Print Word Doc", command=self.PrintWordDoc)
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Exit", command=self.destrparent)
        self.menubar.add_cascade(label="File", menu=self.filemenu)

        self.pricemenu = Menu(self.menubar, tearoff=0)
        self.pricemenu.add_command(label="Reciprocating Pump Skid", command=self.PumpSkidPrice)
        self.pricemenu.add_command(label="PPC Pump Skid")
        self.pricemenu.add_command(label="Centrifugal Pump Skid")
        
        self.menubar.add_cascade(label="Price", menu=self.pricemenu)

        self.helpmenu = Menu(self.menubar, tearoff=0)
        self.helpmenu.add_command(label="About..", command=self.AboutPopUp)
        self.menubar.add_cascade(label="Help", menu=self.helpmenu)

        # display the menu
        root.config(menu=self.menubar)
        ######################################################################################################################################   
        #inizio generazione frame
        frameToolbar = Frame(master, bd=0, relief=FLAT, bg="white")
        frameToolbar.grid(column=0, row=0, columnspan=1, sticky=NW)

        FramePriceLists = Frame(master, bd=0, relief=FLAT, bg="white")
        FramePriceLists.grid(column=0, row=1, columnspan=1, sticky=NW)

        frameInfoJob = Frame(master, bd=0, bg="white", relief=FLAT)
        frameInfoJob.grid(column=0, row=2, sticky=NW)

        framePSTot = Frame(master, bd=0, bg="white", relief=FLAT)
        framePSTot.grid(column=0, row=3, sticky=NW)

        frameRemks = Frame(master, bd=0, relief=FLAT, bg="white")
        frameRemks.grid(column=0, row=4, columnspan=1, sticky=NW)

        self.frameInfoPoint = Frame(master, bd=0, relief=FLAT, bg="white")
        self.frameInfoPoint.grid(column=1, row=2, rowspan=3, columnspan=1, sticky=NW)

        self.frameLabelPriceList = Frame(master, bd=0, relief=FLAT, bg="white")
        self.frameLabelPriceList.grid(column=0, row=5, columnspan=2, sticky=NW)
     
        self.frameListOption = Frame(master, bd=0, relief=FLAT, bg="white")
        self.frameListOption.grid(column=0, row=6, columnspan=2, sticky=NW)

        self.frameCanvas = Frame(master, bg="white", bd=0, relief=FLAT)
        self.frameCanvas.grid(column=1, row=0, rowspan=2, sticky=NE, padx=10, pady=5)

        ######################################################################################################################################
        #Start Toolbar function buttons
        self.printerIMG = Image.open("C:\Python25\TCPriceList\icon\Printer.png")
        self.printerTK = ImageTk.PhotoImage(self.printerIMG)
        self.calculatorIMG = Image.open("C:\Python25\TCPriceList\icon\Calculator.png")
        self.calculatorTK = ImageTk.PhotoImage(self.calculatorIMG)
        self.closeIMG = Image.open("C:\Python25\TCPriceList\icon\Close.png")
        self.closeTK = ImageTk.PhotoImage(self.closeIMG)
        self.RecPSIMG = Image.open("C:\Python25\TCPriceList\icon\RecPS.png")
        self.RecPSTK = ImageTk.PhotoImage(self.RecPSIMG)
        self.PPCIMG = Image.open("C:\Python25\TCPriceList\icon\PPC.png")
        self.PPCTK = ImageTk.PhotoImage(self.PPCIMG)
        self.CentrIMG = Image.open("C:\Python25\TCPriceList\icon\Centr.png")
        self.CentrTK = ImageTk.PhotoImage(self.CentrIMG)
        self.RemarksIMG = Image.open("C:\Python25\TCPriceList\icon\Remarks.png")
        self.RemarksTK = ImageTk.PhotoImage(self.RemarksIMG)
        self.InfoPointIMG = Image.open("C:\Python25\TCPriceList\icon\InfoPoint.png")
        self.InfoPointTK = ImageTk.PhotoImage(self.InfoPointIMG)
        self.Logo_TCIMG = Image.open("C:\Python25\TCPriceList\icon\Logo_TC.png")
        self.Logo_TCTK = ImageTk.PhotoImage(self.Logo_TCIMG)
        
        self.button2 = Button(frameToolbar, compound=TOP, image=self.printerTK, text="PRINT", bg="gray89", width=60,
                              relief=RAISED, font=("Verdana", "9", "bold"), command=self.printGen)
        self.button2.grid(row=0, column=1, padx=1, sticky=N+W)
        self.button2.image = self.printerTK
        
        self.button = Button(frameToolbar, compound=TOP, image=self.closeTK, text="CLOSE", bg="gray89", width=60,
                             relief=RAISED, font=("Verdana", "9", "bold"), command=self.destrparent)
        self.button.grid(row=0, column=2, padx=1, sticky=N+W)
        self.button.image = self.closeTK
        
        self.button1 = Button(frameToolbar, compound=TOP, image=self.calculatorTK, text="SUM", bg="gray89", width=60,
                              relief=RAISED, font=("Verdana", "9", "bold"), command=self.multRecPS)
        self.button1.grid(row=0, column=0,padx=1, sticky=N+W)
        self.button1.image = self.calculatorTK

        self.buttonRecPS = Button(FramePriceLists, compound=TOP, image=self.RecPSTK, text="PS Pump Skid", bg="light blue", width=110,
                              relief=RAISED, font=("Verdana", "7", "bold"), command=self.PumpSkidPrice)
        self.buttonRecPS.grid(row=1, column=0, padx=1, pady=2, sticky=N+W)
        self.buttonRecPS.image = self.RecPSTK

        self.buttonPPC = Button(FramePriceLists, compound=TOP, image=self.PPCTK, text="PPC Pump Skid", bg="light blue", width=110,
                              relief=RAISED, font=("Verdana", "7", "bold"))
        self.buttonPPC.grid(row=1, column=1, padx=1, pady=2, sticky=N+W)
        self.buttonPPC.image = self.PPCTK

        self.buttonCentr = Button(FramePriceLists, compound=TOP, image=self.CentrTK, text="Centrifugal Pump Skid", bg="light blue", width=110,
                              relief=RAISED, font=("Verdana", "7", "bold"))
        self.buttonCentr.grid(row=1, column=2, padx=1, pady=2, sticky=N+W)
        self.buttonCentr.image = self.CentrTK

       
        self.logo = Canvas(self.frameCanvas, width=70, height=70, bg="white", bd=0)
        self.logo.create_image(36, 36, image=self.Logo_TCTK)
        self.logo.grid()
        self.logo.image = self.Logo_TCTK
        
        
                
        ######################################################################################################################################
        #Start entry job data
        self.labCSFjob = Label(frameInfoJob, relief=RIDGE, bg="light yellow", text="CSF JOB:", font=("Verdana", "9", "bold"))
        self.labCSFjob.grid(column=0, row=0, sticky=NW)
        self.entryCSFjob = Entry(frameInfoJob,relief=RIDGE ,bg="white smoke", font=("Verdana", "9", "bold"), width=10)  
        self.entryCSFjob.grid(column=1, row=0, sticky=NW)
        self.labTCjob = Label(frameInfoJob, relief=RIDGE, bg="light yellow", text="TC JOB:", font=("Verdana", "9", "bold"))
        self.labTCjob.grid(column=2, row=0, sticky=NW)
        self.entryTCjob = Entry(frameInfoJob,relief=RIDGE,bg="white smoke", font=("Verdana", "9", "bold"), width=10) 
        self.entryTCjob.grid(column=3, row=0, sticky=NW)
        self.labTCsn = Label(frameInfoJob, relief=RIDGE, bg="light yellow", text="TC SN:", font=("Verdana", "9", "bold"))
        self.labTCsn.grid(column=4, row=0, sticky=NW)
        self.entryTCsn = Entry(frameInfoJob,relief=RIDGE, bg="white smoke", font=("Verdana", "9", "bold"), width=10) 
        self.entryTCsn.grid(column=5, row=0, sticky=NW)
        self.LabTOT = Label(framePSTot, relief=RIDGE, bg="bisque", text="TOTAL PRICE:", font=("Verdana", "9", "bold"), width=13)
        self.LabTOT.grid(column=0, row=0, sticky=NW) 
        self.EntryTOT = Entry(framePSTot,relief=RIDGE, bg="white smoke", font=("Verdana", "9", "bold"), width=39)
        self.EntryTOT.grid(column=1, row=0, sticky=NW)
        self.LabRemks = Label(frameRemks, compound=LEFT, image=self.RemarksTK, relief=RIDGE, bg="light yellow", text="REMARKS", font=("Verdana", "9", "bold"), width=462)
        self.LabRemks.grid(sticky=NW)
        self.LabRemks.image=self.RemarksTK
        self.Remks = Text(frameRemks, relief=RIDGE, bg="white smoke", height=7, width=58, font=("Verdana", "8", "bold"))
        self.Remks.grid(sticky=NW)
        self.LabInfo = Label(self.frameInfoPoint, compound=LEFT, image=self.InfoPointTK, relief=RIDGE, bg="light yellow", text="INFO POINT", font=("Verdana", "9", "bold"), width=495)
        self.LabInfo.grid(row=0, columnspan=2, sticky=NW)
        self.LabInfo.image=self.InfoPointTK

        self.scrollbar = Scrollbar(self.frameInfoPoint)
        self.scrollbar.grid(sticky=N+S, row=1, column=1)
        self.Info

that's it!
Thank you so much!

By the way, any advice to change the default menu grey colour? Just setting the bg option doesn't work. Somewhere I read it's a Tkinter bug.
Any idea?

Gab

That works fine indeed on the canvas widget.
For the menu it's not a valid option however.
I tried and googled some time ago and found only one reference stating that the bg setting in the menu widget it's broken.
That's why I was wondering if someone of you already faced such a problem.

This article has been dead for over six months. Start a new discussion instead.