学习python不久,学软件编程,最有兴趣的就是图形界面编程了。
用生涩的代码,写下了这个简陋的邮件群发程序。
Tkinter这个GUI模块,windows下安装了python环境的默认已经安装了这个模块,不用另外下载安装
见笑了
#-*- coding:utf-8 -*-
#file:smtp.py
import Tkinter #GUI图形界面模块
import smtplib #邮件smtplib模块
from email.mime.text import MIMEText #邮件MIMEText
from ConfigParser import ConfigParser #配置文件模块
import os
import tkFileDialog
import re
class Window:
def __init__(self, root):
#Label标签
Host = /doc/953fb6195a8102d276a22f86.htmlbel(root, text = '服务器')
Port = /doc/953fb6195a8102d276a22f86.htmlbel(root, text = '端口')
User = /doc/953fb6195a8102d276a22f86.htmlbel(root, text = '用户名')
Passwd = /doc/953fb6195a8102d276a22f86.htmlbel(root, text = '密码')
Subject = /doc/953fb6195a8102d276a22f86.htmlbel(root, text = '主题')
To = /doc/953fb6195a8102d276a22f86.htmlbel(root, text = '收件人')
MailFile = Tkinter.Button(root, text = '浏览', command = self.MailFile) #调用MailFile函数
#定义Label的位置
Host.place(x = 5, y = 5)
Port.place(x = 200, y = 5)
User.place(x = 5, y = 30)
Passwd.place(x = 200, y = 30)
Subject.place(x = 5, y = 55)
To.place(x = 5, y = 83)
#定义浏览按钮的位置
MailFile.place(x = 345, y = 80)
#Entry文本框
self.entryHost = Tkinter.Entry(root)
self.entryUser = Tkinter.Entry(root)
self.entryPasswd = Tkinter.Entry(root, show = '*')
self.entryTo = Tkinter.Entry(root, width = 40)
self.entryPort = Tkinter.Entry(root)
self.entrySub = Tkinter.Entry(root, width = 40)
#读取配置文件
config = ConfigParser()
config.read('smtp.conf')