ross_liu 2019-06-03 21:26 采纳率: 20%
浏览 693
已采纳

如何将之前弹出的message清空只显示一条信息,OK或者Fail?

import xlwt
import pymssql
import tkinter as tk

window = tk.Tk()
window.title('my window')
window.geometry('300x300')
e = tk.Entry(window, show=None)
e.pack()
def set_style(name, height, bold=False):
style = xlwt.XFStyle()
font = xlwt.Font()
font.name = name
font.bold = bold
font.color_index = 4
font.height = height
style.font = font
return style
def write_excel(d):
f = xlwt.Workbook()
sheet1 = f.add_sheet('学生',cell_overwrite_ok=True)
row0 = ["id","username","age"]
#写第一行
for i in range(0,len(row0)):
sheet1.write(0,i,row0[i],set_style('Times New Roman',220,True))
#从第二行开始写从数据库里面捞出来的数据
for i in range(0,len(d)):
for m in range(0, len(d[i])):
sheet1.write(i + 1, m, d[i][m], set_style('Times New Roman', 220, True))
f.save('F:/'+tt+'.xls',)

def insert_point():
conn = pymssql.connect(host="localhost", user='sa', password='@eecvs', database='master')
cur = conn.cursor()
cur.execute('select * from temp_ross where id=%s', (e.get()))
global tt
tt=e.get()
data = cur.fetchall()
if len(data) !=0:
t = []
d = []
for i in range(len(data)):
t.append(data[i][0])
t.append(data[i][1].rstrip())
t.append(data[i][2])
d.append(t)
t = []
write_excel(d)
cur.close()
show_eff(True)
else:
show_eff(False)

def show_eff(e):
Mes1 = tk.Message(text='OK' if e else'Fail' ,width = 60)
Mes1.pack()
def windowset():
b1 = tk.Button(window, text='insert point', width=15,
height=2, command=insert_point)
b1.pack()
window.mainloop()
windowset()
图片说明

  • 写回答

2条回答 默认 最新

  • threenewbee 2019-06-03 21:47
    关注
    Mes1 = None
    def show_eff(e):
      if  Msg1 is None:
        Mes1 = tk.Message(text=text='OK' if e else'Fail',width = 60)
        Mes1.pack()
      else:
        Mes1.pack_forget()
        Mes1 = tk.Message(text=text='OK' if e else'Fail',width = 60)
        Mes1.pack()
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题