Issue
I want to create a python executable file with tkinter module, so far this is the code I have typed:
import tkinter as Tk
from tkinter import geometry, title, BooleanVar, set, Button
from tkinter import filedialog
import subprocess
root = Tk()
root.geometry('500x400')
root.title("Bulk upload to OpenSea")
I know that tkinter module doesn't come by default on Spyder environment, so before compiling the program above, I watched this video , then installed miniconda, and then did all the necesary steps explained in that video to allow importing the tkinter module, I also changed the default environment to C:\Users\ResetStoreX\miniconda3\envs\spyder-env\python.exe
which is the PATH
in which I installed the tkinter module with anaconda prompt.
Unfortunately, after compiling the program above with the necessary steps done, I get the following error:
Traceback (most recent call last):
File "C:\Users\ResetStoreX\bulk masive\untitled0.py", line 9, in from tkinter import geometry, title, BooleanVar, set, Button
ImportError: cannot import name 'geometry' from 'tkinter' (C:\Users\ResetStoreX\miniconda3\envs\spyder-env\lib\tkinter_init_.py)
May I know what I'm doing wrong?
Solution
geometry
and title
is a method of tkinter window and toplevels, it is neither a class nor a file you can import. And set
is part of python builtins
. You prolly need just one type of tkinter
import:
import tkinter as tk # OR from tkinter import *
from tkinter import filedialog
import subprocess
root = tk.Tk()
root.geometry('500x400')
root.title("Bulk upload to OpenSea")
Now if you want classes, like BooleanVar
or Button
, you'd say tk.BooleanVar
and so on... Or if you want files from tkinter
package, you'd say from tkinter import filedialog
and so on...
Answered By - Delrius Euphoria
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.