Python学习(tkinter系列)

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值