From Vasilis.Vlachoudis at cern.ch Mon Mar 9 16:01:35 2015 From: Vasilis.Vlachoudis at cern.ch (Vasilis Vlachoudis) Date: Mon, 9 Mar 2015 15:01:35 +0000 Subject: [Tkinter-discuss] Persistent Listbox selection Message-ID: <0BC70B5D93E054469872FFD0FE07220E01631C37CD@CERNXCHG54.cern.ch> Dear all, how can I keep the listbox selection persistent when user selects something in the entry? In the following example, the rows 0 to 10 are selected in the listbox If you click and select something in the entry box the selection is lost Is there an option to avoid this behaviour? Best Regards Vasilis from Tkinter import * tk = Tk() listbox = Listbox(tk, selectmode=EXTENDED, exportselection=True) listbox.pack(fill=BOTH, expand=YES) for i in range(100): listbox.insert(END,"line %d"%(i)) listbox.selection_set(0,10) entry = Entry(tk) entry.pack(side=BOTTOM, fill=X) entry.insert(0,"Hello world") tk.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Mar 9 19:14:40 2015 From: klappnase at web.de (Michael Lange) Date: Mon, 9 Mar 2015 19:14:40 +0100 Subject: [Tkinter-discuss] Persistent Listbox selection In-Reply-To: <0BC70B5D93E054469872FFD0FE07220E01631C37CD@CERNXCHG54.cern.ch> References: <0BC70B5D93E054469872FFD0FE07220E01631C37CD@CERNXCHG54.cern.ch> Message-ID: <20150309191440.a8c35b595aedde0e479642b1@web.de> Hi Vasilis, try exportselection=False Regards Michael On Mon, 9 Mar 2015 15:01:35 +0000 Vasilis Vlachoudis wrote: > Dear all, > > how can I keep the listbox selection persistent when user selects > something in the entry? In the following example, the rows 0 to 10 are > selected in the listbox If you click and select something in the entry > box the selection is lost Is there an option to avoid this behaviour? > > Best Regards > Vasilis > > from Tkinter import * > tk = Tk() > > listbox = Listbox(tk, selectmode=EXTENDED, exportselection=True) > listbox.pack(fill=BOTH, expand=YES) > for i in range(100): listbox.insert(END,"line %d"%(i)) > listbox.selection_set(0,10) > > entry = Entry(tk) > entry.pack(side=BOTTOM, fill=X) > entry.insert(0,"Hello world") > tk.mainloop() .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You speak of courage. Obviously you do not know the difference between courage and foolhardiness. Always it is the brave ones who die, the soldiers. -- Kor, the Klingon Commander, "Errand of Mercy", stardate 3201.7 From jevan at freenet.de Wed Mar 18 02:49:22 2015 From: jevan at freenet.de (jevan at freenet.de) Date: Wed, 18 Mar 2015 02:49:22 +0100 Subject: [Tkinter-discuss] Is there a way to scroll Tkinter.Text widget by pixel instead of see() (which scrolls by line)? Message-ID: <95177afee00749c95fab1e7a2f1a0c8c@email.freenet.de> ? When I type in the Text widget the text lines wrap toward the bottom of the page, the caret reaches the bottom of the Text widget. When I hit return, the caret dissapears out of view. When I type a character, the view finally scrolls up one line allowing me to see the character just typed. ? See doesn't seem to want to show this next line always, so I can't see. Is there a way scroll the Text widget by pixel, so I can get pixel perfect scrolling?? And/or how do I get the line that get the carriage return to allways bee seen on a enter? ? FYI: I am breaking each character because I have to custom process each character because the editor has several custom formating things that must occur. So the Enter is actually put in with Text.insert(), not after I have return 'break' in from the keypress event. Could this be something to do with it? --- Alle Postf?cher an einem Ort. Jetzt wechseln und E-Mail-Adresse mitnehmen! Rundum gl?cklich mit freenetMail -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Wed Mar 18 11:59:44 2015 From: klappnase at web.de (Michael Lange) Date: Wed, 18 Mar 2015 11:59:44 +0100 Subject: [Tkinter-discuss] Is there a way to scroll Tkinter.Text widget by pixel instead of see() (which scrolls by line)? In-Reply-To: <95177afee00749c95fab1e7a2f1a0c8c@email.freenet.de> References: <95177afee00749c95fab1e7a2f1a0c8c@email.freenet.de> Message-ID: <20150318115944.830763170fa2756b58dfb7e6@web.de> Hi, On Wed, 18 Mar 2015 02:49:22 +0100 jevan at freenet.de wrote: > ? > When I type in the Text widget the text lines wrap toward the bottom > of the page, the caret reaches the bottom of the Text widget. When I > hit return, the caret dissapears out of view. When I type a character, > the view finally scrolls up one line allowing me to see the character > just typed. I cannot reproduce this behavior here, could you please post a minimal code example that shows the problem? > See doesn't seem to want to show this next line always, so > I can't see. Is there a way scroll the Text widget by pixel, so I can > get pixel perfect scrolling?? And/or how do I get the line that get the > carriage return to allways bee seen on a enter? Hmm, I think text.see('insert') should do the trick, maybe you would have to add update_idletasks() for it to take effect, however if you process every key press it is probably no good idea to call update_idletasks() every time... > FYI: I am breaking each > character because I have to custom process each character because the > editor has several custom formating things that must occur. So the > Enter is actually put in with Text.insert(), not after I have return > 'break' in from the keypress event. Could this be something to do with > it? Probably, if we could see a code example it might help to track down the cause for the problem. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We'll pivot at warp 2 and bring all tubes to bear, Mr. Sulu!