英文:
tkinter window will not pop up
问题
我正在使用tkinter做一个项目。最近我在我的计算机上切换到了Linux Mint。程序没有错误,但图形界面没有显示出来。我正在使用PyCharm。
import sys
from tkinter import *
THEME_COLOR = "#375362"
class QuizInterface:
def __init__(self):
self.window = Tk()
self.window.title("Quizzler")
self.window.config(padx=30, pady=30)
self.card = Canvas(width=300, height=250)
self.card.create_text(text="问题在这里", font=("arial", 20, "italic"))
self.card.grid(row=1, column=0, columnspan=2)
self.score = Label(text="得分: ", font=("arial", 13, "bold"))
self.score.grid(row=0, column=1)
true_image = PhotoImage(file="images/true.png")
self.true_button = Button(image=true_image, highlightthickness=0)
false_image = PhotoImage(file="images/false.png")
self.f_button = Button(image=false_image, highlightthickness=0)
self.window.mainloop()
英文:
I am doing a project with tkinter. I've recently switched to linux Mint on my computer. The program runs fine with no errors, the gui just won't come up. I'm using pycharm.
import sys
from tkinter import *
THEME_COLOR = "#375362"
class QuizInterface:
def __int__(self):
self.window = Tk()
self.window.title("Quizzler")
self.window.config(padx=30, pady=30)
self.card = Canvas(width=300, height=250)
self.card.create_text(text="Question goes here", font=("arial", 20, "italic"))
self.card.grid(row=1, column=0, columnspan=2)
self.score = Label(text="Score: ", font=("arial", 13, "bold"))
self.score.grid(row=0, column=1)
true_image = PhotoImage(file="images/true.png")
self.true_button = Button(image=true_image, highlightthickness=0)
false_image = PhotoImage(file="images/false.png")
self.f_button = Button(image=false_image, highlightthickness=0)
self.window.mainloop()
答案1
得分: 2
当一个类被初始化时调用的一个函数是 `__init__`,但你定义了 `def __int__(self):`,所以:
```python
class QuizInterface:
def __init__(self):
...
<details>
<summary>英文:</summary>
One of the function that gets called when a class is intitialized is `__init__`, but you are defining `def __int__(self):`, so:
class QuizInterface:
def init(self):
...
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论