From: <kim...@ya...> - 2005-07-18 19:49:32
|
Schollnick, Benjamin wrote: > 1) How do I find out what Row the user has highlighted? I know > GetSelectedString will return the text, but I'm interested in finding > out row #666 is selected. > If nothing else, you can do a match of the list to get the number. if self.components.myMulList.GetSelectedString==self.components.myMulList.items[665]: May be there is an easier way that others can point you to. > a) How do I set the active row back to 667 or after I reload the > list? > Don't know how to set to a specific number but in my case, I've been using the SetStringSelection method. x=self.components.myMulList.items[666] self.components.myMulList.SetStringSelection(x,select=1) > 2) I have buttons on the custom dialog / MultiColumnList... But I would > like to activate the edit function if they double click on a row. I > thought it would be either on_Activate or on_ActivatedEvent but neither > of those seemed to work when I created a event handler. > I don't know the answer to that. > 3) > I don't know the answer to that neither. :=) -- John Henry |
From: Schollnick, B. <Ben...@xe...> - 2005-07-18 23:46:04
|
>2) I have buttons on the custom dialog / MultiColumnList... But I = would >like to activate the edit function if they double click on a row. I >thought it would be either on_Activate or on_ActivatedEvent but neither >of those seemed to work when I created a event handler. =20 | What did the MessageWatcher say the event was ? | It's itemActivated :-) Yes, I tried (from memory, I'm at home)... def on_itemActivated ( self, event): print "yes, it's me..." And got nowhere.... I was assuming that I was doing something=20 incorrect... I also tried... on_itemActivated_Command (...) on_itemActivated_Selected (...) I assume that I'm using the wrong event syntax...? - Benjamin |
From: Alex T. <al...@tw...> - 2005-07-19 00:17:17
|
Schollnick, Benjamin wrote: > | What did the MessageWatcher say the event was ? > >| It's itemActivated :-) > >Yes, I tried (from memory, I'm at home)... > >def on_itemActivated ( self, event): > print "yes, it's me..." > >And got nowhere.... I was assuming that I was doing something >incorrect... I also tried... > >on_itemActivated_Command (...) > >on_itemActivated_Selected (...) > >I assume that I'm using the wrong event syntax...? > > > Should be something like on_myList_itemActivated() -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005 |
From: Schollnick, B. <Ben...@xe...> - 2005-07-19 14:08:16
|
> Should be something like on_myList_itemActivated() Ah... I see.. Obvious.... =20 That's now working... Now regarding the reset of the selected item on a multicolumn list... def gather_data ( self ): current_item =3D self.last_picked[0] highlited =3D -1 for x in xrange(0, len(self.components.MultiColumnList1.items)): if current_item =3D=3D self.components.MultiColumnList1.items[x][0]: highlited =3D x break =20 vsoftware =3D None self.components.MultiColumnList1.items =3D [] self.components.MultiColumnList1.columnHeadings =3D [] headings =3D [] vsoftware, structure =3D self.odbc_database.select_statement ( fetch=3D"*", table=3Dself.database_name, orderby=3Dself.orderbys) for x in structure: headings.append ( x[0].replace("_", " ") ) self.components.MultiColumnList1.columnHeadings =3D headings data =3D [] line =3D [] for x in vsoftware: for y in x: line.append ( str(y) ) data.append ( line ) line =3D [] self.components.MultiColumnList1.items =3D data print dir(self.components.MultiColumnList1) self.components.MultiColumnList1.SetFocus ( highlited ) The penalty is too high..... Here's some background. The multicolumn list is a representation of what data is in a database (accessed via ODBC)... The gather_data function is used to refresh the data in the database view... After any changes (Editting, Adding, Removing) I need to refresh, but the table could be 400+ entries. It would be rather annoying for a user to make a change at the end of the table, and then have the table refreshed, and have to scroll all the way down to the end (again)..... SetSelection works to highlight the text. But it doesn't change the visible portion of the table to be in the viewing area....=20 The verified Software table is only roughly 100+ items, but if I use the for loop... for x in xrange(0, len(self.components.MultiColumnList1.items)): if current_item =3D=3D self.components.MultiColumnList1.items[x][0]: highlited =3D x break It adds roughly a 1-2 seconds to the load process.... Any suggestions? - Benjamin >=20 > --=20 > Alex Tweedly http://www.tweedly.net >=20 >=20 >=20 > --=20 > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date:=20 > 16/07/2005 >=20 >=20 |
From: Alex T. <al...@tw...> - 2005-07-19 15:09:28
|
Schollnick, Benjamin wrote: > Now regarding the reset of the selected item on a multicolumn list... > > def gather_data ( self ): > current_item = self.last_picked[0] > highlited = -1 > for x in xrange(0, len(self.components.MultiColumnList1.items)): > if current_item == >self.components.MultiColumnList1.items[x][0]: > highlited = x > break > > vsoftware = None > self.components.MultiColumnList1.items = [] > self.components.MultiColumnList1.columnHeadings = [] > headings = [] > > vsoftware, structure = self.odbc_database.select_statement ( >fetch="*", > table=self.database_name, >orderby=self.orderbys) > for x in structure: > headings.append ( x[0].replace("_", " ") ) > self.components.MultiColumnList1.columnHeadings = headings > > data = [] > line = [] > for x in vsoftware: > for y in x: > line.append ( str(y) ) > data.append ( line ) > line = [] > > self.components.MultiColumnList1.items = data > print dir(self.components.MultiColumnList1) > self.components.MultiColumnList1.SetFocus ( highlited ) > >The penalty is too high..... > >Here's some background. The multicolumn list is a representation of >what data is in a database (accessed via ODBC)... The gather_data >function is used to refresh the data in the database view... > >After any changes (Editting, Adding, Removing) I need to refresh, but >the table could be 400+ entries. > > > Do you need to re-retrieve the whole table ? Can you not remember which row you were editing and deal only with that ? (I'm naive about DBs - can you tell ? :-) >It would be rather annoying for a user to make a change at the end of >the table, and then have the table refreshed, and have to scroll all the >way down to the end (again)..... > > >SetSelection works to highlight the text. But it doesn't change the >visible portion of the table to be in the viewing area.... > >The verified Software table is only roughly 100+ items, but if I use the >for loop... > > for x in xrange(0, len(self.components.MultiColumnList1.items)): > if current_item == >self.components.MultiColumnList1.items[x][0]: > highlited = x > break > >It adds roughly a 1-2 seconds to the load process.... > >Any suggestions? > > I'm surprised that the time to load the whole table from the DB, then load that whole thing into the multicolumnlist is small enough for the extra 1-2 seconds to matter. But .... it looks to me as though what you're doing in the loop for x in xrange(0, len(self.components.MultiColumnList1.items)): if current_item == self.components.MultiColumnList1.items[x][0]: highlited = x break is getting the row number where the current_item was *before* any edit to the db. I'd have thought that once you'd edited (or deleted or added), it could be in a different row number - no ? Can't you remove that loop entirely, and get the line number while loading the table from the DB : data = [] line = [] highlited = -1 count = 0 for x in vsoftware: for y in x: line.append ( str(y) ) data.append ( line ) if line[0] == current_item: highlighted = count count += 1 line = [] self.components.MultiColumnList1.items = data print dir(self.components.MultiColumnList1) self.components.MultiColumnList1.SetFocus ( highlited ) If you can't use that, then the other possibility is to retrieve the entire table, and scan that. This saves a significant overhead for accessing each item within the multicolumnlist - but obviously can't be done if your table is too large - i.e. 400 x ?? columns (if it is too large, you may still be able to retrieve the datamap dictionary, and access that - but if you can do this it is easier) What I tried in my copy of the sample/multicolumnlist was > def on_which_mouseClick(self, event): > # current_item = "Yes" > current_item = "Not to be found" > tstart = time.time() > highlited = -1 > for j in range(20): # 20 time just to make it measurable > for x in xrange(0, len(self.components.theList.items)): > if current_item == self.components.theList.items[x][0]: > highlited = x > break > print highlited, time.time()-tstart > > tstart = time.time() > them = self.components.theList.items > highlited = -1 > for j in range(20): # 20 time just to make it measurable > for x in xrange(0, len(them)): > if current_item == them[x][0]: > highlited = x > break > print highlited, time.time()-tstart and this gave times of ~ 6 seconds for the first loop, versus no measurable time for the second. -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005 |
From: Schollnick, B. <Ben...@xe...> - 2005-07-19 15:29:13
|
> Do you need to re-retrieve the whole table ? Technically at this time, no. But in theory, this database could be accessed by multiple systems at the same time... And thus it is safer to refresh the entire table then it is to reread just a single row. > I'm surprised that the time to load the whole table from the DB, then=20 > load that whole thing into the multicolumnlist is small=20 > enough for the=20 > extra 1-2 seconds to matter. Reading the table from the database is very fast... The majority of the time involved in the gather_data routine is the Dialog window redrawing the data.... > But .... it looks to me as though what you're doing in the loop > is getting the row number where the current_item was *before*=20 > any edit to the db. Quite possible. I just did a simple check to see how it woruld work. > I'd have thought that once you'd edited (or deleted or=20 > added), it could be in a different row number - no ? Yes... It could... But even if the data is indifferent position, I don't mind the cursor being where it was previously. =20 These are software titles, etc... (It's a auditing system...) So if your editting "Norton Utilities v2.0", probably you'll want to edit something nearby... > Can't you remove that loop entirely, and get the line number=20 > while loading the table from the DB : It is possible. For some reason (I forget), I did not want to do that...... I'll make a quick model... Possibly lost in the email was a small issue... 1) SetSelected does not reposition the list to be in the visible area. Is there some other way to force the selectedvalue to be in the visible area of the dialog? - Benjamin |
From: Alex T. <al...@tw...> - 2005-07-19 15:45:38
|
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005 |
From: Schollnick, B. <Ben...@xe...> - 2005-07-19 16:57:13
|
| Even if you do it in a loop after the data is loaded (equivalent to my second timed-test) it will still be faster than going through =20 | the self.components.MultiColumnList.items[x][0] loop.=20 =20 Why is there a speed penalty in looping through the Items loop?=20 =20 | It did get kind of lost - I assumed that you did the SetFocus to overcome it ....=20 =20 I tried it, but I couldn't find heads or tails on the SetFocus documentation from wxPython.... And it appears to be for setting the focus on a group/item, not on a element in a list. | The wxPython doc for ListCtrl say you can use EnsureVisible - and I verified it by adding to my version of the sample | self.components.theList.EnsureVisible(itemidx)=20 =20 I searched, but must of missed that....=20 [Remember - PythonCard is just a layer over wxPython, you can generally look in the wxPython docs and call those functions listed there for the underlying control. You'll get faster turn-around on questions by looking up the docs yourself than waiting for me to happen to read email - 'cause all I do then is look at the docs, or at the source for the sample and/or the components/multicolumn.py :-) =20 =20 Except for the fact that I couldn't find EnsureVisible.... I'm not very happy with wxPython documentation... It's usable, but I prefer the layout of the Python docs... =20 =20 Either way, it's working now... Is the WIKI open to everyone? I'm considering trying my hands at adding some of these to the Pythoncard wiki... =20 - Benjamin =20 |
From: Alex T. <al...@tw...> - 2005-07-19 22:41:48
|
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005 |
From: Alex T. <al...@tw...> - 2005-07-19 23:46:31
|
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005 |
From: Alex T. <al...@tw...> - 2005-07-20 02:10:15
|
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005 |
From: Kooshesh, S. A <KOO...@do...> - 2005-07-19 18:02:02
|
I'm just coming in on the middle of this. If you want to focus on an item in a list use .selection =3D index If this isn't what you were looking for, sorry, I just joined this list. =20 ******************************************=20 Sayed Arian Sterling Kooshesh=20 Computer Applications Technician=20 District 2/IDOT=20 819 Depot Ave=20 Dixon, IL 61021=20 koo...@do...=20 (815) 284-5494=20 =20 ________________________________ From: pyt...@li... [mailto:pyt...@li...] On Behalf Of Schollnick, Benjamin Sent: Tuesday, July 19, 2005 11:56 AM To: Alex Tweedly Cc: pyt...@li... Subject: RE: [Pythoncard-users] Multicolumn List Questions... | Even if you do it in a loop after the data is loaded (equivalent to my second timed-test) it will still be faster than going through =20 | the self.components.MultiColumnList.items[x][0] loop.=20 =20 Why is there a speed penalty in looping through the Items loop?=20 =20 | It did get kind of lost - I assumed that you did the SetFocus to overcome it ....=20 =20 I tried it, but I couldn't find heads or tails on the SetFocus documentation from wxPython.... And it appears to be for setting the focus on a group/item, not on a element in a list. | The wxPython doc for ListCtrl say you can use EnsureVisible - and I verified it by adding to my version of the sample | self.components.theList.EnsureVisible(itemidx)=20 =20 I searched, but must of missed that....=20 [Remember - PythonCard is just a layer over wxPython, you can generally look in the wxPython docs and call those functions listed there for the underlying control. You'll get faster turn-around on questions by looking up the docs yourself than waiting for me to happen to read email - 'cause all I do then is look at the docs, or at the source for the sample and/or the components/multicolumn.py :-) =20 =20 Except for the fact that I couldn't find EnsureVisible.... I'm not very happy with wxPython documentation... It's usable, but I prefer the layout of the Python docs... =20 =20 Either way, it's working now... Is the WIKI open to everyone? I'm considering trying my hands at adding some of these to the Pythoncard wiki... =20 - Benjamin =20 |
From: Alex T. <al...@tw...> - 2005-07-19 22:43:46
|
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005 |
From: Steve C. <stn...@xm...> - 2005-07-18 21:26:10
|
John Henry wrote: > Schollnick, Benjamin wrote: > > 1) How do I find out what Row the user has > highlighted? I know > > GetSelectedString will return the text, but I'm > interested in finding > > out row #666 is selected. > > > > If nothing else, you can do a match of the list to get > the number. > > if > self.components.myMulList.GetSelectedString==self.components.myMulList.items[665]: > > May be there is an easier way that others can point > you to. > You could cheat. Make the row index either the first column or last column of the row (first if you don't mind it showing, last if you want to 'hide' it), then look at that column in the return value of getStringSelection() for example, if it's in the last column : rows = self.componenets.myMlist.getStringSelection() rowIndex = rows[0][-1:][0] -Steve |