From andrewerol at gmail.com Tue Feb 1 10:12:21 2011 From: andrewerol at gmail.com (Andrey Antonov (Gmail)) Date: Tue, 1 Feb 2011 11:12:21 +0200 Subject: [Tkinter-discuss] GUI with SWITCHING BETWEEN SEVERAL REGIONAL LANGUAGES References: Message-ID: Hi folks, I have a GUI and I want to redraw/refresh all the GUI elements/widgets when the user wants to switch to its own regional language. Any tools with Tkinter, or any idea outside Tkinter. Thx Andrewerol From python at bdurham.com Tue Feb 1 14:15:40 2011 From: python at bdurham.com (python at bdurham.com) Date: Tue, 01 Feb 2011 08:15:40 -0500 Subject: [Tkinter-discuss] Tkinter library/technique that supports panels that can be docked, undocked, and resized? Message-ID: <1296566140.27463.1418347069@webmail.messagingengine.com> Wondering if there's a 3rd party Tkinter or Tk library or a general programming technique that would allow one to create Tkinter based applications with panels that can be docked, undocked, and resized (while docked and undocked)? Here's an example of what I'm talking about. This is a short 1 minute screencast of a wxPython based framework called Dabo demonstrating the capabilities that my users have asked for. http://screencast.com/t/3qRgqHsJVbK I'm using Python 2.7 under Windows and have noticed that Tkinter appears to have some built-in concept of docking when TopLevel windows are moved around the desktop. Is there a way to trap these Tkinter docking events and use Tkinter's built-in docking behaviors to implement this type of functionality? Regards, Malcolm From kw at codebykevin.com Tue Feb 1 15:29:12 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 01 Feb 2011 09:29:12 -0500 Subject: [Tkinter-discuss] Tkinter library/technique that supports panels that can be docked, undocked, and resized? In-Reply-To: <1296566140.27463.1418347069@webmail.messagingengine.com> References: <1296566140.27463.1418347069@webmail.messagingengine.com> Message-ID: <4D4818B8.3030805@codebykevin.com> On 2/1/11 8:15 AM, python at bdurham.com wrote: > Wondering if there's a 3rd party Tkinter or Tk library or a general > programming technique that would allow one to create Tkinter based > applications with panels that can be docked, undocked, and resized > (while docked and undocked)? I don't think Tk has support for this, either as a library or a core function. You can fake it using various techniques, but it would be a lot of work. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From spooky.ln at tbs-software.com Tue Feb 1 16:16:56 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Tue, 1 Feb 2011 16:16:56 +0100 Subject: [Tkinter-discuss] scrolling more widgets with one scrollbar Message-ID: <20110201161656.4da1c7b2@tbs-software.com> Hi all, I need scroll 3 Text widgets with one scrollbar. All is packed into grid [text, text, text, scrollbar] all Text widgets have font on same size how i scroll all 3 widgets 'synced' using scrollbar ? i have a method which is scrollbar.command def update_widgets(self, *args): # scrolling all 3 widgets for win in self.textwindows: win.yview_moveto(args[1]) this scrolling widgets but after few 'slides' rows are not synced :( and second question is 'how i set next 2 widgets and scrollbar if i scroll some widget using keyboard? ' i think it must be something like scrollbar.set(*args) in widget.yscrollcommand but i'm trying without luck. thanks From klappnase at web.de Thu Feb 3 11:56:35 2011 From: klappnase at web.de (Michael Lange) Date: Thu, 3 Feb 2011 11:56:35 +0100 Subject: [Tkinter-discuss] scrolling more widgets with one scrollbar In-Reply-To: <20110201161656.4da1c7b2@tbs-software.com> References: <20110201161656.4da1c7b2@tbs-software.com> Message-ID: <20110203115635.ab3b7812.klappnase@web.de> Hi, Thus spoketh "Martin B." unto us on Tue, 1 Feb 2011 16:16:56 +0100: > Hi all, > I need scroll 3 Text widgets with one scrollbar. > All is packed into grid [text, text, text, scrollbar] > > all Text widgets have font on same size > how i scroll all 3 widgets 'synced' using scrollbar ? > > i have a method which is scrollbar.command > > def update_widgets(self, *args): > # scrolling all 3 widgets > for win in self.textwindows: > win.yview_moveto(args[1]) > > this scrolling widgets but after few 'slides' rows are not synced :( I'd replace this with something like: def update_widgets(self, *args): for win in self.textwindows: win.yview(*args) If this still doesn't work properly, i would try and add an update_idletasks() to the function. At least here this does not seem to be necessary though. > > and second question is 'how i set next 2 widgets and scrollbar if i > scroll some widget using keyboard? ' This appears to be a lot more tricky ;) These key bindings are defined in the file text.tcl and I am afraid in order to properly set up synchrounous scrolling you will have to dig yourself through this and add appropriate callbacks to all of the default bindings for Up, Down, Prior, Next ... keys and some mouse events. Fortunately this doesn't seem to be too hard once you understand how this works: For example, the binding for the event on the tcl level looks like this (%W replaces the widget taht receives the event here): bind Text { tk::TextSetCursor %W [tk::TextUpDownLine %W 1] } In order to "translate" this into python, you will have to use the widget's tk.call() magic (it does not matter which is the "calling" widget here). First check the return value of the embedded tk command and then pass it to the outer tk command: x = root.tk.call('tk::TextUpDownLine', textwidget, 1) root.tk.call('tk::TextSetCursor', textwidget, x) I set up a minimal example that shows how to use this technique to set up modified key bindings that allow to scroll two text widgets synchronously with the Up and Down keys: ########################################### from Tkinter import * root = Tk() t1 = Text(root, height=20, width=40) t1.pack(side='left') t2 = Text(root, height=20, width=40) t2.pack(side='left') # add some text to scroll f = open(__file__, 'r') text = f.read() f.close() t1.insert('end', text) t2.insert('end', text) def yview(*args): t1.yview(*args) t2.yview(*args) sb = Scrollbar(root, command=yview) sb.pack(side='right', fill='y') t1.configure(yscrollcommand=sb.set) t2.configure(yscrollcommand=sb.set) slave = {t1: t2, t2: t1} for t in (t1, t2): def down(event): root.tk.call('tk::TextSetCursor', slave[event.widget], root.tk.call('tk::TextUpDownLine', event.widget, 1)) t.bind('', down, add=True) def up(event): root.tk.call('tk::TextSetCursor', slave[event.widget], root.tk.call('tk::TextUpDownLine', event.widget, -1)) t.bind('', up, add=True) root.mainloop() ########################################### I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. You'll learn something about men and women -- the way they're supposed to be. Caring for each other, being happy with each other, being good to each other. That's what we call love. You'll like that a lot. -- Kirk, "The Apple", stardate 3715.6 From spooky.ln at tbs-software.com Thu Feb 3 18:34:24 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Thu, 3 Feb 2011 18:34:24 +0100 Subject: [Tkinter-discuss] scrolling more widgets with one scrollbar In-Reply-To: <20110203115635.ab3b7812.klappnase@web.de> References: <20110201161656.4da1c7b2@tbs-software.com> <20110203115635.ab3b7812.klappnase@web.de> Message-ID: <20110203183424.28af08d5@tbs-software.com> Thanks this helps a lot. Your code for keypress looks like you call internal Tcl/Tk commands ? Seems like my for mousewheel. But dont generate any signal i must use Button-4 and Button-5 on linux. def mousewheel_cb(event): direction = 1 if event.num == 5 else -1 for win in self.textwindows: win.yview('scroll', direction, 'units') this working nice. From spooky.ln at tbs-software.com Thu Feb 3 18:50:30 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Thu, 3 Feb 2011 18:50:30 +0100 Subject: [Tkinter-discuss] Text spacing. Message-ID: <20110203185030.4792f21f@tbs-software.com> Hi again, I write simple hexedit for my home use and i searching solution for setting some spaces between chars in Text widget. Something like 'spacingN' for Y. Exists ? I dont want to insert extra space between chars like now. i have 16bytes on line in {0:02X}format. 0011223344556677 > this is ugly 00 11 22 33 44 55 66 77 > this with spaces in bettween is better can i make this without spaces ? thanks From klappnase at web.de Thu Feb 3 18:55:40 2011 From: klappnase at web.de (Michael Lange) Date: Thu, 3 Feb 2011 18:55:40 +0100 Subject: [Tkinter-discuss] scrolling more widgets with one scrollbar In-Reply-To: <20110203115635.ab3b7812.klappnase@web.de> References: <20110201161656.4da1c7b2@tbs-software.com> <20110203115635.ab3b7812.klappnase@web.de> Message-ID: <20110203185540.4726df51.klappnase@web.de> Hi again, Thus spoketh Michael Lange unto us on Thu, 3 Feb 2011 11:56:35 +0100: > I set up a minimal example that shows how to use this technique to set > up modified key bindings that allow to scroll two text widgets > synchronously with the Up and Down keys: > At a second glance my example isn't so nice either, because it does not only sync the yview but also the cursor position, which is most likely not wanted. However this can be easily fixed by restoring the "slave" widget's cursor position with something like: def down(event): oldinsert = slave[event.widget].index('insert') root.tk.call('tk::TextSetCursor', slave[event.widget], root.tk.call('tk::TextUpDownLine', event.widget, 1)) slave[event.widget].mark_set('insert', oldinsert) Doing this for lots of event sequences is quite a pita though, maybe wrapping it like this is a bit better: slave = {t1: t2, t2: t1} def callback(textwidget, *args): oldinsert = slave[textwidget].index('insert') root.tk.call(*args) slave[textwidget].mark_set('insert', oldinsert) for t in (t1, t2): def down(event): callback(event.widget, 'tk::TextSetCursor', slave[event.widget], root.tk.call('tk::TextUpDownLine', event.widget, 1)) t.bind('', down, add=True) def up(event): callback(event.widget, 'tk::TextSetCursor', slave[event.widget], root.tk.call('tk::TextUpDownLine', event.widget, -1)) t.bind('', up, add=True) Unfortunately nothing that uses just the yview() methods seems to work, too bad that the most "obvious" thing, simply doing text2.yview(text1.yview ()) is not supported. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. But Captain -- the engines can't take this much longer! From spooky.ln at tbs-software.com Thu Feb 3 18:57:39 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Thu, 3 Feb 2011 18:57:39 +0100 Subject: [Tkinter-discuss] scrolling more widgets with one scrollbar In-Reply-To: <20110203115635.ab3b7812.klappnase@web.de> References: <20110201161656.4da1c7b2@tbs-software.com> <20110203115635.ab3b7812.klappnase@web.de> Message-ID: <20110203185739.04fc2b0b@tbs-software.com> sorry im late. this is picture with 'not synced rows'. http://oops.rajce.idnes.cz/nastenka/#xcg.jpg From klappnase at web.de Thu Feb 3 19:12:46 2011 From: klappnase at web.de (Michael Lange) Date: Thu, 3 Feb 2011 19:12:46 +0100 Subject: [Tkinter-discuss] scrolling more widgets with one scrollbar In-Reply-To: <20110203183424.28af08d5@tbs-software.com> References: <20110201161656.4da1c7b2@tbs-software.com> <20110203115635.ab3b7812.klappnase@web.de> <20110203183424.28af08d5@tbs-software.com> Message-ID: <20110203191246.39a55d2b.klappnase@web.de> Hi, Thus spoketh "Martin B." unto us on Thu, 3 Feb 2011 18:34:24 +0100: > Thanks this helps a lot. > Your code for keypress looks like you call internal Tcl/Tk commands ? Yes, as I said these commands are defined in text.tcl (on linux this can usually be found at /usr/lib/tk8.x or so), and the widget.tk.call() mechanism is the magic that allows us to access Tcl/Tk's internal commands from Python. Once you understood how to handle Tcl/Tk commands from Python it is quite straightforward and a great and powerful way to enhance Tkinter's capabilities, so I absolutely recommend to have a closer look at it ;) A great way to learn using tk.call() is to compare for example the button widget's tcl man page (just try "man button") with the code from "class Button" in Tkinter.py, you will easily see how this works. > > Seems like my for mousewheel. > > But dont generate any signal i must use Button-4 and > Button-5 on linux. I think is windows and OSX only. > > def mousewheel_cb(event): > direction = 1 if event.num == 5 else -1 > for win in self.textwindows: > win.yview('scroll', direction, 'units') You should be careful here, according to text.tcl the default on X11 is +/- 50 pixels , so your success here depends if one unit equals to 50 pixels. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. There's coffee in that nebula! -- Capt. Kathryn Janeway, Star Trek: Voyager, "The Cloud" From spooky.ln at tbs-software.com Fri Feb 4 17:21:49 2011 From: spooky.ln at tbs-software.com (Martin B.) Date: Fri, 4 Feb 2011 17:21:49 +0100 Subject: [Tkinter-discuss] removing tags from tkinter.Text Message-ID: <20110204172149.68fe7d60@tbs-software.com> Hi all, I'm trying some code snippets with tags in Text. In example i only hilite line on cursor.insert. 1. first tag removing is only from visible lines 2. second removing from whole buffer all this using -after command 3. using -bind to event 3 is unusable for me coz highlighted line is always after cursor if i move UP and DOWN 2 is better but tag is applied on last line too if i move UP after. But still better than 3 1 on first i dont want to remove tags from whole widget but after some timing this way is faster than 2. [ tested on 120kb .py file] any ideas for improvement and some speedup for this ? thanks. ########################################################################## #encoding: utf-8 from tkinter import * import time class MyText(Text): def __init__(self, parent, **kwargs): super().__init__(parent, **kwargs) self.focus() self.update = None #self.bind('', self.hilite) self.tag_configure('cyanline', background='cyan') if self.update is None: self.hilite() def hilite(self, event=None): start = time.time() cur_line = int(self.index('insert').split('.')[0]) #self.tag_remove('cyanline', 1.0, 'end') self.tag_remove('cyanline', '@0,0', '@0,{0}'.format(self.winfo_height())) self.tag_add('cyanline', '{0}.0'.format(cur_line), '{0}.0'.format(cur_line +1)) self.update = self.after(100, self.hilite) end = time.time() print('Time: ', (end - start) * 10000) #return 'break' class Test(Tk): def __init__(self): super().__init__() text = MyText(self, width=40, height=10, font='courier 8 normal') text.pack(fill='both', expand='yes') if __name__ == '__main__': app = Test() app.title('Hilite line test') app.mainloop() ######################################################################## From trevor at jcmanagement.net Wed Feb 9 17:54:13 2011 From: trevor at jcmanagement.net (Trevor J. Christensen) Date: Wed, 9 Feb 2011 09:54:13 -0700 Subject: [Tkinter-discuss] TclStackFree Error Message-ID: <000701cbc879$faeff920$0802a8c0@trevor> Under Windows XP, the following simple program crashes after 20 seconds or so with the following error: TclStackFree: incorrect freePtr. Call out of sequence? It behaves the same under python 2.6 and python 2.7. I suspect it has something to do with Tk/Tcl's multithreading model. I did discover that if you comment out the vertical scrollbar code, this program will run fine. I could use some help here in figuring out what the problem is. import threading, ttk, time from Tkinter import * EVENT = '<>' class Monitor(threading.Thread): def run(self): while True: text.event_generate(EVENT) time.sleep(.5) def on_event(*args): text.insert(END, time.ctime()+'\n') text.see(END) root = Tk() text = Text(root) vbar = ttk.Scrollbar(root, orient=VERTICAL) vbar['command'] = text.yview text['yscrollcommand'] = vbar.set text.grid(column=0, row=0, sticky=NSEW) vbar.grid(column=1, row=0, sticky=NS) root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) text.bind(EVENT, on_event) worker = Monitor() worker.start() root.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Wed Feb 9 19:31:55 2011 From: klappnase at web.de (Michael Lange) Date: Wed, 9 Feb 2011 19:31:55 +0100 Subject: [Tkinter-discuss] TclStackFree Error In-Reply-To: <000701cbc879$faeff920$0802a8c0@trevor> References: <000701cbc879$faeff920$0802a8c0@trevor> Message-ID: <20110209193155.5293b3ce.klappnase@web.de> Hi Trevor, Thus spoketh "Trevor J. Christensen" unto us on Wed, 9 Feb 2011 09:54:13 -0700: > Under Windows XP, the following simple program crashes after 20 seconds > or so with the following error: > > TclStackFree: incorrect freePtr. Call out of sequence? > > It behaves the same under python 2.6 and python 2.7. > > I suspect it has something to do with Tk/Tcl's multithreading model. I > did discover that if you comment out the vertical scrollbar code, this > program will run fine. I could use some help here in figuring out what > the problem is. The problem is that you must _n e v e r_ access the tk event loop from more than one thread. The best practice is to always run the mainloop () within the main program thread and, if child threads are really necessary, to use e.g. threading.Condition or Queue.Queue objects to handle the communication between Tkinter and the child thread. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Without facts, the decision cannot be made logically. You must rely on your human intuition. -- Spock, "Assignment: Earth", stardate unknown From sharalyn at jcmanagement.net Wed Feb 9 17:31:38 2011 From: sharalyn at jcmanagement.net (Sharalyn C. Christensen) Date: Wed, 9 Feb 2011 09:31:38 -0700 Subject: [Tkinter-discuss] TclStackFree error Message-ID: <000201cbc876$d378b330$0802a8c0@trevor> The following simple program crashes after about 20 seconds or so with the following error: TclStackFree: incorrect FreePtr. Call out of sequence? It behaves the same under Python 2.6 and Python 2.7 under Window XP service pack 2. I have a hunch it has to do with Tk/Tcl's multithreading model. I could use some help here. I did discover that if one removes the scrollbar code, this program runs forever with out a hitch. CODE: import threading, ttk, time from Tkinter import * EVENT = '<>' class Monitor(threading.Thread): def run(self): while True: text.event_generate(EVENT) time.sleep(.5) def on_event(*args): text.insert(END, time.ctime()+'\n') text.see(END) root = Tk() text = Text(root) vbar = ttk.Scrollbar(root, orient=VERTICAL) vbar['command'] = text.yview text['yscrollcommand'] = vbar.set text.grid(column=0, row=0, sticky=NSEW) vbar.grid(column=1, row=0, sticky=NS) root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) text.bind(EVENT, on_event) worker = Monitor() worker.start() root.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From trevor at jcmanagement.net Fri Feb 11 16:20:27 2011 From: trevor at jcmanagement.net (Trevor J. Christensen) Date: Fri, 11 Feb 2011 08:20:27 -0700 Subject: [Tkinter-discuss] TclStackFree Error Message-ID: <000101cbc9ff$36490670$0802a8c0@trevor> > The problem is that you must _n e v e r_ access the tk event loop > from more than one thread. The best practice is to always run the > mainloop () within the main program thread and, if child threads are > really necessary, to use e.g. threading.Condition or Queue.Queue > objects to handle the communication between Tkinter and the child > thread. > Michael Thank you for your help. Yes, you are right. Child threads must not control Tk and must communicate via share a thread communication mechanism. The following is my solution which works very well: import threading, time, socket from Tkinter import * EVENT = '<>' PORT = 12339 ADDR = ('', PORT) BUFSIZ = 1024 class Monitor(object): def __init__(self): self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.s.settimeout(0.0) # non-blocking self.s.bind(ADDR) self.run() def run(self): while True: try: data, addr = self.s.recvfrom(BUFSIZ) except socket.error, msg: break # I modified Tkinter.py slightly to support the 'data' key text.event_generate(EVENT, data=data) root.after(500, self.run) # Reschedule def On_EVENT(*args): event = args[0] text.insert(END, event.data) try: # Handle Tk vertical scroll bar bug v = vbar.get()[1] except ValueError: v = 0.0 if not v < 0.95: # Support user review of history text.see(tk.END) text.see(END) root = Tk() #--------------------------------------- text = Text(root) vbar = Scrollbar(root, orient=VERTICAL) vbar['command'] = text.yview text['yscrollcommand'] = vbar.set #--------------------------------------- text.grid(column=0, row=0, sticky=NSEW) vbar.grid(column=1, row=0, sticky=NS) root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) #--------------------------------------- text.bind(EVENT, On_EVENT) #--------------------------------------- worker = Monitor() #--------------------------------------- root.mainloop() Trevor -------------- next part -------------- An HTML attachment was scrubbed... URL: From trevor at jcmanagement.net Fri Feb 11 16:09:21 2011 From: trevor at jcmanagement.net (Trevor J. Christensen) Date: Fri, 11 Feb 2011 08:09:21 -0700 Subject: [Tkinter-discuss] TclStackFree Error In-Reply-To: <20110209193155.5293b3ce.klappnase@web.de> Message-ID: <000001cbc9fd$aa424610$0802a8c0@trevor> > Hi Trevor, > > Thus spoketh "Trevor J. Christensen" > unto us on Wed, 9 Feb 2011 09:54:13 -0700: > > > Under Windows XP, the following simple program crashes after 20 > > seconds or so with the following error: > > > > TclStackFree: incorrect freePtr. Call out of sequence? > > > > It behaves the same under python 2.6 and python 2.7. > > > > I suspect it has something to do with Tk/Tcl's > multithreading model. > > I did discover that if you comment out the vertical scrollbar code, > > this program will run fine. I could use some help here in figuring > > out what the problem is. > > The problem is that you must _n e v e r_ access the tk event > loop from more than one thread. The best practice is to > always run the mainloop () within the main program thread > and, if child threads are really necessary, to use e.g. > threading.Condition or Queue.Queue objects to handle the > communication between Tkinter and the child thread. > > Regards > > Michael > Michael, thank you for your help. The following is my final solution which works very well: import threading, time, socket from Tkinter import * EVENT = '<>' PORT = 12339 ADDR = ('', PORT) BUFSIZ = 1024 class Monitor(object): def __init__(self): self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.s.settimeout(0.0) # non-blocking self.s.bind(ADDR) self.run() def run(self): while True: try: data, addr = self.s.recvfrom(BUFSIZ) except socket.error, msg: break # I modified Tkinter.py slightly to support the 'data' key text.event_generate(EVENT, data=data) root.after(200, self.run) # Reschedule def On_EVENT(*args): event = args[0] text.insert(END, event.data) try: # Handle Tk vertical scroll bar bug v = vbar.get()[1] except ValueError: v = 0.0 if not v < 0.95: # Support user review of history text.see(tk.END) text.see(END) root = Tk() #--------------------------------------- text = Text(root) vbar = Scrollbar(root, orient=VERTICAL) vbar['command'] = text.yview text['yscrollcommand'] = vbar.set #--------------------------------------- text.grid(column=0, row=0, sticky=NSEW) vbar.grid(column=1, row=0, sticky=NS) root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) #--------------------------------------- text.bind(EVENT, On_EVENT) #--------------------------------------- worker = Monitor() #--------------------------------------- root.mainloop() From prog at vtr.net Tue Feb 15 20:58:25 2011 From: prog at vtr.net (craf) Date: Tue, 15 Feb 2011 16:58:25 -0300 Subject: [Tkinter-discuss] justify text in Text widget Message-ID: <1297799905.5136.7.camel@cristian-desktop> Hi. Is there any possibility to justify the text within a Text control?. In my example code, I set the text using the wrap option value 'word' Code:-------------------------------------------------------------- import Tkinter master = Tkinter.Tk() master.geometry('150x100') t = Tkinter.Text(master, wrap='word') t.pack(side='top', fill='both') master.mainloop() Thanks in advance.! Regards Cristian Abarz?a F. ----------------------- S.O: Ubuntu 9.10 Python 2.7 Gnome 2.28 Tkinter 8.5 From michael.odonnell at uam.es Tue Feb 15 21:09:03 2011 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Tue, 15 Feb 2011 21:09:03 +0100 Subject: [Tkinter-discuss] justify text in Text widget In-Reply-To: <1297799905.5136.7.camel@cristian-desktop> References: <1297799905.5136.7.camel@cristian-desktop> Message-ID: I had a look at the tcl8.6 page (the most recent version) and it only allows -justify: left, right or center. Some notes/code how to justify text in a text widget shown in http://wiki.tcl.tk/1774 but that would need to be translated to python code. Seems lots of work, and highly artificial Mick On Tue, Feb 15, 2011 at 8:58 PM, craf wrote: > Hi. > > Is there any possibility to justify the text within a Text control?. In > my example code, I set the text using the wrap option value 'word' > > Code:-------------------------------------------------------------- > > import Tkinter > > master = Tkinter.Tk() > master.geometry('150x100') > t = Tkinter.Text(master, wrap='word') > t.pack(side='top', fill='both') > > master.mainloop() > > > Thanks in advance.! > > Regards > > Cristian Abarz?a F. > > ----------------------- > S.O: Ubuntu 9.10 > Python 2.7 > Gnome 2.28 > Tkinter 8.5 > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From klappnase at web.de Tue Feb 15 21:45:04 2011 From: klappnase at web.de (Michael Lange) Date: Tue, 15 Feb 2011 21:45:04 +0100 Subject: [Tkinter-discuss] justify text in Text widget In-Reply-To: References: <1297799905.5136.7.camel@cristian-desktop> Message-ID: <20110215214504.06d06ac5.klappnase@web.de> Thus spoketh "Michael O'Donnell" unto us on Tue, 15 Feb 2011 21:09:03 +0100: > I had a look at the tcl8.6 page (the most recent version) > and it only allows -justify: left, right or center. As far as I see, there is no such option for the widget as a whole, but only for a particular tag. So in order to right-justify the contents of a text widget you will need to do: textwidget.tag_configure('sometag', justify='right') textwidget.tag_add('sometag', 1.0, 'end') The problem here is that you will have to do this explicitely every time some new text is inserted into the text widget. Even worse, you will have to find a way to automatically keep track of the widget's contents. I don't know if there is a way to configure the text's "default tag" so you will only have to do this once. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. After a time, you may find that "having" is not so pleasing a thing, after all, as "wanting." It is not logical, but it is often true. -- Spock, "Amok Time", stardate 3372.7 From georges.arsouze at gmail.com Wed Feb 16 14:43:26 2011 From: georges.arsouze at gmail.com (Georges Arsouze) Date: Wed, 16 Feb 2011 14:43:26 +0100 Subject: [Tkinter-discuss] Help Message-ID: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> I'm beginning with Python 3.1 I'm working on Mac Os Snow leopard I have Tcl/tk on my mac : in a terminal when i do wish I obtain a window with title Wish and when I do About Tcl/Tk i have Tcl 8.5 &Tk 8.5 Another way : in a terminal i do tclsh and infopatchlevel i obtain 8.5.7 I want to use tkinter.ttk in Python 3.1 I go at this adress on the web http://www.tkdocs.com/tutorial/install.html In python 3.1 I try >>> import tkinter >>> tkinter._test() This should pop up a small window; the first line at the top of the window should say "This is Tcl/Tk version 8.5"; make sure it is not 8.4! On my Mac I have a window. Inside of this window i have : This is Tc/Tk version 8.4 ............. Another thing In python 3.1 when i try to use ttk i have an error message about package tile Can you help me ? Sorry for my english. I'm a french teatcher -------------- next part -------------- An HTML attachment was scrubbed... URL: From prog at vtr.net Wed Feb 16 16:13:34 2011 From: prog at vtr.net (craf) Date: Wed, 16 Feb 2011 12:13:34 -0300 Subject: [Tkinter-discuss] [Fwd: Re: justify text in Text widget] Message-ID: <1297869214.2616.1.camel@cristian-desktop> --------- Mensaje reenviado -------- > De: Michael Lange > Para: tkinter-discuss at python.org > Asunto: Re: [Tkinter-discuss] justify text in Text widget > Fecha: Tue, 15 Feb 2011 21:45:04 +0100 > > Thus spoketh "Michael O'Donnell" > unto us on Tue, 15 Feb 2011 21:09:03 +0100: > > > I had a look at the tcl8.6 page (the most recent version) > > and it only allows -justify: left, right or center. > > As far as I see, there is no such option for the widget as a whole, but > only for a particular tag. So in order to right-justify the contents of a > text widget you will need to do: > > textwidget.tag_configure('sometag', justify='right') > textwidget.tag_add('sometag', 1.0, 'end') > > The problem here is that you will have to do this explicitely every time > some new text is inserted into the text widget. Even worse, you will have > to find a way to automatically keep track of the widget's contents. > > I don't know if there is a way to configure the text's "default tag" so > you will only have to do this once. > > Regards > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > After a time, you may find that "having" is not so pleasing a thing, > after all, as "wanting." It is not logical, but it is often true. > -- Spock, "Amok Time", stardate 3372.7 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss Thanks for the info! Regards Cristian From davecortesi at gmail.com Wed Feb 16 17:28:41 2011 From: davecortesi at gmail.com (David Cortesi) Date: Wed, 16 Feb 2011 08:28:41 -0800 Subject: [Tkinter-discuss] Help In-Reply-To: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> References: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> Message-ID: > > On my Mac I have a window. Inside of this window i have : This is Tc/Tk > version 8.4 ............. > > Another thing > In python 3.1 when i try to use ttk i have an error message about package > tile > This is a problem that I encountered and was discussed in several messages on this list a few months ago. Look in the list archives for August, http://mail.python.org/pipermail/tkinter-discuss/2010-August/thread.html The problem is that Apple distributes Tcl/Tk 8.4 with OS X, located in /System/Library/Frameworks/Tcl.framework and Tk.framework. You have also installed a later Tcl/Tk but alas, the location of Tcl/Tk is compiled into the tkinter module as the default Apple location. Thus tkinter will always load the old version. This is a long-standing problem with no simple solution for the beginner. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nad at acm.org Thu Feb 17 11:33:58 2011 From: nad at acm.org (Ned Deily) Date: Thu, 17 Feb 2011 02:33:58 -0800 Subject: [Tkinter-discuss] Help References: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> Message-ID: In article , David Cortesi wrote: > > On my Mac I have a window. Inside of this window i have : This is Tc/Tk > > version 8.4 ............. > > > > Another thing > > In python 3.1 when i try to use ttk i have an error message about package > > tile > > > > > This is a problem that I encountered and was discussed in several messages > on this list a few months ago. Look in the list archives for August, > > http://mail.python.org/pipermail/tkinter-discuss/2010-August/thread.html > > The problem is that Apple distributes Tcl/Tk 8.4 with OS X, located in > /System/Library/Frameworks/Tcl.framework and Tk.framework. You have also > installed a later Tcl/Tk but alas, the location of Tcl/Tk is compiled into > the tkinter module as the default Apple location. Thus tkinter will always > load the old version. That's not quite accurate. With Mac OS X 10.6 (Snow Leopard), Apple distributes both a Tcl/Tk 8.4 and 8.5 and does not distribute a Python 3.x, only Python 2.6 and 2.5. If you are using a Python 3.1.x installer for Mac OS X from python.org, it is linked only with Tk 8.4, although you can install a more recent version of Tcl/Tk 8.4 from ActiveState. Python 3.2, which is scheduled to be officially released this weekend, will have two OS X installers, one only for OS X 10.6 and linked with Tcl/Tk 8.5. However, there are a number of serious problems with the version of Tcl/Tk 8.5 currently supplied by Apple with OS X 10.6; to successfully use tkinter (and IDLE) with this version you must also install the most recent ActiveState Tcl/Tk 8.5.9 version for OS X. -- Ned Deily, nad at acm.org From davecortesi at gmail.com Thu Feb 17 17:29:36 2011 From: davecortesi at gmail.com (David Cortesi) Date: Thu, 17 Feb 2011 08:29:36 -0800 Subject: [Tkinter-discuss] Help In-Reply-To: References: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> Message-ID: > On Thu, Feb 17, 2011 at 2:33 AM, Ned Deily wrote: > That's not quite accurate. With Mac OS X 10.6 (Snow Leopard), Apple > distributes both a Tcl/Tk 8.4 and 8.5 and does not distribute a Python > 3.x, only Python 2.6 and 2.5. If you are using a Python 3.1.x installer > for Mac OS X from python.org, it is linked only with Tk 8.4, although > you can install a more recent version of Tcl/Tk 8.4 from ActiveState. > Python 3.2, which is scheduled to be officially released this weekend, > will have two OS X installers, one only for OS X 10.6 and linked with > Tcl/Tk 8.5. However, there are a number of serious problems with the > version of Tcl/Tk 8.5 currently supplied by Apple with OS X 10.6; to > successfully use tkinter (and IDLE) with this version you must also > install the most recent ActiveState Tcl/Tk 8.5.9 version for OS X. > Thank you for clarifying. However, I believe I will stand by my closing sentence which you did not quote, "This is a long-standing problem with no simple solution for the beginner." (Georges, who asked the original question, is clearly a beginner.) I am pleased to hear that the next Py3 will begin to recognize this problem with "two installers" but it is not clear from your brief description how this will help. If both installers follow the former practice, of hard-coding the path to /System/Frameworks/(etc) into the tkinter module, neither will be able to use the ActiveState Tcl, which doesn't install into /System. For Python 3.1, the only solution I found was to use ActiveState's latest Python with ActiveState's latest Tcl/Tk. Will the new python.org package do something smart, like finding all Tcl/Tk frameworks at install time and offering the user a choice? Or by using a shell variable in tkinter to locate Tcl/Tk dynamically at run time? Dave Cortesi -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.odonnell at uam.es Thu Feb 17 18:51:10 2011 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 17 Feb 2011 18:51:10 +0100 Subject: [Tkinter-discuss] Help In-Reply-To: References: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> Message-ID: A solution here (but not for beginners to programming) is to compile python yourself, and tell the compile script where to look for TCL/TK. A comment from somewhere else and 2 years old or so. Hopefully things are still the same: -------------------- [Kevin's post of 6.Oct, 02:58] You can avoid this problem by building Python yourself and putting /Library/Frameworks first on the search path for Tcl/Tk. Look in setup.py in the source code, around line 1438 (in the 'detect_tkinter_darwin' function), and either comment out /System/Library or put it underneath /Library/Frameworks. This is what the official build from Python.org should do--look first in /Library/Frameworks and then fall back on /System/Library/Frameworks. I'm not sure why it doesn't. ------------------- On Thu, Feb 17, 2011 at 5:29 PM, David Cortesi wrote: > >> On Thu, Feb 17, 2011 at 2:33 AM, Ned Deily wrote: >> That's not quite accurate. ?With Mac OS ?X 10.6 (Snow Leopard), Apple >> distributes both a Tcl/Tk 8.4 and 8.5 and does not distribute a Python >> 3.x, only Python 2.6 and 2.5. ?If you are using a Python 3.1.x installer >> for Mac OS X from python.org, it is linked only with Tk 8.4, although >> you can install a more recent version of Tcl/Tk 8.4 from ActiveState. >> Python 3.2, which is scheduled to be officially released this weekend, >> will have two OS X installers, one only for OS X 10.6 and linked with >> Tcl/Tk 8.5. ?However, there are a number of serious problems with the >> version of Tcl/Tk 8.5 currently supplied by Apple with OS X 10.6; ?to >> successfully use tkinter (and IDLE) with this version you must also >> install the most recent ActiveState Tcl/Tk 8.5.9 version for OS X. > > Thank you for clarifying. However, I believe I will stand by my closing > sentence which you did not quote, "This is a long-standing problem with no > simple solution for the beginner." (Georges, who asked the original > question, is clearly a beginner.) > > I am pleased to hear that the next Py3 will begin to recognize this problem > with "two installers" but it is not clear from your brief description how > this will help. If both installers follow the former practice, of > hard-coding the path to /System/Frameworks/(etc) into the tkinter module, > neither will be able to use the ActiveState Tcl, which doesn't install into > /System. For Python 3.1, the only solution I found was to use ActiveState's > latest Python with ActiveState's latest Tcl/Tk. > > Will the new python.org package do something smart, like finding all Tcl/Tk > frameworks at install time and offering the user a choice? Or by using a > shell variable in tkinter to locate Tcl/Tk dynamically at run time? > > Dave Cortesi > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > From nad at acm.org Thu Feb 17 19:45:05 2011 From: nad at acm.org (Ned Deily) Date: Thu, 17 Feb 2011 10:45:05 -0800 Subject: [Tkinter-discuss] Help References: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> Message-ID: In article , "Michael O'Donnell" wrote: > A solution here (but not for beginners to programming) is > to compile python yourself, and tell the compile script > where to look for TCL/TK. > > A comment from somewhere else > and 2 years old or so. Hopefully things are still the same: > > -------------------- > [Kevin's post of 6.Oct, 02:58] > You can avoid this problem by building Python yourself and putting > /Library/Frameworks first on the search path for Tcl/Tk. Look in > setup.py in the source code, around line 1438 (in the > 'detect_tkinter_darwin' function), and either comment out > /System/Library or put it underneath /Library/Frameworks. This is what > the official build from Python.org should do--look first in > /Library/Frameworks and then fall back on /System/Library/Frameworks. > I'm not sure why it doesn't. > ------------------- There's no need to build it yourself. All recent (within the past two years at least) python.org installers are built this way, so that they will use the ActiveState Tcl/Tk 8.4 (or, with the 2.7 and 3.2 64-bit/32-bit 10.6 installers, 8.5) if it is available at runtime (in /Library/Frameworks) and, if not, fall back to the Apple-supplied versions in /System/Library/Frameworks/). You can check for yourself: $ otool -L $(python3.1 -c 'import _tkinter;print(_tkinter.__file__)') /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/lib-dynlo ad/_tkinter.so: /Library/Frameworks/Tcl.framework/Versions/8.4/Tcl (compatibility version 8.4.0, current version 8.4.19) /Library/Frameworks/Tk.framework/Versions/8.4/Tk (compatibility version 8.4.0, current version 8.4.19) /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 47.1.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10) You should see /Library/Frameworks/Tcl... rather than /System/Library/... -- Ned Deily, nad at acm.org From nad at acm.org Thu Feb 17 19:49:21 2011 From: nad at acm.org (Ned Deily) Date: Thu, 17 Feb 2011 10:49:21 -0800 Subject: [Tkinter-discuss] Help References: <669B61EC-D064-41C3-BCAB-B5C3E052858A@gmail.com> Message-ID: In article , > Will the new python.org package do something smart, like finding all Tcl/Tk > frameworks at install time and offering the user a choice? Or by using a > shell variable in tkinter to locate Tcl/Tk dynamically at run time? As I explained in another reply, all recent python.org installers (in at least the last two years, as far as I recall) are built so that at runtime Tkinter (2.x) or tkinter (3.x) will attempt to dynamically link with a Tcl/Tk in /Library/Frameworks (the location where ActiveState versions are installed) and, if not found, fall back to the Apple-supplied version in /System/Library/Frameworks. -- Ned Deily, nad at acm.org From georges.arsouze at gmail.com Sat Feb 19 11:39:19 2011 From: georges.arsouze at gmail.com (Georges Arsouze) Date: Sat, 19 Feb 2011 11:39:19 +0100 Subject: [Tkinter-discuss] Help Message-ID: Sorry, i'm beginning with tk I'm working with Snow leopard and Python 3.1 As you say, I have download Tcl/tk with ActivateState Now I have Tcl.framework and Tk.framework in /Library/Framework In a mail, i read : "There's no need to build it yourself. " So , i try in Python 3 In python 3.1 I try >>> *import tkinter* >>> *tkinter._test()* ans i always obtain This is Tc/Tk version 8.4 ............ -------------- next part -------------- An HTML attachment was scrubbed... URL: From nad at acm.org Sat Feb 19 12:25:22 2011 From: nad at acm.org (Ned Deily) Date: Sat, 19 Feb 2011 03:25:22 -0800 Subject: [Tkinter-discuss] Help References: Message-ID: In article , Georges Arsouze wrote: > Sorry, i'm beginning with tk > I'm working with Snow leopard and Python 3.1 > As you say, I have download Tcl/tk with ActivateState > Now I have Tcl.framework and Tk.framework in /Library/Framework > > In a mail, i read : "There's no need to build it yourself. " > > So , i try in Python 3 > In python 3.1 I try > > >>> *import tkinter* > >>> *tkinter._test()* > > ans i always obtain > > This is Tc/Tk version 8.4 ............ Yes, as I noted in previous posts, until recently all python.org installers (including those for Python 3.1.x) have been linked with Tcl/Tk 8.4 as that has been the only version supplied with Mac OS X prior to 10.6. ?With Python 2.7 and Python 3.2, there is now a second python.org installer variant available, one which only works on 10.6, is 64-bit/32-bit, and is linked with Tcl/Tk 8.5. ?If you want to use Tcl/Tk 8.5, you can use that installer for Python 3.2, which is being released this weekend and should be officially available in the next 2 to 3 days. ?You will need to use the latest ActiveState Tcl/Tk 8.5 with it as the Apple-supplied Tcl/Tk 8.5 in OS X 10.6 is known to have serious problems. ?Python 3.2 should be preferred to 3.1, in any case, as there are many bug fixes in it. If you don't want to use 3.2 and don't mind using an X11-based Tk, another option is to install Python 3.1 using MacPorts. ?The default MacPorts Tk is 8.5 via X11. -- Ned Deily, nad at acm.org From bill.kidder at gmail.com Sat Feb 19 22:23:24 2011 From: bill.kidder at gmail.com (Bill Kidder) Date: Sat, 19 Feb 2011 13:23:24 -0800 Subject: [Tkinter-discuss] How do I control the application details on OSX? Message-ID: Hi I'm using ActivePython 3.1, Active Tcl 8.5, and have built a simple app using tkinter. The application's icon is the ActivePython icon, not the one I set (this is a port of a Windows/Linux app, where the icon shows up), and the Application Menu has a label of "ActivePython 3.1" -- How do I get my icon to show up in the dock and the icon list when I do Command-Tab, and how can I change the instances of "Active Python 3.1" in the Application menu to my app's? Bill bwk software From bill.kidder at gmail.com Sat Feb 19 22:35:41 2011 From: bill.kidder at gmail.com (Bill Kidder) Date: Sat, 19 Feb 2011 13:35:41 -0800 Subject: [Tkinter-discuss] How do I control the application details on OSX? In-Reply-To: References: Message-ID: btw this happens with Idle too On Sat, Feb 19, 2011 at 1:23 PM, Bill Kidder wrote: > Hi > > I'm using ActivePython 3.1, Active Tcl 8.5, and have built a simple > app using tkinter. > > The application's icon is the ActivePython icon, not the one I set > (this is a port of a Windows/Linux app, where the icon shows up), > and the Application Menu has a label of "ActivePython 3.1" -- > > How do I get my icon to show up in the dock and the icon list > when I do Command-Tab, and how can I change the instances > of "Active Python 3.1" in the Application menu to my app's? > > Bill > bwk software > From kw at codebykevin.com Sun Feb 20 01:30:37 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Feb 2011 19:30:37 -0500 Subject: [Tkinter-discuss] How do I control the application details on OSX? In-Reply-To: References: Message-ID: <4D6060AD.1070706@codebykevin.com> On 2/19/11 4:23 PM, Bill Kidder wrote: > Hi > > I'm using ActivePython 3.1, Active Tcl 8.5, and have built a simple > app using tkinter. > > The application's icon is the ActivePython icon, not the one I set > (this is a port of a Windows/Linux app, where the icon shows up), > and the Application Menu has a label of "ActivePython 3.1" -- > > How do I get my icon to show up in the dock and the icon list > when I do Command-Tab, and how can I change the instances > of "Active Python 3.1" in the Application menu to my app's? How did you build the app? py2app has an option to set the app icon. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From kw at codebykevin.com Sun Feb 20 04:39:31 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Sat, 19 Feb 2011 22:39:31 -0500 Subject: [Tkinter-discuss] How do I control the application details on OSX? In-Reply-To: References: <4D6060AD.1070706@codebykevin.com> Message-ID: <4D608CF3.3090200@codebykevin.com> On 2/19/11 10:12 PM, Bill Kidder wrote: > Thanks. I haven't wrapped it yet. If I wrap it with pyapp does that > mean that I don't have to make ActivePython and ActiveTcl > dependencies in my app? > > |bk (cc-ing reply to the list)... If you simply run your application script with an installation of Python and Tcl/Tk on the Mac, you will get whatever default application icon is defined for Python (or ActivePython, in this case). Using py2app means that you will bundle the Python and Tcl/Tk frameworks into a standalone app bundle (ActivePython and ActiveTcl can be used this way) and they can run on other systems without AP and AT being installed. And you can define your own icon. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From bugcy013 at gmail.com Mon Feb 21 10:44:02 2011 From: bugcy013 at gmail.com (Ganesh Kumar) Date: Mon, 21 Feb 2011 15:14:02 +0530 Subject: [Tkinter-discuss] Tkinter Title Bar Icon Message-ID: Hai.. I am new to python Tkinter..i want Title Bar Icon.. plz..Guide me to set up icon in Title Bar Advance Thanks Thanks -Ganesh. -- Did I learn something today? If not, I wasted it.