use*_*917 0 python user-interface class tkinter button
我正在尝试使用类在Python中创建按钮,但在运行它时按钮不会出现.以下是我的代码
#Button_2
#Using Classes
from Tkinter import *
class Application(Frame):
"""A GUI application with three button"""
def _init_(self, master):
""" Initialise the Frame. """
Frame._init_(self, master)
self.grid()
self.create_widgets()
def create_widgets(self):
#"""Create three buttons"""
#Create first buttom
self.btn1 = Button(self, text = "I do nothing")
self.btn1.grid()
#Create second button
self.btn2 = Button(self)
self.btn2.grid()
self.btn2.configure(text = "T do nothing as well")
#Create third button
self.btn3 = Button(self)
self.btn3.grid()
self.btn3.configure(text = "I do nothing as well as well")
root = Tk()
root.title("Lazy Button 2")
root.geometry("500x500")
app = Application(root)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激
归档时间: |
|
查看次数: |
13343 次 |
最近记录: |