The following code runs fine, but is reporting an unresolved reference in Pycharm. This code doesn't report any unresolved references on my other machine. I have run 'invalidate caches' in Pycharm, and I have re-installed everything to no avail. This is also occuring on other function calls such as tk.Grid.conlumnconfigure, tk.Grid.rowconfigure etc.
I'm using Python 3.10 and pycharm 2021.3.1
# Create the Menu Bar
self.main_menu = tk.Menu(master)
master.config(menu=self.main_menu)
self.file_menu = tk.Menu(self.main_menu, tearoff=False)
self.main_menu.add_cascade(label="File", menu=self.file_menu)
self.file_menu.add_command(label="Open...", command=self.open)
self.file_menu.add_command(label="Save", command=self.save)
self.file_menu.add_command(label="Save As...", command=self.save_as)
i get the following error on master.config:
Cannot find reference 'config' in 'Misc | None'
ignore an unresolved reference 'tkinter.Misc.config'
Edit: Here's a full minimal example. "columnconfigure" throws the same error:
import tkinter
from tkinter import *
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
Button(self.master, text="test").grid(row=0, column=0)
Grid.columnconfigure(self.master, 0, weight=1)
# initialize tkinter
root = Tk()
app = Window(root)
# set window title
root.wm_title("Tkinter window")
# show window
root.mainloop()
CodePudding user response:
The problem is PyCharm. To be precise, the problem is with the version.
The solution to your question is to install an older version. The version you use was released on December 01 2021 from JetBrains.
You need a version earlier than 2021.3.1. Try version 2021.2.3 which was released on July 28 2021 from JetBrains.
In this way all the functions of Tkinter will be available
CodePudding user response:
Are you sure PyCharm is using the correct interpreter with the same version of Python? You can check this by going to Preferences > Project > Project Interpreter. I have run into many issues in the past because I did not realize that PyCharm had defaulted to an interpreter with Python 2.7.
CodePudding user response:
Solved: The issue was with PyCharm 2021.3.1
I downgraded to 2021.2.3 and everything works now.
