Home>
IDLE cannot resolve the "root.geometry" error.
I'm new to Python.
I'm writing the code based on a reference book,
The following error message has occurred.
I don't know how to deal with it, so I would appreciate it if you could ask.
Traceback (most recent call last):
File "C: /Users/ken/Desktop/de01.py", line 21, in<module>
root.geometry ("200x150")
File "C: \ Program Files \ WindowsApps \ PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0 \ lib \ tkinter \ __ init__.py", line 2035, in wm_geometry
return self.tk.call ('wm','geometry', self._w, newGeometry)
AttributeError:'str' object has no attribute'tk'
Corresponding source code
import tkinter as tk
import tkinter.filedialog as fd
import PIL.Image
import PIL.ImageTk
def dispPhoto (path):
#Load image
newImage = PTL.Image.open (path) .resize ((300,300))
#Display the image on the label
imageData = PIL.ImageTK.PhotoImage (newImege)
imageLabel.configure (image = imageData)
imageLabel.image = imageData
def openFile ():
fpath = fd.askopenfilename ()
if fpath:
dispPhoto (fpath)
root = tk.TK
root.geometry ("200x150")
btn = tk.Button (text = "open file", command = openFile)
imageLabel = tk.Label ()
btn.pack ()
imageLabel.pack ()
tkmainloop ()
Supplementary information (FW/tool version, etc.)
windouws10
Python 3.8.3
-
Answer # 1
Related articles
- python - error message cannot unpack non-iterable int object resolution
- python 3x - library cannot be installed due to ssl error in python pip
- python - categorical_crossentoropy error does not resolve
- resolve python error code
- python - tuple error does not resolve
- python - how to resolve attribute error
- python - resolve program error "keyerror: 0"
- i want to resolve a syntax error in a python while statement
- python - the py file cannot be executed in the task scheduler 0x2 error
- python - program error removal with opencv tracker
- python - an error occurs in the if statement program that compares the size of numbers
- error in import xlrd of python file from cakephp
- python - image cannot be read by opencv
- python - cannot convert csv file to excel file (contents are not copied )
- python - error in beautifulsoup4
- ios - [unity] i want to resolve the build error of unity cloud build
- python - i get an error when i try to do a simple regression analysis using sklearn
- indent error doesn't go away, python
- python - sklearn, svm error
For the time being
Is not it
Besides
dispPhoto
There seems to be a misspelling in the function.