小编use*_*257的帖子

Python:Tkinter -- 如何让光标显示忙碌状态

我正在尝试让 Tkinter 显示繁忙的光标。不幸的是,我一定错过了一些非常明显的东西。以下是一个非常简单的程序,可以重现我的问题:

 from Tkinter import *
 import time

 def do_something():
     print "starting"
     window.config(cursor="wait")
     time.sleep(5)
     window.config(cursor="")
     print "done"
     return

 root = Tk()
 menubar = Menu(root)
 filemenu = Menu(menubar, tearoff=0)
 filemenu.add_command(label="Do Something", command=do_something)
 filemenu.add_command(label="Exit", command=root.quit)
 menubar.add_cascade(label="File", menu=filemenu)
 root.config(menu=menubar)
 root.mainloop()
Run Code Online (Sandbox Code Playgroud)

我没有看到光标有任何变化

python tkinter

5
推荐指数
1
解决办法
1万
查看次数

python:带TLS的smtp不提供任何消息

我正在尝试通过office365服务器发送电子邮件.电子邮件已正确发送,但邮件未附加

非常感谢援助

import smtplib

to = "me@gmail.com"
office365_user = 'announcement@somewhere.com'
office365_pwd = 'password'

smtpserver = smtplib.SMTP("smtp.office365.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo()
smtpserver.login(office365_user,office365_pwd)
msg = "This is a test email \n"
smtpserver.sendmail(office365_user, to, msg)
smtpserver.close()
Run Code Online (Sandbox Code Playgroud)

python ssl smtplib

5
推荐指数
1
解决办法
2296
查看次数

在"try"运算符中嵌套"for"循环

伙计们,

我已经辞职以解决这个问题,但我想检查Python是否真的按预期运行.

在示例中,"sample.txt"是任何读取和解析的多行文本文件.

try:
    file=open('sample.txt','r')
    for line in file:
          (some action here)
except:
    print "Couldn't open file"
file.close()
Run Code Online (Sandbox Code Playgroud)

我观察到的动作是打开"sample.txt"并处理第一行,然后逻辑进入"except"子句.

WAD还是这个bug?

python nested-loops

0
推荐指数
1
解决办法
7488
查看次数

标签 统计

python ×3

nested-loops ×1

smtplib ×1

ssl ×1

tkinter ×1