Question

Need help with this problem using Python programming as soon as possible, thank you! Write a...

Need help with this problem using Python programming as soon as possible, thank you!


Write a GUI-based program that implements an image browser for your computer’s file system. The file dialog should filter for GIF image files, and create and open a PhotoImage when a file is accessed.


0 0
Add a comment Improve this question Transcribed image text
Answer #1
 

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

Note: Please maintain proper code spacing (indentation), just copy the code part and paste it in your compiler/IDE directly, no modifications required.

#code

from tkinter import *
from tkinter.filedialog import askopenfilename

#a class representing ImageBrowser GUI
class ImageBrowser:
    #constructor
    def __init__(self):
        #creating a window
        self.root = Tk()
        #creating an empty photoimage (you can pass a file name if you want to set
        # an image initially)
        self.photo = PhotoImage()
        #creating a label with above photo as image
        self.imgLabel = Label(self.root, image=self.photo)
        #adding label to window
        self.imgLabel.pack()
        #creating a button, enabling it to call action() method on click
        self.btn=Button(self.root,text='Open Image', command=self.action)
        self.btn.pack()
        self.root.mainloop() #staying until user closes window

    #event handler method
    def action(self):
        #using askopenfilename dialog window, asking for a .gif extension image file
        filename=askopenfilename(filetypes=[("Gif Images","*.gif")])
        #resetting photo image with above file
        self.photo=PhotoImage(file=filename)
        #updating image of image label
        self.imgLabel.config(image=self.photo)

#creating an object of ImageBrowser which will display the GUI and interact with the user
browser=ImageBrowser()

#OUTPUT

Add a comment
Know the answer?
Add Answer to:
Need help with this problem using Python programming as soon as possible, thank you! Write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need help on following Java GUI problem: Write a program that lets a user display and...

    Need help on following Java GUI problem: Write a program that lets a user display and modify pictures. Create a window. Add four buttons so that clicking a particular button will shift the image by a small amount in the north, south, east or west direction inside the window. Add a menu bar with two menus: File and Image. The File menu should contain an Open menu item that the user can select to display JPEG and PNG files from...

  • please i need as soon as possible thank you A classical concurrent programming problem is called...

    please i need as soon as possible thank you A classical concurrent programming problem is called readers and writers. A data area is shared between several processes. Some processes, the writers, write to the area, the others, the readers, only read the data. At any given time only one reader can read the data or writer can write to the data. Also, no readers are allowed while a writer is executing. Problem Statement: Devise suitable semaphores for this situation and...

  • Python 3.6 I need the code ready to run using GUI programming Write a program for...

    Python 3.6 I need the code ready to run using GUI programming Write a program for the Knight's Tour problem. Your program should let the user move a knight to any starting square and click the Solve button to animate a knight moving along the path, as shown below.

  • Need help with understanding these topics as soon as possible will give thumbs up These topics...

    Need help with understanding these topics as soon as possible will give thumbs up These topics are based on python and software engineering Topics from Exercises in Programming Style: – The input, output, and behavior of and code for the program calculating term frequency – The way in which a programming style emerges from a system’s design constraints – The benefits and drawbacks associated with using styles during software engineering – How different programming styles support and/or limit various software...

  • Please help with this python assignment. Thank you. question 1 Write a Python program to read...

    Please help with this python assignment. Thank you. question 1 Write a Python program to read a file line by line store it into a variable. question 2 Write a Python program to read a file line by line store it into an array. question 3 Write a python program to find the longest words. question 4 Write a Python program to count the number of lines in a text file. question 5 Write a Python program to count the...

  • I need help with this python programming exercise, please! thanks in advance Create a Python script...

    I need help with this python programming exercise, please! thanks in advance Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...

  • Python help. Any help is appreciated, thank you! Write a program that asks the user for...

    Python help. Any help is appreciated, thank you! Write a program that asks the user for a CSV of collision data (see note below about obtaining reported collisions from NYC OpenData). Your program should then list the top three contributing factors for the primary vehicle of collisions "CONTRIBUTING FACTOR VEHICLE 1"in the file. A sample run: Enter CSV file name: collisionsNewYears2016.csv Top three contributing factors for collisions: Driver Inattention/Distraction 136 Unspecified 119 Following To0 Closely 37 Name: CONTRIBUTING FACTOR VEHICLE...

  • Problem 4: (7 pts) To understand the value of recursion in a programming language, write a...

    Problem 4: (7 pts) To understand the value of recursion in a programming language, write a Program in C++ or Python that implements quicksort, first using recursion and then without recursion. Submit your program source code and  screenshot(s) of the output in a separate file (pdf or .docx) Problem 5: (7 pts) To understand the value of counting loops, write a program in C++ or Python that implements matrix multiplication using counting loop constructs. Let the user input the size/dimensions of...

  • Please, build calculator to exact image as below using Python. Write a GUI that implements the...

    Please, build calculator to exact image as below using Python. Write a GUI that implements the calculator shown in the following image: Calculator х Plus Equals: Add Clear Quit - User enters two integers into the text fields. - When Add button is pressed, the sum of the values in the text fields are shown after the Equals: as a label. - The Clear button clears the values in the text fields. The cleared values can be blank or zero....

  • Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to...

    I need some help with programming this assignment. Programming Assignment 6: A Python Class, Attributes, Methods, and Objects Obiectives .Be able to write a Python class Be able to define class attributes Be able to define class methods .Be able to process input from a text file .Be able to write an application using objects The goal of this programming assignment is to develop a simple image processing application. The application will import a class that creates image objects with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT