Thanks. Here's the essential code:
···
------------------------------------------------------
# Module KeywordMapClass
"""This module implements a map of keywords that have been applied to the selected Episode"""
import os
# load wxPython for GUI and MySQLdb for Database Access
from wxPython.wx import *
# Declare Control IDs
# Series List Combo Box
ID_SERIESLIST = 1001
# Episode List Combo Box
ID_EPISODELIST = 1002
class KeywordMap(wxFrame):
""" This is the Main Window for the Keyword Map application """
def __init__(self, parent, ID, title):
# Create the basic Frame structure with a white background
self.frame = wxFrame.__init__(self, parent, ID, title, pos=(10, 10), size=(780, 560), style=wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
self.SetBackgroundColour(wxWHITE)
# Get all Series Records
# Create a Choice Box of Series IDs
# Create a label for the choice box
self.lblSeries = wxStaticText(self, -1, "Series:", wxPoint(10,10))
# This data structure mirrors what is returned from the Database calls
SeriesIDs = (('Series1',), ('Series2',), ('Series3',))
# put all the Series IDs into a List Object
choiceList = ['']
for (Series,) in SeriesIDs:
choiceList.append(Series)
self.SeriesList = wxChoice(self, ID_SERIESLIST, wxPoint(60,7), size=(300, 26), choices=choiceList)
self.SeriesList.SetSelection(0)
EVT_CHOICE(self, ID_SERIESLIST, self.SeriesSelect)
# Create a Choice Box for Episodes, even though it's not needed yet
self.lblEpisode = wxStaticText(self, -1, "Episode:", wxPoint(400,10))
self.lblEpisode.Show(false)
# Initialize the list with 10 elements to get a decent-sized dropdown when it is populated later (!)
choiceList = ['', '', '', '', '', '', '', '', '', '']
self.EpisodeList = wxChoice(self, ID_EPISODELIST, wxPoint(450, 7), size = (300, 26), choices = choiceList)
self.EpisodeList.Show(false)
EVT_CHOICE(self, ID_EPISODELIST, self.EpisodeSelect)
# Add a Status Bar
self.CreateStatusBar()
# Show the Frame
self.Show(true)
def SeriesSelect(self, event):
# This data structure mirrors what is returned from the database
EpisodeIDs = (('%s, Episode1' % event.GetString(),), ('%s, Episode2' % event.GetString(),), ('%s, Episode3' % event.GetString(),))
self.EpisodeList.Clear()
self.EpisodeList.Append('')
for (Episode,) in EpisodeIDs:
self.EpisodeList.Append(Episode)
self.EpisodeList.SetSelection(0)
self.lblEpisode.Show(true)
self.EpisodeList.Show(true)
self.SetStatusText('Series %s selected.' % event.GetString())
def EpisodeSelect(self, event):
self.SetStatusText('Episode %s selected.' % event.GetString())
# Populate the drawing
# self.ProcessEpisode()
class MyApp(wxApp):
def OnInit(self):
frame = KeywordMap(None, -1, "Transana Keyword Map")
frame.Show(true)
self.SetTopWindow(frame)
return true
# run the application
app = MyApp()
app.MainLoop()
------------------------------------------------------
This code produces the results as if the database returned 3 rows to the first query. If you change the relevant line (line 28) to:
SeriesIDs = (('Series1',))
then you will see what happens when the database returns only one row.
In Windows, the choice box has a blank line as the first entry, and when you choose something in the "Series" choice box, the "Episode" choice box appears populated with appropriate values based on the value of Series. On the Mac, there is no blank entry (the user cannot clear the screen by deselecting), and making a selection in either box returns the wrong result, as reflected in the status bar and in the entries that populate the Episode dropdown.
(Note: I am at home, where I don't have access to a Mac, so I have not tested this exact code to prove that it fails as I describe. However, based on what occurred at the office today, I'm confident it will when I try it on Monday.)
Thanks for your time and assistance,
David Woods, Ph.D.
Wisconsin Center for Education Research
University of Wisconsin, Madison
Chris.Barker@noaa.gov 12/13/02 13:50 PM >>>
David Woods wrote:
If
the database returns only a single record, there's no way to select
anything, so the next round of processing never gets triggered. Worse, if
you have multiple records, when you make a selection, the program thinks you
selected the item in the list above it. That is, choose line 3, and the
programs processes it as if you had selected line 2. There's no way to
select and have properly processed the last item in the list.
I'm not quite sure I follow this
Is this a bug in the Mac version of wxPython? Is this an issue with Mac
OS-X that I have to work around? Am I just missing something obvious?
(Always a possibility.) Anyone have any suggestions for how I should
proceed?
I've used a wxChoice on OS-X, and the only problem I had was it no
automatically sizing for me. However, I never tried to put a blank line
in either.
If you make a small demo, with nothing but a couple of wxChoices and
simple callbacks that demonstrate the problem, I'd be glad to take a
look
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org