Anygui Redux

Years ago, I was involved in the development of Anygui, a GUI development wrapper designed for python. Basically, it was supposed to be like anydbm is for accessing database modules from python. That is, it was intended to make it into the standard library, and use the best GUI available from it’s list on a given system. I was responsible for the BeOS components, using Donn Cave’s excellent Bethon package. Today, I noticed a referer in my backend from someone searching for PyMail on Google. I had a look on Google as to what else is found on this search, and came across a site with the following content (I’ve reformatted it, since the site was gone, and this is from the cache):

 1     #!/usr/bin/env python
 2     #pyMail 0.1 
 3     #my first program with python and anygui interface 
 4     #coded by teknux ~ teknux@ustc.edu 
 5     #2002/11/4 
 6     #copyright 2002 under GPL
 7     
 8     from anygui import *
 9     import smtplib 
10     from email.MIMEText import MIMEText 
11     import sys as sys
12     
13     #edit these fields with your informations
14     mail_sender = "teknux@localhost"
15     mail_from = "teknux@localhost" 
16     
17     #initialize window 
18     app = Application() 
19     win = Window(title="pyMail 0.1",size=(460,385)) 
20     app.add(win) 
21     opt = Options(left=5, width=21, height=30) 
22     banner = Label(size=(70,25), position=(385,10), text="pyMail 0.1") 
23     to = Label(opt, text="To:") 
24     to_text = TextField(size=(230,25)) 
25     win.add((to,to_text), position=(0,10), direction="right", space=5) 
26     win.add(banner) subject = Label(size=(51,25), text="Subject:") 
27     subject_text = TextField(size=(398,25)) 
28     win.add((subject,subject_text), position=(0,45), direction="right", space=5) 
29     body = TextArea(size=(450,250)) 
30     win.add(body, position=(5,80)) 
31     btn_send = Button(left=5, size=(100,30), text="Send message") 
32     btn_exit = Button(left=5, size=(100,30), text="Exit") 
33     status = Label(size=(240,25), text="...status...") 
34     win.add((btn_send,btn_exit,status), position=(5,350), space=6) 
35     
36     def statbar(stat_msg):
37         status.text = stat_msg status.refresh() 
38     
39     def sendmail(**args): 
40         msg = MIMEText(body.text) 
41         msg["Subject"] = subject_text.text 
42         msg["From"] = mail_from 
43         msg["To"] = to_text.text 
44         mail_to = to_text.text 
45         mail = smtplib.SMTP() 
46         statbar("connecting to SMTP") 
47         mail.connect() 
48         statbar("sendin message") 
49         mail.sendmail(mail_sender, mail_to, msg.as_string()) 
50         statbar("done")
51         mail.close() 
52         
53     def exit(**args): 
54         sys.exit(2) 
55         
56     link(btn_exit, exit) 
57     link(btn_send, sendmail) 
58     app.run()

I don’t have Anygui anymore, and the old site appears to be gone, so I can’t test this out! I do love the cleanliness of this system, however. It’s almost as easy to create a UI in this as in Interface Builder. Amd the coolest thing from my perspective was that this was so easy to implement in BeOS/Bethon. I did write a few of the modules for Donn, and these two bits were probably the first bits of Open Source code I wrote, and that other people might have used.

blog comments powered by Disqus