Re: [Tutor] How to allow user to choose an option from a window

2006-12-12 Thread Jason Massey

If you mean which type of GUI model to use you have at least two popular
choices.

Tkinter: It's bundled with Python, and there's a tutorial at:
http://www.pythonware.com/library/tkinter/introduction/
wxPython: My GUI of choice.  http://wxpython.org

A quick and dirty example in wxPython of what you wanted:

import wx

class MainWindow(wx.Frame):
   def __init__(self,parent,id,title):
   wx.Frame.__init__(self,parent,wx.ID_ANY,title,size=(200,200))
   self.radiobox = wx.RadioBox(self,wx.ID_ANY
,'Options',choices=['One','Two','Three'],style=wx.RA_SPECIFY_ROWS)

   self.Bind(wx.EVT_RADIOBOX,self.OnRadioBoxChoose,self.radiobox)
   self.Show()

   def OnRadioBoxChoose(self,event):
   choice = self.radiobox.GetStringSelection()
   wx.MessageBox("You selected: %s" % choice)

app = wx.PySimpleApp()
frame = MainWindow(None,-1,"Options")
app.MainLoop()




On 12/12/06, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:


I'm trying to allow a user to select one option from a list.

My simple code works:
OptionList = ['One', 'Two', 'Three']
while 1:
  print 'Here are your options:'
  for option in OptionList:
  print option
  optionChosen = raw_input("Which one do you want? ")
  if optionChosen in OptionList:
  break
  print "That is not a valid option.  Please re-enter your choice."
print "You have chosen: ", optionChosen

However, Now I'd like to display the options within a MsgBox-type display
and have the user click on the option of choice.

Any suggestions of a model I can adapt to accomplish this?

Thanks.

Urban Landreman

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to allow user to choose an option from a window

2006-12-12 Thread Urban . Landreman
I'm trying to allow a user to select one option from a list.

My simple code works:
OptionList = ['One', 'Two', 'Three']
while 1:
  print 'Here are your options:'
  for option in OptionList:
  print option
  optionChosen = raw_input("Which one do you want? ")
  if optionChosen in OptionList:
  break
  print "That is not a valid option.  Please re-enter your choice." 
print "You have chosen: ", optionChosen 

However, Now I'd like to display the options within a MsgBox-type display 
and have the user click on the option of choice.

Any suggestions of a model I can adapt to accomplish this?

Thanks.

Urban Landreman

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor