liyaanns...@gmail.com 在 2021年6月18日 星期五下午2:28:35 [UTC+8] 的信中寫道: > I am using Colab. How could solve this problem. > import tkinter as Tk > from tkinter import * > import sys > import os > #create main window > master = Tk() > master.title("tester") > master.geometry("300x100") > > > #make a label for the window > label1 = tkinter.Label(master, text='Hellooooo') > # Lay out label > label1.pack() > > # Run forever! > master.mainloop() > The error shows that : > <ipython-input-17-a60049376d65> in <module>() > 9 > 10 #create main window > ---> 11 master = Tk() > 12 master.title("tester") > 13 master.geometry("300x100") > > /usr/lib/python3.7/tkinter/__init__.py in __init__(self, screenName, > baseName, className, useTk, sync, use) > 2021 baseName = baseName + ext > 2022 interactive = 0 > -> 2023 self.tk = _tkinter.create(screenName, baseName, className, > interactive, wantobjects, useTk, sync, use) > 2024 if useTk: > 2025 self._loadtk() > > TclError: couldn't connect to display ":0.0"
>>> import tkinter as Tk >>> Tk <module 'tkinter' from 'C:\\Users\\jfong\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\tkinter\\__init__.py'> >>> from tkinter import * >>> Tk <class 'tkinter.Tk'> >>> tkinter Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'tkinter' is not defined >>> --Jach -- https://mail.python.org/mailman/listinfo/python-list