1、tkinter入门学习
import tkinter as tk
app = tk.Tk()
app.title(“FishC Demo”)
theLabel=tk.Label(app,text=“我的第二个窗口程序!”)
theLabel.pack()
app.mainloop()
2、进阶学习
import tkinter as tk
class APP:
def init(self,master):
frame=tk.Frame(master)
frame.pack(side=tk.LEFT,padx=10,pady=10) #距离设置
self.hi_there=tk.Button(frame,text="打招呼",fg="red",command=self.say_hi)
self.hi_there.pack() #背景色设置
def say_hi(self):
print("互联网的广大朋友们大家好,我是小鲫鱼!") #按钮设置
root=tk.Tk()
app=APP(root)
root.mainloop()
3、出错!!!!
import tkinter as tk
root=tk.Tk()
root.title(‘春哥!’)
textLabel=tk.Label(root,text=“情人节快乐呀,大哥!”,fg=‘blue’)
textLabel.pack(side=tk.LEFT)
photo=tk.PhotoImage(file=r’D:\Codes\untitled\test\520.gif’)
imgLabel=tk.Label(root,image=photo)
imgLabel.pack()
tk.mainloop()
4、
修改后
import tkinter as tk
root = tk.Tk()
root.geometry(‘600*400’)
root.title(‘忠告!’)
textlable = tk.Label(root,text=‘情人节个鬼!’,fg=‘blue’)
text