Adding the company logo

With our knowledge of PhotoImage, adding the company logo to our program should be simple; however, we have to solve the problem of how to determine the image file's path. The path can be either absolute or relative to the working directory, but we don't know what those will be on another system. Fortunately, there's a way to figure it out.

Under the abq_data_entry directory, create a new directory called images, and within it place an appropriately-sized PNG file that we can use in our application (the image has an 8x5 aspect ratio, so in this case, we're using 32x20). To get an absolute path to the image, we're going to rely on a built-in variable in Python called __file__. In any Python script, the __file__ variable ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.