CVS: nondist/sandbox/dallasj/Gnosis/lib/Gnosis GnosisGUI.py,1.3,1.4
"Dallas T. Johnston" <[email protected]> Wed, 13 Nov 2002 09:32:46 -0800
| Newsgroups | gmane.comp.python.anygui.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/anygui/nondist/sandbox/dallasj/Gnosis/lib/Gnosis
In directory usw-pr-cvs1:/tmp/cvs-serv15639
Modified Files:
GnosisGUI.py
Log Message:
GnosisGUI now uses menu and anygui about dialog
Index: GnosisGUI.py
===================================================================
RCS file: /cvsroot/anygui/nondist/sandbox/dallasj/Gnosis/lib/Gnosis/GnosisGUI.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** GnosisGUI.py 8 Nov 2002 12:04:35 -0000 1.3
--- GnosisGUI.py 13 Nov 2002 17:32:43 -0000 1.4
***************
*** 1,40 ****
! from anygui import *
from Gnosis import Gnosis
from thread import start_new_thread
! lbx = None
! txa = None
! txf = None
!
! list = ['Web Search', 'Word Look-up', 'Find Synonym', 'Search Encyclopedia']
! gn = Gnosis()
! actions = {0: gn.GetWebSearchInfo, 1: gn.GetDefinition, 2: gn.GetSynonyms, 3: gn.GetEncyclopediaInfo}
!
! def query(lbx, txf, txa, actions):
! txa.text = actions[lbx.selection](txf.text)
!
! def send_query(event):
! global lbx, txf, txa, actions
! start_new_thread(query, (lbx, txf, txa, actions))
def main():
! global lbx, txf, txa
! app = Application()
! win = Window(x=150, y=150, size=(600, 600), \
! title = 'Gnosis: What the Web is all about!')
! app.add(win)
! lbx = ListBox(width=130)
! lbx.items = ListModel(list)
! lbx.items.value = list
! txa = TextArea(editable=0)
! txf = TextField(width=275)
! btn = Button(text='Send Query')
! link(btn, send_query)
! win.add(lbx, left=10, top=10, bottom=10, vstretch = 1)
! win.add(txa, top=10, left=(lbx, 10), right = 10, bottom = 45, hstretch = 1, vstretch = 1)
! win.add(txf, top=(txa, 10), left=(lbx, 10),\
! bottom=10, hstretch = 1, vmove = 1)
! win.add(btn, top=(txa, 10), left=(txf, 10), right=10,\
! bottom=10, hmove = 1, vmove = 1)
app.run()
--- 1,77 ----
! from anygui import Application, Window, MenuBar, Menu, Button, ListBox, TextField, TextArea
! from anygui import application, link
! from anygui.Models import ListModel
! from anygui import AboutAnyguiDlg
from Gnosis import Gnosis
from thread import start_new_thread
! gn = Gnosis()
! app = None
!
! class GnosisGUI(Window):
! actions = {0: gn.GetWebSearchInfo, 1: gn.GetDefinition, 2: gn.GetSynonyms, 3: gn.GetEncyclopediaInfo}
!
! def __init__(self, *args, **kwds):
! Window.__init__(self, *args, **kwds)
! self.init_menu()
! self.init_widgets()
!
! def init_menu(self):
! mbar = self.menuBar = MenuBar()
! self.addMenu(mbar)
! file = self.mnuFile = Menu(text="&File")
! mbar.add(file)
!
! self.cmdClose = file.addCommand(text="&Close")
! link(self.cmdClose, self.quit)
!
! help = self.mnuHelp = Menu(text="&Help")
! mbar.add(help)
!
! self.cmdAboutAnygui = help.addCommand(text="&About Anygui")
! link(self.cmdAboutAnygui, self.showAboutAnyguiDlg)
!
! def init_widgets(self):
! self.lbx = ListBox(width=130)
! list_items = ['Web Search', 'Word Look-up', 'Find Synonym', 'Search Encyclopedia']
! self.lbx.installItemsModel(ListModel(list_items))
! self.txa = TextArea(editable=0)
! self.txf = TextField(width=275)
! self.btn = Button(text='Send Query')
! link(self.btn, self.send_query)
! self.add(self.lbx, left=10, top=10, bottom=10, vstretch = 1)
! self.add(self.txa, top=10, left=(self.lbx, 10), right = 10, bottom = 45, hstretch = 1, vstretch = 1)
! self.add(self.txf, top=(self.txa, 10), left=(self.lbx, 10),\
! bottom=10, hstretch = 1, vmove = 1)
! self.add(self.btn, top=(self.txa, 10), left=(self.txf, 10), right=10,\
! bottom=10, hmove = 1, vmove = 1)
!
! def query(self):
! self.txa.text = self.actions[self.lbx.selection](self.txf.text)
!
! def send_query(self, event):
! start_new_thread(self.query, ())
!
! def quit(self, event):
! global app
! app.quit()
!
! def showAboutAnyguiDlg(self, event):
! about = AboutAnyguiDlg()
! app.add(about)
def main():
! global app
!
! app = Application(name="Gnosis", version="0.1a")
! print "Gnosis app name -> ", application().name
! print "Gnosis app version -> ", application().version
!
! try:
! app.add(GnosisGUI(x=150, y=150, size=(600, 600), \
! title = 'Gnosis: What the Web is all about!'))
! except:
! import traceback
! traceback.print_exc()
app.run()
***************
*** 42,44 ****
if __name__=='__main__':
main()
-
--- 79,80 ----
-------------------------------------------------------
This sf.net email is sponsored by: Are you worried about
your web server security? Click here for a FREE Thawte
Apache SSL Guide and answer your Apache SSL security
needs: http://www.gothawte.com/rd523.html