gui development question

Ali Dada afd00 at aub.edu.lb
Fri May 2 13:56:43 EDT 2003


hi all:


i am using Pmw (can be downloaded from www.sf.net) and Tkinter in an
application. i wrote the file below, called ScrolledListBox.py, and it works
fine when run directly from the terminal (ie it brings up a ScrolledListBox with
three entries so that when you select any of them it performs it function
properly, writing 'hi' to stdout)





#!/usr/bin/env python
from Tkinter import *
import Pmw

class ImageSelection(Frame ):
		
	def __init__( self):
		root = Tk()
		Frame.__init__( self )
		Pmw.initialise()
		self.pack( expand = YES, fill=BOTH)
		self.suites=['a', 'b', 'c']
		self.listBox = Pmw.ScrolledListBox( root, items = self.suites, listbox_height
= 5, vscrollmode = "static", selectioncommand  = self.switchSuite)
		self.listBox.pack( side = LEFT, expand = YES, fill= BOTH, padx = 5, pady=5)
		
	def switchSuite(self):
		print 'hi'
		
def main():
	ImageSelection().mainloop()
	
	
if __name__ == "__main__":
	ImageSelection().mainloop()


now the problem comes. i need to call the  above from a new file called
Index.py, shown below. Index.py imports ScrolledListBox and makes a Button that
calls ScrolledListBox. surprisingly (for me at least) the three entries in the
ListBox don't perform as expected. thanks for any help cause i am completely
mixed up!!



#!/usr/bin/env python
from Tkinter import *
import ScrolledListBox

class Index(Frame):
	def __init__(self, parent=None):
		
		Frame.__init__(self, parent)
		Button(self, text='Regression', command=ScrolledListBox.main).pack(side=TOP,
fill=BOTH)
		
	
if __name__ == '__main__':
	i = Index()
	i.pack()
	i.mainloop()








More information about the Python-list mailing list