使用python制作一个简单的留言板

相关阅读:

虚拟机上linux操纵系统的安装(centos)

Linux的部分终端操作

Tkinter的安装

su root                //切换到根目录下
Password:              //输入密码
yum install tkinter    //安装Tkinter,需要注意,这里“tkinter”的“t”是小写

留言板代码

#!usr/bin/python 2.6
#-*- coding:UTF-8 -*-
import Tkinter as tk


#case
root=tk.Tk()


#title
root.title("Liu Yan Ban")


#label
label1=tk.Label(root,text="Hello!")
label2=tk.Label(root,text="Welcome to RC180603!")
label1.pack()
label2.pack()


#input your case
entry=tk.Entry(root,text=None,font=("Arial", 18))
entry.pack()


#frame
frame=tk.Frame(root)


#button2 def qingchu
def qingchu():
    entry.delete(0,100)


#button3 def guanbi
def guanbi():
    frame.pack_forget()


#button def fasong
def fasong():
    ai=entry.get()
    frame.pack()
    label3=tk.Label(frame,text=ai)
    label3.pack() 
   
#button
button2=tk.Button(root,text="Clear",command=qingchu)
button2.pack()
button=tk.Button(root,text="Send",command=fasong)
button.pack()
button3=tk.Button(root,text="Close",command=guanbi)
button3.pack()


#loop
root.mainloop()

注意点

  1.  如果使用了本公众号提供的操作系统,在安装时使用 yum install tkinter。在使用时使用 import Tkinter

  2. 在创建 Entry(用户可编辑模块), Button(按键模块Labe(普通文本模块l时,需要使用 Entry.pack()Button.pack()Label.pack() 来使定义的实例显示在面板上,否则只是创建实例并不会显示。

  3. 代码中的entry, button和label是自定义的实例名,可根据自己爱好随意定义。

视频讲解

(B站:https://www.bilibili.com/video/BV1cZ4y1W7Ye/)

我们的公众号:认知无线电

我们的网站:www.lolplayer.club

欢迎关注和指正

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月丶匈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值