From fgragu023 at gmail.com Fri Dec 2 13:09:32 2011 From: fgragu023 at gmail.com (Francisco Gracia) Date: Fri, 2 Dec 2011 13:09:32 +0100 Subject: [Tkinter-discuss] Syntactic problems Message-ID: ?I am exploring the possibilities of using *Tkinter* for a serious application mainly devoted to the handling of pure text. As en exercise I have tried to rewrite in *Python* an interesting example that is unusually included in the manual page of *Tk* for the *font* component (*Tcl8.5.7/Tk8.5.7 Documentation > TkCmd > font > example*); this code works fine under *tclsh* and *wish*. What is does is getting a list of the font names available in the machine in which it is running and displaying nicely each of its items with a sample of the corresponding font. I have performed most of my purpose and my *Python* script works. Along the way have learned a lot about *Tkinter/Tk/Tcl*, which was also a desired goal of the exercise. But the script does not work completely well, as I have also hit against an obstacle that I do not know how to overcome and seems to be rather deep. It is the following: Some of the names of the font families returned by the operating system (be it Windows or Linux) are composed of two or more words (like *Times New Roman CE*). Now these multiword arguments are not easily accepted by *Tcl/Tk*, especially if they are referenced by some variable, so that for instance tags cannot be reconfigured this way in order to apply such fonts; or the size of sentences using them cannot be measured, two operations that are essential for the procedure. I have learned that this is a real and inherent difficulty with *Tcl* (Harrison and McLennan, *Effective Tcl/Tk programming*: 34, 66); this is why the original code uses such a strange syntax like .t tag configure f[incr count] -font [list $family 10] The function *list* of *Tcl* seems to be mainly dedicated to solve this odd problem with the dereferencing of multiword contents of variables (*family* in this case, which holds the name of the font). But apparently this does not work when *Tcl/Tk* are finally moved by *Tkinter* during the execution of the script or at least I have been unable to find a way to make it work in due form. Which does not mean much, as I am not a programmer or, at most, I am a very unseasoned one. Can somebody who has had the same problem and solved it succesfully from *Tkinter* offer me (and perhaps us) his insight and describe the essentials of how to do it? Many thanks in advance! -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Fri Dec 2 16:45:04 2011 From: kw at codebykevin.com (Kevin Walzer) Date: Fri, 02 Dec 2011 10:45:04 -0500 Subject: [Tkinter-discuss] Syntactic problems In-Reply-To: References: Message-ID: <4ED8F280.4070108@codebykevin.com> On 12/2/11 7:09 AM, Francisco Gracia wrote: > ? > Some of the names of the font families returned by the operating system > (be it Windows or Linux) are composed of two or more words (like *Times > New Roman CE*). Now these multiword arguments are not easily accepted by > *Tcl/Tk*, especially if they are referenced by some variable, so that > for instance tags cannot be reconfigured this way in order to apply such > fonts; or the size of sentences using them cannot be measured, two > operations that are essential for the procedure. Multi-named fonts can be tricky. > ? > I have learned that this is a real and inherent difficulty with *Tcl* > (Harrison and McLennan, *Effective Tcl/Tk programming*: 34, 66); this is > why the original code uses such a strange syntax like > ? > ? ? ? .t tag configure f[incr count] -font [list $family 10] > ? > The function *list* of *Tcl* seems to be mainly dedicated to solve this > odd problem with the dereferencing of multiword contents of variables > (*family* in this case, which holds the name of the font). But > apparently this does not work when *Tcl/Tk* are finally moved by > *Tkinter* during the execution of the script or at least I have been > unable to find a way to make it work in due form. I'm not quite clear on what problem you are experiencing here, as there are no code snippets or Python errors outlined. Are you just trying to understand the underlying Tcl idioms? In Tcl, the [list $family 10] converts the multi-named font into a single string that can be parsed by the font code. Tcl's [list] idiom is very handy for things like this. I'm not sure about how the Tkinter module interacts with Tcl at that low level, but this Python code has always worked for me in displaying and selecting a font from a listbox: self.fonts=list(tkFont.families()) self.fonts.sort() for item in self.fonts: self.fontlist.insert(END, item) newfontlist = list(self.fontlist.get(0, END)) if self.fontname in newfontlist: i = newfontlist.index(self.fontname) self.fontlist.see(i) self.fontlist.select_set(i) self.fontlist.select_anchor(i) else: pass (This code is partly based on code in IDLE. The code in idleib is a bit wooly, but snippets of it are quite useful for Tkinter samples.) Hope this helps, Kevin > ? > Which does not mean much, as I am not a programmer or, at most, I am a > very unseasoned one. Can somebody who has had the same problem and > solved it succesfully from *Tkinter* offer me (and perhaps us) his > insight and describe the essentials of how to do it? > ? > Many thanks in advance! > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -- Kevin Walzer Code by Kevin http://www.codebykevin.com From klappnase at web.de Fri Dec 2 19:24:19 2011 From: klappnase at web.de (Michael Lange) Date: Fri, 2 Dec 2011 19:24:19 +0100 Subject: [Tkinter-discuss] Syntactic problems In-Reply-To: <4ED8F280.4070108@codebykevin.com> References: <4ED8F280.4070108@codebykevin.com> Message-ID: <20111202192419.b35e6619.klappnase@web.de> Hi, Thus spoketh Kevin Walzer unto us on Fri, 02 Dec 2011 10:45:04 -0500: > > ? ? ? .t tag configure f[incr count] -font [list $family 10] > > ? > > The function *list* of *Tcl* seems to be mainly dedicated to solve > > this odd problem with the dereferencing of multiword contents of > > variables (*family* in this case, which holds the name of the font). > > But apparently this does not work when *Tcl/Tk* are finally moved by > > *Tkinter* during the execution of the script or at least I have been > > unable to find a way to make it work in due form. > > I'm not quite clear on what problem you are experiencing here, as there > are no code snippets or Python errors outlined. > > Are you just trying to understand the underlying Tcl idioms? Maybe Francisco meant the following: >>> l = Label(text='foo') >>> l.pack() >>> l.config(font='Helvetica 12') this works, but: >>> l.config(font='Bitstream Vera Sans 12') Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1205, in configure return self._configure('configure', cnf, kw) File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1196, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: expected integer but got "Vera" I think the Tkinter equivalent to tcl's list command in this context is to simply pass a sequence instead of a string to the font option: >>> l.config(font=('Bitstream Vera Sans', '12')) >>> just like one would do in other cases where Tk expects a list, as e.g. canvas coords. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. It would seem that evil retreats when forcibly confronted. -- Yarnek of Excalbia, "The Savage Curtain", stardate 5906.5 From fgragu023 at gmail.com Sat Dec 3 18:48:36 2011 From: fgragu023 at gmail.com (Francisco Gracia) Date: Sat, 3 Dec 2011 18:48:36 +0100 Subject: [Tkinter-discuss] Syntactic problems Message-ID: Many thanks to you both, Kevin and Michael for your quick and sensible responses. My problems are more in the line suggested by Michael, although his hint has not solved them, at least as I have tried to implement it. In order for you to have all the information together, I transcribe the original Tcl code and my *porting* of it to *tkinter*. I commented it for my own use, in the process of conjecturing and confirming what the original code was intended to perform. If you run the original code with *tclsh* or *wish* and then my code with *Idle*, you will see very clearly where the problem lies. Kind regards Francisco # original Tcl code # offered as example in the *font manual page* of TkDocs. # Runs without problems with *tclsh* and *wish* # pack [text .t -wrap none] -fill both -expand 1 # set count 0 # set tabwidth 0 # foreach family [lsort -dictionary [font families]] { # .t tag configure f[incr count] -font [list $family 10] # .t insert end ${family}:\t {} \ # "This is a simple sampler\n" f$count # set w [font measure [.t cget -font] ${family}:] # if {$w+5 > $tabwidth} { # set tabwidth [expr {$w+5}] # .t configure -tabs $tabwidth # } # } from tkinter import * from tkinter import font # creation of the main window master = Tk() # creation of a text widget tw = Text( master ) tw.config( wrap = NONE ) tw.pack( fill = BOTH, expand = 1 ) tw.insert( END, "Display of available fonts:\n\n" ) count = 0 tabwidth = 0 # identification of the font being used f1 = tw.cget( 'font' ) # a measurement function used later # is a method of class *tkinter.font.Font*, # so that it is good to have the required instance of it fo = font.Font( font = ( f1, 10 ) ) # let us get the ordered list of all # available font families sampler = sorted( list( font.families() ) ) # handling and display of the elements for f in sampler : # the counter is updated count += 1 # display of the provided font name plus # a separator and a tabulator tw.insert( END, f + ":\t" ) # creation of an individual name for the tag # that will be applied to the sample for this item ftag = f + str( count ) # my (vain) efforts to solve the multiword problem if ' ' in f : # fm = "('" + f + "', '10')" # as for Michael's hint fm = '[list ' + f + ']' # fm = f.replace( ' ', '_' ) # fm = f.replace( ' ', '' ) tw.tag_config( ftag, font = ( fm, 10 ) ) # tw.tag_config( ftag, font = fm ) else : # single word names work as expected tw.tag_config( ftag, font = ( f, 10 ) ) # and the sample text: tw.insert( END, "This is a simple sampler\n", ftag ) # nice columnar disposition by # a clever configuration of the tabulator w = fo.measure( f + ':' ) if ( w + 5 ) > tabwidth : tabwidth = w + 5 # this equalizes all the lines as required tw.config( tabs = tabwidth ) if __name__ == '__main__' : master.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Sat Dec 3 19:16:38 2011 From: klappnase at web.de (Michael Lange) Date: Sat, 3 Dec 2011 19:16:38 +0100 Subject: [Tkinter-discuss] Syntactic problems In-Reply-To: References: Message-ID: <20111203191638.2579210e.klappnase@web.de> Hi Francisco, Thus spoketh Francisco Gracia unto us on Sat, 3 Dec 2011 18:48:36 +0100: > Many thanks to you both, Kevin and Michael for your quick and sensible > responses. My problems are more in the line suggested by Michael, > although his hint has not solved them, at least as I have tried to > implement it. The problem in you code is not the white space in the font name but the white space in the tag name (actually this is where the python code differs from the tcl example, maybe due to a typo). I changed (the relevant part of) your code into: for f in sampler : # the counter is updated count += 1 # display of the provided font name plus # a separator and a tabulator tw.insert( END, f + ":\t" ) # creation of an individual name for the tag # that will be applied to the sample for this item ftag = 'f' + str( count )# please note the quotes ! tw.tag_config( ftag, font = ( f, 10 ) ) # and the sample text: tw.insert( END, "This is a simple sampler\n", ftag ) and then it worked as expected. Best regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. First study the enemy. Seek weakness. -- Romulan Commander, "Balance of Terror", stardate 1709.2 From fgragu023 at gmail.com Sun Dec 4 13:36:10 2011 From: fgragu023 at gmail.com (Francisco Gracia) Date: Sun, 4 Dec 2011 13:36:10 +0100 Subject: [Tkinter-discuss] Syntactic problems In-Reply-To: <20111203191638.2579210e.klappnase@web.de> References: <20111203191638.2579210e.klappnase@web.de> Message-ID: 2011/12/3 Michael Lange said: Hi Francisco, > > The problem in you code is not the white space in the font name but the > white space in the tag name ... > You are right, Michael, that was a mistake on my side. It was not a typo, but a confusion due to my bad knowledge of *Tcl*'s syntax and to my not having given due consideration to the bussines at hand. Changing the name of the tag to an only word eliminates the problem in this case and the tag's handling becomes unproblematic. ... and then it worked as expected. > But with this not all problems are solved. Although the display varies with the machine used, if one scans carefully the whole output, one usually finds one or more lines where long font names of several words invade the area of the samples display; this should not happen and does not happen with Tcl's script. This is due to the malfunction of the measuring function and in this case one cannot avoid that the string to be measured has several words; on the contrary this should be the normal case. It seems however that I have been lucky enough to find an apparently general solution. You can see it in the transcription of the whole script that follows; for the moment this seems to be my final version. I even consider the patch general because it also solves the difficulty of your initial sample code, so that while >>> c = 'Bitstream Vera Sans 12' >>> l.config(font=c) continues originating an error, >>> c = '"[list Bitstream Vera Sans 12]"' >>> l.config(font=c) seems to work. I want to thank you very much for your kindness and your interest. Best regards Francisco # *Sampler.py* # Display the names of the typographical fonts # available in the present machine # with a sample of the appearance of each one. # Python version of the following *Tcl* code # offered as example in the *font* manual page of *TkDocs*: # pack [text .t -wrap none] -fill both -expand 1 # set count 0 # set tabwidth 0 # foreach family [lsort -dictionary [font families]] { # .t tag configure f[incr count] -font [list $family 10] # .t insert end ${family}:\t {} \ # "This is a simple sampler\n" f$count # set w [font measure [.t cget -font] ${family}:] # if {$w+5 > $tabwidth} { # set tabwidth [expr {$w+5}] # .t configure -tabs $tabwidth # } # } from tkinter import * from tkinter import font # creation of the main window master = Tk() # creation of a text widget tw = Text( master ) tw.config( wrap = NONE ) tw.pack( fill = BOTH, expand = 1 ) tw.insert( END, "Display of available fonts:\n\n" ) count = 0 # cardinal of the element tabwidth = 0 # tabulator's position (in pixel) # identification of the font in use (default) f1 = tw.cget( 'font' ) # a measurement function to be applied later # is a method of class *tkinter.font.Font*, so that # it is good to get now the required instance of it fo = font.Font( font = ( f1, 10 ) ) # let us get the alphabetically ordered list # of all the font families available in this machine sampler = sorted( list( font.families() ) ) # handling and display of its elements for f in sampler : # the counter is updated count += 1 # the provided font name is displayed # plus a separator and a tabulator tw.insert( END, f + ":\t" ) # creation of an individual name for the tag # to be applied to this item's sample ftag = 'f' + str( count ) # creation and typographical configuration of *ftag* tw.tag_config( ftag, font = ( f, 10 ) ) # the sample text is finally tagged and displayed tw.insert( END, "This is a simple sampler\n", ftag ) # nice columnar disposition of the output by # a clean and clever (re)configuration of the tabulator f = f + ':' if ' ' in f : # the name has several words # (these strings of several words # are not well handled here by the complex *Tkinter/Tcl/Tk*; # fortunately it seems that the problem can be solved # by mimicking *Tcl*'s syntax for the occasion, # i.e. by flanking them with # the *magic* prefix: '"[list ' # and the *magic* suffix: ']"' ) f = '"[list ' + f + ']"' w = fo.measure( f ) # in pixel as unit if ( w + 5 ) > tabwidth : tabwidth = w + 5 # this aligns all the lines as required tw.config( tabs = tabwidth ) if __name__ == '__main__' : master.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.oakley at gmail.com Tue Dec 6 18:09:09 2011 From: bryan.oakley at gmail.com (Bryan Oakley) Date: Tue, 6 Dec 2011 11:09:09 -0600 Subject: [Tkinter-discuss] why tkinter hangs on windows with tcl server socket? Message-ID: I?m running the following program on Windows, and when I close the app by clicking on the window manage close button the app hangs. Obviously this isn?t my real code, but I can?t explain why the code is hanging, or what the workaround is to get it to not hang. Interestingly, the last line of code is executing, so the main loop is terminating but the python process refuses to die ? I?m having to kill it via the task manager. Even explicitly calling sys.exit() has no effect. Notice how I create a server socket, then immediately close the socket. No client is connecting to the server. It doesn?t matter that I close it or not, or if I close it after some period of time, it is the creation of the socket that seems to cause tkinter to hang. Any ideas? This is with python 2.7.2.5 from ActiveState, FWIW. # --- the code --- import Tkinter as tk root = tk.Tk() root.eval(''' proc Server {args} {puts "Server... $args"} set ::the_socket [socket -server Server 0] close $::the_socket ''') root.mainloop() print "mainloop has exited" # --- end of the code --- From raycores at gmail.com Wed Dec 7 19:07:12 2011 From: raycores at gmail.com (Lynn Oliver) Date: Wed, 7 Dec 2011 10:07:12 -0800 Subject: [Tkinter-discuss] Differences between two installations Message-ID: <11E0214C-6E31-43F8-B0AC-6BAB17335C95@gmail.com> I've been using Python 2.7.2 with Tkinter.Tcl version 8.5.11, which I installed using the instructions here. Recently I did another installation using the instructions here in order to get SciPy to build correctly. The newer installation also shows as Python 2.7.2 and Tkinter.Tcl 8.5.11, but the same code does not work on both installs. I am on a Mac running OS X 10.7.2. On the earlier install, LabelFrame() keywords "bd" and "font" are recognized, while on the second install they are not. I can use "borderwidth" instead of "bd" on the second install. Also on the earlier install, LabelFrame(text="mylabel") displays the text imbedded in the frame. On the second install, the text is displayed outside of the frame. From the description here under the heading "Label Frames", I see that is the expected behavior, but it is different on the earlier install. The biggest problem is not being able to use named fonts on the second install, but the differences in how LabelFrame works also causes some platform-specific issues. On both builds, Tkinter.__version__ returns $Revision$. Any ideas as to what is going on? -Lynn -------------- next part -------------- An HTML attachment was scrubbed... URL: From spooky.ln at tbs-software.com Sun Dec 18 16:48:40 2011 From: spooky.ln at tbs-software.com (Martin B) Date: Sun, 18 Dec 2011 16:48:40 +0100 Subject: [Tkinter-discuss] Getting object Y pos in Canvas Message-ID: <20111218164840.2f50235c@tbs-software.com> Hi all, For my little app i need know last Y coord of object i created on Canvas. I'm creating a text Object. For his last X coord i use font.measure('bla bla bla') this working.But i want know last Y coord coz i need create next text object bottom. How i get Y if i create this text object create_text(0, 0, anchor='nw', text='bla\n bla\n bla', font=boldfont) thanks From spooky.ln at tbs-software.com Sun Dec 18 17:32:34 2011 From: spooky.ln at tbs-software.com (Martin B) Date: Sun, 18 Dec 2011 17:32:34 +0100 Subject: [Tkinter-discuss] Getting object Y pos in Canvas In-Reply-To: <20111218164840.2f50235c@tbs-software.com> References: <20111218164840.2f50235c@tbs-software.com> Message-ID: <20111218173234.6089e434@tbs-software.com> V Sun, 18 Dec 2011 16:48:40 +0100 Martin B naps?no: sry i forgot add tag to object. now i get bounding box of objects with canvas.bbox('mytag') sry once more. > Hi all, > For my little app i need know last Y coord of object i created on > Canvas. > I'm creating a text Object. For his last X coord i use > font.measure('bla bla bla') this working.But i want know last Y coord > coz i need create next text object bottom. > > How i get Y if i create this text object > create_text(0, 0, anchor='nw', text='bla\n bla\n bla', font=boldfont) > > thanks > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From klappnase at web.de Sun Dec 18 17:47:26 2011 From: klappnase at web.de (Michael Lange) Date: Sun, 18 Dec 2011 17:47:26 +0100 Subject: [Tkinter-discuss] Changing image data in ttk does not work Message-ID: <20111218174726.5a4c7942.klappnase@web.de> Hi, I just noticed an odd behavior in ttk, when I try to change the image data of a ttk.Label's image, the image isn't actually updated. A simple code example: ######################################## from Tkinter import * import ttk icon1 = ('R0lGODlhEAAQAJEAANnZ2QAAAISEAP///yH5BAEAAAAALAAAAAAQABAAAAJ' 'WhI9pFB8RIIRC+BYQFqQQvkWEBSmEbyFhQQrhW0hYkEL4FhIWpBC+hYQFSYxvIgF' 'AoXy0AAiSGP8kAIIkxgcICSBEQvEBQgIIkVB8gJAAAhgfj+BjWgEAOw==') icon2 = ('R0lGODlhEAAQAKIAANnZ2QAAAP///4SEhP//AP///////////yH5BAEAAAA' 'ALAAAAAAQABAAAANZCLrcjqG7CLqBoquBoBuCoSqBoBsouhoIuiEYqrKBoIGiqwE' 'YEIChyxAIEYGgywEYgKHLDAgRCLozgwABARgIukSEABEBGLq8gAEQCLobgAEAgKH' 'LgaDLzZgAOw==') root = Tk() im = PhotoImage(data=icon1) Label(root, image=im, text='Tkinter', compound='left').pack( padx=100, pady=50) ttk.Label(root, image=im, text='ttk', compound='left').pack( padx=100, pady=50) current = 1 def swapimage(): global current if current == 1: im.configure(data=icon2) current = 2 else: im.configure(data=icon1) current = 1 root.after(1000, swapimage) root.after(1000, swapimage) root.mainloop() ######################################## When I run this code, the image in the Tkinter.Label changes every second, as expected, but the ttk.Label's image doesn't. Is this documented somewhere or is this a bug? Adding update_idletasks() or even update() to swapimage() does not help either. I know that I can change the image by doing ttklabel.configure(image=some_other_photoimage) but I thought changing the image data on the fly should work, too. Btw., the system is debian linux, tcl version is 8.5.8 . Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We do not colonize. We conquer. We rule. There is no other way for us. -- Rojan, "By Any Other Name", stardate 4657.5 From klappnase at web.de Sun Dec 18 17:30:05 2011 From: klappnase at web.de (Michael Lange) Date: Sun, 18 Dec 2011 17:30:05 +0100 Subject: [Tkinter-discuss] Getting object Y pos in Canvas In-Reply-To: <20111218164840.2f50235c@tbs-software.com> References: <20111218164840.2f50235c@tbs-software.com> Message-ID: <20111218173005.184d1e97.klappnase@web.de> Hi Martin, Thus spoketh Martin B unto us on Sun, 18 Dec 2011 16:48:40 +0100: > Hi all, > For my little app i need know last Y coord of object i created on > Canvas. > I'm creating a text Object. For his last X coord i use > font.measure('bla bla bla') this working.But i want know last Y coord > coz i need create next text object bottom. > > How i get Y if i create this text object > create_text(0, 0, anchor='nw', text='bla\n bla\n bla', font=boldfont) > The Canvas'es coords() method is your friend. From the canvas tk manpage: pathName coords tagOrId ?coordList? Query or modify the coordinates that define an item. If no coordinates are specified, this command returns a list whose elements are the coordinates of the item named by tagOrId. If coordinates are specified, then they replace the current coordinates for the named item. If tagOrId refers to multiple items, then the first one in the display list is used. I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Captain's Log, star date 21:34.5... From klappnase at web.de Sun Dec 18 18:06:47 2011 From: klappnase at web.de (Michael Lange) Date: Sun, 18 Dec 2011 18:06:47 +0100 Subject: [Tkinter-discuss] Getting object Y pos in Canvas In-Reply-To: <20111218173234.6089e434@tbs-software.com> References: <20111218164840.2f50235c@tbs-software.com> <20111218173234.6089e434@tbs-software.com> Message-ID: <20111218180647.ec019556.klappnase@web.de> Thus spoketh Martin B unto us on Sun, 18 Dec 2011 17:32:34 +0100: > V Sun, 18 Dec 2011 16:48:40 +0100 > Martin B naps?no: > > sry i forgot add tag to object. > now i get bounding box of objects with canvas.bbox('mytag') > Oops, sure you're right, it must be bbox() not coords() (^.^;) Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Vulcans worship peace above all. -- McCoy, "Return to Tomorrow", stardate 4768.3 From klappnase at web.de Sun Dec 18 18:01:02 2011 From: klappnase at web.de (Michael Lange) Date: Sun, 18 Dec 2011 18:01:02 +0100 Subject: [Tkinter-discuss] Changing image data in ttk does not work In-Reply-To: <20111218174726.5a4c7942.klappnase@web.de> References: <20111218174726.5a4c7942.klappnase@web.de> Message-ID: <20111218180102.0f89957d.klappnase@web.de> Hi again, Thus spoketh Michael Lange unto us on Sun, 18 Dec 2011 17:47:26 +0100: > Hi, > > I just noticed an odd behavior in ttk, when I try to change the image > data of a ttk.Label's image, the image isn't actually updated. A simple > code example: (...) I just noticed that it is even starnger; actually the image *is* updated, as soon as the mouse pointer enters or leaves the ttk.Label . So I think this really appears to be a (maybe Tk-version specific?) bug. Can anyone confirm this behavior? Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "I think they're going to take all this money that we spend now on war and death --" "And make them spend it on life." -- Edith Keeler and Kirk, "The City on the Edge of Forever", stardate unknown. From spooky.ln at tbs-software.com Sun Dec 18 20:43:52 2011 From: spooky.ln at tbs-software.com (Martin B) Date: Sun, 18 Dec 2011 20:43:52 +0100 Subject: [Tkinter-discuss] Changing image data in ttk does not work In-Reply-To: <20111218180102.0f89957d.klappnase@web.de> References: <20111218174726.5a4c7942.klappnase@web.de> <20111218180102.0f89957d.klappnase@web.de> Message-ID: <20111218204352.1ade3073@tbs-software.com> V Sun, 18 Dec 2011 18:01:02 +0100 Michael Lange naps?no: same here. tested with py2.7 and py3.2 Tk version 8.5.11 on ArchLinux i686 > Hi again, > > Thus spoketh Michael Lange > unto us on Sun, 18 Dec 2011 17:47:26 +0100: > > > Hi, > > > > I just noticed an odd behavior in ttk, when I try to change the > > image data of a ttk.Label's image, the image isn't actually > > updated. A simple code example: > (...) > > I just noticed that it is even starnger; actually the image *is* > updated, as soon as the mouse pointer enters or leaves the > ttk.Label . So I think this really appears to be a (maybe Tk-version > specific?) bug. Can anyone confirm this behavior? > > Regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. > --- ... .--. . .-. > > "I think they're going to take all this money that we spend > now on war and death --" > "And make them spend it on life." > -- Edith Keeler and Kirk, "The City on the Edge of > Forever", stardate unknown. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss From spooky.ln at tbs-software.com Sun Dec 18 21:09:52 2011 From: spooky.ln at tbs-software.com (Martin B) Date: Sun, 18 Dec 2011 21:09:52 +0100 Subject: [Tkinter-discuss] Changing image data in ttk does not work In-Reply-To: <20111218204352.1ade3073@tbs-software.com> References: <20111218174726.5a4c7942.klappnase@web.de> <20111218180102.0f89957d.klappnase@web.de> <20111218204352.1ade3073@tbs-software.com> Message-ID: <20111218210952.19af7f08@tbs-software.com> V Sun, 18 Dec 2011 20:43:52 +0100 Martin B naps?no: ugly solution i was found for now is 2 PhotoImages. if current == 1: label1.config(image=photoimage1) label2.config(image=photoimage1) current=0 else: label1.config(image=photoimage2) label2.config(image=photoimage2) current=0 i never use PhotoImage.config() until this test. i always used Label.config() for changing From klappnase at web.de Sun Dec 18 21:24:40 2011 From: klappnase at web.de (Michael Lange) Date: Sun, 18 Dec 2011 21:24:40 +0100 Subject: [Tkinter-discuss] Changing image data in ttk does not work In-Reply-To: <20111218210952.19af7f08@tbs-software.com> References: <20111218174726.5a4c7942.klappnase@web.de> <20111218180102.0f89957d.klappnase@web.de> <20111218204352.1ade3073@tbs-software.com> <20111218210952.19af7f08@tbs-software.com> Message-ID: <20111218212440.93204681.klappnase@web.de> Hi, Thus spoketh Martin B unto us on Sun, 18 Dec 2011 21:09:52 +0100: > V Sun, 18 Dec 2011 20:43:52 +0100 > Martin B naps?no: > > ugly solution i was found for now is 2 PhotoImages. > > if current == 1: > label1.config(image=photoimage1) > label2.config(image=photoimage1) > current=0 > else: > label1.config(image=photoimage2) > label2.config(image=photoimage2) > current=0 > > i never use PhotoImage.config() until this test. > i always used Label.config() for changing Yes this works, but unfortunately this breaks the pseudo-animated-gif class I've been using. For now I think I will stick with the Tkinter.Label, it does not seem to be a problem as long as you don't want to change the theme on the fly. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Actual war is a very messy business. Very, very messy business. -- Kirk, "A Taste of Armageddon", stardate 3193.0 From emilianogavilan at gmail.com Mon Dec 19 15:02:18 2011 From: emilianogavilan at gmail.com (Emiliano Gavilan) Date: Mon, 19 Dec 2011 11:02:18 -0300 Subject: [Tkinter-discuss] Changing image data in ttk does not work In-Reply-To: <20111218174726.5a4c7942.klappnase@web.de> References: <20111218174726.5a4c7942.klappnase@web.de> Message-ID: 2011/12/18 Michael Lange : > Hi, > > I just noticed an odd behavior in ttk, when I try to change the image > data of a ttk.Label's image, the image isn't actually updated. A simple > code example: Is a bug in ttk redisplay code. I've reported it upstream (bug 3462273). Thanks for spotting. Regards Emiliano From charleshixsn at earthlink.net Thu Dec 29 06:11:20 2011 From: charleshixsn at earthlink.net (Charles Hixson) Date: Wed, 28 Dec 2011 21:11:20 -0800 Subject: [Tkinter-discuss] Hint text Message-ID: <4EFBF678.4030008@earthlink.net> Is there any way to show hints on mouseovers that doesn't require writing a separate function for each, e.g., Radiobutton? The only thing I've seen documentation say changes on mouseovers is the state, and the documentation says it will call the command whenever the state changes...but I don't see any way to tell what is having it's state changed except by having different commands for each selection. -- Charles Hixson From klappnase at web.de Thu Dec 29 11:46:30 2011 From: klappnase at web.de (Michael Lange) Date: Thu, 29 Dec 2011 11:46:30 +0100 Subject: [Tkinter-discuss] Hint text In-Reply-To: <4EFBF678.4030008@earthlink.net> References: <4EFBF678.4030008@earthlink.net> Message-ID: <20111229114630.726932f9.klappnase@web.de> Hi Charles, Thus spoketh Charles Hixson unto us on Wed, 28 Dec 2011 21:11:20 -0800: > Is there any way to show hints on mouseovers that doesn't require > writing a separate function for each, e.g., Radiobutton? > > The only thing I've seen documentation say changes on mouseovers is the > state, and the documentation says it will call the command whenever the > state changes...but I don't see any way to tell what is having it's > state changed except by having different commands for each selection. > unfortunately there is no such thing built into Tk by default, so you will have to stick with some extra module. The good news is that there are plenty of those available ready to use. If installing the Pmw package is an option for you, you might want to have a look at the Pmw.Ballon class: http://pmw.sourceforge.net/doc/Balloon.html I think Tix has a ballon widget either, but I haven't used Tix for a couple of years, so I'm not exactly sure ;) If you have IDLE already installed you can use its ToolTip class, like this: >>> from Tkinter import * >>> from idlelib import ToolTip >>> b=Button(text='foo') >>> b.pack() >>> ToolTip.ToolTip(b, 'bla') In case you don't want to install IDLE, there is also a modified version of IDLE's ToolTip available as a stand-alone module at: http://tkinter.unpy.net/wiki/ToolTip I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We Klingons believe as you do -- the sick should die. Only the strong should live. -- Kras, "Friday's Child", stardate 3497.2 From python at bdurham.com Thu Dec 29 12:40:34 2011 From: python at bdurham.com (python at bdurham.com) Date: Thu, 29 Dec 2011 06:40:34 -0500 Subject: [Tkinter-discuss] Hint text In-Reply-To: <4EFBF678.4030008@earthlink.net> References: <4EFBF678.4030008@earthlink.net> Message-ID: <1325158834.16793.140661017030121@webmail.messagingengine.com> Hi Charles, There are many modules that add tooltip functionality to Tkinter; google tooltip tkinter for a list. One of my favorite tooltip modules is: http://code.activestate.com/recipes/576688-tooltip-for-tkinter/ If you research this topic in more depth, let us know what module you end up using. Malcolm From Cameron at phaseit.net Thu Dec 29 22:07:53 2011 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 29 Dec 2011 21:07:53 +0000 Subject: [Tkinter-discuss] Hint text In-Reply-To: <1325158834.16793.140661017030121@webmail.messagingengine.com> References: <4EFBF678.4030008@earthlink.net> <1325158834.16793.140661017030121@webmail.messagingengine.com> Message-ID: <20111229210753.GB5512@lairds.us> On Thu, Dec 29, 2011 at 06:40:34AM -0500, python at bdurham.com wrote: . . . > There are many modules that add tooltip functionality to Tkinter; google > tooltip tkinter for a list. > > One of my favorite tooltip modules is: > http://code.activestate.com/recipes/576688-tooltip-for-tkinter/ > > If you research this topic in more depth, let us know what module you > end up using. . . . More to read, on the same subject: .