From davecortesi at gmail.com Wed Aug 4 07:26:22 2010 From: davecortesi at gmail.com (David Cortesi) Date: Tue, 3 Aug 2010 22:26:22 -0700 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? Message-ID: Hello. I'm beginning to explore Python 3 and tkinter (using Mac OSX 10.6). Following the directions in (http://wiki.python.org/moin/TkInter) I verified that >>> import tkinter >>> tkinter._test() does indeed open a little window as expected. So there is SOME fashion of tkinter and TCL/TK installed on this machine. Next I attempt to run the "First (Real) Example" in ( http://www.tkdocs.com/tutorial/firstexample.html), but get the error, File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/tkinter/ttk.py", line 47, in _load_tile master.tk.eval('package require tile') Looking at the ttk.py file I find it checks tkinter.TkVersion < 8.5, and in fact tkinter.TkVersion yields 8.4. Performing the following google search, site:mail.python.org 'package require tile' I observe that this same error has been mentioned 66 times over the last few years and with several versions of Python and different platforms. (It seems odd, when this problem has been arising since 2004, the latest version 3.1.2 of Python is still distributed with tkinter 8.4 and yet no tile package. But I digress.) The usual advice is to install the tile package from sourceforge. So I tried to do this but encountered several problems, beginning with, where, ie what folder? Doesn't really matter, as I find that its ./configure script looks for a C compiler -- and the Apple Developer package is not installed on this system. I looked around in /bin and /usr but there doesn't seem to even be a lowly cc anywhere. I'd appreciate any suggestions to get past this stone wall. Thanks, Dave Cortesi -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Wed Aug 4 13:53:29 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 04 Aug 2010 07:53:29 -0400 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: References: Message-ID: <4C5954B9.7020406@codebykevin.com> You're correct that ttk didn't come built-in to Tk until 8.5--hence the need for the Tile package with 8.4. I believe the most recent Tile package is 0.8 or 0.8.2, at the site you referenced. As for a compiler, install Apple's developer tools (Xcode and friends) and you'll have a working gcc. The dev tools are an optional install on the DVD, or can be downloaded from Apple. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From davecortesi at gmail.com Wed Aug 4 17:13:43 2010 From: davecortesi at gmail.com (David Cortesi) Date: Wed, 4 Aug 2010 08:13:43 -0700 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: <4C5954B9.7020406@codebykevin.com> References: <4C5954B9.7020406@codebykevin.com> Message-ID: On Wed, Aug 4, 2010 at 4:53 AM, Kevin Walzer wrote: > You're correct that ttk didn't come built-in to Tk until 8.5--hence the > need for the Tile package with 8.4. I believe the most recent Tile package > is 0.8 or 0.8.2, at the site you referenced. > > As for a compiler, install Apple's developer tools (Xcode and friends) and > you'll have a working gcc. The dev tools are an optional install on the DVD, > or can be downloaded from Apple. > Kevin, thanks for taking the time to reply. I have Xcode installed on one of my macs, but not on the laptop where I meant to experiment with Py 3 and Tk. I had hoped, since Tk is the default, expected, distributed-with-python GUI framework (so says the python wiki) that it would "just work." On the contrary, it appears that to make it work, I will have to install Xcode, and figure out how to do an install of this package. And there are several unknowns in that install, for OS X, beginning with, where in /Library to put it, or if not in /Library, where? Wherever, I also have to edit my .login to set PYTHONPATH appropriately so it can be found. It seems to me this all amounts to quite a steep barrier for someone to climb, just in order to try out the supposed default GUI. To me, the really puzzling question is, since this has been the case for several years (based on the history of the same error being encountered repeatedly), why is the very latest Python apparently being distributed with tkinter 8.4 but without tile? Dave Cortesi -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Wed Aug 4 23:23:28 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 04 Aug 2010 17:23:28 -0400 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: References: <4C5954B9.7020406@codebykevin.com> Message-ID: <4C59DA50.2070104@codebykevin.com> On 8/4/10 11:13 AM, David Cortesi wrote: > I have Xcode installed on one of my macs, but not on the laptop where I > meant to experiment with Py 3 and Tk. > > I had hoped, since Tk is the default, expected, distributed-with-python > GUI framework (so says the python wiki) that it would "just work." On > the contrary, it appears that to make it work, I will have to install > Xcode, and figure out how to do an install of this package. And there > are several unknowns in that install, for OS X, beginning with, where in > /Library to put it, or if not in /Library, where? Wherever, I also have > to edit my .login to set PYTHONPATH appropriately so it can be found. > > It seems to me this all amounts to quite a steep barrier for someone to > climb, just in order to try out the supposed default GUI. I believe that the system build of Python 2.6 on Snow Leopard (the one installed by Apple) is linked against Tk 8.5, which includes the ttk widgets. You'd still need to install the Python ttk wrapper module from http://code.google.com/p/python-ttk/, but that's easier than building the Tile module from scratch. Just download the code, and run "sudo /usr/bin/python setup.py install" and you should be in business. > > To me, the really puzzling question is, since this has been the case for > several years (based on the history of the same error being encountered > repeatedly), why is the very latest Python apparently being distributed > with tkinter 8.4 but without tile? The maintainers of the Mac build of Python from Python.org (not the same as the system install of Python included by Apple) decided to keep their build of Python linked to 8.4 for backward compatibility--that build of Python has to support several versions of OS X. While they do distribute Tkinter, they don't include the Tcl/Tk libraries that Tkinter depends on--those are installed by Apple. Apple's installation of Tcl/Tk 8.4 doesn't include Tile for whatever reason, hence, Python's ttk module won't work. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From hyperila at hotmail.com Wed Aug 11 16:33:57 2010 From: hyperila at hotmail.com (diskhub) Date: Wed, 11 Aug 2010 07:33:57 -0700 (PDT) Subject: [Tkinter-discuss] Tkinter GUI change background image on button pressed? Message-ID: <29408957.post@talk.nabble.com> How do i make my tkinter gui change background image on button pressed? Can someone guide me? -- View this message in context: http://old.nabble.com/Tkinter-GUI-change-background-image-on-button-pressed--tp29408957p29408957.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From smokefloat at gmail.com Thu Aug 12 01:54:56 2010 From: smokefloat at gmail.com (David Hutto) Date: Wed, 11 Aug 2010 19:54:56 -0400 Subject: [Tkinter-discuss] Tkinter GUI change background image on button pressed? In-Reply-To: <29408957.post@talk.nabble.com> References: <29408957.post@talk.nabble.com> Message-ID: On Wed, Aug 11, 2010 at 10:33 AM, diskhub wrote: > > How do i make my tkinter gui change background image on button pressed? > Can someone guide me? > -- > View this message in context: http://old.nabble.com/Tkinter-GUI-change-background-image-on-button-pressed--tp29408957p29408957.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > try background ='red' in the ()'s From chrischia82 at gmail.com Thu Aug 12 01:48:36 2010 From: chrischia82 at gmail.com (Chris Chia) Date: Thu, 12 Aug 2010 09:48:36 +1000 Subject: [Tkinter-discuss] Python Tkinter Simple Qn Message-ID: Hi i have the following problem with Python Tkinter. I switch to switch the image background (which i used Tkinter.Label with image arg to display on the GUI). How can I do that? the callback function which i have created doesn't seem to work... some advice? below is my code: import Tkinter as tk from PIL import Image, ImageTk root = tk.Tk() # having problem with switching the image def callback(event): global root root.panel1.pack_forget() root.panel1.image = image2 root.panel1.pack() def app(): root.title('FIT 2022 Assignment 1') # pick an image file you have .bmp .jpg .gif. .png # load the file and covert it to a Tkinter image object imageFile = "c:\\test1.jpg" image1 = ImageTk.PhotoImage(Image.open(imageFile)) imageFile2 = "c:\\test2.jpg" image2 = ImageTk.PhotoImage(Image.open(imageFile2)) # get the image size w = image1.width() h = image1.height() # position coordinates of root 'upper left corner' x = 0 y = 0 # make the root window the size of the image root.geometry("%dx%d+%d+%d" % (w, h, x, y)) # root has no image argument, so use a label as a panel panel1 = tk.Label(root, image=image1) panel1.pack(side='top', fill='both', expand='yes') panel1.image = image1 panel1.bind("", callback) panel1.pack() root.mainloop() app() -- Regards, Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Thu Aug 12 08:15:06 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Thu, 12 Aug 2010 09:15:06 +0300 Subject: [Tkinter-discuss] Python Tkinter Simple Qn In-Reply-To: References: Message-ID: Hello, I posted the code in here: http://paste-it.net/public/y1ba880/ Firat 2010/8/12 Chris Chia > Hi i have the following problem with Python Tkinter. > I switch to switch the image background (which i used Tkinter.Label with > image arg to display on the GUI). > > How can I do that? the callback function which i have created doesn't seem > to work... > some advice? > > below is my code: > > > import Tkinter as tk > from PIL import Image, ImageTk > > root = tk.Tk() > > # having problem with switching the image > def callback(event): > global root > root.panel1.pack_forget() > root.panel1.image = image2 > root.panel1.pack() > > > def app(): > > root.title('FIT 2022 Assignment 1') > > # pick an image file you have .bmp .jpg .gif. .png > # load the file and covert it to a Tkinter image object > imageFile = "c:\\test1.jpg" > image1 = ImageTk.PhotoImage(Image.open(imageFile)) > imageFile2 = "c:\\test2.jpg" > image2 = ImageTk.PhotoImage(Image.open(imageFile2)) > > > # get the image size > w = image1.width() > h = image1.height() > > > # position coordinates of root 'upper left corner' > x = 0 > y = 0 > > > # make the root window the size of the image > root.geometry("%dx%d+%d+%d" % (w, h, x, y)) > > > # root has no image argument, so use a label as a panel > panel1 = tk.Label(root, image=image1) > panel1.pack(side='top', fill='both', expand='yes') > panel1.image = image1 > panel1.bind("", callback) > > > panel1.pack() > root.mainloop() > > > app() > > > > > -- > Regards, > Chris > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Thu Aug 12 14:55:04 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Thu, 12 Aug 2010 15:55:04 +0300 Subject: [Tkinter-discuss] Python Tkinter Simple Qn In-Reply-To: References: Message-ID: My previous code was erroneous. Therefore I edited it. http://paste-it.net/public/u46e119/ 2010/8/12 Chris Chia > Hi i have the following problem with Python Tkinter. > I switch to switch the image background (which i used Tkinter.Label with > image arg to display on the GUI). > > How can I do that? the callback function which i have created doesn't seem > to work... > some advice? > > below is my code: > > > import Tkinter as tk > from PIL import Image, ImageTk > > root = tk.Tk() > > # having problem with switching the image > def callback(event): > global root > root.panel1.pack_forget() > root.panel1.image = image2 > root.panel1.pack() > > > def app(): > > root.title('FIT 2022 Assignment 1') > > # pick an image file you have .bmp .jpg .gif. .png > # load the file and covert it to a Tkinter image object > imageFile = "c:\\test1.jpg" > image1 = ImageTk.PhotoImage(Image.open(imageFile)) > imageFile2 = "c:\\test2.jpg" > image2 = ImageTk.PhotoImage(Image.open(imageFile2)) > > > # get the image size > w = image1.width() > h = image1.height() > > > # position coordinates of root 'upper left corner' > x = 0 > y = 0 > > > # make the root window the size of the image > root.geometry("%dx%d+%d+%d" % (w, h, x, y)) > > > # root has no image argument, so use a label as a panel > panel1 = tk.Label(root, image=image1) > panel1.pack(side='top', fill='both', expand='yes') > panel1.image = image1 > panel1.bind("", callback) > > > panel1.pack() > root.mainloop() > > > app() > > > > > -- > Regards, > Chris > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hyperila at hotmail.com Fri Aug 13 12:19:26 2010 From: hyperila at hotmail.com (chris chia) Date: Fri, 13 Aug 2010 20:19:26 +1000 Subject: [Tkinter-discuss] Continued: force the GUI to switch image instead of relying on the event Message-ID: I wish to do a multi threading program such that user can still use the console to control this GUI. Can I ask u how can i write a command to force the GUI to switch image instead of relying on the event. thanks to Firat, his code is as the following: import sys import Tkinter as tk from PIL import Image, ImageTk class ImageViewer(object): def __init__(self): self.imagelist = [image1, image2] self.create_widgets() self.ind = 0 def create_widgets(self): self.label = tk.Label(image = self.imagelist[0]) self.label.pack() self.label.bind("", self.change_image) def change_image(self, event): self.ind += 1 self.label.update() try: self.label["image"] = self.imagelist[self.ind] except IndexError: pass root = tk.Tk() image1 = ImageTk.PhotoImage(file = "test1.jpg") image2 = ImageTk.PhotoImage(file = "test2.jpg") w = image1.width() h = image1.height() x = 0 y = 0 root.geometry("%dx%d+%d+%d" % (w, h, x, y)) app = ImageViewer() root.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From charras at me.com Sun Aug 15 04:06:41 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Sat, 14 Aug 2010 20:06:41 -0600 Subject: [Tkinter-discuss] Recognizing buttons Message-ID: Hello; Is it possible to have a set of buttons, all calling to the same function, recognize which of the buttons was the one that call the function? 'Cause what I want to do, is create a set of buttons, where I will not know how many buttons will be created, that will depend on the input of the user. Once the user have this, he will click one of those buttons, and depending on which button was press, the program will erase that part of the input that the operator gave. Regards! Guido Carballo From michael.odonnell at uam.es Sun Aug 15 10:08:16 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Sun, 15 Aug 2010 10:08:16 +0200 Subject: [Tkinter-discuss] Recognizing buttons In-Reply-To: References: Message-ID: Hi Guido, > Is it possible to have a set of buttons, all calling to the same function, recognize which of the buttons was the one that call the function? One solution to your problem, using lambda to define the function call. from Tkinter import * def killBut(but): but.pack_forget() tk = Tk() but1=Button(tk, text="B1") but1['command']=lambda b=but1: killBut(b) but1.pack(side=LEFT) but2=Button(tk, text="B2") but2['command']=lambda b=but2: killBut(b) but2.pack(side=LEFT) tk.mainloop() On Sun, Aug 15, 2010 at 4:06 AM, Guido Carballo-Guerrero wrote: > Hello; > > > 'Cause what I want to do, is create a set of buttons, where I will not know how many buttons will be created, that will depend on the input of the user. Once the user have this, he will click one of those buttons, and depending on which button was press, the program will erase that part of the input that the operator gave. > > Regards! > > Guido Carballo > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From klappnase at web.de Sun Aug 15 13:55:47 2010 From: klappnase at web.de (Michael Lange) Date: Sun, 15 Aug 2010 13:55:47 +0200 Subject: [Tkinter-discuss] Continued: force the GUI to switch image instead of relying on the event In-Reply-To: References: Message-ID: <20100815135547.00e0283f.klappnase@web.de> Hi Chris, On Fri, 13 Aug 2010 20:19:26 +1000 chris chia wrote: > > I wish to do a multi threading program such that user can still use > the console to control this GUI. Can I ask u how can i write a > command to force the GUI to switch image instead of relying on the > event. > I am not sure what you want to achieve; in case you want the user to be able to use the keyboard insted of the mouse, you can simply use bindings to Key events instead of , like for a "next image"-callback and for "previous image". You can even apply such bindings to the toplevel window as a whole, so the users will not have to set the keyboard focus to a particular widget. If you want to control the window from a different application, you can try to add a signal handler using Python's signal module (however, this may not be supported on all platforms). Or do you want the application to automagically switch the image after a given amount of time? Then you can use a simple after() loop, like: def switch_image(): ImageViewer.change_image() root.after(5000, switch_image) root.after(5000, switch_image) In this example the change_image() method of course needs to take care that after displaying the last image from the images list it will start over again with the first one. I hope this helps Michael From Cameron at phaseit.net Sun Aug 15 17:39:32 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 15 Aug 2010 15:39:32 +0000 Subject: [Tkinter-discuss] Recognizing buttons In-Reply-To: References: Message-ID: <20100815153932.GA25774@lairds.us> On Sat, Aug 14, 2010 at 08:06:41PM -0600, Guido Carballo-Guerrero wrote: . . . > Is it possible to have a set of buttons, all calling to the same function, recognize which of the buttons was the one that call the function? > > 'Cause what I want to do, is create a set of buttons, where I will not know how many buttons will be created, that will depend on the input of the user. Once the user have this, he will click one of those buttons, and depending on which button was press, the program will erase that part of the input that the operator gave. . . . presents multiple techniques to achieve exactly what you seek. From Cameron at phaseit.net Sun Aug 15 19:26:12 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 15 Aug 2010 17:26:12 +0000 Subject: [Tkinter-discuss] Continued: force the GUI to switch image instead of relying on the event In-Reply-To: <20100815135547.00e0283f.klappnase@web.de> References: <20100815135547.00e0283f.klappnase@web.de> Message-ID: <20100815172612.GA9996@lairds.us> On Sun, Aug 15, 2010 at 01:55:47PM +0200, Michael Lange wrote: . . . > > I wish to do a multi threading program such that user can still use > > the console to control this GUI. Can I ask u how can i write a > > command to force the GUI to switch image instead of relying on the > > event. > > > > I am not sure what you want to achieve; in case you want the user to be > able to use the keyboard insted of the mouse, you can simply use > bindings to Key events instead of , like for a > "next image"-callback and for "previous image". You can even > apply such bindings to the toplevel window as a whole, so the users > will not have to set the keyboard focus to a particular widget. > > If you want to control the window from a different application, you can > try to add a signal handler using Python's signal module (however, > this may not be supported on all platforms). > > Or do you want the application to automagically switch the image after > a given amount of time? Then you can use a simple after() loop, like: > > def switch_image(): > ImageViewer.change_image() > root.after(5000, switch_image) > root.after(5000, switch_image) > > In this example the change_image() method of course needs to take care > that after displaying the last image from the images list it will start > over again with the first one. . . . And, in yet another direction, I wonder if the original questioner is confused about the relation between "multi threading" and GUI responsiveness (and concurrency, and so on). It's possible will be pertinent. From jepler at unpythonic.net Mon Aug 16 14:35:43 2010 From: jepler at unpythonic.net (Jeff Epler) Date: Mon, 16 Aug 2010 07:35:43 -0500 Subject: [Tkinter-discuss] wiki: Fixed ApprovedEditorsGroup Message-ID: <20100816123542.GA3177@unpythonic.net> The ApprovedEditorsGroup security policy was broken after an upgrade of moin. It is now fixed. Thank you to Anthony Glaser for bringing this to my attention. Jeff From wet_colored_arch at yahoo.com Tue Aug 17 03:52:19 2010 From: wet_colored_arch at yahoo.com (wet_colored)arch) Date: Mon, 16 Aug 2010 18:52:19 -0700 (PDT) Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. Message-ID: <29449209.post@talk.nabble.com> What basically happens is if I use the application all features work fine except the entry widget I have created. I cannot add text or even get the cursor to appear in the entry field. What is odd is I have a askyesno button for quiting. If I hit "no" and return to the application, I can then enter text and move the cursor with the tab to other features and buttons in my gui. How do I get the entry box to work? The problem might be tied to windows, frames and parents (which I still don't fully understand even though I have built 5 gui's now). The relevant code is abridged as below: if __name__ == '__main__': root = Tk() root.title('Artifact Pointer')# adapted from_PyView 1.0') Label(root, text="Point to Artifacts Observed").pack() SlideShow(root, picdir=picdir, artdir=artdir, bd=3, relief=SUNKEN) root.mainloop() preceeded by: class SlideShow(Frame): def __init__(self, parent=root, picdir='.', artdir='.', msecs=3000, **args):#msecs is legacy Frame.__init__(self, parent, args) self.parent = root self.makeWidgets() and under def makeWidgets I have: self.vent=StringVar() Entry(self,textvariable=self.vent).pack() I have tried some variants and have read several forums and Lutz and still am not getting this sorted out. It is odd to me that it works, but only AFTER, I hit no under askyesno button. -- View this message in context: http://old.nabble.com/Entry-Widget-that-can%27t-enter-into-at-first.-tp29449209p29449209.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From sigma.z.1980 at gmail.com Tue Aug 17 14:50:38 2010 From: sigma.z.1980 at gmail.com (Alex Ter-Sarkissov) Date: Wed, 18 Aug 2010 00:50:38 +1200 Subject: [Tkinter-discuss] update of elements in GUI Message-ID: I have some elements on the screen (Labels, most importantly) which content has to be updated every iteration of the algorithm run, e.g. "Iteration =" [i] for i in range(n). I've tried using mainframe.update_idletasks() and Label(mainframe.update_ideltasks(),textvariable=var).grid(column=1,row=1), but without success so far. In MATLAB this command is drawnow. thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From Cameron at phaseit.net Tue Aug 17 16:25:05 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 17 Aug 2010 14:25:05 +0000 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: References: Message-ID: <20100817142505.GB5661@lairds.us> On Wed, Aug 18, 2010 at 12:50:38AM +1200, Alex Ter-Sarkissov wrote: . . . > I have some elements on the screen (Labels, most importantly) which content > has to be updated every iteration of the algorithm run, e.g. "Iteration =" > [i] for i in range(n). I've tried using mainframe.update_idletasks() > and Label(mainframe.update_ideltasks(),textvariable=var).grid(column=1,row=1), > but without success so far. In MATLAB this command is drawnow. . . . I believe I understand your description. For a "quick fix", I recommend you experiment with update() (as opposed to update_idletasks()) applied to mainframe. For better long-term maintainability, though, you almost certainly should "return to the event loop" on each iteration of your run (there are also multi-threading approaches, but they're somewhat trickier to code correctly). You might find , , and of interest. From sigma.z.1980 at gmail.com Wed Aug 18 06:58:24 2010 From: sigma.z.1980 at gmail.com (Alex Ter-Sarkissov) Date: Wed, 18 Aug 2010 16:58:24 +1200 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: <20100817142505.GB5661@lairds.us> References: <20100817142505.GB5661@lairds.us> Message-ID: thanks, in one of these articles it says. 'Be careful - Tkinter in not re-entrant'. MAybe this is the problem? So far I've tried (1) Label(mainframe.update_idletasks(),textvariable=best,bg='#321000',fg='#000fff000',font=("Helvetica",x1)).grid(column=1,row=1) and (2) mainframe = Frame(root) mainframe.grid(column=1000, row=1000, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) mainframe.update() Neither worked, of course, otherwise I woudln't be posting it) I'm not using any classes 2010/8/18 Cameron Laird > On Wed, Aug 18, 2010 at 12:50:38AM +1200, Alex Ter-Sarkissov wrote: > . > . > . > > I have some elements on the screen (Labels, most importantly) which > content > > has to be updated every iteration of the algorithm run, e.g. "Iteration > =" > > [i] for i in range(n). I've tried using mainframe.update_idletasks() > > and > Label(mainframe.update_ideltasks(),textvariable=var).grid(column=1,row=1), > > but without success so far. In MATLAB this command is drawnow. > . > . > . > I believe I understand your description. > > For a "quick fix", I recommend you experiment with update() (as > opposed to update_idletasks()) applied to mainframe. > > For better long-term maintainability, though, you almost > certainly should "return to the event loop" on each iteration > of your run (there are also multi-threading approaches, but > they're somewhat trickier to code correctly). > > You might find , http://wiki.tcl.tk/1526 >, and http://osdir.com/ml/python.tkinter/2008-05/msg00014.html > of > interest. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Wed Aug 18 07:19:38 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Wed, 18 Aug 2010 08:19:38 +0300 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: References: <20100817142505.GB5661@lairds.us> Message-ID: If I am not mistaken you want something like this: 1) http://paste-it.net/public/i2de44d/ (with threads and classes) 2) http://paste-it.net/public/f5e340e/ (without threads and classes) Note that without threads, we need to use the update() method. However, without threads you will experience some degree of "blockage" in the application anyway. 2010/8/18 Alex Ter-Sarkissov > thanks, in one of these articles it says. 'Be careful - Tkinter in not > re-entrant'. MAybe this is the problem? So far I've tried > > > (1) Label(mainframe.update_idletasks(),textvariable=best,bg='#321000',fg='#000fff000',font=("Helvetica",x1)).grid(column=1,row=1) > > and > > (2) > mainframe = Frame(root) > mainframe.grid(column=1000, row=1000, sticky=(N, W, E, S)) > mainframe.columnconfigure(0, weight=1) > mainframe.rowconfigure(0, weight=1) > mainframe.update() > > Neither worked, of course, otherwise I woudln't be posting it) > > I'm not using any classes > > 2010/8/18 Cameron Laird > >> On Wed, Aug 18, 2010 at 12:50:38AM +1200, Alex Ter-Sarkissov wrote: >> . >> . >> . >> > I have some elements on the screen (Labels, most importantly) which >> content >> > has to be updated every iteration of the algorithm run, e.g. "Iteration >> =" >> > [i] for i in range(n). I've tried using mainframe.update_idletasks() >> > and >> Label(mainframe.update_ideltasks(),textvariable=var).grid(column=1,row=1), >> > but without success so far. In MATLAB this command is drawnow. >> . >> . >> . >> I believe I understand your description. >> >> For a "quick fix", I recommend you experiment with update() (as >> opposed to update_idletasks()) applied to mainframe. >> >> For better long-term maintainability, though, you almost >> certainly should "return to the event loop" on each iteration >> of your run (there are also multi-threading approaches, but >> they're somewhat trickier to code correctly). >> >> You might find , > http://wiki.tcl.tk/1526 >, and > http://osdir.com/ml/python.tkinter/2008-05/msg00014.html > of >> interest. >> > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.odonnell at uam.es Wed Aug 18 08:58:42 2010 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 18 Aug 2010 16:58:42 +1000 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: <29449209.post@talk.nabble.com> References: <29449209.post@talk.nabble.com> Message-ID: Hi, Its always better if you provide code which can be run. Reduce out all irrelevant code. (often this process shows you the problem in your code). If you have an askyesno dialogue open, that hogs the keyboard, so you cannot type to another window while it is open. Mick On Tue, Aug 17, 2010 at 11:52 AM, wet_colored)arch wrote: > > What basically happens is if I use the application all features work fine > except the entry widget I have created. I cannot add text or even get the > cursor to appear in the entry field. > > ?What is odd is I have a askyesno button for quiting. If I hit "no" and > return to the application, I can then enter text and move the cursor with > the tab to other features and buttons in my gui. > > How do I get the entry box to work? > > The problem might be tied to windows, frames and parents (which I still > don't fully understand even though I have built 5 gui's now). ?The relevant > code is abridged as below: > > if __name__ == '__main__': > ? ?root = Tk() > ? ?root.title('Artifact Pointer')# adapted from_PyView 1.0') > ? ?Label(root, text="Point to Artifacts Observed").pack() > ? ?SlideShow(root, picdir=picdir, artdir=artdir, bd=3, relief=SUNKEN) > ? ?root.mainloop() > > preceeded by: > > class SlideShow(Frame): > ? ?def __init__(self, parent=root, picdir='.', artdir='.', msecs=3000, > **args):#msecs is legacy > ? ? ? ?Frame.__init__(self, parent, args) > ? ? ? ?self.parent = root > ? ? ? ?self.makeWidgets() > > and under def makeWidgets I have: > > self.vent=StringVar() > Entry(self,textvariable=self.vent).pack() > > > I have tried some variants and have read several forums and Lutz and still > am not getting this sorted out. ?It is odd to me that it works, but only > AFTER, I hit no under askyesno button. > -- > View this message in context: http://old.nabble.com/Entry-Widget-that-can%27t-enter-into-at-first.-tp29449209p29449209.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From Cameron at phaseit.net Wed Aug 18 15:22:30 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Wed, 18 Aug 2010 13:22:30 +0000 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: References: <20100817142505.GB5661@lairds.us> Message-ID: <20100818132230.GB30376@lairds.us> On Wed, Aug 18, 2010 at 08:19:38AM +0300, Firat Ozgul wrote: . . . > If I am not mistaken you want something like this: > > 1) http://paste-it.net/public/i2de44d/ (with threads and classes) > > 2) http://paste-it.net/public/f5e340e/ (without threads and classes) > > Note that without threads, we need to use the update() method. However, > without threads you will experience some degree of "blockage" in the > application anyway. . . . update() is *not* essential: after() provides a non-threading alternative. I entirely agree with your main point, though, that you have two codings which supply the desired functionality. From ozgulfirat at gmail.com Wed Aug 18 15:59:38 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Wed, 18 Aug 2010 16:59:38 +0300 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: <20100818132230.GB30376@lairds.us> References: <20100817142505.GB5661@lairds.us> <20100818132230.GB30376@lairds.us> Message-ID: [quote]Cameron Laird: "update() is *not* essential: after() provides a non-threading alternative."[/quote] I agree. If you would not like to use update(), you can use after() in your code with pretty much the same functionality: http://paste-it.net/public/e7ce371/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From sigma.z.1980 at gmail.com Thu Aug 19 02:24:35 2010 From: sigma.z.1980 at gmail.com (Alex Ter-Sarkissov) Date: Thu, 19 Aug 2010 12:24:35 +1200 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: References: <20100817142505.GB5661@lairds.us> <20100818132230.GB30376@lairds.us> Message-ID: thanks guys, this does seem to work...nevertheless, since I'm quite new to both python and gui design, one more question: how would I do the same, but launching the counter at the click of the button? I tried (from Firat's last example) def increment(*args): var.set(var.get()+1) root.after(1000, increment) but1=Button(text="click me", command=increment) but1.grid() but without any success. cheers! 2010/8/19 Firat Ozgul > [quote]Cameron Laird: "update() is *not* essential: after() provides a > non-threading alternative."[/quote] > > I agree. If you would not like to use update(), you can use after() in your > code with pretty much the same functionality: > > http://paste-it.net/public/e7ce371/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sigma.z.1980 at gmail.com Thu Aug 19 05:44:11 2010 From: sigma.z.1980 at gmail.com (Alex Ter-Sarkissov) Date: Thu, 19 Aug 2010 15:44:11 +1200 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: References: <20100817142505.GB5661@lairds.us> <20100818132230.GB30376@lairds.us> Message-ID: Ok, it actually seems to work, apart from one thing: what if I need to update an array, rather than a single element? I mean, each iteration I store an array, then use it the next iteration (naturally, the first array is generated randomly). This worked for the counter: 1. def run(*args): 2. n=0;master=mainframe 3. best.set('test # %d' % (n)) 4. n += 1 5. if n <= 10: 6. mainframe.after(1000, run, n, master) but when I do the same for a matrix, I get the computer either hung or some errors. Ususally, I run a loop for G generations within the function, but in this example the algorithm itself restarts G times. Any ideas how to handle this? Sorry for being messy, it's just the ONLY thing that I can't make work here, everything is is just fine) thanks 2010/8/19 Alex Ter-Sarkissov > thanks guys, this does seem to work...nevertheless, since I'm quite new to > both python and gui design, one more question: how would I do the same, but > launching the counter at the click of the button? I tried (from Firat's last > example) > > def increment(*args): var.set(var.get()+1) root.after(1000, increment) > > > but1=Button(text="click me", command=increment) > but1.grid() > > but without any success. > > cheers! > > > 2010/8/19 Firat Ozgul > > [quote]Cameron Laird: "update() is *not* essential: after() provides a >> non-threading alternative."[/quote] >> >> I agree. If you would not like to use update(), you can use after() in >> your code with pretty much the same functionality: >> >> http://paste-it.net/public/e7ce371/ >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Thu Aug 19 07:47:53 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Thu, 19 Aug 2010 08:47:53 +0300 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: References: <20100817142505.GB5661@lairds.us> <20100818132230.GB30376@lairds.us> Message-ID: I am not sure whether my understanding of your problem is correct, but if I am not wrong you want something like this: http://paste-it.net/public/i866d84/ 2010/8/19 Alex Ter-Sarkissov > Ok, it actually seems to work, apart from one thing: what if I need to > update an array, rather than a single element? I mean, each iteration I > store an array, then use it the next iteration (naturally, the first array > is generated randomly). This worked for the counter: > > > 1. def run(*args): > 2. n=0;master=mainframe > 3. best.set('test # %d' % (n)) > 4. n += 1 > 5. if n <= 10: > 6. mainframe.after(1000, run, n, master) > > > > > but when I do the same for a matrix, I get the computer either hung or some > errors. Ususally, I run a loop for G generations within the function, but in > this example the > algorithm itself restarts G times. Any ideas how to handle this? > > Sorry for being messy, it's just the ONLY thing that I can't make work > here, everything is is just fine) > > thanks > > 2010/8/19 Alex Ter-Sarkissov > > thanks guys, this does seem to work...nevertheless, since I'm quite new to >> both python and gui design, one more question: how would I do the same, but >> launching the counter at the click of the button? I tried (from Firat's last >> example) >> >> def increment(*args): var.set(var.get()+1) root.after(1000, increment) >> >> >> but1=Button(text="click me", command=increment) >> but1.grid() >> >> but without any success. >> >> cheers! >> >> >> 2010/8/19 Firat Ozgul >> >> [quote]Cameron Laird: "update() is *not* essential: after() provides a >>> non-threading alternative."[/quote] >>> >>> I agree. If you would not like to use update(), you can use after() in >>> your code with pretty much the same functionality: >>> >>> http://paste-it.net/public/e7ce371/ >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sigma.z.1980 at gmail.com Thu Aug 19 09:57:00 2010 From: sigma.z.1980 at gmail.com (Alex Ter-Sarkissov) Date: Thu, 19 Aug 2010 19:57:00 +1200 Subject: [Tkinter-discuss] update of elements in GUI In-Reply-To: References: <20100817142505.GB5661@lairds.us> <20100818132230.GB30376@lairds.us> Message-ID: thnx a lot, Firat, I sorted it out a few minutes b4 reading yr post) i just needed 2 loops: one for the counter (while j > I am not sure whether my understanding of your problem is correct, but if I > am not wrong you want something like this: > > http://paste-it.net/public/i866d84/ > > > > 2010/8/19 Alex Ter-Sarkissov > >> Ok, it actually seems to work, apart from one thing: what if I need to >> update an array, rather than a single element? I mean, each iteration I >> store an array, then use it the next iteration (naturally, the first array >> is generated randomly). This worked for the counter: >> >> >> 1. def run(*args): >> 2. n=0;master=mainframe >> 3. best.set('test # %d' % (n)) >> 4. n += 1 >> 5. if n <= 10: >> 6. mainframe.after(1000, run, n, master) >> >> >> >> >> but when I do the same for a matrix, I get the computer either hung or >> some errors. Ususally, I run a loop for G generations within the function, >> but in this example the >> algorithm itself restarts G times. Any ideas how to handle this? >> >> Sorry for being messy, it's just the ONLY thing that I can't make work >> here, everything is is just fine) >> >> thanks >> >> 2010/8/19 Alex Ter-Sarkissov >> >> thanks guys, this does seem to work...nevertheless, since I'm quite new to >>> both python and gui design, one more question: how would I do the same, but >>> launching the counter at the click of the button? I tried (from Firat's last >>> example) >>> >>> def increment(*args): var.set(var.get()+1) root.after(1000, increment) >>> >>> >>> but1=Button(text="click me", command=increment) >>> but1.grid() >>> >>> but without any success. >>> >>> cheers! >>> >>> >>> 2010/8/19 Firat Ozgul >>> >>> [quote]Cameron Laird: "update() is *not* essential: after() provides a >>>> non-threading alternative."[/quote] >>>> >>>> I agree. If you would not like to use update(), you can use after() in >>>> your code with pretty much the same functionality: >>>> >>>> http://paste-it.net/public/e7ce371/ >>>> >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.hedman at mac.com Sun Aug 22 06:45:30 2010 From: robert.hedman at mac.com (Rlain) Date: Sat, 21 Aug 2010 21:45:30 -0700 (PDT) Subject: [Tkinter-discuss] Multiple windows, accessing variables across them won't work for me (Using Tkinter) Message-ID: <29503063.post@talk.nabble.com> Hi! I've been working on this app last days, and can't get passed this problem: I've created two windows, (one is created by a button click in the first window), and from the other window I want to change some variables defined in the first window. I'm guessing either I haven't understood the whole parent thingy, or messed up somewhere there. The source code is: (there's some translations and explanations below) #!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import division import Tkinter class enhetsomvandlare_tk(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): self.grid() self.LV = Tkinter.StringVar() label = Tkinter.Label(self,textvariable=self.LV, anchor="w",fg="white",bg="blue") label.grid(column=0,row=0,columnspan=1,sticky='EW') self.LV.set(u"Lbs to Kg") global enhet enhet = "lbstokg" self.entryVariable1 = Tkinter.StringVar() self.entry = Tkinter.Entry(self,textvariable=self.entryVariable1) self.entry.grid(column=0,row=1,sticky='W') self.entry.bind("", self.OnPressEnter) self.entryVariable1.set(u"") self.entryVariable2 = Tkinter.StringVar() self.entry = Tkinter.Entry(self,textvariable=self.entryVariable2) self.entry.grid(column=1,row=1,sticky='W') self.entry.bind("", self.OnPressEnter) self.entryVariable2.set(u"") raknaknapp = Tkinter.Button(self,text=u"R?kna ut!", command=self.Onraknaknapp1) raknaknapp.grid(column=2,row=1) Change_units = Tkinter.Button(self,text=u"Change Units", command=self.OnChange_units) Change_units.grid(column=1,row=2) self.grid_columnconfigure(0,weight=1) self.grid_columnconfigure(1,weight=1) self.grid_columnconfigure(2,weight=1) self.resizable(True,False) self.update() self.geometry(self.geometry()) def Onraknaknapp1(self): if enhet == "lbstokg": lbs = float(self.entryVariable1.get()) kg = lbs / 0.455 self.entryVariable2.set(kg) elif enhet == "kgtolbs": kg = float(self.entryVariable1.get()) lbs = kg * 0.455 self.entryVariable2.set(lbs) def OnChange_units(self): class Change_units_tk(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent = parent self.initialize() def initialize(self): self.grid() self.LV2 = Tkinter.StringVar() label = Tkinter.Label(self,textvariable=self.LV2, anchor="w",fg="white",bg="blue") label.grid(column=0,row=0,columnspan=2,sticky='EW') self.LV2.set(u"Choose Unit...") kgtolbs = Tkinter.Button(self,text=u"Kg to lbs", command=self.Onkgtolbs) kgtolbs.grid(column=0,row=1) lbstokg = Tkinter.Button(self,text=u"Lbs to kg", command=self.Onlbstokg) lbstokg.grid(column=1,row=1) self.grid_columnconfigure(0,weight=1) self.grid_columnconfigure(1,weight=1) self.grid_columnconfigure(2,weight=1) self.resizable(True,False) self.update() self.geometry(self.geometry()) def Onkgtolbs(self): self.LV.set("Kg to lbs") global enhet enhet = "kgtolbs" def Onlbstokg(self): self.LV.set("Lbs to kg") global enhet enhet = "lbstokg" if __name__ == "__main__": app = Change_units_tk(enhetsomvandlare_tk) app.title("What unit?") def OnPressEnter(self,event): self.LV.set( "Hej" ) if __name__ == "__main__": app = enhetsomvandlare_tk(None) app.title("Robert's Enhetsomvandlare") app.mainloop() (Some things are swedish, so I'll translate them to make this easier to understand) Legend for my code: enhet = unit LV = Labelvariable raknaknapp = calculatebutton R?kna ut = calculate Now as soon as I get the crossover thing to work I'll start adding more math, functions and other things to it to make it useful. But right now I want to get rid of this error message: Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__ return self.func(*args) File "/home/robert/Desktop/programmering/python/12 enhets omvandlare/12.py", line 118, in OnChange_units app = Change_units_tk(enhetsomvandlare_tk) File "/home/robert/Desktop/programmering/python/12 enhets omvandlare/12.py", line 78, in __init__ Tkinter.Tk.__init__(self,parent) File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1646, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) TypeError: create() argument 1 must be string or None, not classobj OR when i have the line: app = Change_units_tk(enhetsomvandlare_tk) changed to: app = Change_units_tk(None) I will get the error message: Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__ return self.func(*args) File "/home/robert/Desktop/programmering/python/12 enhets omvandlare/12.py", line 107, in Onkgtolbs self.LV.set("Kg to lbs") File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1725, in __getattr__ return getattr(self.tk, attr) AttributeError: LV Which is the one I really don't get... Anyways, I've searched the net for some help, but couldn't find anything really helpful. (I know I probably missed it, but this was easier... :P) Help is appreciated, (I'm a first time poster). Have a nice day! :) /Robert -- View this message in context: http://old.nabble.com/Multiple-windows%2C-accessing-variables-across-them-won%27t-work-for-me-%28Using-Tkinter%29-tp29503063p29503063.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From ozgulfirat at gmail.com Mon Aug 23 08:22:27 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Mon, 23 Aug 2010 09:22:27 +0300 Subject: [Tkinter-discuss] Multiple windows, accessing variables across them won't work for me (Using Tkinter) In-Reply-To: <29503063.post@talk.nabble.com> References: <29503063.post@talk.nabble.com> Message-ID: Hello, In Tkinter, when you want to create a secondary window you do not have to implement a whole new class. What you need to do is just create a new toplevel. Furthermore, never use "globals" within a class. I made some modifications to your code. You can find the modified version of your code in here: http://paste-it.net/public/hc7b554/ Firat 2010/8/22 Rlain > > Hi! > I've been working on this app last days, and can't get passed this problem: > I've created two windows, (one is created by a button click in the first > window), and from the other window I want to change some variables defined > in the first window. > > I'm guessing either I haven't understood the whole parent thingy, or messed > up somewhere there. > > The source code is: > (there's some translations and explanations below) > > > #!/usr/bin/python > # -*- coding: utf-8 -*- > > from __future__ import division > import Tkinter > > > class enhetsomvandlare_tk(Tkinter.Tk): > def __init__(self,parent): > Tkinter.Tk.__init__(self,parent) > self.parent = parent > self.initialize() > > > def initialize(self): > self.grid() > > self.LV = Tkinter.StringVar() > label = Tkinter.Label(self,textvariable=self.LV, > anchor="w",fg="white",bg="blue") > label.grid(column=0,row=0,columnspan=1,sticky='EW') > self.LV.set(u"Lbs to Kg") > > global enhet > enhet = "lbstokg" > > > self.entryVariable1 = Tkinter.StringVar() > self.entry = Tkinter.Entry(self,textvariable=self.entryVariable1) > self.entry.grid(column=0,row=1,sticky='W') > self.entry.bind("", self.OnPressEnter) > self.entryVariable1.set(u"") > > self.entryVariable2 = Tkinter.StringVar() > self.entry = Tkinter.Entry(self,textvariable=self.entryVariable2) > self.entry.grid(column=1,row=1,sticky='W') > self.entry.bind("", self.OnPressEnter) > self.entryVariable2.set(u"") > > > > raknaknapp = Tkinter.Button(self,text=u"R?kna ut!", > command=self.Onraknaknapp1) > raknaknapp.grid(column=2,row=1) > > Change_units = Tkinter.Button(self,text=u"Change Units", > command=self.OnChange_units) > Change_units.grid(column=1,row=2) > > > self.grid_columnconfigure(0,weight=1) > self.grid_columnconfigure(1,weight=1) > self.grid_columnconfigure(2,weight=1) > self.resizable(True,False) > self.update() > self.geometry(self.geometry()) > > > > > def Onraknaknapp1(self): > if enhet == "lbstokg": > lbs = float(self.entryVariable1.get()) > kg = lbs / 0.455 > self.entryVariable2.set(kg) > > elif enhet == "kgtolbs": > kg = float(self.entryVariable1.get()) > lbs = kg * 0.455 > self.entryVariable2.set(lbs) > > > > def OnChange_units(self): > > class Change_units_tk(Tkinter.Tk): > def __init__(self,parent): > Tkinter.Tk.__init__(self,parent) > self.parent = parent > self.initialize() > > def initialize(self): > self.grid() > > self.LV2 = Tkinter.StringVar() > label = Tkinter.Label(self,textvariable=self.LV2, > > anchor="w",fg="white",bg="blue") > label.grid(column=0,row=0,columnspan=2,sticky='EW') > self.LV2.set(u"Choose Unit...") > > kgtolbs = Tkinter.Button(self,text=u"Kg to lbs", > command=self.Onkgtolbs) > kgtolbs.grid(column=0,row=1) > > lbstokg = Tkinter.Button(self,text=u"Lbs to kg", > command=self.Onlbstokg) > lbstokg.grid(column=1,row=1) > > self.grid_columnconfigure(0,weight=1) > self.grid_columnconfigure(1,weight=1) > self.grid_columnconfigure(2,weight=1) > self.resizable(True,False) > self.update() > self.geometry(self.geometry()) > > def Onkgtolbs(self): > self.LV.set("Kg to lbs") > global enhet > enhet = "kgtolbs" > > def Onlbstokg(self): > self.LV.set("Lbs to kg") > global enhet > enhet = "lbstokg" > > > if __name__ == "__main__": > app = Change_units_tk(enhetsomvandlare_tk) > app.title("What unit?") > > > def OnPressEnter(self,event): > self.LV.set( "Hej" ) > > > > if __name__ == "__main__": > app = enhetsomvandlare_tk(None) > app.title("Robert's Enhetsomvandlare") > app.mainloop() > > > > (Some things are swedish, so I'll translate them to make this easier to > understand) > Legend for my code: > > enhet = unit > LV = Labelvariable > raknaknapp = calculatebutton > R?kna ut = calculate > > > > > > > Now as soon as I get the crossover thing to work I'll start adding more > math, functions and other things to it to make it useful. But right now I > want to get rid of this error message: > > Exception in Tkinter callback > Traceback (most recent call last): > File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__ > return self.func(*args) > File "/home/robert/Desktop/programmering/python/12 enhets > omvandlare/12.py", line 118, in OnChange_units > app = Change_units_tk(enhetsomvandlare_tk) > File "/home/robert/Desktop/programmering/python/12 enhets > omvandlare/12.py", line 78, in __init__ > Tkinter.Tk.__init__(self,parent) > File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1646, in __init__ > self.tk = _tkinter.create(screenName, baseName, className, interactive, > wantobjects, useTk, sync, use) > TypeError: create() argument 1 must be string or None, not classobj > > OR > > when i have the line: > app = Change_units_tk(enhetsomvandlare_tk) > changed to: > app = Change_units_tk(None) > I will get the error message: > > Exception in Tkinter callback > Traceback (most recent call last): > File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__ > return self.func(*args) > File "/home/robert/Desktop/programmering/python/12 enhets > omvandlare/12.py", line 107, in Onkgtolbs > self.LV.set("Kg to lbs") > File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1725, in __getattr__ > return getattr(self.tk, attr) > AttributeError: LV > > Which is the one I really don't get... > > > > Anyways, I've searched the net for some help, but couldn't find anything > really helpful. (I know I probably missed it, but this was easier... :P) > > Help is appreciated, (I'm a first time poster). > > Have a nice day! :) > > /Robert > -- > View this message in context: > http://old.nabble.com/Multiple-windows%2C-accessing-variables-across-them-won%27t-work-for-me-%28Using-Tkinter%29-tp29503063p29503063.html > Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Aug 23 22:23:19 2010 From: klappnase at web.de (Michael Lange) Date: Mon, 23 Aug 2010 22:23:19 +0200 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly Message-ID: <20100823222319.76ee2caa.klappnase@web.de> Hello all, I am stuck here with a strange problem creating postscript from a Tkinter Canvas (the OS is debian linux). I found that Canvas.postscript() fails to render some fonts correctly and uses something like helvetica or courier (I guess) instead. From what the canvas man page says, I thought I should try to add a fontmap to the postscript() command, but I cannot seem to get it working, and I am not sure if it is because of improper use of the fontmap option or if something else is wrong. >From the few Tcl resources I could find I tried to set up a minimal tcl example, trying to find out how the "fontmap" works, because I could not find any useful Python resources: canvas .c -width 300 -height 300 -bg white pack .c set fonty [font create -family "comic sans ms" -size 16] .c create text 20 20 -font $fonty -text "ich wollt ich waer ein huhn" -anchor nw set fontMap($fonty) [list "comic sans ms" 16] update idletasks .c postscript -file "~/test.ps" -fontmap fontMap However this produces an obviously broken postscript file that cannot be opened. If I omit the -fontmap option, the file can be opened, but I get a font like helvetica or so. Does anyone have a clue on this? Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "Life and death are seldom logical." "But attaining a desired goal always is." -- McCoy and Spock, "The Galileo Seven", stardate 2821.7 From ozgulfirat at gmail.com Tue Aug 24 08:16:41 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 09:16:41 +0300 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: <20100823222319.76ee2caa.klappnase@web.de> References: <20100823222319.76ee2caa.klappnase@web.de> Message-ID: Hello, Unfortunately there are not enough documentation about Python-tk postscript manipulation. Information is scattered here and there. A sample code could be like this: [0] http://paste-it.net/public/l5a7036/ Some useful discussions on the topic: [0] http://www.velocityreviews.com/forums/t326920-tkinter-canvas-postscript-fontmap.html [1] http://wiki.tcl.tk/8483 Firat 2010/8/23 Michael Lange > Hello all, > > I am stuck here with a strange problem creating postscript from a > Tkinter Canvas (the OS is debian linux). > I found that Canvas.postscript() fails to render some fonts correctly and > uses something like helvetica or courier (I guess) instead. From what the > canvas man page says, I thought I should try to add a fontmap to the > postscript() command, but I cannot seem to get it working, and I am not > sure if it is because of improper use of the fontmap option or if > something else is wrong. > >From the few Tcl resources I could find I tried to set up a minimal tcl > example, trying to find out how the "fontmap" works, because I could not > find any useful Python resources: > > canvas .c -width 300 -height 300 -bg white > pack .c > set fonty [font create -family "comic sans ms" -size 16] > .c create text 20 20 -font $fonty -text "ich wollt ich waer ein huhn" > -anchor nw > set fontMap($fonty) [list "comic sans ms" 16] > update idletasks > .c postscript -file "~/test.ps" -fontmap fontMap > > However this produces an obviously broken postscript file that cannot be > opened. > If I omit the -fontmap option, the file can be opened, but I get a font > like > helvetica or so. > > Does anyone have a clue on this? > > Regards > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > "Life and death are seldom logical." > "But attaining a desired goal always is." > -- McCoy and Spock, "The Galileo Seven", stardate 2821.7 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Tue Aug 24 08:33:36 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 09:33:36 +0300 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: <20100823222319.76ee2caa.klappnase@web.de> References: <20100823222319.76ee2caa.klappnase@web.de> Message-ID: In addition to my previous e-mail, I want to add the following link in which there are some explanations and an example code for creating postscript. However the following is only useful if you are into Tcl/Tk: http://flylib.com/books.php?ln=en&n=3&p=480&c=292&p1=1&c1=1&c2=478&view=2 Firat 2010/8/23 Michael Lange > Hello all, > > I am stuck here with a strange problem creating postscript from a > Tkinter Canvas (the OS is debian linux). > I found that Canvas.postscript() fails to render some fonts correctly and > uses something like helvetica or courier (I guess) instead. From what the > canvas man page says, I thought I should try to add a fontmap to the > postscript() command, but I cannot seem to get it working, and I am not > sure if it is because of improper use of the fontmap option or if > something else is wrong. > >From the few Tcl resources I could find I tried to set up a minimal tcl > example, trying to find out how the "fontmap" works, because I could not > find any useful Python resources: > > canvas .c -width 300 -height 300 -bg white > pack .c > set fonty [font create -family "comic sans ms" -size 16] > .c create text 20 20 -font $fonty -text "ich wollt ich waer ein huhn" > -anchor nw > set fontMap($fonty) [list "comic sans ms" 16] > update idletasks > .c postscript -file "~/test.ps" -fontmap fontMap > > However this produces an obviously broken postscript file that cannot be > opened. > If I omit the -fontmap option, the file can be opened, but I get a font > like > helvetica or so. > > Does anyone have a clue on this? > > Regards > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > "Life and death are seldom logical." > "But attaining a desired goal always is." > -- McCoy and Spock, "The Galileo Seven", stardate 2821.7 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wet_colored_arch at yahoo.com Tue Aug 24 09:51:32 2010 From: wet_colored_arch at yahoo.com (wet_colored)arch) Date: Tue, 24 Aug 2010 00:51:32 -0700 (PDT) Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: References: <29449209.post@talk.nabble.com> Message-ID: <29519501.post@talk.nabble.com> Hi, Its always better if you provide code which can be run. Reduce out all irrelevant code. (often this process shows you the problem in your code). If you have an askyesno dialogue open, that hogs the keyboard, so you cannot type to another window while it is open. Mick >>> >>>>>>>>>>>>>> >>>>>I have attached a stripped down version of the code. [I do realize that the askyesno takes priority.] The code is intended to bring in an image and place it on a canvas, and allow the user to mark locations on the image with their mouse. You will need a small jpg or other to run the code when requested by askfilename. The entry field is to allow for extraneous comment. I am having trouble with this entry field. I cannot 1) enter content into the entry field without first trying to quit and then cancelling - I cannot expect the user to do this because it is not intuitive. I should be able to enter the entry field immediately if I want to. 2) I cannot seem to get the radio button to default to something I want.. instead it has all buttons marked when the gui comes up. [disclosure: code leveraged from Lutz] http://old.nabble.com/file/p29519501/artID_ver03_shortened.py artID_ver03_shortened.py -- View this message in context: http://old.nabble.com/Entry-Widget-that-can%27t-enter-into-at-first.-tp29449209p29519501.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From klappnase at web.de Tue Aug 24 10:41:42 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 24 Aug 2010 10:41:42 +0200 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: <29519501.post@talk.nabble.com> References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> Message-ID: <20100824104142.c1e3d76c.klappnase@web.de> Hi, Thus spoketh "wet_colored)arch" unto us on Tue, 24 Aug 2010 00:51:32 -0700 (PDT): > > I cannot > 1) enter content into the entry field without first trying to quit and > then cancelling - I cannot expect the user to do this because it is not > intuitive. I should be able to enter the entry field immediately if I > want to. I cannot reproduce this here, as soon as the file dialog is closed I can click into the entry and type something in. > 2) I cannot seem to get the radio button to default to something I > want.. instead it has all buttons marked when the gui comes up. You need to define a value for the radiobutton's variable, otherwise all buttons will be "off" when instantiated, so simply add something like self.var.set('key1') to makeWidgets() . I hope this helps Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Not one hundred percent efficient, of course ... but nothing ever is. -- Kirk, "Metamorphosis", stardate 3219.8 From ozgulfirat at gmail.com Tue Aug 24 10:57:57 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 11:57:57 +0300 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: <20100824104142.c1e3d76c.klappnase@web.de> References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> Message-ID: Actually, I can reproduce the error described by the original poster... I am not exactly sure about the true dynamics of the solution, but after_idle() method seems to solve the problem in a way. Perhaps, for one reason or the other, the program cannot return to the main window properly even though the open dialog is terminated. Therefore: [code] def __init__(self, parent=None, picdir='.', artdir='.', **args): Frame.__init__(self, parent, args) self.parent = parent self.makeWidgets() self.pack(expand=YES, fill=BOTH) self.makeBindings() self.opens = picdir self.artpics = artdir self.drawn = None #note the use of after_idle() self.begin = self.after_idle(self.onOpen) self.pick = 'TBD' return [/code] 2010/8/24 Michael Lange > Hi, > > Thus spoketh "wet_colored)arch" > unto us on Tue, 24 Aug 2010 00:51:32 -0700 (PDT): > > > > > > I cannot > > 1) enter content into the entry field without first trying to quit and > > then cancelling - I cannot expect the user to do this because it is not > > intuitive. I should be able to enter the entry field immediately if I > > want to. > > I cannot reproduce this here, as soon as the file dialog is closed I can > click into the entry and type something in. > > > 2) I cannot seem to get the radio button to default to something I > > want.. instead it has all buttons marked when the gui comes up. > > You need to define a value for the radiobutton's variable, otherwise all > buttons will be "off" when instantiated, so simply add something like > > self.var.set('key1') > > to makeWidgets() . > > I hope this helps > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Not one hundred percent efficient, of course ... but nothing ever is. > -- Kirk, "Metamorphosis", stardate 3219.8 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Tue Aug 24 11:05:31 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 24 Aug 2010 11:05:31 +0200 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: References: <20100823222319.76ee2caa.klappnase@web.de> Message-ID: <20100824110531.2d0edf54.klappnase@web.de> Thanks Firat for the reply, Thus spoketh Firat Ozgul unto us on Tue, 24 Aug 2010 09:16:41 +0300: > Hello, > > Unfortunately there are not enough documentation about Python-tk > postscript manipulation. Information is scattered here and there. > > A sample code could be like this: > [0] http://paste-it.net/public/l5a7036/ > this example does basically the same as my tcl snippet; it works ok with verdana, but for some reason fails on comic sans ms and some other fonts, but I cannot see why some fonts work and some don't. For example, also "bitstream vera sans mono" fails wheras "andale mono" works. Maybe I should mention that all these fonts are displayed correctly in the canvas. For the "working" fonts I do not even need to pass a fontmap to postscript(). > Some useful discussions on the topic: > [0] > http://www.velocityreviews.com/forums/t326920-tkinter-canvas-postscript-fontmap.html > [1] http://wiki.tcl.tk/8483 I have already seen these, however they don't help me much, because of the strange problems described above. So I am still not sure if it's improper use of the fontmap or some other weird problem with either Tk or maybe my system's postscript engine. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. The heart is not a logical organ. -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4 From ozgulfirat at gmail.com Tue Aug 24 11:37:41 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 12:37:41 +0300 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: <20100824110531.2d0edf54.klappnase@web.de> References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> Message-ID: Hello, It seems to me that for the most part, you are having issues with font names that have spaces between the words making up the font name. For example: "DejaVu Sans Condensed" If there are spaces between words, you should define self.font as a tuple: self.font = ("DejaVu Sans Condensed",) Note the trailing comma in accordance with the rules of creating a one-element tuple... Although it is not mandatory, you would better use the exact same cases (uppercase vs lowercase) for the fonts as seen from the output of: [code] root = Tk() root.tk.call("font", "families") [/code] Please try this way, and tell me if it solves the problem. 2010/8/24 Michael Lange > Thanks Firat for the reply, > > Thus spoketh Firat Ozgul > unto us on Tue, 24 Aug 2010 09:16:41 +0300: > > > Hello, > > > > Unfortunately there are not enough documentation about Python-tk > > postscript manipulation. Information is scattered here and there. > > > > A sample code could be like this: > > [0] http://paste-it.net/public/l5a7036/ > > > > this example does basically the same as my tcl snippet; it works ok with > verdana, but for some reason fails on comic sans ms and some other fonts, > but I cannot see why some fonts work and some don't. For example, also > "bitstream vera sans mono" fails wheras "andale mono" works. Maybe I > should mention that all these fonts are displayed correctly in the > canvas. For the "working" fonts I do not even need to pass a fontmap to > postscript(). > > > Some useful discussions on the topic: > > [0] > > > http://www.velocityreviews.com/forums/t326920-tkinter-canvas-postscript-fontmap.html > > [1] http://wiki.tcl.tk/8483 > > I have already seen these, however they don't help me much, because of > the strange problems described above. So I am still not sure if it's > improper use of the fontmap or some other weird problem with either Tk or > maybe my system's postscript engine. > > Regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > The heart is not a logical organ. > -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Tue Aug 24 11:51:48 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 12:51:48 +0300 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: <20100824110531.2d0edf54.klappnase@web.de> References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> Message-ID: Hello, I found some useful stuff at: http://www.tcl.tk/man/tcl8.4/TkCmd/canvas.htm(Find "-fontmap" there) The above document recommends a notation like: * -*-Courier-Bold-R-Normal--*-120- *I think this notation will be like this for those fonts that have spaces: *"-*-DejaVu Serif Condensed-Bold-R-Normal--*-120-*" * 2010/8/24 Michael Lange > Thanks Firat for the reply, > > Thus spoketh Firat Ozgul > unto us on Tue, 24 Aug 2010 09:16:41 +0300: > > > Hello, > > > > Unfortunately there are not enough documentation about Python-tk > > postscript manipulation. Information is scattered here and there. > > > > A sample code could be like this: > > [0] http://paste-it.net/public/l5a7036/ > > > > this example does basically the same as my tcl snippet; it works ok with > verdana, but for some reason fails on comic sans ms and some other fonts, > but I cannot see why some fonts work and some don't. For example, also > "bitstream vera sans mono" fails wheras "andale mono" works. Maybe I > should mention that all these fonts are displayed correctly in the > canvas. For the "working" fonts I do not even need to pass a fontmap to > postscript(). > > > Some useful discussions on the topic: > > [0] > > > http://www.velocityreviews.com/forums/t326920-tkinter-canvas-postscript-fontmap.html > > [1] http://wiki.tcl.tk/8483 > > I have already seen these, however they don't help me much, because of > the strange problems described above. So I am still not sure if it's > improper use of the fontmap or some other weird problem with either Tk or > maybe my system's postscript engine. > > Regards > > Michael > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > The heart is not a logical organ. > -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Tue Aug 24 13:01:08 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 24 Aug 2010 13:01:08 +0200 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> Message-ID: <20100824130108.e8061704.klappnase@web.de> Hello, Thus spoketh Firat Ozgul unto us on Tue, 24 Aug 2010 12:37:41 +0300: > Hello, > > It seems to me that for the most part, you are having issues with font > names that have spaces between the words making up the font name. For > example: "DejaVu Sans Condensed" > > If there are spaces between words, you should define self.font as a > tuple: > > self.font = ("DejaVu Sans Condensed",) I know that, otherwise Tk will complain "expected an integer but got 'sans'" or so :) I thought it might have something to do with the spaces first, too, but as I mentioned "andale mono" or "penguin attack" work, wheras "clean" or "avantgarde" don't. > > Note the trailing comma in accordance with the rules of creating a > one-element tuple... > > Although it is not mandatory, you would better use the exact same cases > (uppercase vs lowercase) for the fonts as seen from the output of: > > [code] > root = Tk() > root.tk.call("font", "families") > [/code] > I already used the font names this way, here I get all lower case variants of all font names (like "dejavu sans") from tkFont.families(). I am really baffled with this (o.O) I tried some more with the fontmap, I changed the font in your example into: self.font = tkFont.Font(family="courier", weight='normal', size=43) and changed the first lines of create_ps() into: root.tk.call("set", "fontMap(%s)" % self.font, ('verdana-bold', 43)) self.ps = self.canvas.postscript(fontmap='fontMap') however if I change "verdana-bold" into "verdana" or "verdana-normal" it does *not* work and the postscript uses "courier" (as seen on the screen). I was not able yet to add a font name containing white space to the fontmap though :( Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. No one may kill a man. Not for any purpose. It cannot be condoned. -- Kirk, "Spock's Brain", stardate 5431.6 From Cameron at phaseit.net Tue Aug 24 13:55:13 2010 From: Cameron at phaseit.net (Cameron Laird) Date: Tue, 24 Aug 2010 11:55:13 +0000 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> Message-ID: <20100824115513.GA24030@lairds.us> On Tue, Aug 24, 2010 at 11:57:57AM +0300, Firat Ozgul wrote: . . . > Actually, I can reproduce the error described by the original poster... I am > not exactly sure about the true dynamics of the solution, but after_idle() > method seems to solve the problem in a way. Perhaps, for one reason or the > other, the program cannot return to the main window properly even though the > open dialog is terminated. . . . Gentlemen, I recommend you mention what operating system (or perhaps, more to the point, what windowing system) is giving you these results. Errors or inconsistencies in Tkinter are particularly likely to arise in platform-specific code having to do with window managers. From ozgulfirat at gmail.com Tue Aug 24 14:36:56 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 15:36:56 +0300 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: <20100824115513.GA24030@lairds.us> References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> <20100824115513.GA24030@lairds.us> Message-ID: I could reproduce the error on a Windows XP machine. I will test it on GNU/Linux (Ubuntu Karmic Koala - GNOME) in the evening. 2010/8/24 Cameron Laird > On Tue, Aug 24, 2010 at 11:57:57AM +0300, Firat Ozgul wrote: > . > . > . > > Actually, I can reproduce the error described by the original poster... I > am > > not exactly sure about the true dynamics of the solution, but > after_idle() > > method seems to solve the problem in a way. Perhaps, for one reason or > the > > other, the program cannot return to the main window properly even though > the > > open dialog is terminated. > . > . > . > Gentlemen, I recommend you mention what operating system (or perhaps, > more to the point, what windowing system) is giving you these results. > Errors or inconsistencies in Tkinter are particularly likely to arise > in platform-specific code having to do with window managers. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Tue Aug 24 15:54:30 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 16:54:30 +0300 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: <20100824134402.e70162c8.klappnase@web.de> References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> <20100824134402.e70162c8.klappnase@web.de> Message-ID: Hello, It looks like that postscript() function cannot render every font with no obvious reason. "Renderable" fonts are rendered correctly regardless of whether they contain spaces or not... However it seems that, alternatively, we can achieve what we want through the Image, ImageDraw and ImageFont modules. All we need to know is the name of the .ttf file to which the font name corresponds. Here is the code: http://paste-it.net/public/t66c5c0/ Please note that I wrote this code on an XP machine. Considering that you are on Debian, this little how to might be of help to you for configuring TrueType fonts: http://www.faqs.org/docs/Linux-mini/TT-Debian.html Firat 2010/8/24 Michael Lange > Hi Firat, > > Thus spoketh Firat Ozgul > unto us on Tue, 24 Aug 2010 12:51:48 +0300: > > > Hello, > > > > I found some useful stuff at: > > http://www.tcl.tk/man/tcl8.4/TkCmd/canvas.htm(Find"-fontmap" there) > > > > The above document recommends a notation like: * > > -*-Courier-Bold-R-Normal--*-120- > > > > *I think this notation will be like this for those fonts that have > > spaces: > > > > *"-*-DejaVu Serif Condensed-Bold-R-Normal--*-120-*" > > I have already seen this, too, however this does not change anything :( > Using "-*-comic sans ms-Bold-R-Normal--*-240-*" the font is displayed > correctly as always,but not in the postscript :( > > Thanks for all your efforts ! > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > "I'm a doctor, not a mechanic." > -- "The Doomsday Machine", when asked if he had heard of > the idea of a doomsday machine. > "I'm a doctor, not an escalator." > -- "Friday's Child", when asked to help the very pregnant > Ellen up a steep incline. > "I'm a doctor, not a bricklayer." > -- Devil in the Dark", when asked to patch up the Horta. > "I'm a doctor, not an engineer." > -- "Mirror, Mirror", when asked by Scotty for help in > Engineering aboard the ISS Enterprise. > "I'm a doctor, not a coalminer." > -- "The Empath", on being beneath the surface of Minara 2. > "I'm a surgeon, not a psychiatrist." > -- "City on the Edge of Forever", on Edith Keeler's remark > that Kirk talked strangely. > "I'm no magician, Spock, just an old country doctor." > -- "The Deadly Years", to Spock while trying to cure the > aging effects of the rogue comet near Gamma Hydra 4. > "What am I, a doctor or a moonshuttle conductor?" > -- "The Corbomite Maneuver", when Kirk rushed off from a > physical exam to answer the alert. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgulfirat at gmail.com Tue Aug 24 18:43:54 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 19:43:54 +0300 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: <20100824124742.GB30643@lairds.us> References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> <20100824115513.GA24030@lairds.us> <20100824124742.GB30643@lairds.us> Message-ID: I tested the original poster's code on Ubuntu Karmic Koala (GNOME). As soon as the file dialog is closed, the entry widget is ready for typing. So it seems that this problem is specific to Windows OS. 2010/8/24 Cameron Laird > On Tue, Aug 24, 2010 at 03:36:56PM +0300, Firat Ozgul wrote: > . > . > . > > I could reproduce the error on a Windows XP machine. I will test it on > > GNU/Linux (Ubuntu Karmic Koala - GNOME) in the evening. > . > . > . > 'Sounds good. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Tue Aug 24 19:00:54 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 24 Aug 2010 19:00:54 +0200 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> <20100824115513.GA24030@lairds.us> Message-ID: <20100824190054.172e9d9c.klappnase@web.de> Thus spoketh Firat Ozgul unto us on Tue, 24 Aug 2010 15:36:56 +0300: > I could reproduce the error on a Windows XP machine. I will test it on > GNU/Linux (Ubuntu Karmic Koala - GNOME) in the evening. > Here it is a debian linux with IceWM running where I could *not* reproduce the error :) Regards Michael > 2010/8/24 Cameron Laird > > > On Tue, Aug 24, 2010 at 11:57:57AM +0300, Firat Ozgul wrote: > > . > > . > > . > > > Actually, I can reproduce the error described by the original > > > poster... I > > am > > > not exactly sure about the true dynamics of the solution, but > > after_idle() > > > method seems to solve the problem in a way. Perhaps, for one reason > > > or > > the > > > other, the program cannot return to the main window properly even > > > though > > the > > > open dialog is terminated. > > . > > . > > . > > Gentlemen, I recommend you mention what operating system (or perhaps, > > more to the point, what windowing system) is giving you these results. > > Errors or inconsistencies in Tkinter are particularly likely to arise > > in platform-specific code having to do with window managers. > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "The release of emotion is what keeps us health. Emotionally healthy." "That may be, Doctor. However, I have noted that the healthy release of emotion is frequently unhealthy for those closest to you." -- McCoy and Spock, "Plato's Stepchildren", stardate 5784.3 From ozgulfirat at gmail.com Tue Aug 24 20:03:51 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 21:03:51 +0300 Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: <20100824190054.172e9d9c.klappnase@web.de> References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> <20100824115513.GA24030@lairds.us> <20100824190054.172e9d9c.klappnase@web.de> Message-ID: It is Debian, after all... :) By the way, I created a new record for this issue with Cameron Laird's suggestion: http://bugs.python.org/issue9673 Cheers, Firat 2010/8/24 Michael Lange > > Here it is a debian linux with IceWM running where I could *not* reproduce > the error :) > > Regards > > Michael > > > 2010/8/24 Cameron Laird > > > > > On Tue, Aug 24, 2010 at 11:57:57AM +0300, Firat Ozgul wrote: > > > . > > > . > > > . > > > > Actually, I can reproduce the error described by the original > > > > poster... I > > > am > > > > not exactly sure about the true dynamics of the solution, but > > > after_idle() > > > > method seems to solve the problem in a way. Perhaps, for one reason > > > > or > > > the > > > > other, the program cannot return to the main window properly even > > > > though > > > the > > > > open dialog is terminated. > > > . > > > . > > > . > > > Gentlemen, I recommend you mention what operating system (or perhaps, > > > more to the point, what windowing system) is giving you these results. > > > Errors or inconsistencies in Tkinter are particularly likely to arise > > > in platform-specific code having to do with window managers. > > > > > > > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > "The release of emotion is what keeps us health. Emotionally > healthy." "That may be, Doctor. However, I have noted that the healthy > release of emotion is frequently unhealthy for those closest to you." > -- McCoy and Spock, "Plato's Stepchildren", stardate > 5784.3 > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Tue Aug 24 20:44:01 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 24 Aug 2010 20:44:01 +0200 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> <20100824134402.e70162c8.klappnase@web.de> Message-ID: <20100824204401.52ff1281.klappnase@web.de> Hello, Thus spoketh Firat Ozgul unto us on Tue, 24 Aug 2010 16:54:30 +0300: > Hello, > > It looks like that postscript() function cannot render every font with > no obvious reason. "Renderable" fonts are rendered correctly regardless > of whether they contain spaces or not... I guess you are right, and using the fontmap option does not seem to make any difference; when I use e.g. times in the canvas and override it through the fontmap with verdana, I get verdana in the postscript. If I use e.g. "clean" instead of verdana I get something that looks like courier. So it looks like the good news is that I don't need to bother trying to get the fontmap working when the font name contains white space :) > However it seems that, > alternatively, we can achieve what we want through the Image, ImageDraw > and ImageFont modules. All we need to know is the name of the .ttf file > to which the font name corresponds. > > Here is the code: http://paste-it.net/public/t66c5c0/ Nice, i did not know that this is possible, but unfortunately this is no option for me. I want that my app can be run on any linux machine, so I would have to ship my own fonts to know where exactly the files are. I wonder if there is some way to determine from within Tkinter which fonts can't be used with postscript; if yes I could simply remove these from the menu where the font can be selected, I could live very well with that. What's bad is that the font that is printed is not the one the user sees on the screen. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. There's a way out of any cage. -- Captain Christopher Pike, "The Menagerie" ("The Cage"), stardate unknown. From ozgulfirat at gmail.com Tue Aug 24 21:49:28 2010 From: ozgulfirat at gmail.com (Firat Ozgul) Date: Tue, 24 Aug 2010 22:49:28 +0300 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: <20100824204401.52ff1281.klappnase@web.de> References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> <20100824134402.e70162c8.klappnase@web.de> <20100824204401.52ff1281.klappnase@web.de> Message-ID: In Tk documentation, it reads: "(...) Tk attempts to guess what Postscript font to use. Tk's guesses generally only work for well-known fonts such as Times and Helvetica and Courier (...)" source: http://www.tcl.tk/man/tcl8.4/TkCmd/canvas.htm (see "-fontmap" section) So if you would like to be on the safe side, you are only limited to Times, Helvetica and Courier... In GNU/Linux, as you know, fonts are generally in /usr/share/fonts. Therefore you can take this path as the base for your application's font folder. Also I believe that distributing your own fonts is not a bad idea. If I were you, I would just collect all the fonts I need into a folder, and distribute that folder with my application. This way, I would always know where and what the fonts are... For instance, suppose that you collected all your .tff files in a folder named "freefont", and you know that there is a .tff file named "FreeSansOblique.ttf" in that folder: http://paste-it.net/public/ke2fa61/ There are some interesting websites giving away free fonts over the net. For example: http://www.webpagepublicity.com/free-fonts.html I tested some of these fonts in my code (under Ubuntu), and they all work. Good Luck! Firat 2010/8/24 Michael Lange > Hello, > > Thus spoketh Firat Ozgul > unto us on Tue, 24 Aug 2010 16:54:30 +0300: > > > Hello, > > > > It looks like that postscript() function cannot render every font with > > no obvious reason. "Renderable" fonts are rendered correctly regardless > > of whether they contain spaces or not... > > I guess you are right, and using the fontmap option does not seem to make > any difference; when I use e.g. times in the canvas and override it > through the fontmap with verdana, I get verdana in the postscript. If I > use e.g. "clean" instead of verdana I get something that looks like > courier. So it looks like the good news is that I don't need to bother > trying to get the fontmap working when the font name contains white > space :) > > > However it seems that, > > alternatively, we can achieve what we want through the Image, ImageDraw > > and ImageFont modules. All we need to know is the name of the .ttf file > > to which the font name corresponds. > > > > Here is the code: http://paste-it.net/public/t66c5c0/ > > Nice, i did not know that this is possible, but unfortunately this is no > option for me. I want that my app can be run on any linux machine, so I > would have to ship my own fonts to know where exactly the files are. > > I wonder if there is some way to determine from within Tkinter which > fonts can't be used with postscript; if yes I could simply remove these > from the menu where the font can be selected, I could live very well with > that. What's bad is that the font that is printed is not the one the user > sees on the screen. > > Regards > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > There's a way out of any cage. > -- Captain Christopher Pike, "The Menagerie" ("The Cage"), > stardate unknown. > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Tue Aug 24 22:29:18 2010 From: klappnase at web.de (Michael Lange) Date: Tue, 24 Aug 2010 22:29:18 +0200 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> <20100824134402.e70162c8.klappnase@web.de> <20100824204401.52ff1281.klappnase@web.de> Message-ID: <20100824222918.fddc77a6.klappnase@web.de> Thus spoketh Firat Ozgul unto us on Tue, 24 Aug 2010 22:49:28 +0300: > In Tk documentation, it reads: > > "(...) Tk attempts to guess what Postscript font to use. Tk's guesses > generally only work for well-known fonts such as Times and Helvetica and > Courier (...)" > > source: http://www.tcl.tk/man/tcl8.4/TkCmd/canvas.htm (see "-fontmap" > section) > > So if you would like to be on the safe side, you are only limited to > Times, Helvetica and Courier... I have seen this in the description of the fontmap option, but it seems a little outdated to me, as there is no difference between using fontmap or not and even obscure fonts as "penguin attack" are found, no matter if they are written upper or lower case. I also got the same impression from a comp.lang.tcl search for "fontmap", where tha vast majority of matches was older than 6 or 7 years; it looks like Tk's guessing capabilities have improved :) > > In GNU/Linux, as you know, fonts are generally in /usr/share/fonts. > Therefore you can take this path as the base for your application's font > folder. Not necessarily, for example might people install third-party fonts into /usr/local or /opt or into their /home directory. > > Also I believe that distributing your own fonts is not a bad idea. If I > were you, I would just collect all the fonts I need into a folder, and > distribute that folder with my application. This way, I would always > know where and what the fonts are... For instance, suppose that you > collected all your .tff files in a folder named "freefont", and you > know that there is a .tff file named "FreeSansOblique.ttf" in that > folder: The downside is, that people then cannot use their system-wide installed fonts which they might prefer... Anyway, I think I will just keep it like it is for now. If I weren't such a "comic sans ms" aficinado maybe I had never noticed this and no one complained so far, so I guess people can live with it, too. It just would have been nice to have a bug free UI. Thanks again Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. We fight only when there is no other choice. We prefer the ways of peaceful contact. -- Kirk, "Spectre of the Gun", stardate 4385.3 From wet_colored_arch at yahoo.com Tue Aug 24 23:12:25 2010 From: wet_colored_arch at yahoo.com (Michael Frauens) Date: Tue, 24 Aug 2010 14:12:25 -0700 (PDT) Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> <20100824115513.GA24030@lairds.us> <20100824124742.GB30643@lairds.us> Message-ID: <911254.71356.qm@web120015.mail.ne1.yahoo.com> I am the original poster.? I can confirm that I am using a Windows XP operating system.? I do not have ready access to another OS (right now). ________________________________ From: Firat Ozgul To: tkinter-discuss at python.org Sent: Tue, August 24, 2010 12:43:54 PM Subject: Re: [Tkinter-discuss] Entry Widget that can't enter into at first. I tested the original poster's code on Ubuntu Karmic Koala (GNOME). As soon as the file dialog is closed, the entry widget is ready for typing. So it seems that this problem is specific to Windows OS. 2010/8/24 Cameron Laird On Tue, Aug 24, 2010 at 03:36:56PM +0300, Firat Ozgul wrote: >? ? ? ? ? ? ? ? ? ? ? ?. >? ? ? ? ? ? ? ? ? ? ? ?. >? ? ? ? ? ? ? ? ? ? ? ?. > >> I could reproduce the error on a Windows XP machine. I will test it on >> GNU/Linux (Ubuntu Karmic Koala - GNOME) in the evening. >? ? ? ? ? ? ? ? ? ? ? ?. >? ? ? ? ? ? ? ? ? ? ? ?. >? ? ? ? ? ? ? ? ? ? ? ?. >'Sounds good. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wet_colored_arch at yahoo.com Tue Aug 24 23:16:44 2010 From: wet_colored_arch at yahoo.com (wet_colored)arch) Date: Tue, 24 Aug 2010 14:16:44 -0700 (PDT) Subject: [Tkinter-discuss] Entry Widget that can't enter into at first. In-Reply-To: References: <29449209.post@talk.nabble.com> <29519501.post@talk.nabble.com> <20100824104142.c1e3d76c.klappnase@web.de> <20100824115513.GA24030@lairds.us> Message-ID: <29526544.post@talk.nabble.com> I confirm the problem was on Windows XP. I do not have another OS handy to try. THanks all Firat Ozgul wrote: > > I tested the original poster's code on Ubuntu Karmic Koala (GNOME). As > soon > as the file dialog is closed, the entry widget is ready for typing. So it > seems that this problem is specific to Windows OS. > > 2010/8/24 Cameron Laird > >> On Tue, Aug 24, 2010 at 03:36:56PM +0300, Firat Ozgul wrote: >> . >> . >> . >> > I could reproduce the error on a Windows XP machine. I will test it on >> > GNU/Linux (Ubuntu Karmic Koala - GNOME) in the evening. >> . >> . >> . >> 'Sounds good. >> > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -- View this message in context: http://old.nabble.com/Entry-Widget-that-can%27t-enter-into-at-first.-tp29449209p29526544.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From memilanuk at gmail.com Fri Aug 27 06:15:01 2010 From: memilanuk at gmail.com (Monte Milanuk) Date: Thu, 26 Aug 2010 21:15:01 -0700 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: <4C59DA50.2070104@codebykevin.com> References: <4C5954B9.7020406@codebykevin.com> <4C59DA50.2070104@codebykevin.com> Message-ID: On 8/4/10 2:23 PM, Kevin Walzer wrote: > I believe that the system build of Python 2.6 on Snow Leopard (the one > installed by Apple) is linked against Tk 8.5, which includes the ttk > widgets. You'd still need to install the Python ttk wrapper module from > http://code.google.com/p/python-ttk/, but that's easier than building > the Tile module from scratch. Just download the code, and run "sudo > /usr/bin/python setup.py install" and you should be in business. > Hello Kevin, I downloaded the python ttk wrapper and ran the command as you suggested... but I'm not having any luck importing ttk (Mac OS X 10.6.4, running the supplied python 2.6.5). Any suggestions? TIA, Monte From kw at codebykevin.com Fri Aug 27 13:40:27 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Fri, 27 Aug 2010 07:40:27 -0400 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: References: <4C5954B9.7020406@codebykevin.com> <4C59DA50.2070104@codebykevin.com> Message-ID: <4C77A42B.7060201@codebykevin.com> On 8/27/10 12:15 AM, Monte Milanuk wrote: > > Hello Kevin, > > I downloaded the python ttk wrapper and ran the command as you > suggested... but I'm not having any luck importing ttk (Mac OS X 10.6.4, > running the supplied python 2.6.5). What error messages do you see? -- Kevin Walzer Code by Kevin http://www.codebykevin.com From memilanuk at gmail.com Fri Aug 27 18:15:07 2010 From: memilanuk at gmail.com (Monte Milanuk) Date: Fri, 27 Aug 2010 09:15:07 -0700 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: <4C77A42B.7060201@codebykevin.com> References: <4C5954B9.7020406@codebykevin.com> <4C59DA50.2070104@codebykevin.com> <4C77A42B.7060201@codebykevin.com> Message-ID: On 8/27/10 4:40 AM, Kevin Walzer wrote: > What error messages do you see? > IDLE 2.6.5 >>> from Tkinter import * >>> from Tkinter import ttk Traceback (most recent call last): File "", line 1, in from Tkinter import ttk ImportError: cannot import name ttk >>> or >>> import ttk Traceback (most recent call last): File "", line 1, in import ttk ImportError: No module named ttk If there is a different syntax I should be using, please let me know. Thanks, Monte From klappnase at web.de Fri Aug 27 19:33:00 2010 From: klappnase at web.de (Michael Lange) Date: Fri, 27 Aug 2010 19:33:00 +0200 Subject: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly In-Reply-To: <20100824222918.fddc77a6.klappnase@web.de> References: <20100823222319.76ee2caa.klappnase@web.de> <20100824110531.2d0edf54.klappnase@web.de> <20100824134402.e70162c8.klappnase@web.de> <20100824204401.52ff1281.klappnase@web.de> <20100824222918.fddc77a6.klappnase@web.de> Message-ID: <20100827193300.ebd1a005.klappnase@web.de> Hello all, I did now some further investigation on this topic and I thought I might share what I found here, for the archives :) It seems that in fact the problem is the name of the postscript font created by Tk. Tk itself treats all font names case insensitive, so "cOMiC SanS mS" is equivalent with "comic sans ms". Postscript however appears to be quite fastidious about the spelling of a font name. Even worse, it looks like the requested spelling of a font can differ from one postscript interpreter to another. Tk itself creates postscript font names always the same way: the first letter capitalized, the rest lower case, as in "Courier". If the name contains white space, each "word" is capitalized and the white space removed, so e.g. "comic sans ms" becomes "ComicSansMs". This behavior is hard coded in tkFont.c . In my example the postscript interpreter insists on "ComicSansMS" though and therefore fails to print the font correctly. This is where the fontmap option comes in, passing the exact postscript font name to the fontmap like: set fontMap($fonty) {"ComicSansMS" 16} .c postscript -file "~/test.ps" -fontmap fontMap the "comic" font works as expected. However the bad thing is that this does not mean that it will work on any system, e.g. the same postscript file that works on my debian linux system did *not* work on my windows2000 box with a newly installed ghostscript (latest version). However if it is for personal use only, it seems to be better to directly add entries to the postscript fontmap (on unix systems usually /usr/share/ghostscript//lib/Fontmap ) In my example this entry simply looks like: /ComicSansMs /ComicSansMS ; or, probably better, add custom entries like this to a file MyFontmap in the same folder and add a line (MyFontmap) .runlibfile to Fontmap, so the private entries won't be lost after an update. Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. "Beauty is transitory." "Beauty survives." -- Spock and Kirk, "That Which Survives", stardate unknown From charras at me.com Sat Aug 28 15:42:48 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Sat, 28 Aug 2010 07:42:48 -0600 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: References: Message-ID: <566457F7-7FAF-4E1E-AD55-13401769E5B2@me.com> Monte, do you have python 3.1 or 2.6.5. I had a mac as well, and when I try to use ttk didn't work. They way I solve was to copy the ttk.py file inside of the site-packages, which in my case is inside of: Library/Frameworks/Python.framewors/Versions/2.7/lib/python2.7/site-packages Than, what I will recommend is to install from the source, not the installer disk image. If you install from the installer disk image, once you try to use ttk, you will see that the Tk and Tcl connected to ttk are version 8.4, which will not work. If you need details instructions on how to install from the source let me know. I hope this helps. Regards! Guido Carballo On Aug 28, 2010, at 4:00 AM, tkinter-discuss-request at python.org wrote: > Send Tkinter-discuss mailing list submissions to > tkinter-discuss at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tkinter-discuss > or, via email, send a message with subject or body 'help' to > tkinter-discuss-request at python.org > > You can reach the person managing the list at > tkinter-discuss-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tkinter-discuss digest..." > Today's Topics: > > 1. Re: python 3.1 - tkinter 8.4 - no tile? (Kevin Walzer) > 2. Re: python 3.1 - tkinter 8.4 - no tile? (Monte Milanuk) > 3. Re: Canvas.postscript() fails to render some fonts properly > (Michael Lange) > > From: Kevin Walzer > Date: August 27, 2010 5:40:27 AM GMT-06:00 > To: tkinter-discuss at python.org > Subject: Re: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? > Reply-To: kw at codebykevin.com > > > On 8/27/10 12:15 AM, Monte Milanuk wrote: > >> >> Hello Kevin, >> >> I downloaded the python ttk wrapper and ran the command as you >> suggested... but I'm not having any luck importing ttk (Mac OS X 10.6.4, >> running the supplied python 2.6.5). > > What error messages do you see? > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com > > > > > From: Monte Milanuk > Date: August 27, 2010 10:15:07 AM GMT-06:00 > To: tkinter-discuss at python.org > Subject: Re: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? > > > On 8/27/10 4:40 AM, Kevin Walzer wrote: > >> What error messages do you see? >> > > IDLE 2.6.5 > >>> from Tkinter import * > >>> from Tkinter import ttk > > Traceback (most recent call last): > File "", line 1, in > from Tkinter import ttk > ImportError: cannot import name ttk > >>> > > or > > >>> import ttk > > Traceback (most recent call last): > File "", line 1, in > import ttk > ImportError: No module named ttk > > > If there is a different syntax I should be using, please let me know. > > Thanks, > > Monte > > > > > > From: Michael Lange > Date: August 27, 2010 11:33:00 AM GMT-06:00 > To: tkinter-discuss at python.org > Subject: Re: [Tkinter-discuss] Canvas.postscript() fails to render some fonts properly > > > Hello all, > > I did now some further investigation on this topic and I thought I > might share what I found here, for the archives :) > > It seems that in fact the problem is the name of the postscript font > created by Tk. Tk itself treats all font names case insensitive, so > "cOMiC SanS mS" is equivalent with "comic sans ms". Postscript however > appears to be quite fastidious about the spelling of a font name. Even > worse, it looks like the requested spelling of a font can differ from one > postscript interpreter to another. > Tk itself creates postscript font names always the same way: the first > letter capitalized, the rest lower case, as in "Courier". If the name > contains white space, each "word" is capitalized and the white space > removed, so e.g. "comic sans ms" becomes "ComicSansMs". This behavior is > hard coded in tkFont.c . In my example the postscript interpreter insists > on "ComicSansMS" though and therefore fails to print the font correctly. > This is where the fontmap option comes in, passing the exact postscript > font name to the fontmap like: > > set fontMap($fonty) {"ComicSansMS" 16} > .c postscript -file "~/test.ps" -fontmap fontMap > > the "comic" font works as expected. > However the bad thing is that this does not mean that it will work on any > system, e.g. the same postscript file that works on my debian linux system > did *not* work on my windows2000 box with a newly installed ghostscript > (latest version). > However if it is for personal use only, it seems to be better to directly > add entries to the postscript fontmap (on unix systems usually > /usr/share/ghostscript//lib/Fontmap ) > In my example this entry simply looks like: > > /ComicSansMs /ComicSansMS ; > > or, probably better, add custom entries like this to a file MyFontmap in > the same folder and add a line > > (MyFontmap) .runlibfile > > to Fontmap, so the private entries won't be lost after an update. > > Michael > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > "Beauty is transitory." > "Beauty survives." > -- Spock and Kirk, "That Which Survives", stardate unknown > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ttk.py Type: text/x-python-script Size: 56892 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From memilanuk at gmail.com Sun Aug 29 17:06:15 2010 From: memilanuk at gmail.com (Monte Milanuk) Date: Sun, 29 Aug 2010 08:06:15 -0700 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: <566457F7-7FAF-4E1E-AD55-13401769E5B2@me.com> References: <566457F7-7FAF-4E1E-AD55-13401769E5B2@me.com> Message-ID: On 8/28/10 6:42 AM, Guido Carballo-Guerrero wrote: > > Monte, do you have python 3.1 or 2.6.5. I had a mac as well, and when I > try to use ttk didn't work. They way I solve was to copy the ttk.py file > inside of the site-packages, which in my case is inside of: > > Library/Frameworks/Python.framewors/Versions/2.7/lib/python2.7/site-packages > > Than, what I will recommend is to install from the source, not the > installer disk image. If you install from the installer disk image, once > you try to use ttk, you will see that the Tk and Tcl connected to ttk > are version 8.4, which will not work. > > If you need details instructions on how to install from the source let > me know. > > I hope this helps. Regards! > > Guido Carballo Hello Guido, I recently (yesterday) went through and cleaned out the 'other' stuff I'd accumulated over a period of tinkering; currently I have the default Python that ships with 10.6.x, and then a 'fresh' install of MacPython 2.6.5 from python.org via the disk image file I downloaded from there. I'd debated about whether to use MacPython or Activestate Python, which sounded like it supported the newer versions of tk better, but it also sounded like in order for that to work I'd have to download and install Activestate Tcl as well... maybe that's the simplest option...? Are you saying that in order to use ttk with MacPython I need to compile python from the source code? Is there some particular reason why the folks @ python seem to resist upgrading to tkinter 8.5 & tile/ttk? I thought it had been out for *years* now (well before python 2.6, anyways)... why do I need to jump thru all these dang hoops to use what seems like it should be the current version of things? Sorry for the vent... I realize I'm very new to this and probably lack perspective and all that, but I'd really like to know. Thanks, Monte From charras at me.com Tue Aug 31 06:15:25 2010 From: charras at me.com (Guido Carballo-Guerrero) Date: Mon, 30 Aug 2010 22:15:25 -0600 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: References: Message-ID: Monte; I don't know that. Maybe somebody from here might be able to answer that, but I don't know. I'm kinda new into Tkinter as well. I have less than a year using it. What I told you was what worked for me. And yes, what worked for me was installing source, which I download from here: http://www.python.org/download/ I don't understand as well, why the Mac Os x Installer Disk Image don't come already with Tk/Tcl 8.5, specially since the Windows installer already comes with all that ready, but well. I would even suggest that Python should come with ttk. Those anybody knows what Python doesn't comes already with ttk? Why the Mac installer doesn't have Tk/Tcl as part of the installation? But anyway Monte, in the mean time, try what I suggest. For me works just fine. As I told you before, if you need detail instructions on how to install Python and ttk from source, let me know. Regards! Guido Carballo On Aug 30, 2010, at 4:00 AM, tkinter-discuss-request at python.org wrote: > Send Tkinter-discuss mailing list submissions to > tkinter-discuss at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tkinter-discuss > or, via email, send a message with subject or body 'help' to > tkinter-discuss-request at python.org > > You can reach the person managing the list at > tkinter-discuss-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tkinter-discuss digest..." > Today's Topics: > > 1. Re: python 3.1 - tkinter 8.4 - no tile? (Monte Milanuk) > > From: Monte Milanuk > Date: August 29, 2010 9:06:15 AM GMT-06:00 > To: tkinter-discuss at python.org > Subject: Re: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? > > > On 8/28/10 6:42 AM, Guido Carballo-Guerrero wrote: >> >> Monte, do you have python 3.1 or 2.6.5. I had a mac as well, and when I >> try to use ttk didn't work. They way I solve was to copy the ttk.py file >> inside of the site-packages, which in my case is inside of: >> >> Library/Frameworks/Python.framewors/Versions/2.7/lib/python2.7/site-packages >> >> Than, what I will recommend is to install from the source, not the >> installer disk image. If you install from the installer disk image, once >> you try to use ttk, you will see that the Tk and Tcl connected to ttk >> are version 8.4, which will not work. >> >> If you need details instructions on how to install from the source let >> me know. >> >> I hope this helps. Regards! >> >> Guido Carballo > > Hello Guido, > > I recently (yesterday) went through and cleaned out the 'other' stuff I'd accumulated over a period of tinkering; currently I have the default Python that ships with 10.6.x, and then a 'fresh' install of MacPython 2.6.5 from python.org via the disk image file I downloaded from there. I'd debated about whether to use MacPython or Activestate Python, which sounded like it supported the newer versions of tk better, but it also sounded like in order for that to work I'd have to download and install Activestate Tcl as well... maybe that's the simplest option...? > > Are you saying that in order to use ttk with MacPython I need to compile python from the source code? > > Is there some particular reason why the folks @ python seem to resist upgrading to tkinter 8.5 & tile/ttk? I thought it had been out for *years* now (well before python 2.6, anyways)... why do I need to jump thru all these dang hoops to use what seems like it should be the current version of things? Sorry for the vent... I realize I'm very new to this and probably lack perspective and all that, but I'd really like to know. > > Thanks, > > Monte > > > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Tue Aug 31 14:25:14 2010 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 31 Aug 2010 08:25:14 -0400 Subject: [Tkinter-discuss] python 3.1 - tkinter 8.4 - no tile? In-Reply-To: References: Message-ID: <4C7CF4AA.7000004@codebykevin.com> On 8/31/10 12:15 AM, Guido Carballo-Guerrero wrote: > > I don't understand as well, why the Mac Os x Installer Disk Image don't > come already with Tk/Tcl 8.5, specially since the Windows installer > already comes with all that ready, but well. I would even suggest that > Python should come with ttk. > > Those anybody knows what Python doesn't comes already with ttk? Why the > Mac installer doesn't have Tk/Tcl as part of the installation? ttk is standard, I believe, in 3.1, and perhaps 2.7? (Someone correct me here.) The Mac installer doesn't include Tcl/Tk because the Mac already ships Tcl/Tk, both 8.5 and 8.4 on Snow Leopard. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com