Re: Tkinter problem
Am 19.06.21 um 08:48 schrieb Jach Feng: Christian Gollwitzer 在 2021年6月19日 星期六下午1:54:46 [UTC+8] 的信中寫道: I guess you wanted to post another question? Then please open a new thread. In addition, the question is unclear, you just posted a transcript of three lines of Python. I posted to point out there is an error in Liya's script. It's not related to Colab, but it may relate to his problem. Ah! Now I get it, sorry, missed that earlier. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Am 19.06.21 um 07:16 schrieb Jach Feng: Christian Gollwitzer 在 2021年6月19日 星期六下午12:27:54 [UTC+8] 的信中寫道: Am 19.06.21 um 05:59 schrieb Jach Feng: import tkinter as Tk Tk from tkinter import * Tk tkinter Traceback (most recent call last): File "", line 1, in NameError: name 'tkinter' is not defined What's the point? That has no relation to the question. "import A as B" does not define A. That's a feature, not a bug. Christian No, it's not. It's only because this line triggers my response:-) label1 = tkinter.Label(master, text='Hello') You have posted this as an answer to Liya's question about Google Colab. What you wrote has nothing to do with it and does not help with Liya's problem. I guess you wanted to post another question? Then please open a new thread. In addition, the question is unclear, you just posted a transcript of three lines of Python. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
On 6/18/2021 2:28 AM, Liya Ann Sunny wrote: I am using Colab. How could solve this problem. import tkinter as Tk If you do this, import 'as tk'. from tkinter import * The second import overwrites the first since it imports tkinter.Tk as 'Tk'. Don't try to do both. import sys import os #create main window master = Tk() master.title("tester") master.geometry("300x100") #make a label for the window label1 = tkinter.Label(master, text='Hello') # Lay out label label1.pack() # Run forever! master.mainloop() The error shows that : in () 9 10 #create main window ---> 11 master = Tk() 12 master.title("tester") 13 master.geometry("300x100") /usr/lib/python3.7/tkinter/__init__.py in __init__(self, screenName, baseName, className, useTk, sync, use) 2021 baseName = baseName + ext 2022 interactive = 0 -> 2023 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) 2024 if useTk: 2025 self._loadtk() TclError: couldn't connect to display ":0.0" -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Am 19.06.21 um 05:59 schrieb Jach Feng: import tkinter as Tk Tk from tkinter import * Tk tkinter Traceback (most recent call last): File "", line 1, in NameError: name 'tkinter' is not defined What's the point? That has no relation to the question. "import A as B" does not define A. That's a feature, not a bug. Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Christian Gollwitzer 在 2021年6月19日 星期六下午1:54:46 [UTC+8] 的信中寫道: > Am 19.06.21 um 07:16 schrieb Jach Feng: > > Christian Gollwitzer 在 2021年6月19日 星期六下午12:27:54 [UTC+8] 的信中寫道: > >> Am 19.06.21 um 05:59 schrieb Jach Feng: > >> import tkinter as Tk > >> Tk > >>> >>> 'C:\\Users\\jfong\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\tkinter\\__init__.py'> > >>> > >> from tkinter import * > >> Tk > >>> > >> tkinter > >>> Traceback (most recent call last): > >>> File "", line 1, in > >>> NameError: name 'tkinter' is not defined > >> > >> What's the point? That has no relation to the question. > >> > >> "import A as B" does not define A. That's a feature, not a bug. > >> > >> Christian > > No, it's not. It's only because this line triggers my response:-) > >> label1 = tkinter.Label(master, text='Hello') > You have posted this as an answer to Liya's question about Google Colab. > What you wrote has nothing to do with it and does not help with Liya's > problem. > > I guess you wanted to post another question? Then please open a new > thread. In addition, the question is unclear, you just posted a > transcript of three lines of Python. > > Christian I posted to point out there is an error in Liya's script. It's not related to Colab, but it may relate to his problem. --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Christian Gollwitzer 在 2021年6月19日 星期六下午12:27:54 [UTC+8] 的信中寫道: > Am 19.06.21 um 05:59 schrieb Jach Feng: > import tkinter as Tk > Tk > > > 'C:\\Users\\jfong\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\tkinter\\__init__.py'> > > > from tkinter import * > Tk > > > tkinter > > Traceback (most recent call last): > > File "", line 1, in > > NameError: name 'tkinter' is not defined > > What's the point? That has no relation to the question. > > "import A as B" does not define A. That's a feature, not a bug. > > Christian No, it's not. It's only because this line triggers my response:-) > label1 = tkinter.Label(master, text='Hello') --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
liyaanns...@gmail.com 在 2021年6月18日 星期五下午2:28:35 [UTC+8] 的信中寫道: > I am using Colab. How could solve this problem. > import tkinter as Tk > from tkinter import * > import sys > import os > #create main window > master = Tk() > master.title("tester") > master.geometry("300x100") > > > #make a label for the window > label1 = tkinter.Label(master, text='Hello') > # Lay out label > label1.pack() > > # Run forever! > master.mainloop() > The error shows that : > in () > 9 > 10 #create main window > ---> 11 master = Tk() > 12 master.title("tester") > 13 master.geometry("300x100") > > /usr/lib/python3.7/tkinter/__init__.py in __init__(self, screenName, > baseName, className, useTk, sync, use) > 2021 baseName = baseName + ext > 2022 interactive = 0 > -> 2023 self.tk = _tkinter.create(screenName, baseName, className, > interactive, wantobjects, useTk, sync, use) > 2024 if useTk: > 2025 self._loadtk() > > TclError: couldn't connect to display ":0.0" >>> import tkinter as Tk >>> Tk >>> from tkinter import * >>> Tk >>> tkinter Traceback (most recent call last): File "", line 1, in NameError: name 'tkinter' is not defined >>> --Jach -- https://mail.python.org/mailman/listinfo/python-list
Tkinter problem
I am using Colab. How could solve this problem. import tkinter as Tk from tkinter import * import sys import os #create main window master = Tk() master.title("tester") master.geometry("300x100") #make a label for the window label1 = tkinter.Label(master, text='Hello') # Lay out label label1.pack() # Run forever! master.mainloop() The error shows that : in () 9 10 #create main window ---> 11 master = Tk() 12 master.title("tester") 13 master.geometry("300x100") /usr/lib/python3.7/tkinter/__init__.py in __init__(self, screenName, baseName, className, useTk, sync, use) 2021 baseName = baseName + ext 2022 interactive = 0 -> 2023 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) 2024 if useTk: 2025 self._loadtk() TclError: couldn't connect to display ":0.0" -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Am 18.06.21 um 08:28 schrieb Liya Ann Sunny: I am using Colab. How could solve this problem. TclError: couldn't connect to display ":0.0" You're either not running an X server, or having problems to connect to it. Are you sure that Google Colab supports X11 at all? This link doesn't seem to support that idea: https://stackoverflow.com/questions/61168210/is-there-any-way-to-use-tkinter-with-google-colaboratory Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
Às 20:35 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 4:20 AM, Terry Reedy wrote: >> On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >>> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >>> Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod >>> ^^it works if you remove the staticmethod here >> >> staticmethods are essentially useless in Python. What little was >> gained by their addition is partly offset by the introduced confusion. > def cmd(): print("Test") > > The confusion is that methods are callable, whereas 'staticmethods' are > not. I was not completely aware of this until pointed out by Peter > Otten with example > > " cmd() > > Traceback (most recent call last): > File "", line 1, in > class C: > File "", line 4, in C > cmd() > TypeError: 'staticmethod' object is not callable > > You have to go through the descriptor protocol:" > > Indeed, dir(cmd) shows that it does not have a .__call__ attribute. > >> top=tkinter.Tk() >> cb=Checkbutton(command=cmd) > >> Button commands have to be tcl functions. Tkinter wraps Python >> functions as tcl function. Static methods also wrap python functions, >> as a .__func__ attribute. So the code if one passes cmd.__func__. > > "So the code works if one passes the callable cmd.__func__." > >>> Maybe there is a bug in tkinter, that it doesn't work with static >>> methods? >> >> One could propose that tkinter test whether callables are staticmethods > > Command options, as documented, must be callables. Neither staticmethods > nor classmethods are callable. > >> and unwrap them when they are. > > I would propose instead that if possible tkinter raise TypeError when > passed a non-callable as a command. > Yes, that would be much better. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
On 1/7/2021 4:20 AM, Terry Reedy wrote: On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod ^^it works if you remove the staticmethod here staticmethods are essentially useless in Python. What little was gained by their addition is partly offset by the introduced confusion. def cmd(): print("Test") The confusion is that methods are callable, whereas 'staticmethods' are not. I was not completely aware of this until pointed out by Peter Otten with example "cmd() Traceback (most recent call last): File "", line 1, in class C: File "", line 4, in C cmd() TypeError: 'staticmethod' object is not callable You have to go through the descriptor protocol:" Indeed, dir(cmd) shows that it does not have a .__call__ attribute. top=tkinter.Tk() cb=Checkbutton(command=cmd) Button commands have to be tcl functions. Tkinter wraps Python functions as tcl function. Static methods also wrap python functions, as a .__func__ attribute. So the code if one passes cmd.__func__. "So the code works if one passes the callable cmd.__func__." Maybe there is a bug in tkinter, that it doesn't work with static methods? One could propose that tkinter test whether callables are staticmethods Command options, as documented, must be callables. Neither staticmethods nor classmethods are callable. and unwrap them when they are. I would propose instead that if possible tkinter raise TypeError when passed a non-callable as a command. Classmethods also do not work as is. By experiment, the following works. cb=Checkbutton(command=lambda: C.cmd.__func__(C)) But if the class were nested, it would be more complicated. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
Às 07:29 de 07/01/21, Paulo da Silva escreveu: > Hi! > > Does anybody know why cmd method isn't called when I change the button > state (clicking on it) in this example? > I know that this seems a weird class use. But why doesn't it work? > Thanks. > > class C: > from tkinter import Checkbutton > import tkinter > > @staticmethod > def cmd(): > print("Test") > > top=tkinter.Tk() > cb=Checkbutton(command=cmd) > cb.pack() > > @staticmethod > def loop(): > C.top.mainloop() > > c=C() > c.loop() > After some experiments I found two solutions: 1) class C: @staticmethod def cmd(): print("Test") class C: #@DuplicatedSignature from tkinter import Checkbutton import tkinter top=tkinter.Tk() cb=Checkbutton(command=C.cmd) cb.pack() @staticmethod def loop(): C.top.mainloop() c=C() c.loop() 2) class C: from tkinter import Checkbutton import tkinter @staticmethod def cmd(): print("Test") top=tkinter.Tk() cb=Checkbutton(command=lambda : C.cmd()) cb.pack() @staticmethod def loop(): C.top.mainloop() c=C() c.loop() This one as a sequence of the answer of Terry - thanks. BTW, does anyone know I can I get the arguments eventually passed by the Checkbutton event, or any other widget callback (*pargs, **kargs) using this "solution"? -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
Às 16:02 de 07/01/21, Peter Otten escreveu: > On 07/01/2021 08:42, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> ... > > I recommend that the OP use a more conventional stye and do the setup > outside the class or, better, in an instance of the class. > There are lots of possible more conventional ways, of course. My purpose was only to understand what was wrong. Thanks anyway. -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
Às 09:20 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> >>> Does anybody know why cmd method isn't called when I change the button >>> state (clicking on it) in this example? >>> I know that this seems a weird class use. But why doesn't it work? >>> Thanks. >>> >>> class C: >>> from tkinter import Checkbutton >>> import tkinter >>> >>> @staticmethod >> ^^it works if you remove the staticmethod here > > staticmethods are essentially useless in Python. What little was gained > by their addition is partly offset by the introduced confusion. It depends on what the classes are being used for. Sometimes I just want to use them as static wrappers. Of course I could use them in the conventional way for this purpose, but it's not so clean :-) ... > > Classmethods also do not work as is. By experiment, the following works. > cb=Checkbutton(command=lambda: C.cmd.__func__(C)) Why not just cb=Checkbutton(command=lambda : C.cmd()) ? Also works. BTW, just for curiosity, and for my personal learning ... What does "__func__" does? Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
Às 07:42 de 07/01/21, Christian Gollwitzer escreveu: > Am 07.01.21 um 08:29 schrieb Paulo da Silva: > >> Does anybody know why cmd method isn't called when I change the button >> state (clicking on it) in this example? >> I know that this seems a weird class use. But why doesn't it work? >> Thanks. >> >> class C: >> from tkinter import Checkbutton >> import tkinter >> >> @staticmethod > ^^it works if you remove the staticmethod here Yes, that's the coventional way. Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
On 07/01/2021 08:42, Christian Gollwitzer wrote: Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod ^^it works if you remove the staticmethod here def cmd(): print("Test") Maybe there is a bug in tkinter, that it doesn't work with static methods? It has nothing to do with tkinter, a staticmethod object cannot be called directly: >>> class C: @staticmethod def cmd(): print("Hello") cmd() Traceback (most recent call last): File "", line 1, in class C: File "", line 4, in C cmd() TypeError: 'staticmethod' object is not callable You have to go through the descriptor protocol: >>> class C: @staticmethod def cmd(): print("Hello") >>> C.cmd() Hello I recommend that the OP use a more conventional stye and do the setup outside the class or, better, in an instance of the class. -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod ^^it works if you remove the staticmethod here staticmethods are essentially useless in Python. What little was gained by their addition is partly offset by the introduced confusion. I am not sure is removing @staticmethod would have been sufficient in 2.x. def cmd(): print("Test") top=tkinter.Tk() cb=Checkbutton(command=cmd) cb.pack() Button commands have to be tcl functions. Tkinter wraps Python functions as tcl function. Static methods also wrap python functions, as a .__func__ attribute. So the code if one passes cmd.__func__. Maybe there is a bug in tkinter, that it doesn't work with static methods? One could propose that tkinter test whether callables are staticmethods and unwrap them when they are. Classmethods also do not work as is. By experiment, the following works. cb=Checkbutton(command=lambda: C.cmd.__func__(C)) But if the class were nested, it would be more complicated. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Class and tkinter problem
Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod ^^it works if you remove the staticmethod here def cmd(): print("Test") Maybe there is a bug in tkinter, that it doesn't work with static methods? Christian -- https://mail.python.org/mailman/listinfo/python-list
Class and tkinter problem
Hi! Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod def cmd(): print("Test") top=tkinter.Tk() cb=Checkbutton(command=cmd) cb.pack() @staticmethod def loop(): C.top.mainloop() c=C() c.loop() -- https://mail.python.org/mailman/listinfo/python-list
Re: Ask for help about a tkinter problem
> On 2017-08-21 01:28, jf...@ms4.hinet.net wrote: >> Peter Otten at 2017/8/20 UTC+8 PM 5:52:24 wrote: > [snip] > >>> That is just a peculiarity of TCL; a "-" is added to the option by the >>> Python wrapper before passing it along >> >> This extra "-" confuses people when showing up in the Traceback info. >> Can't figure out why the author want to do this. >> > To clarify what Peter said, tkinter is a GUI library written in the Tcl > programming language. The Tcl GUI framework is tk, not tkinter. > The 'tkinter' module in Python's standard library is just a wrapper > around that library. tkinter abbreviates tk interface. In particular, it adds a Python class-based interface to tcl and tk functions and structures. > The "-" is added because the Tcl language requires it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Ask for help about a tkinter problem
On 2017-08-21 01:28, jf...@ms4.hinet.net wrote: Peter Otten at 2017/8/20 UTC+8 PM 5:52:24 wrote: [snip] That is just a peculiarity of TCL; a "-" is added to the option by the Python wrapper before passing it along This extra "-" confuses people when showing up in the Traceback info. Can't figure out why the author want to do this. To clarify what Peter said, tkinter is a GUI library written in the Tcl programming language. The 'tkinter' module in Python's standard library is just a wrapper around that library. The Perl and Ruby programming languages also have wrappers. The "-" is added because the Tcl language requires it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Ask for help about a tkinter problem
Peter Otten at 2017/8/20 UTC+8 PM 5:52:24 wrote: > jf...@ms4.hinet.net wrote: > > > I am running a tkinter tutor downloaded from web, > > https://github.com/daleathan/widget-tour-py3. there are two files > > involved: > > > > > > #file button.py > > > > from tkinter import * > > from tkinter.ttk import * > > import infrastructure > > ... > > class ButtonsDemoWindow( infrastructure.DemoWindow ): > > ... > > def __init__( self ): > > ... > > ... > > for c in ('Peach Puff', 'Light Blue', 'Sea Green', 'Yellow' ): > > b = Button(self.frame, text=c) > > b['command'] = infrastructure.callit( self.callback, c ) > > b.pack( side=TOP, expand=YES, pady=2 ) > > > > def callback(self, color): > > self.frame['background']=color > > > > def runDemo(): > > ButtonsDemoWindow() > > > > -- > > #file infrastructure.py > > ... > > class DemoWindow( Toplevel ): > > ... > > ... > > class callit: > > def __init__(self, function, *args ): > > self.f = function > > self.args = args > > > > def __call__(self, *ignored): > > self.f( *self.args) > > > > > > I run it under the DOS box: > > > > D:\Works\Python\widget-tour-py3-master>python > > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 > > 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or > > "license" for more information. > > >>> import button > > >>> button.runDemo() > > > > after the window shows up, I pressed one of the buttons and get the error > > below: > > > Exception in Tkinter callback > > Traceback (most recent call last): > > File "C:\Python34\lib\tkinter\__init__.py", line 1538, in __call__ > > return self.func(*args) > > File "D:\Works\Python\widget-tour-py3-master\infrastructure.py", line > > 216, in __call__ > > self.f( *self.args) > > File "D:\Works\Python\widget-tour-py3-master\button.py", line 39, in > > callback > > self.frame['background']=color > > File "C:\Python34\lib\tkinter\__init__.py", line 1331, in __setitem__ > > self.configure({key: value}) > > File "C:\Python34\lib\tkinter\__init__.py", line 1324, in configure > > return self._configure('configure', cnf, kw) > > File "C:\Python34\lib\tkinter\__init__.py", line 1315, in _configure > > self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) > > _tkinter.TclError: unknown option "-background" > > > > > > When I looked into the file tkinter\__init__.py, I found there is codes > > which add conditionally a '-' onto the original cnf argument: > > That is just a peculiarity of TCL; a "-" is added to the option by the > Python wrapper before passing it along > > > 1305 def _configure(self, cmd, cnf, kw): > > 1306 """Internal function.""" > > ... > > ... > > 1313 if isinstance(cnf, str): > > 1314 return self._getconfigure1(_flatten((self._w, cmd, > > '-'+cnf))) > > > > Is it the reason this exception raised? Why is that? > > I can confirm the problem. It looks like the bug was introduced when the > example was converted from stock tkinter to the new ttk widget set. > > While > > frame["background"] = color > > works when frame is a tkinter.Frame widget the newer tkinter.ttk.Frame > widget uses "styles" to configure its appearance. > > I have not used that new feature, but with the help of > > http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-style-layer.html > > and some trial and error I modified the example to use a style: > > $ diff -u button.py button_fixed.py > --- button.py 2017-08-20 11:44:33.841839812 +0200 > +++ button_fixed.py 2017-08-20 11:44:04.032426163 +0200 > @@ -25,7 +25,9 @@ > > infrastructure.DemoWindow.__init__(self, intro, 'button.py' ) > > -self.frame=Frame(self) > +self.style = Style(self) > +self.frame=Frame(self, style="foo.TFrame") > + > self.frame.pack(expand=YES, fill=BOTH ) > for c in ('Peach Puff', 'Light Blue', >'Sea Green', 'Yellow' ): > @@ -36,7 +38,7 @@ > > > def callback(self, color): > -self.frame['background']=color > +self.style.configure("foo.TFrame", background=color) > > > def runDemo(): > $ > > However, I'm not sure if this is the canonical way to write it... Thank you for your answer. I try not to use the ttk by comment the line "from tkinter.ttk import *", and also try your "Style" modification codes, both work:-) > That is just a peculiarity of TCL; a "-" is added to the option by the > Python wrapper before passing it along This extra "-" confuses people when showing up in the Traceback info. Can't figure out why the author want to do this. --Jach -- https://mail.python.org/mailman/listinfo/python-list
Re: Ask for help about a tkinter problem
jf...@ms4.hinet.net wrote: > I am running a tkinter tutor downloaded from web, > https://github.com/daleathan/widget-tour-py3. there are two files > involved: > > > #file button.py > > from tkinter import * > from tkinter.ttk import * > import infrastructure > ... > class ButtonsDemoWindow( infrastructure.DemoWindow ): > ... > def __init__( self ): > ... > ... > for c in ('Peach Puff', 'Light Blue', 'Sea Green', 'Yellow' ): > b = Button(self.frame, text=c) > b['command'] = infrastructure.callit( self.callback, c ) > b.pack( side=TOP, expand=YES, pady=2 ) > > def callback(self, color): > self.frame['background']=color > > def runDemo(): > ButtonsDemoWindow() > > -- > #file infrastructure.py > ... > class DemoWindow( Toplevel ): > ... > ... > class callit: > def __init__(self, function, *args ): > self.f = function > self.args = args > > def __call__(self, *ignored): > self.f( *self.args) > > > I run it under the DOS box: > > D:\Works\Python\widget-tour-py3-master>python > Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 > 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or > "license" for more information. > >>> import button > >>> button.runDemo() > > after the window shows up, I pressed one of the buttons and get the error > below: > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python34\lib\tkinter\__init__.py", line 1538, in __call__ > return self.func(*args) > File "D:\Works\Python\widget-tour-py3-master\infrastructure.py", line > 216, in __call__ > self.f( *self.args) > File "D:\Works\Python\widget-tour-py3-master\button.py", line 39, in > callback > self.frame['background']=color > File "C:\Python34\lib\tkinter\__init__.py", line 1331, in __setitem__ > self.configure({key: value}) > File "C:\Python34\lib\tkinter\__init__.py", line 1324, in configure > return self._configure('configure', cnf, kw) > File "C:\Python34\lib\tkinter\__init__.py", line 1315, in _configure > self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) > _tkinter.TclError: unknown option "-background" > > > When I looked into the file tkinter\__init__.py, I found there is codes > which add conditionally a '-' onto the original cnf argument: That is just a peculiarity of TCL; a "-" is added to the option by the Python wrapper before passing it along > 1305 def _configure(self, cmd, cnf, kw): > 1306 """Internal function.""" > ... > ... > 1313 if isinstance(cnf, str): > 1314 return self._getconfigure1(_flatten((self._w, cmd, > '-'+cnf))) > > Is it the reason this exception raised? Why is that? I can confirm the problem. It looks like the bug was introduced when the example was converted from stock tkinter to the new ttk widget set. While frame["background"] = color works when frame is a tkinter.Frame widget the newer tkinter.ttk.Frame widget uses "styles" to configure its appearance. I have not used that new feature, but with the help of http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-style-layer.html and some trial and error I modified the example to use a style: $ diff -u button.py button_fixed.py --- button.py 2017-08-20 11:44:33.841839812 +0200 +++ button_fixed.py 2017-08-20 11:44:04.032426163 +0200 @@ -25,7 +25,9 @@ infrastructure.DemoWindow.__init__(self, intro, 'button.py' ) -self.frame=Frame(self) +self.style = Style(self) +self.frame=Frame(self, style="foo.TFrame") + self.frame.pack(expand=YES, fill=BOTH ) for c in ('Peach Puff', 'Light Blue', 'Sea Green', 'Yellow' ): @@ -36,7 +38,7 @@ def callback(self, color): -self.frame['background']=color +self.style.configure("foo.TFrame", background=color) def runDemo(): $ However, I'm not sure if this is the canonical way to write it... -- https://mail.python.org/mailman/listinfo/python-list
Ask for help about a tkinter problem
I am running a tkinter tutor downloaded from web, https://github.com/daleathan/widget-tour-py3. there are two files involved: #file button.py from tkinter import * from tkinter.ttk import * import infrastructure ... class ButtonsDemoWindow( infrastructure.DemoWindow ): ... def __init__( self ): ... ... for c in ('Peach Puff', 'Light Blue', 'Sea Green', 'Yellow' ): b = Button(self.frame, text=c) b['command'] = infrastructure.callit( self.callback, c ) b.pack( side=TOP, expand=YES, pady=2 ) def callback(self, color): self.frame['background']=color def runDemo(): ButtonsDemoWindow() -- #file infrastructure.py ... class DemoWindow( Toplevel ): ... ... class callit: def __init__(self, function, *args ): self.f = function self.args = args def __call__(self, *ignored): self.f( *self.args) I run it under the DOS box: D:\Works\Python\widget-tour-py3-master>python Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import button >>> button.runDemo() after the window shows up, I pressed one of the buttons and get the error below: >>> Exception in Tkinter callback Traceback (most recent call last): File "C:\Python34\lib\tkinter\__init__.py", line 1538, in __call__ return self.func(*args) File "D:\Works\Python\widget-tour-py3-master\infrastructure.py", line 216, in __call__ self.f( *self.args) File "D:\Works\Python\widget-tour-py3-master\button.py", line 39, in callback self.frame['background']=color File "C:\Python34\lib\tkinter\__init__.py", line 1331, in __setitem__ self.configure({key: value}) File "C:\Python34\lib\tkinter\__init__.py", line 1324, in configure return self._configure('configure', cnf, kw) File "C:\Python34\lib\tkinter\__init__.py", line 1315, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: unknown option "-background" When I looked into the file tkinter\__init__.py, I found there is codes which add conditionally a '-' onto the original cnf argument: 1305 def _configure(self, cmd, cnf, kw): 1306 """Internal function.""" ... ... 1313 if isinstance(cnf, str): 1314 return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf))) Is it the reason this exception raised? Why is that? Best Regards, Jach Fong -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
gemjack...@gmail.com wrote: >This fixed my problem with thkinter. sudo cp ~/.Xauthority ~root/ Which means that you were creating a GUI window with Python as root, which is to be avoided if you can. If you can't avoid it and you're running it with sudo in a bash console, rather than a root console, then I'd suggest adding the line... XAUTHORITY=$HOME/.Xauthority ...to the root's .bashrc which avoids putting a specific user's xauthority file in the root directory. -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
On Sunday, 29 December 2013 20:20:00 UTC, Michael Matveev wrote: > Hi, > I use live Debian on VM and trying to compile this code. > > > import Tkinter > > root = Tkinter.Tk() > > root.title("Fenster 1") > root.geometry("100x100") > > root.mainloop() > > > The shell gives out that kind of message: > > File "test.py", line 5, in > root = Tkinter.Tk() > File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__ > self.tk = _tkinter.create(screenName, baseName, className, interactive, > wantobjects, useTk, sync, use) > _tkinter.TclError: couldn't connect to display ":0" > > > > thanks for helping out. > > greets. > Mike This fixed my problem with thkinter. sudo cp ~/.Xauthority ~root/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
On Sun, Dec 29, 2013 at 10:29 PM, Steven D'Aprano wrote: > On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote: > > > On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano > > wrote: > >> So you need to X-forward from the remote machine to the machine you are > >> physically on, or perhaps it's the other way (X is really weird). I > >> have no idea how to do that, but would love to know. > > > > With SSH, that's usually just "ssh -X target", and it'll mostly work. > > Holy cow, it works! Slwly, but works. > I usually use "ssh -Y". The -Y argument toggles trusted forwarding. From the ssh man-page: -Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls. I've found -Y is a bit faster than -X in my experience (I've never really had many problems with X-forwarding on LANs in my experience -- even with OpenGL windows) -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
On Mon, Dec 30, 2013 at 2:29 PM, Steven D'Aprano wrote: > On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote: > >> On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano >> wrote: >>> So you need to X-forward from the remote machine to the machine you are >>> physically on, or perhaps it's the other way (X is really weird). I >>> have no idea how to do that, but would love to know. >> >> With SSH, that's usually just "ssh -X target", and it'll mostly work. > > Holy cow, it works! Slwly, but works. > > > steve@runes:~$ ssh -X ando.pearwood.info > st...@ando.pearwood.info's password: > Last login: Mon Dec 30 10:10:13 2013 from orac > [steve@ando ~]$ python2.7 test.py > [steve@ando ~]$ On a LAN, it's not even slow! I've actually run VLC through ssh -X and watched a DVD that was in a different computer's drive. That was fun. You can even get a Windows X server and run Linux GUI programs on a Windows client. *Very* useful if you're working with both types of computer. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote: > On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano > wrote: >> So you need to X-forward from the remote machine to the machine you are >> physically on, or perhaps it's the other way (X is really weird). I >> have no idea how to do that, but would love to know. > > With SSH, that's usually just "ssh -X target", and it'll mostly work. Holy cow, it works! Slwly, but works. steve@runes:~$ ssh -X ando.pearwood.info st...@ando.pearwood.info's password: Last login: Mon Dec 30 10:10:13 2013 from orac [steve@ando ~]$ python2.7 test.py [steve@ando ~]$ -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano wrote: > So you need to X-forward from the remote machine to the machine you are > physically on, or perhaps it's the other way (X is really weird). I have no > idea how to do that, but would love to know. With SSH, that's usually just "ssh -X target", and it'll mostly work. But there are potential issues with .Xauthority, which is why the sudo example fails. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
Michael Matveev wrote: > Hi, > I use live Debian on VM and trying to compile this code. > > > import Tkinter > > root = Tkinter.Tk() > > root.title("Fenster 1") > root.geometry("100x100") > > root.mainloop() > > > The shell gives out that kind of message: > > File "test.py", line 5, in > root = Tkinter.Tk() > File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__ > self.tk = _tkinter.create(screenName, baseName, className, interactive, > wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to > display ":0" Are you using ssh to connect to the system? If I create a file and run it directly from the machine I am physically sitting at, it works fine and the window is displayed as expected: [steve@ando ~]$ cat test.py import Tkinter root = Tkinter.Tk() root.title("Fenster 1") root.geometry("100x100") root.mainloop() [steve@ando ~]$ python2.7 test.py [steve@ando ~]$ But if I ssh to the machine, I get an error (although a different error from you): steve@orac:~$ ssh ando steve@ando's password: Last login: Thu Dec 12 19:27:04 2013 from 203.7.155.68 [steve@ando ~]$ python2.7 test.py Traceback (most recent call last): File "test.py", line 2, in root = Tkinter.Tk() File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 1685, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable If I set the $DISPLAY environment variable, it works for me: [steve@ando ~]$ export DISPLAY=":0" [steve@ando ~]$ python2.7 test.py [steve@ando ~]$ logout Connection to ando closed. But ando is the machine I am physically seated at, so it's not surprising that I can see the window on the X display. If I go the other way, and try to run the code on orac (the remote machine), I get the same error as you: steve@orac:~$ export DISPLAY=":0" steve@orac:~$ python2.6 test.py No protocol specified Traceback (most recent call last): File "test.py", line 2, in root = Tkinter.Tk() 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) _tkinter.TclError: couldn't connect to display ":0" So you need to X-forward from the remote machine to the machine you are physically on, or perhaps it's the other way (X is really weird). I have no idea how to do that, but would love to know. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem: TclError> couldn't connect to display ":0
On Mon, Dec 30, 2013 at 7:20 AM, Michael Matveev wrote: > The shell gives out that kind of message: > > File "test.py", line 5, in > root = Tkinter.Tk() > File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__ > self.tk = _tkinter.create(screenName, baseName, className, interactive, > wantobjects, useTk, sync, use) > _tkinter.TclError: couldn't connect to display ":0" Worked for me on an installed Debian, inside Xfce with xfce4-terminal. 1) What version of Python are you running? 2) Are you running inside some kind of graphical environment? 3) Do you have any sort of permissions/environment change happening? I get an error like that if I try "sudo python" without any sort of guard. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Tkinter problem: TclError> couldn't connect to display ":0
Hi, I use live Debian on VM and trying to compile this code. import Tkinter root = Tkinter.Tk() root.title("Fenster 1") root.geometry("100x100") root.mainloop() The shell gives out that kind of message: File "test.py", line 5, in root = Tkinter.Tk() File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to display ":0" thanks for helping out. greets. Mike -- https://mail.python.org/mailman/listinfo/python-list
tkinter problem with treeview
Hi all, I have written some helper functions for the tkinter.ttk.treeview widget (using python3, version 3.2). This functions dont work as i expect: #! /usr/bin/env pyhon3 # -*- encoding: utf-8 -*- from tkinter import * from tkinter.ttk import * # now tkinter widgets get replaced by # tkinter.ttk widgets from tkinter.font import Font def makeTreeview(root, fields, scrollbars=True, show='tree headings', packOptions={'side': RIGHT, 'expand': YES, 'fill': BOTH, 'padx': 2, 'pady': 2}, **extras): """ root: the containing frame fields: [('name', {options})] field[0] is the tree label scrollbars: True: use scrollbars, False: dont use scrollbars show: 'tree' or 'headings' or 'tree headings' """ # define Treeview # fiels[0] belongs to the tree label # fields[1:] belongs to the data values # t is a tuple ('name', {options}) widget=Treeview(root, columns=[t[0] for t in fields[1:]], show=show) # define scrollbars is necessary if scrollbars: ybar=Scrollbar(root) ybar.config(command=widget.yview) ybar.pack(side=RIGHT, expand=YES, fill=Y) # pack ybar first xbar=Scrollbar(root,orient='horizontal') xbar.config(command=widget.xview) xbar.pack(side=BOTTOM, expand=YES, fill=X) # then xbar widget.config(yscrollcommand=ybar.set, xscrollcommand=xbar.set) widget.pack(packOptions) # pack widget last # process the header and the options # of the data values # (n,o) is a tuple consisting of a name and an option i=0 for (n,o) in fields: widget.heading('#%s' % i, text=n) if o: widget.column('#%s' % i, **o) i += 1 if extras: widget.config(**extras) return widget def insert_node_to_treeview(tv, parent, subtree, resize=True, **extras): ''' tv: the treeview to insert the new values parent: the parent node subtree: a tuple (row, children) with row: list of values to insert into this node row[0] belongs to the tree label row[1:] belongs to the data values children: list of children to insert each child is a valid subtree ''' (row, children) = subtree nd=tv.insert(parent, 'end', text=row[0], values=row[1:], **extras) # resize fields if necessary rowsize=[Font().measure(f) for f in row] i=0 for s in rowsize: if tv.column('#%s' %i, option='width') < s: tv.column('#%s' %i, width=rowsize[i]) i += 1 # insert children recursivly if children: for t in children: insert_node_to_treeview(tv, nd, t, resize, **extras) if __name__ == '__main__': class TestMixin(GuiMixin, Frame): def __init__(self, parent=None): Frame.__init__(self, parent) self.pack(expand=YES, fill=BOTH) longline=\ 'This is a longer line that needs a little more space' MyTree=[(['1', 'Line 1'], [(['1.1', 'Line 1.1'],[]), (['1.2', 'Linee 1.2'], [(['1.2.1', 'Linee 1.2.1'],[]), (['1.2.2', 'Line 1.2.2'],[])])]), (['2', 'Line 2'], [(['2.1', longline], [(['2.1.1', 'This is line 2.1.1'],[])])])] self.tv=makeTreeview(self, fields=[('head', {}), ('zeile 1',{})], scrollbars=True) for t in MyTree: insert_node_to_treeview(self.tv, '', t, open=True) top = self.tv.get_children()[0] self.tv.focus_set() self.tv.focus(top) self.tv.selection_set(top) TestMixin().mainloop() There are some things i dont understand: 1) resizing of the field widths does work in principle, but the resulting field is exactly one charakter to small. 2) I think, resizing should be clearer, but i have no idea, how. 3) The horizontal scrollbar does not work as expected. It does not react on resizing the application window but only on resizing the headers of the fields. Maybe someone can give me some hints. Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.7, tkinter problem on OSX
On Jun 25, 1:54 am, Julien Pauty wrote: > Last version of my software relies on ttk. Under windows and linux > this is fine. But, OSX users are facing problems (I don't have access > to a Mac myself for testing...). Those with OSX 10.6 can run the > program. It seems that OSX 8.6 ships with Tk8.5. > > People with OSX 8.5 cannot run the app. I told them to install python > 2.7 which seems to be the first version on OSX to ship with Tk8.5. > However, the program still does not run. I asked a person to launch a > python 2.7 interpreter and try to import tkinter. This is an excerpt > of the output: > > from Tkinter import * > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", > line 39, in > import _tkinter # If this fails your Python may not be configured for Tk > ImportError: > dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so, > 2): no suitable image found. Did find: > > /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so: > no matching architecture in universal wrapper > > Full log is there:http://pastebin.com/vky8FbrP > > I asked a person to simply open a python2.7 shell and import Tkinter. > He got the same error. > > All of this is executed with Python 2.7rc1. Archives that are on the > ftp of python.org. > > I have seen this bughttp://bugs.python.org/issue9045, which is > related, but deals with the specificities if OSX 64bit. > > Can this problem be solved by installing Active TK 8.5 for OSX ? > > Anybody knows what is the good combination of installer / libraries to > install to run a ttk application on OSX 8.5 ? Ideally, I would like to > document the setup procedure for 8.5 users. The OS X equation is confuzzulating due to version and API changes in Mac OS X. Let's review ... OS X 10.5 ships Tcl/Tk 8.4 built 32-bit only i386+ppc using Carbon. OS X 10.6 ships Tcl/Tk 8.5 built 32/64 i386+x86_64 using Cocoa. The Cocoa port of Tk was necessary for 64-bit support, as Apple never did supply the promised 64-bit Carbon. Tk 8.5 has Cocoa as an option, and it is default in Tk 8.6. ActiveTcl 8.5 still ships as 32-bit i386+ppc Carbon because going to Cocoa also means you have to drop OS X 10.4 support (out of curiousity - does anyone care about OS X 10.4 anymore that isn't stuck on what's already installed?). 8.5 plans to do so later this year (leaving behind our OS X 10.4 brethren to older versions). ActiveTcl 8.6 (Tcl/ Tk 8.6 is in beta) already ships i386+x86_64 Cocoa. Now there is the issue that Tkinter links to a specific version of Tcl/ Tk. I am currently working on a patch that will remove this limitation (making the binary Tk version independent). So what do you do? Well, it depends on what mix you are trying to make. The easiest is to just run arch -i386 python2.7 and then it will find the compatible i386 Tk. The next release of ActivePython 2.7 (which is building i386+x86_64) will have the Tk version independence, so it could work with core Tk or AT 8.6, or 8.5 in 32-bit mode. Less confuzzulated? Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.7, tkinter problem on OSX
There has been a lot of traffic on the MacPython list about this--see the list archives. -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
Python 2.7, tkinter problem on OSX
Dear list, Last version of my software relies on ttk. Under windows and linux this is fine. But, OSX users are facing problems (I don't have access to a Mac myself for testing...). Those with OSX 10.6 can run the program. It seems that OSX 8.6 ships with Tk8.5. People with OSX 8.5 cannot run the app. I told them to install python 2.7 which seems to be the first version on OSX to ship with Tk8.5. However, the program still does not run. I asked a person to launch a python 2.7 interpreter and try to import tkinter. This is an excerpt of the output: from Tkinter import * File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 39, in import _tkinter # If this fails your Python may not be configured for Tk ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so, 2): no suitable image found. Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_tkinter.so: no matching architecture in universal wrapper Full log is there: http://pastebin.com/vky8FbrP I asked a person to simply open a python2.7 shell and import Tkinter. He got the same error. All of this is executed with Python 2.7rc1. Archives that are on the ftp of python.org. I have seen this bug http://bugs.python.org/issue9045, which is related, but deals with the specificities if OSX 64bit. Can this problem be solved by installing Active TK 8.5 for OSX ? Anybody knows what is the good combination of installer / libraries to install to run a ttk application on OSX 8.5 ? Ideally, I would like to document the setup procedure for 8.5 users. Cheers, Julien -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
"David Smith" wrote in message news:h35f78$pt...@ruby.cit.cornell.edu... > Paul Simon wrote: >> "Peter Otten" <__pete...@web.de> wrote in message >> news:h3481q$d95$0...@news.t-online.com... >>> Paul Simon wrote: >>> >>>> "Chris Rebert" wrote in message >>>> news:mailman.2863.1247095339.8015.python-l...@python.org... >>>> On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: >>>>> I have the "tkinter" problem and need some assistance to straighten it >>>>> out. >>>>> >From the web page "http://wiki.python.org/moin/TkInter"; I tested as >>>>> >in >>>>>> "step >>>>> 1" and cannot import "_tkinter." I do not have that file on my >>>>> computer, >>>>> but >>>>> do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the >>>>> directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. >>>>> This python stuff is great, but the documentation frequently >>>>> feels like it is just a bit out of my grasp. I realize that all of >>>>> this >>>>> is free but I understand the instructions on the web page to repair >>>>> only >>>>> to the >>>>> point of confusion. I'm not an expert. How do I modify my python >>>>> configuration? Is there a file that needs to be edited? Which setup.py >>>>> file >>>>> do I use? Make? or python setup.py build and python setup.py install? >>>>> Thanks. I appreciate your help. >>>> - How did you install Python? >>>> - What Linux distro are you using? >>>> >>>> Cheers, >>>> Chris >>>> http://blog.rebertia.com >>>> I"m using Mandriva 2008.1. I have to tell you honestly that I'm not >>>> sure >>>> exactly how I installed Python. Originally I had installed 2.5 from >>>> RPM >>>> but 2.6 was not available for my distro (2008.1) in RPM. I downloaded >>>> something from python.org and installed. Not sure if it was tarball or >>>> zip file. >>> Zip or tar doesn't matter, you are installing "from source". >>> >>> Python has to find the necessary include files for tcl/tk. These are in >>> separate packages that you have to install before you invoke Python's >>> configure script. >>> >>> I don't know what they are called on your system -- look for tk-dev.rpm, >>> tcl-dev.rpm or similar. >>> >>> You may run into the same problem with other modules like readline. >>> >>> Peter >>> >> >> Thank you Peter. I understand what you are saying but don't know how to >> do >> it. Although I installed from source, I followed a "cookbook" recipe. >> Could you tell me what files to execute, where they might be, and file >> arguments? I'm just ignorant, not stupid. ;-). >> >> Paul >> >> > > Just install the tkinter package from the Mandriva Linux Control > Center's Software Management system. I just did it, doing a search for > tkinter brought it right up. All done. > > --David Thanks to all for your patient help. I have made some progress, but still no success. I installed Active Tcl-8.5.7 and corrected the PATH accordingly. However I still get a "missing" message on building Python. "Failed to find the necessary bits (!) to build these modules: _tkinter (among others) To find the necessary bits, look in setup.py in detect_modules() for teh module's name." Not sure what bits are, euphemism? but am about to wipe the disk and reinstall linux, etc. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
Paul Simon wrote: > "Peter Otten" <__pete...@web.de> wrote in message > news:h3481q$d95$0...@news.t-online.com... >> Paul Simon wrote: >> >>> "Chris Rebert" wrote in message >>> news:mailman.2863.1247095339.8015.python-l...@python.org... >>> On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: >>>> I have the "tkinter" problem and need some assistance to straighten it >>>> out. >>>> >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in >>>>> "step >>>> 1" and cannot import "_tkinter." I do not have that file on my computer, >>>> but >>>> do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the >>>> directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. >>>> This python stuff is great, but the documentation frequently >>>> feels like it is just a bit out of my grasp. I realize that all of this >>>> is free but I understand the instructions on the web page to repair only >>>> to the >>>> point of confusion. I'm not an expert. How do I modify my python >>>> configuration? Is there a file that needs to be edited? Which setup.py >>>> file >>>> do I use? Make? or python setup.py build and python setup.py install? >>>> Thanks. I appreciate your help. >>> - How did you install Python? >>> - What Linux distro are you using? >>> >>> Cheers, >>> Chris >>> http://blog.rebertia.com >>> I"m using Mandriva 2008.1. I have to tell you honestly that I'm not sure >>> exactly how I installed Python. Originally I had installed 2.5 from RPM >>> but 2.6 was not available for my distro (2008.1) in RPM. I downloaded >>> something from python.org and installed. Not sure if it was tarball or >>> zip file. >> Zip or tar doesn't matter, you are installing "from source". >> >> Python has to find the necessary include files for tcl/tk. These are in >> separate packages that you have to install before you invoke Python's >> configure script. >> >> I don't know what they are called on your system -- look for tk-dev.rpm, >> tcl-dev.rpm or similar. >> >> You may run into the same problem with other modules like readline. >> >> Peter >> > > Thank you Peter. I understand what you are saying but don't know how to do > it. Although I installed from source, I followed a "cookbook" recipe. > Could you tell me what files to execute, where they might be, and file > arguments? I'm just ignorant, not stupid. ;-). > > Paul > > Just install the tkinter package from the Mandriva Linux Control Center's Software Management system. I just did it, doing a search for tkinter brought it right up. All done. --David -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
Paul Simon wrote: "Peter Otten" <__pete...@web.de> wrote in message news:h3481q$d95$0...@news.t-online.com... Paul Simon wrote: I"m using Mandriva 2008.1. I have to tell you honestly that I'm not sure exactly how I installed Python. Originally I had installed 2.5 from RPM but 2.6 was not available for my distro (2008.1) in RPM. I downloaded something from python.org and installed. Not sure if it was tarball or zip file. Zip or tar doesn't matter, you are installing "from source". Python has to find the necessary include files for tcl/tk. These are in separate packages that you have to install before you invoke Python's configure script. I don't know what they are called on your system -- look for tk-dev.rpm, tcl-dev.rpm or similar. You may run into the same problem with other modules like readline. Peter Thank you Peter. I understand what you are saying but don't know how to do it. Although I installed from source, I followed a "cookbook" recipe. Could you tell me what files to execute, where they might be, and file arguments? I'm just ignorant, not stupid. ;-). Is there a Mandriva list where you can ask such distribution-specific questions? -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
Paul Simon wrote: > > "Peter Otten" <__pete...@web.de> wrote in message > news:h3481q$d95$0...@news.t-online.com... >> Paul Simon wrote: >> >>> "Chris Rebert" wrote in message >>> news:mailman.2863.1247095339.8015.python-l...@python.org... >>> On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: >>>> I have the "tkinter" problem and need some assistance to straighten it >>>> out. >>>> >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in >>>> >"step >>>> 1" and cannot import "_tkinter." I do not have that file on my >>>> computer, but >>>> do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the >>>> directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. >>>> This python stuff is great, but the documentation frequently >>>> feels like it is just a bit out of my grasp. I realize that all of this >>>> is free but I understand the instructions on the web page to repair >>>> only to the >>>> point of confusion. I'm not an expert. How do I modify my python >>>> configuration? Is there a file that needs to be edited? Which setup.py >>>> file >>>> do I use? Make? or python setup.py build and python setup.py install? >>>> Thanks. I appreciate your help. >>> >>> - How did you install Python? >>> - What Linux distro are you using? >>> >>> Cheers, >>> Chris >>> http://blog.rebertia.com >>> I"m using Mandriva 2008.1. I have to tell you honestly that I'm not >>> sure >>> exactly how I installed Python. Originally I had installed 2.5 from RPM >>> but 2.6 was not available for my distro (2008.1) in RPM. I downloaded >>> something from python.org and installed. Not sure if it was tarball or >>> zip file. >> >> Zip or tar doesn't matter, you are installing "from source". >> >> Python has to find the necessary include files for tcl/tk. These are in >> separate packages that you have to install before you invoke Python's >> configure script. >> >> I don't know what they are called on your system -- look for tk-dev.rpm, >> tcl-dev.rpm or similar. >> >> You may run into the same problem with other modules like readline. >> >> Peter >> > > Thank you Peter. I understand what you are saying but don't know how to > do > it. Although I installed from source, I followed a "cookbook" recipe. > Could you tell me what files to execute, where they might be, and file > arguments? I'm just ignorant, not stupid. ;-). > > Paul Once you have the necessary development packages for tcl/tk just go into the directory where you unzipped the source and ./configure make sudo make altinstall Unfortunately I don't know the names of these packages nor how to install them, and Google didn't turn up anything useful. If you don't get any additional answers here you may try a Mandriva forum since this is not a question that requires python knowlegde. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
"Peter Otten" <__pete...@web.de> wrote in message news:h3481q$d95$0...@news.t-online.com... > Paul Simon wrote: > >> "Chris Rebert" wrote in message >> news:mailman.2863.1247095339.8015.python-l...@python.org... >> On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: >>> I have the "tkinter" problem and need some assistance to straighten it >>> out. >>> >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in >>> >"step >>> 1" and cannot import "_tkinter." I do not have that file on my computer, >>> but >>> do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the >>> directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. >>> This python stuff is great, but the documentation frequently >>> feels like it is just a bit out of my grasp. I realize that all of this >>> is free but I understand the instructions on the web page to repair only >>> to the >>> point of confusion. I'm not an expert. How do I modify my python >>> configuration? Is there a file that needs to be edited? Which setup.py >>> file >>> do I use? Make? or python setup.py build and python setup.py install? >>> Thanks. I appreciate your help. >> >> - How did you install Python? >> - What Linux distro are you using? >> >> Cheers, >> Chris >> http://blog.rebertia.com >> I"m using Mandriva 2008.1. I have to tell you honestly that I'm not sure >> exactly how I installed Python. Originally I had installed 2.5 from RPM >> but 2.6 was not available for my distro (2008.1) in RPM. I downloaded >> something from python.org and installed. Not sure if it was tarball or >> zip file. > > Zip or tar doesn't matter, you are installing "from source". > > Python has to find the necessary include files for tcl/tk. These are in > separate packages that you have to install before you invoke Python's > configure script. > > I don't know what they are called on your system -- look for tk-dev.rpm, > tcl-dev.rpm or similar. > > You may run into the same problem with other modules like readline. > > Peter > Thank you Peter. I understand what you are saying but don't know how to do it. Although I installed from source, I followed a "cookbook" recipe. Could you tell me what files to execute, where they might be, and file arguments? I'm just ignorant, not stupid. ;-). Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
Paul Simon wrote: > "Chris Rebert" wrote in message > news:mailman.2863.1247095339.8015.python-l...@python.org... > On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: >> I have the "tkinter" problem and need some assistance to straighten it >> out. >> >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in >> >"step >> 1" and cannot import "_tkinter." I do not have that file on my computer, >> but >> do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the >> directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. >> This python stuff is great, but the documentation frequently >> feels like it is just a bit out of my grasp. I realize that all of this >> is free but I understand the instructions on the web page to repair only >> to the >> point of confusion. I'm not an expert. How do I modify my python >> configuration? Is there a file that needs to be edited? Which setup.py >> file >> do I use? Make? or python setup.py build and python setup.py install? >> Thanks. I appreciate your help. > > - How did you install Python? > - What Linux distro are you using? > > Cheers, > Chris > http://blog.rebertia.com > I"m using Mandriva 2008.1. I have to tell you honestly that I'm not sure > exactly how I installed Python. Originally I had installed 2.5 from RPM > but 2.6 was not available for my distro (2008.1) in RPM. I downloaded > something from python.org and installed. Not sure if it was tarball or > zip file. Zip or tar doesn't matter, you are installing "from source". Python has to find the necessary include files for tcl/tk. These are in separate packages that you have to install before you invoke Python's configure script. I don't know what they are called on your system -- look for tk-dev.rpm, tcl-dev.rpm or similar. You may run into the same problem with other modules like readline. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
"Chris Rebert" wrote in message news:mailman.2863.1247095339.8015.python-l...@python.org... On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: > I have the "tkinter" problem and need some assistance to straighten it > out. > >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in > >"step > 1" and cannot import "_tkinter." I do not have that file on my computer, > but > do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the > directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. > This python stuff is great, but the documentation frequently > feels like it is just a bit out of my grasp. I realize that all of this is > free but I understand the instructions on the web page to repair only to > the > point of confusion. I'm not an expert. How do I modify my python > configuration? Is there a file that needs to be edited? Which setup.py > file > do I use? Make? or python setup.py build and python setup.py install? > Thanks. I appreciate your help. - How did you install Python? - What Linux distro are you using? Cheers, Chris -- http://blog.rebertia.com I"m using Mandriva 2008.1. I have to tell you honestly that I'm not sure exactly how I installed Python. Originally I had installed 2.5 from RPM but 2.6 was not available for my distro (2008.1) in RPM. I downloaded something from python.org and installed. Not sure if it was tarball or zip file. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter problem
On Wed, Jul 8, 2009 at 4:18 PM, Paul Simon wrote: > I have the "tkinter" problem and need some assistance to straighten it out. > >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in "step > 1" and cannot import "_tkinter." I do not have that file on my computer, but > do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the > directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. > This python stuff is great, but the documentation frequently > feels like it is just a bit out of my grasp. I realize that all of this is > free but I understand the instructions on the web page to repair only to the > point of confusion. I'm not an expert. How do I modify my python > configuration? Is there a file that needs to be edited? Which setup.py file > do I use? Make? or python setup.py build and python setup.py install? > Thanks. I appreciate your help. - How did you install Python? - What Linux distro are you using? Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
tkinter problem
I have the "tkinter" problem and need some assistance to straighten it out. >From the web page "http://wiki.python.org/moin/TkInter"; I tested as in "step 1" and cannot import "_tkinter." I do not have that file on my computer, but do have tkinter.py in /usr/local/lib/python2.6/lib-tk. as well as the directories /usr/lib/tk8.5 and /usr/lib/tcl8.5. This python stuff is great, but the documentation frequently feels like it is just a bit out of my grasp. I realize that all of this is free but I understand the instructions on the web page to repair only to the point of confusion. I'm not an expert. How do I modify my python configuration? Is there a file that needs to be edited? Which setup.py file do I use? Make? or python setup.py build and python setup.py install? Thanks. I appreciate your help. Paul Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestions wanted on Tkinter problem
On Thu, 16 Apr 2009 16:18:03 -0700, norseman wrote: > At this point the program runs, but I cannot control gray-out of a > specific Radiobutton. > > If I: > > counter=0 > for mode, text > c[counter] = Radiobuton(specified_frame,.. > c[counter].pack() > counter += 1 > . > . > blockUseOf= $varSetElsewhere What language are you programming in? $varSetElsewhere isn't legal Python. > c[blockUseOf].config(state = strSetElsewhere) > > Program crashes on Radiobutton line. No no, don't tell us *what* error you got! We LOVE guessing games!!! Hmm, this guessing game might be harder than I like. Not only aren't we told what the error is, but half of the line that contains the error is a secret. How about telling us what the actual error is, and the actual line that causes the error? Chances are very good that the error message will tell you everything you need to know about why the program fails. > There are a number of Frames containing Radiobuttons in the program. The > individual lists are long enough no one in their right mind wants to > hand code such repetition and then try to maintain it. Then perhaps you should think about changing the user interface to make it simpler to manage, and simpler to use. Not every task requires a hammer. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestions wanted on Tkinter problem
Dave Angel wrote: norseman wrote: One suggested I change the subject line - OK I also replaced the [TAB]s since I noticed the Emailer seems to get very confused with them. Problem: Using Python 2.5.2 and Tkinter ??? (came with system) List made and for loop in use lst=[ ("S", "Single"), .] for mode, text c = Radiobuton(. c.pack() At this point the program runs, but I cannot control gray-out of a specific Radiobutton. If I: counter=0 for mode, text c[counter] = Radiobuton(specified_frame,.. c[counter].pack() counter += 1 . . blockUseOf= $varSetElsewhere c[blockUseOf].config(state = strSetElsewhere) Program crashes on Radiobutton line. There are a number of Frames containing Radiobuttons in the program. The individual lists are long enough no one in their right mind wants to hand code such repetition and then try to maintain it. Not even with a code generator. (Number and organization will change over time.) How do I set things to be able to control any given Radiobutton from elsewhere in the program and still use the for-loop loader? Steve Try posting as text. The html tags in the message are distracting. I don't know tkinter, but I can see a problem with your code. You're using the [] operators on c, but you never initialize c. Of course, you have a tiny fragment of code, and we're supposed to guess the rest. But normally, when you build a list, you start with: mylist = [] for in : c = new widget mylist.append(c) Now, c is just temporary, but mylist contains reference to all the widgets. So later on, you can use mylist[42] to get button# 42. A separate problem is that mylist should be a member of a class derived from the frame widget, or something like that. So if this code is part of an __init__ method of a class, there are a few "self" items needed. -- http://mail.python.org/mailman/listinfo/python-list === I don't use HTML! I re-checked the file I sent and it is plain text. I have no idea where the file you received has been, but sorry for problem because Yes, they are distracting from my own experiences. "... if code is part of an __init__..." No. It's for Global control. I have tried every combination I could dream up -- except the (now) obvious one. Being too close to the problem is just that - too close. Problem solved - Thank you very much. Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestions wanted on Tkinter problem
norseman wrote: One suggested I change the subject line - OK I also replaced the [TAB]s since I noticed the Emailer seems to get very confused with them. Problem: Using Python 2.5.2 and Tkinter ??? (came with system) List made and for loop in use lst=[ ("S", "Single"), .] for mode, text c = Radiobuton(. c.pack() At this point the program runs, but I cannot control gray-out of a specific Radiobutton. If I: counter=0 for mode, text c[counter] = Radiobuton(specified_frame,.. c[counter].pack() counter += 1 . . blockUseOf= $varSetElsewhere c[blockUseOf].config(state = strSetElsewhere) Program crashes on Radiobutton line. There are a number of Frames containing Radiobuttons in the program. The individual lists are long enough no one in their right mind wants to hand code such repetition and then try to maintain it. Not even with a code generator. (Number and organization will change over time.) How do I set things to be able to control any given Radiobutton from elsewhere in the program and still use the for-loop loader? Steve Try posting as text. The html tags in the message are distracting. I don't know tkinter, but I can see a problem with your code. You're using the [] operators on c, but you never initialize c. Of course, you have a tiny fragment of code, and we're supposed to guess the rest. But normally, when you build a list, you start with: mylist = [] for in : c = new widget mylist.append(c) Now, c is just temporary, but mylist contains reference to all the widgets. So later on, you can use mylist[42] to get button# 42. A separate problem is that mylist should be a member of a class derived from the frame widget, or something like that. So if this code is part of an __init__ method of a class, there are a few "self" items needed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestions wanted on Tkinter problem
On Fri, 17 Apr 2009 00:18:03 +0100, norseman wrote: One suggested I change the subject line - OK I also replaced the [TAB]s since I noticed the Emailer seems to get very confused with them. Problem: Using Python 2.5.2 and Tkinter ??? (came with system) List made and for loop in use lst=[ ("S", "Single"), .] for mode, text c = Radiobuton(. c.pack() At this point the program runs, but I cannot control gray-out of a specific Radiobutton. If I: counter=0 for mode, text c[counter] = Radiobuton(specified_frame,.. c[counter].pack() counter += 1 . . blockUseOf= $varSetElsewhere c[blockUseOf].config(state = strSetElsewhere) Program crashes on Radiobutton line. And what, pray, did the traceback say? What was |c| before you started that last loop of Radiobutton creation? -- Rhodri James *-* Wildebeeste Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Suggestions wanted on Tkinter problem
One suggested I change the subject line - OK I also replaced the [TAB]s since I noticed the Emailer seems to get very confused with them. Problem: Using Python 2.5.2 and Tkinter ??? (came with system) List made and for loop in use lst=[ ("S", "Single"), .] for mode, text c = Radiobuton(. c.pack() At this point the program runs, but I cannot control gray-out of a specific Radiobutton. If I: counter=0 for mode, text c[counter] = Radiobuton(specified_frame,.. c[counter].pack() counter += 1 . . blockUseOf= $varSetElsewhere c[blockUseOf].config(state = strSetElsewhere) Program crashes on Radiobutton line. There are a number of Frames containing Radiobuttons in the program. The individual lists are long enough no one in their right mind wants to hand code such repetition and then try to maintain it. Not even with a code generator. (Number and organization will change over time.) How do I set things to be able to control any given Radiobutton from elsewhere in the program and still use the for-loop loader? Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: TkInter: Problem with propagation of resize events through geometry manager hierarchy?
curiouserra...@gmail.com wrote: Thanks! I hadn't known about the "return 'break'" technique. But I don't follow your sentinel suggestion; how would that sentinel ever get reset? Presumably you would set it from some kind of input. Basically, if you don't need to zoom, you wouldn't bother scaling the image. It is the scaling step that is expanding your image. You might want to set any borders to 0. It seems as if the first time through the event chain it'd be set to the sentinel, and the routines that pay attention to it would never execute. What am I missing? I tried simply returning 'break' at the end of "refresh()" and that made no change in behavior. You will want to return 'break' at the end of callbacks, like display_tag_and_size() One thing I've been looking for (including in the source :-J) is a description of the precise process that the geometry manager goes through in figuring out and then setting sizes for the various widgets (on resize or, apparently, startup). I suspect with that + the "return 'break'" technique I could get this to work. But I haven't been having any luck finding that documentation. I've never found that either. I usually tweak things by trial and error. Tkinter (Tk) has some bad habits. Most of the time it is very hard to get the precise dimensions of widgets by asking them. The problem is exacerbated by platform specific modifications like TkAqua. Ive found the best approach is to tweak the math so that the sizing comes out consistent and then test and patch for every platform you support. Sometimes, if you experiment enough, you can figure out by inference what Tk is actually doing under the hood. The other, more sane option, is to attempt to make guis that don't rely on precise size information. Its less satisfying than the pixel level control one hopes for, but makes for a faster development process. Also, you might want to look into Pmw. It has scrolled canvas and scrolled frame widgets that might be helpful to you. There is no need to reinvent the wheel except for your own enlightenment. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com -- http://mail.python.org/mailman/listinfo/python-list
Re: TkInter: Problem with propagation of resize events through geometry manager hierarchy?
On Feb 8, 6:27 am, James Stroud wrote: > I can't test your code because I don't have the test image and for some > reason it does not recognize a tiff of my own. But, just glancing at > your code, it looks like a quick-fix would be to set self.zoom to a > sentinel at the end of refresh() and return 'break' at the top of the > methods that use self.zoom if it is said sentinel value (e.g. "if > self.zoom == WHATEVER_SENTINEL: return 'break'). You may also want to > return 'break' for event responders that should terminate the event > chain. This is a general technique to stop a lot of unwanted event > propagation. Thanks! I hadn't known about the "return 'break'" technique. But I don't follow your sentinel suggestion; how would that sentinel ever get reset? It seems as if the first time through the event chain it'd be set to the sentinel, and the routines that pay attention to it would never execute. What am I missing? I tried simply returning 'break' at the end of "refresh()" and that made no change in behavior. (Note that zoom should be constant at 1.0 for the life of this program; I put it in because I'm planning to put in expansion/ contraction of images after I get resize & scrolling working together. Eliminating all multiplications by self.zoom confirms this belief; no change in behavior). One thing I've been looking for (including in the source :-J) is a description of the precise process that the geometry manager goes through in figuring out and then setting sizes for the various widgets (on resize or, apparently, startup). I suspect with that + the "return 'break'" technique I could get this to work. But I haven't been having any luck finding that documentation. If you'd like me to send you the test.tiff image, I'm happy to, but it's nothing special; just a screen capture of a random google maps satellite view that I use for testing. -- Randy > > James > > -- > James Stroud > UCLA-DOE Institute for Genomics and Proteomics > Box 951570 > Los Angeles, CA 90095 > > http://www.jamesstroud.com -- http://mail.python.org/mailman/listinfo/python-list
Re: TkInter: Problem with propagation of resize events through geometry manager hierarchy?
Randy Smith wrote: The cropping and scrolling works fine. But when I try to add responding to resize events, I get into trouble. Specifically: * When I naively change the size of the image shown to be borderwidth less than the size indicated in the configure event, the size of the image shown grows gradually but inexorably when I start the test app. (Sorta scary, actually :-}) * When I fiddle a bit to figure out what the actual difference in size is between the Configure event and the image that can be displayed, I get a vibrating, jagged display of the image. Investigation suggests that multiple configure events are hitting the label in response to each user resize with different sizes. I'm guessing that when I resize the image in response to those different events, that creates new resize events propagating through the window manager hierarchy, which creates new configure events, which means my handler changes the image size, which ... you get the idea. I can't test your code because I don't have the test image and for some reason it does not recognize a tiff of my own. But, just glancing at your code, it looks like a quick-fix would be to set self.zoom to a sentinel at the end of refresh() and return 'break' at the top of the methods that use self.zoom if it is said sentinel value (e.g. "if self.zoom == WHATEVER_SENTINEL: return 'break'). You may also want to return 'break' for event responders that should terminate the event chain. This is a general technique to stop a lot of unwanted event propagation. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com -- http://mail.python.org/mailman/listinfo/python-list
TkInter: Problem with propagation of resize events through geometry manager hierarchy?
Hi! I'm looking for help with a Tkinter program's handling of resize. I'm trying to do a fairly simple widget that shows a cropped part of a larger image, and let's you navigate within the larger image through a variety of methods. The widget hierarchy is: root ImageWidget (my class) Label (contains the image) Horizontal Scroll Bar Vertical scroll bar The cropping and scrolling works fine. But when I try to add responding to resize events, I get into trouble. Specifically: * When I naively change the size of the image shown to be borderwidth less than the size indicated in the configure event, the size of the image shown grows gradually but inexorably when I start the test app. (Sorta scary, actually :-}) * When I fiddle a bit to figure out what the actual difference in size is between the Configure event and the image that can be displayed, I get a vibrating, jagged display of the image. Investigation suggests that multiple configure events are hitting the label in response to each user resize with different sizes. I'm guessing that when I resize the image in response to those different events, that creates new resize events propagating through the window manager hierarchy, which creates new configure events, which means my handler changes the image size, which ... you get the idea. However, everything seems to work fine if I leave out the scroll bars and just have a label in a frame inside the root window; the image resizes fine. If the scroll bars are in place but I don't have the image resize bound to the configure event, I get two sets of resize events propagaing through the system on startup; without, I just get one. Event lists and code included below. Any help would be appreciated. Thanks! -- Randy Smith -- Event list on startup with scroll bars: : width height root : 220 220 root : 1 1 iwidget : 220 220 root : 220 220 vscroll : 16 204 root : 16 204 hscroll : 204 16 root : 204 16 ilabel : 204 204 root : 204 204 vscroll : 15 205 root : 15 205 hscroll : 205 15 root : 205 15 ilabel : 205 205 root : 205 205 root : 219 219 ilabel : 205 205 root : 205 205 hscroll : 205 15 root : 205 15 vscroll : 15 205 root : 15 205 iwidget : 219 219 root : 219 219 vscroll : 15 204 root : 15 204 hscroll : 204 15 root : 204 15 ilabel : 204 204 root : 204 204 -- Event list on startup without scroll bars root : 204 204 root : 1 1 iwidget : 204 204 root : 204 204 ilabel : 204 204 root : 204 204 -- Code, without image resize. If you want to see the vibration, uncomment the line self.label.bind("", self.reconfigure, "+") To actually run it you'll need an image "test.tiff" in the current directory (any image of size > 200x200 will do) and access to the python imaging library (PIL), but I hope the code is pretty clear (other than the math transforming between various coordinate systems, which I don't believe is relevant; focus on reconfigure(), refresh, and __init__). #!/usr/bin/python import traceback from Tkinter import * from PIL import Image import ImageTk debug = 4 def display_args(*args): print "Args: ", args def display_event(event): print event.__dict__ def display_tag_and_size(tag, event): print tag, ": ", event.width, event.height class NotYetImplemented(Exception): pass def mapnum(x, fromrange, torange): assert fromrange[0] <= x < fromrange[1], (fromrange[0], x, fromrange[1]) assert torange[0] < torange[1], (torange[0], torange[1]) ## Need to force floating point x *= 1.0 return (x - fromrange[0]) / (fromrange[1] - fromrange[0]) * (torange[1] - torange[0]) + torange[0] class ImageWidget(Frame): def __init__(self, parent, gfunc, image_size, starting_zoom=1, starting_ul=(0,0), starting_size = None): """Create an Image Widget which will display an image based on the function passed. That function will be called with the arguments (zoom_factor, (xstart, xend), (ystart, yend)) and must return a TkInter PhotoImage object of size (xend-xstart, yend-ystart). IMAGE_SIZE describes the "base size" of the image being backed by gfunc. starting_* describes the starting window on the image.""" ## Default starting size to whole image if not starting_size: starting_size = image_size ## Init parent Frame.__init__(self, parent) self.bind("", lambda e, t="iwidget": display_tag_and_size(t, e)) ## Base image parameters self.generator_func = gfunc self.isize = image_size ## Modifier of base image size for coords currently working in self.zoom = starting_zoom ## Interval of augmented (zoomed) image currently shown ## Note that these must be integers; these map directly to pixels self.xint = [starting
Re: Tkinter - problem closing window
Wow, nice! But, with join i can't padding with 0. '-'.join(str(random.randint(0, 60)) for dummy in xrange(6)) Then, i has been used: a[i] = "%02d" % int(random.randint(0,60)) I will change int(random.randint(0,60)) for random.randint(0,60), only. Thank you, guys !! ;-) The problem was solved when removed the second "mainloop". I will use the Toplevel instead Tk() again. Thank you for the nice lesson !! On Tue, Jan 6, 2009 at 6:47 AM, Marc 'BlackJack' Rintsch wrote: > On Mon, 05 Jan 2009 12:25:53 -0200, Djames Suhanko wrote: > >> I has a litle program that open another window. When I close de root >> window in quit button, I need clicking 2 times to close. is where the >> problem? >> >> […] >> >> 17 def gera_seis(self): >> 18a = {} >> 19for i in range(6): >> 20 a[i] = "%02d" % int (random.randint(0,60)) >> 21resultadoA = "%s-%s-%s-%s-%s-%s" % >> (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) >> 22return resultadoA > > Not the problem but unnecessary complex. `random.randint()` already > returns an int, no need to call `int()` on it. The string formatting > with ``%`` returns strings, so there is no need to call `str()` on the > values. Even if the values where not strings: The '%s' place holder > implies a call to `str()` while formatting. If you put something into a > dictionary with consecutive `int` keys, you might use a list instead. > > All this can be written as a simple one liner:: > >'-'.join(str(random.randint(0, 60)) for dummy in xrange(6)) > >> 24 def say_hi(self): >> 25resultado = self.gera_seis() >> 26raiz = Tk() > > The problem is here… > >> 27F = Frame(raiz) >> 28F.pack() >> 29hello = Label(F, text=resultado) 30hello.pack() >> 31F.mainloop() > > …and here. > > There is only one `Tk` instance and mainloop allowed per `Tkinter` > application. Otherwise really strange things can happen. Additional > windows have to be created as `Toplevel` instances. > > Ciao, >Marc 'BlackJack' Rintsch > -- > http://mail.python.org/mailman/listinfo/python-list > -- Djames Suhanko LinuxUser 158.760 -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - problem closing window
On Mon, 05 Jan 2009 12:25:53 -0200, Djames Suhanko wrote: > I has a litle program that open another window. When I close de root > window in quit button, I need clicking 2 times to close. is where the > problem? > > […] > > 17 def gera_seis(self): > 18a = {} > 19for i in range(6): > 20 a[i] = "%02d" % int (random.randint(0,60)) > 21resultadoA = "%s-%s-%s-%s-%s-%s" % > (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) > 22return resultadoA Not the problem but unnecessary complex. `random.randint()` already returns an int, no need to call `int()` on it. The string formatting with ``%`` returns strings, so there is no need to call `str()` on the values. Even if the values where not strings: The '%s' place holder implies a call to `str()` while formatting. If you put something into a dictionary with consecutive `int` keys, you might use a list instead. All this can be written as a simple one liner:: '-'.join(str(random.randint(0, 60)) for dummy in xrange(6)) > 24 def say_hi(self): > 25resultado = self.gera_seis() > 26raiz = Tk() The problem is here… > 27F = Frame(raiz) > 28F.pack() > 29hello = Label(F, text=resultado) 30hello.pack() > 31F.mainloop() …and here. There is only one `Tk` instance and mainloop allowed per `Tkinter` application. Otherwise really strange things can happen. Additional windows have to be created as `Toplevel` instances. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - problem closing window
On Jan 5, 9:21 am, Roger wrote: > On Jan 5, 11:52 am, Collin D wrote: > > > > > On Jan 5, 6:25 am, "Djames Suhanko" wrote: > > > > Hello! > > > I'm sorry my terrible english (my native language is portuguese). > > > I has a litle program that open another window. When I close de root > > > window in quit button, I need clicking 2 times to close. is where the > > > problem? > > > > The source: > > > 1 #!/usr/bin/env python > > > 2 from Tkinter import * > > > 3 import sys > > > 4 import random > > > 5 class App: > > > 6 def __init__(self, master): > > > 7 frame = Frame(master) > > > 8 frame.pack() > > > 9 rotulo = Label(frame, text="Clique em 'Gerar' e boa > > > sorte!",borderwidth=2,bg="gray",justify=C ENTER,relief=SUNKEN) > > > 10 rotulo.pack() > > > 11 > > > 12 self.button = Button(frame, text="Sair", fg="red", > > > command=frame.quit,borderwidth=1) > > > 13 self.button.pack(side=LEFT) > > > 14 self.hi_there = Button(frame, text="Gerar Numero", > > > command=self.say_hi,borderwidth=1) > > > 15 self.hi_there.pack(side=RIGHT,padx=2,pady=2) > > > 16 > > > 17 def gera_seis(self): > > > 18 a = {} > > > 19 for i in range(6): > > > 20 a[i] = "%02d" % int (random.randint(0,60)) > > > 21 resultadoA = "%s-%s-%s-%s-%s-%s" % > > > (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) > > > 22 return resultadoA > > > 23 > > > 24 def say_hi(self): > > > 25 resultado = self.gera_seis() > > > 26 raiz = Tk() > > > 27 F = Frame(raiz) > > > 28 F.pack() > > > 29 hello = Label(F, text=resultado) > > > 30 hello.pack() > > > 31 F.mainloop() > > > 32 > > > 33 root = Tk() > > > 34 root.title("$$$ Loteria $$$") > > > 35 app = App(root) > > > 36 root.mainloop() > > > > -- > > > Djames Suhanko > > > LinuxUser 158.760 > > > Also for style, you might want to group the import lines so they look > > like this: > > > from Tkinter import * > > import sys, random > > > A bit more pythonic. :P > > In that case you probably want to take out the 'from' import and: > > import Tkinter, sys, random > > in order to avoid any namespace issues especially if you have a large > project with lots of gui manipulations. But that's just me being > pedantic. ;) I agree... you could have conflicting functions.. not fun. XD -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - problem closing window
On Jan 5, 11:52 am, Collin D wrote: > On Jan 5, 6:25 am, "Djames Suhanko" wrote: > > > > > Hello! > > I'm sorry my terrible english (my native language is portuguese). > > I has a litle program that open another window. When I close de root > > window in quit button, I need clicking 2 times to close. is where the > > problem? > > > The source: > > 1 #!/usr/bin/env python > > 2 from Tkinter import * > > 3 import sys > > 4 import random > > 5 class App: > > 6 def __init__(self, master): > > 7 frame = Frame(master) > > 8 frame.pack() > > 9 rotulo = Label(frame, text="Clique em 'Gerar' e boa > > sorte!",borderwidth=2,bg="gray",justify=C ENTER,relief=SUNKEN) > > 10 rotulo.pack() > > 11 > > 12 self.button = Button(frame, text="Sair", fg="red", > > command=frame.quit,borderwidth=1) > > 13 self.button.pack(side=LEFT) > > 14 self.hi_there = Button(frame, text="Gerar Numero", > > command=self.say_hi,borderwidth=1) > > 15 self.hi_there.pack(side=RIGHT,padx=2,pady=2) > > 16 > > 17 def gera_seis(self): > > 18 a = {} > > 19 for i in range(6): > > 20 a[i] = "%02d" % int (random.randint(0,60)) > > 21 resultadoA = "%s-%s-%s-%s-%s-%s" % > > (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) > > 22 return resultadoA > > 23 > > 24 def say_hi(self): > > 25 resultado = self.gera_seis() > > 26 raiz = Tk() > > 27 F = Frame(raiz) > > 28 F.pack() > > 29 hello = Label(F, text=resultado) > > 30 hello.pack() > > 31 F.mainloop() > > 32 > > 33 root = Tk() > > 34 root.title("$$$ Loteria $$$") > > 35 app = App(root) > > 36 root.mainloop() > > > -- > > Djames Suhanko > > LinuxUser 158.760 > > Also for style, you might want to group the import lines so they look > like this: > > from Tkinter import * > import sys, random > > A bit more pythonic. :P In that case you probably want to take out the 'from' import and: import Tkinter, sys, random in order to avoid any namespace issues especially if you have a large project with lots of gui manipulations. But that's just me being pedantic. ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - problem closing window
On Jan 5, 6:25 am, "Djames Suhanko" wrote: > Hello! > I'm sorry my terrible english (my native language is portuguese). > I has a litle program that open another window. When I close de root > window in quit button, I need clicking 2 times to close. is where the > problem? > > The source: > 1 #!/usr/bin/env python > 2 from Tkinter import * > 3 import sys > 4 import random > 5 class App: > 6 def __init__(self, master): > 7 frame = Frame(master) > 8 frame.pack() > 9 rotulo = Label(frame, text="Clique em 'Gerar' e boa > sorte!",borderwidth=2,bg="gray",justify=C ENTER,relief=SUNKEN) > 10 rotulo.pack() > 11 > 12 self.button = Button(frame, text="Sair", fg="red", > command=frame.quit,borderwidth=1) > 13 self.button.pack(side=LEFT) > 14 self.hi_there = Button(frame, text="Gerar Numero", > command=self.say_hi,borderwidth=1) > 15 self.hi_there.pack(side=RIGHT,padx=2,pady=2) > 16 > 17 def gera_seis(self): > 18 a = {} > 19 for i in range(6): > 20 a[i] = "%02d" % int (random.randint(0,60)) > 21 resultadoA = "%s-%s-%s-%s-%s-%s" % > (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) > 22 return resultadoA > 23 > 24 def say_hi(self): > 25 resultado = self.gera_seis() > 26 raiz = Tk() > 27 F = Frame(raiz) > 28 F.pack() > 29 hello = Label(F, text=resultado) > 30 hello.pack() > 31 F.mainloop() > 32 > 33 root = Tk() > 34 root.title("$$$ Loteria $$$") > 35 app = App(root) > 36 root.mainloop() > > -- > Djames Suhanko > LinuxUser 158.760 Also for style, you might want to group the import lines so they look like this: from Tkinter import * import sys, random A bit more pythonic. :P -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - problem closing window
Djames Suhanko wrote: > Hello! > I'm sorry my terrible english (my native language is portuguese). > I has a litle program that open another window. When I close de root > window in quit button, I need clicking 2 times to close. is where the > problem? > > The source: > 1 #!/usr/bin/env python > 2 from Tkinter import * > 3 import sys > 4 import random > 5 class App: > 6 def __init__(self, master): > 7frame = Frame(master) > 8frame.pack() > 9rotulo = Label(frame, text="Clique em 'Gerar' e boa > sorte!",borderwidth=2,bg="gray",justify=CENTER,relief=SUNKEN) > 10rotulo.pack() > 11 > 12self.button = Button(frame, text="Sair", fg="red", > command=frame.quit,borderwidth=1) > 13self.button.pack(side=LEFT) > 14self.hi_there = Button(frame, text="Gerar Numero", > command=self.say_hi,borderwidth=1) > 15self.hi_there.pack(side=RIGHT,padx=2,pady=2) > 16 > 17 def gera_seis(self): > 18a = {} > 19for i in range(6): > 20 a[i] = "%02d" % int (random.randint(0,60)) > 21resultadoA = "%s-%s-%s-%s-%s-%s" % > (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) > 22return resultadoA > 23 > 24 def say_hi(self): > 25resultado = self.gera_seis() > 26raiz = Tk() > 27F = Frame(raiz) > 28F.pack() > 29hello = Label(F, text=resultado) > 30hello.pack() > 31F.mainloop() You need only one mainloop(). Remove line 31 and you should be OK. > 32 > 33 root = Tk() > 34 root.title("$$$ Loteria $$$") > 35 app = App(root) > 36 root.mainloop() Peter -- http://mail.python.org/mailman/listinfo/python-list
Tkinter - problem closing window
Hello! I'm sorry my terrible english (my native language is portuguese). I has a litle program that open another window. When I close de root window in quit button, I need clicking 2 times to close. is where the problem? The source: 1 #!/usr/bin/env python 2 from Tkinter import * 3 import sys 4 import random 5 class App: 6 def __init__(self, master): 7frame = Frame(master) 8frame.pack() 9rotulo = Label(frame, text="Clique em 'Gerar' e boa sorte!",borderwidth=2,bg="gray",justify=CENTER,relief=SUNKEN) 10rotulo.pack() 11 12self.button = Button(frame, text="Sair", fg="red", command=frame.quit,borderwidth=1) 13self.button.pack(side=LEFT) 14self.hi_there = Button(frame, text="Gerar Numero", command=self.say_hi,borderwidth=1) 15self.hi_there.pack(side=RIGHT,padx=2,pady=2) 16 17 def gera_seis(self): 18a = {} 19for i in range(6): 20 a[i] = "%02d" % int (random.randint(0,60)) 21resultadoA = "%s-%s-%s-%s-%s-%s" % (str(a[0]),str(a[1]),str(a[2]),str(a[3]),str(a[4]),str(a[5])) 22return resultadoA 23 24 def say_hi(self): 25resultado = self.gera_seis() 26raiz = Tk() 27F = Frame(raiz) 28F.pack() 29hello = Label(F, text=resultado) 30hello.pack() 31F.mainloop() 32 33 root = Tk() 34 root.title("$$$ Loteria $$$") 35 app = App(root) 36 root.mainloop() -- Djames Suhanko LinuxUser 158.760 -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread Tkinter problem
"Davy" <[EMAIL PROTECTED]> wrote: >def gen_board_thread(): >print 'enter here' >gen_flip = 1 >while(True): You don't need the brackets: while True: is good enough >time.sleep(0.3) >if (data_queue.full() == False): write: if not data_queue.full(): , and lose the brackets here too. >if (gen_flip == 1): write: if gen_flip: (no brackets - not needed, ugly) >gen_flip = 0 >data = board_1 >else: >gen_flip = 1 >data = board_2 >data_queue.put(data) >print 'put', data_queue.qsize() HTH - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread Tkinter problem
On Dec 4, 9:08 am, Davy <[EMAIL PROTECTED]> wrote: > On Dec 4, 11:13 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote:> "Davy" > <[EMAIL PROTECTED]> wrote: > > > while(data_queue.full() == False): > > > This will fill the queue and stop. > > Use while true and if queue not full... > > Hi Hendrik, > > It works, thank you:) Add changed code: //--code changed --- def gen_board_thread(): print 'enter here' gen_flip = 1 while(True): time.sleep(0.3) if (data_queue.full() == False): if (gen_flip == 1): gen_flip = 0 data = board_1 else: gen_flip = 1 data = board_2 data_queue.put(data) print 'put', data_queue.qsize() // > > Davy > > > > > > > - Hendrik- Hide quoted text - > > - Show quoted text - -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread Tkinter problem
On Dec 4, 11:13 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > "Davy" <[EMAIL PROTECTED]> wrote: > > while(data_queue.full() == False): > > This will fill the queue and stop. > Use while true and if queue not full... Hi Hendrik, It works, thank you:) Davy > > - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread Tkinter problem
"Davy" <[EMAIL PROTECTED]> wrote: > while(data_queue.full() == False): This will fill the queue and stop. Use while true and if queue not full... - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Thread Tkinter problem
Hi all, I am using thread and tkinter to write some simple programs and solidify my understanding of Python thread/GUI programing. The scheme is thread + queue + GUI. One child thread (gen_board_thread) generate board and insert data into queue infinitely. Meanwhile, the main thread canvas widget get the board data from queue. I assume the program will run forever if don't close them explicitly, but the fact is contrary to my understanding. It seems the child thread insert data till queue is full, then the main thread eat the data till the queue is empty, and the main thread starve(when timeout option is set) and die. So the two thread work like two function call, but not two thread! Is this situation caused by deadlock(I guess main thread has higher priority)? Or how can I know whether the child thread is still alive? Ultimately, how to solve the problem? The code are attached. Any suggestion will be appreciated :-) Best regards, Davy //-Code below--- from Tkinter import * import thread import Queue ##import time x = 3 ## vertical y = 5 ## horizontal block_width = 10 block_height = 10 canvas_width = x * block_width canvas_height = y * block_height data_queue = Queue.Queue(20) board_1 = [[1,0,1], [0,1,1], [1,0,0], [0,0,1], [0,1,0]] board_2 = [[0,1,0], [1,0,0], [0,1,1], [1,1,0], [1,0,1]] def gen_board_thread(): ## Problem: the thread seems to be deadlock or killed or postponed after execution was taken over by main thread draw_canvas_loop() print 'enter here' gen_flip = 1 while(data_queue.full() == False): ##print '???' ##time.sleep(0.1) if (gen_flip == 1): gen_flip = 0 data = board_1 else: gen_flip = 1 data = board_2 data_queue.put(data) print 'put', data_queue.qsize() def create_canvas(root,canvas_width,canvas_height,): canvas = Canvas(root, width=canvas_width, height=canvas_height, bg='white') canvas.pack(expand=YES) return canvas def draw_canvas_loop(canvas_b): board = data_queue.get(block = True, timeout=1) print 'get', data_queue.qsize() draw_canvas(board, canvas_b, x, y, block_width, block_height) canvas_b.after(300, lambda:draw_canvas_loop(canvas_b)) def draw_canvas(board, canvas_b, x, y, block_width, block_height): ##canvas_b.after(3000) ##time.sleep(3) for j in range(y): for i in range(x): if board[j][i] == 1: color = 'black' else: color = 'white' start_x = block_width * i start_y = block_height * j end_x = start_x + block_width end_y = start_y + block_height canvas_b.create_rectangle (start_x,start_y,end_x,end_y,fill=color) if __name__ == '__main__': root = Tk() root.title('Tetris') canvas = create_canvas(root,canvas_width,canvas_height) thread.start_new(gen_board_thread,()) draw_canvas_loop(canvas) mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows / Tkinter - problem with grid - not able to place widgets at desired places
On Sun, Sep 14, 2008 at 7:32 AM, Francesco Bochicchio <[EMAIL PROTECTED]> wrote: > Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto: > > >>>Hi, >>> >>>I'm learning Python and Tkinter. I've started programming in Eclipse >>>with PyDev. I'm intending to create a GUI. I'm not able to understand >>>the Grid manager perhaps because there is quite a less documentation >>>available for it on the net. >>> >>>My desired GUI is attached in the mail. Although I've tried writing a >>>class module for this GUI but I'm not able to set all things right in >>>the GUI. The Biggest problem seems to be with the Grid Manager in terms >>>how it divides a window in Rows / columns. etc. I'm not able to place >>>none of the widgets correctly in the GUI. >>> >>>For your convenience, I'm attaching this code also as myModule1.py . >>>Please some one review it and help create me this GUI. >>> > > Uhm, I don't think you should use the grid manager to obtain a window > like that. The grid manager is for equally distributing widgets both > horizontally and vertically. > And I'm not sure that you can realize that window look with Tkinter. Yes you can. > You could get close by horizontally packing each widget row in a frame > and then vertically packing the frames in the window. But the look will be > quite different than your target. If you are not satisfied with that I > suggest you move to other toolkits which have more complex geometry > managers than .pack and .grid. Uhm.. I'm sure it is more a question of learning how to use them properly. The following code should be very close to the original request, depending on the tk version some minor modifications may be needed. from Tkinter import Tk, Button, Checkbutton, Label, Entry, Frame class App: def __init__(self, master): column0_padx = 24 row_pady = 36 #Label 1 lbl_testcase_exec = Label(master, text="Test case execution", wraplength=100, anchor='w', justify='left') lbl_results_cmp = Label(master, text="Results comparison", wraplength=100, justify='left') lbl_tolerance = Label(master, text="Tolerance (5%)", wraplength=100) testcase_exec = Checkbutton(master) results_cmp = Checkbutton(master) tolerance = Entry(master, width=4) lbl_analysis = Label(master, text="Analysis Library") analysis_lib = Entry(master, width=30) lbl_testcase_exec.grid(row=0, column=2, padx=20, pady=12, sticky='w') lbl_results_cmp.grid(row=0, column=3, pady=12, sticky='w') lbl_tolerance.grid(row=0, column=4, padx=20, pady=12, sticky='wn') lbl_analysis.grid(row=1, column=0, sticky='w', padx=column0_padx) analysis_lib.grid(row=1, column=1, sticky='w') testcase_exec.grid(row=1, column=2, padx=20, sticky='w') results_cmp.grid(row=1, column=3, sticky='w') tolerance.grid(row=1, column=4, padx=20, sticky='w') #Label 2 lbl_ref_analysis = Label( master, text="Reference Analysis Libary Version", wraplength=150, justify='left', pady=row_pady) ref_analysis_lib = Entry(master, width=30) lbl_ref_analysis.grid(row=2, column=0, sticky='w', padx=column0_padx) ref_analysis_lib.grid(row=2, column=1, sticky='w') # version lbl_version = Label(master, text="Version under Test") version = Label(master, text="vA.B.C.D") lbl_version.grid(row=3, column=0, sticky='w', padx=column0_padx) version.grid(row=3, column=1, sticky='w') # test all lbl_testall = Label(master, text="Test All") testall = Checkbutton(master) lbl_testall.grid(row=4, column=0, pady=row_pady, padx=column0_padx, sticky='w') testall.grid(row=4, column=1, sticky='w') # buttons bottom_frame = Frame(master) bottom_frame.grid(row=5, column=1, columnspan=3, sticky='w') btn_start = Button(bottom_frame, text = "Go", width=7) btn_start.pack(side='left') btn_commit = Button(bottom_frame, text="Commit", width=7) btn_commit.pack(side='left', padx=80) btn_exit = Button(bottom_frame, text="Exit", width=7) btn_exit.pack(side='left') root = Tk() root.title("Test Automation") root.minsize(800, 400) app = App(root) root.mainloop() > > Ciao > - > FB > -- > http://mail.python.org/mailman/listinfo/python-list > -- -- Guilherme H. Polo Goncalves -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows / Tkinter - problem with grid - not able to place widgets at desired places
Il Mon, 18 Aug 2008 12:15:10 +0100, dudeja.rajat ha scritto: >>Hi, >> >>I'm learning Python and Tkinter. I've started programming in Eclipse >>with PyDev. I'm intending to create a GUI. I'm not able to understand >>the Grid manager perhaps because there is quite a less documentation >>available for it on the net. >> >>My desired GUI is attached in the mail. Although I've tried writing a >>class module for this GUI but I'm not able to set all things right in >>the GUI. The Biggest problem seems to be with the Grid Manager in terms >>how it divides a window in Rows / columns. etc. I'm not able to place >>none of the widgets correctly in the GUI. >> >>For your convenience, I'm attaching this code also as myModule1.py . >>Please some one review it and help create me this GUI. >> Uhm, I don't think you should use the grid manager to obtain a window like that. The grid manager is for equally distributing widgets both horizontally and vertically. And I'm not sure that you can realize that window look with Tkinter. You could get close by horizontally packing each widget row in a frame and then vertically packing the frames in the window. But the look will be quite different than your target. If you are not satisfied with that I suggest you move to other toolkits which have more complex geometry managers than .pack and .grid. Ciao - FB -- http://mail.python.org/mailman/listinfo/python-list
Windows / Tkinter - problem with grid - not able to place widgets at desired places
> >Hi, > >I'm learning Python and Tkinter. I've started programming in Eclipse with >PyDev. >I'm intending to create a GUI. I'm not able to understand the Grid >manager perhaps because there is quite a less documentation available >for it on the net. > >My desired GUI is attached in the mail. Although I've tried writing a >class module for this GUI but I'm not able to set all things right in >the GUI. The Biggest problem seems to be with the Grid Manager in >terms how it divides a window in Rows / columns. etc. I'm not able to >place none of the widgets correctly in the GUI. > >For your convenience, I'm attaching this code also as myModule1.py . >Please some one review it and help create me this GUI. > >PS: The desired GUI is attached as a GIF file. The version v1.4.5.1 is >a label the contents of which are dynamically picked. > >Thanks and regards, >Rajat Guys please help me on this topic. No answers make me suspect if I mailed the query as per the mailing list guidelines. Cheers, rajat <>#Filename:myModule1 #Description: Creates the basic Tkinter programs #Author: Rajat Dudeja #Date:16.08.2008 from Tkinter import * #GUI class class myAppGUI: def __init__(self, master): #Start Test Button self.bStartTest = Button( master, \ text = "Start Test", \ command = self.hStartTest, \ ) self.bStartTest.config( justify = CENTER, \ padx = 20, \ width = 10, #pady= 5, \ relief = RAISED ) self.bStartTest.grid( row = 10, \ column = 2, \ columnspan = 1, \ sticky = EW) #Commit Results Button self.bCommitResults = Button( master, \ text = "Commit Results", \ command = self.hCommitResults \ ) self.bCommitResults.config( justify = CENTER, \ padx = 20, \ #pady= 5, \ width = 10, \ relief = RAISED ) self.bCommitResults.grid( row = 10, \ column = 5, \ columnspan = 1, \ sticky = EW) #Exit Button self.bExit = Button( master, \ text = "Exit", \ command = master.quit ) self.bExit.config( justify = CENTER, \ padx = 20, \ width= 10, \ relief = RAISED, \ ) self.bExit.grid( row = 10, \ column = 8, \ columnspan = 1, \ sticky = EW) #Labels and Drop down menus #Label 1 self.lAnalysisLib = Label( master, \ text = "Analysis Library:", \ justify = RIGHT) self.lAnalysisLib.grid(row = 0) #Label 2 self.lRefAnalysisLibVer = Label( master, \ text = "Reference Analysis Libary Version:", \ justify = LEFT) self.lRefAnalysisLibVer.config( wraplength = 100 ) self.lRefAnalysisLibVer.grid(row = 5) def hStartTest(self): print 'Starting Test...' def hCommitResults(self): print 'Commiting to SVN...' #End of myAppGUI Class # Main Program myRoot = Tk() myRoot.title("Test Automation") myRoot.minsize(800, 400) myAppGUIObject = myAppGUI(myRoot) myRoot.mainloop()-- http://mail.python.org/mailman/listinfo/python-list
Windows / Tkinter - problem with grid - not able to place widgets at desired places
Hi, I'm learning Python and Tkinter. I've started programming in Eclipse with PyDev. I'm intending to create a GUI. I'm not able to understand the Grid manager perhaps because there is quite a less documentation available for it on the net. My desired GUI is attached in the mail. Although I've tried writing a class module for this GUI but I'm not able to set all things right in the GUI. The Biggest problem seems to be with the Grid Manager in terms how it divides a window in Rows / columns. etc. I'm not able to place none of the widgets correctly in the GUI. For your convenience, I'm attaching this code also as myModule1.py . Please some one review it and help create me this GUI. PS: The desired GUI is attached as a GIF file. The version v1.4.5.1 is a label the contents of which are dynamically picked. Thanks and regards, Rajat <>#Filename:myModule1 #Description: Creates the basic Tkinter programs #Author: Rajat Dudeja #Date:16.08.2008 from Tkinter import * #GUI class class myAppGUI: def __init__(self, master): #Start Test Button self.bStartTest = Button( master, \ text = "Start Test", \ command = self.hStartTest, \ ) self.bStartTest.config( justify = CENTER, \ padx = 20, \ width = 10, #pady= 5, \ relief = RAISED ) self.bStartTest.grid( row = 10, \ column = 2, \ columnspan = 1, \ sticky = EW) #Commit Results Button self.bCommitResults = Button( master, \ text = "Commit Results", \ command = self.hCommitResults \ ) self.bCommitResults.config( justify = CENTER, \ padx = 20, \ #pady= 5, \ width = 10, \ relief = RAISED ) self.bCommitResults.grid( row = 10, \ column = 5, \ columnspan = 1, \ sticky = EW) #Exit Button self.bExit = Button( master, \ text = "Exit", \ command = master.quit ) self.bExit.config( justify = CENTER, \ padx = 20, \ width= 10, \ relief = RAISED, \ ) self.bExit.grid( row = 10, \ column = 8, \ columnspan = 1, \ sticky = EW) #Labels and Drop down menus #Label 1 self.lAnalysisLib = Label( master, \ text = "Analysis Library:", \ justify = RIGHT) self.lAnalysisLib.grid(row = 0) #Label 2 self.lRefAnalysisLibVer = Label( master, \ text = "Reference Analysis Libary Version:", \ justify = LEFT) self.lRefAnalysisLibVer.config( wraplength = 100 ) self.lRefAnalysisLibVer.grid(row = 5) def hStartTest(self): print 'Starting Test...' def hCommitResults(self): print 'Commiting to SVN...' #End of myAppGUI Class # Main Program myRoot = Tk() myRoot.title("Test Automation") myRoot.minsize(800, 400) myAppGUIObject = myAppGUI(myRoot) myRoot.mainloop()-- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Problem?
Hi all, I have solved the problem after read some code. Because Tk.Canvas do not have a focus, it does not receive a key input. The solution is bind key input to the highest level 'root' root.bind('',self._onUpKey) Davy On Nov 20, 10:13 am, Davy <[EMAIL PROTECTED]> wrote: > Hi all, > > I have written a simple Tkinter program, that is draw a rectangle in a > canvas, when I press Up key, the rectangle move up. But the program > seems work not properly? My environment is Python2.5+PythonWin. > > ##-- > from Tkinter import * > > class MyApp: > def __init__(self,parent): > self.myContainer1 = Frame(parent) > self.myContainer1.pack() > self.canv = Canvas(relief=SUNKEN) > self.canv.config(width = 300,height=300) > self.canv.pack() > self.canv.create_rectangle(100,100,150,150,tags="rect") > self.canv.bind('',self._onUpKey) > self.canv.bind('', self._onReturnKey) > def _onUpKey(self,event): > self.canv.move(tagOrId,xAmount=0,yAmount=10) > def _onReturnKey(self,event): > print 'Hello world' > > root = Tk() > myapp = MyApp(root) > root.mainloop() > > ##-- > > Best regards, > Davy -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Problem?
Marc 'BlackJack' Rintsch wrote: > On Mon, 19 Nov 2007 18:13:03 -0800, Davy wrote: > >> ##-- >> from Tkinter import * >> >> class MyApp: >> def __init__(self,parent): >> self.myContainer1 = Frame(parent) >> self.myContainer1.pack() >> self.canv = Canvas(relief=SUNKEN) >> self.canv.config(width = 300,height=300) >> self.canv.pack() >> self.canv.create_rectangle(100,100,150,150,tags="rect") >> self.canv.bind('',self._onUpKey) >> self.canv.bind('', self._onReturnKey) >> def _onUpKey(self,event): >> self.canv.move(tagOrId,xAmount=0,yAmount=10) > > Where's `tagOrId` coming from? That's a `NameError` here. Also, the arguments of Canvas.move() are positional. self.canv.move("rect", 0, 10) should work though the direction of the move might surprise you. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Problem?
On Mon, 19 Nov 2007 18:13:03 -0800, Davy wrote: > ##-- > from Tkinter import * > > class MyApp: > def __init__(self,parent): > self.myContainer1 = Frame(parent) > self.myContainer1.pack() > self.canv = Canvas(relief=SUNKEN) > self.canv.config(width = 300,height=300) > self.canv.pack() > self.canv.create_rectangle(100,100,150,150,tags="rect") > self.canv.bind('',self._onUpKey) > self.canv.bind('', self._onReturnKey) > def _onUpKey(self,event): > self.canv.move(tagOrId,xAmount=0,yAmount=10) Where's `tagOrId` coming from? That's a `NameError` here. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Problem?
On Nov 19, 8:13 pm, Davy <[EMAIL PROTECTED]> wrote: > Hi all, > > I have written a simple Tkinter program, that is draw a rectangle in a > canvas, when I press Up key, the rectangle move up. But the program > seems work not properly? My environment is Python2.5+PythonWin. > > ##-- > from Tkinter import * > > class MyApp: > def __init__(self,parent): > self.myContainer1 = Frame(parent) > self.myContainer1.pack() > self.canv = Canvas(relief=SUNKEN) > self.canv.config(width = 300,height=300) > self.canv.pack() > self.canv.create_rectangle(100,100,150,150,tags="rect") > self.canv.bind('',self._onUpKey) > self.canv.bind('', self._onReturnKey) > def _onUpKey(self,event): > self.canv.move(tagOrId,xAmount=0,yAmount=10) > def _onReturnKey(self,event): > print 'Hello world' > > root = Tk() > myapp = MyApp(root) > root.mainloop() > > ##-- > > Best regards, > Davy I'm not sure, but I don't think you can bind the a key to a canvas...you'd want to bind to the rectangle itself somehow. Some articles on binding: http://effbot.org/pyfaq/i-can-t-get-key-bindings-to-work-in-tkinter-why.htm http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm http://docs.huihoo.com/tkinter/an-introduction-to-tkinter-1997/intro06.htm Info on the Canvas object: # this one talks about setting the focus on an item within the canvas so that it has key bindings...maybe that will work. http://effbot.org/tkinterbook/canvas.htm http://www.pythonware.com/library/tkinter/introduction/canvas.htm I am not a Tkinter expert. I am much better with wxPython, but I am only starting to be able to answer questions on that topic. Hopefully someone with more knowledge will show up shortly. Mike -- http://mail.python.org/mailman/listinfo/python-list
Tkinter Problem?
Hi all, I have written a simple Tkinter program, that is draw a rectangle in a canvas, when I press Up key, the rectangle move up. But the program seems work not properly? My environment is Python2.5+PythonWin. ##-- from Tkinter import * class MyApp: def __init__(self,parent): self.myContainer1 = Frame(parent) self.myContainer1.pack() self.canv = Canvas(relief=SUNKEN) self.canv.config(width = 300,height=300) self.canv.pack() self.canv.create_rectangle(100,100,150,150,tags="rect") self.canv.bind('',self._onUpKey) self.canv.bind('', self._onReturnKey) def _onUpKey(self,event): self.canv.move(tagOrId,xAmount=0,yAmount=10) def _onReturnKey(self,event): print 'Hello world' root = Tk() myapp = MyApp(root) root.mainloop() ##-- Best regards, Davy -- http://mail.python.org/mailman/listinfo/python-list
Re: py2exe / Tkinter problem
[EMAIL PROTECTED] wrote: > I've got a python GUI working with Tkinter, and I need to package it as > an executable file, preferably a single file. Why not use an installer to bundle the python interpreter (with TKinter) and your code in a single executable file? If you don't want to distribute source code then .pyc or .pyo files can be used? An example of (freeware) installer software: http://www.jrsoftware.org/isinfo.php -- http://mail.python.org/mailman/listinfo/python-list
py2exe / Tkinter problem
I've got a python GUI working with Tkinter, and I need to package it as an executable file, preferably a single file. I've got py2exe working without the 'bundle_files' option, but when I add that option in ("bundle_files": 1), the built executable gives me the following error: --- Fatal Python error: Interpreter not initialized (version mismatch?) This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. --- This happens when the compiled Python executes the line "from Tkinter import *". Any ideas? I've been trawling Google and Usenet all day... M-A -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Tkinter problem
On Tuesday 07 November 2006 10:38, jim-on-linux wrote: Greg, Run the following code to see how pack_forget() or grid_forget() works, it makes previous widgets disappear but not go away. If you call grid() or pack() again after using grid_forget() the widget returns. root = Tk() class Ktest: def __init__(self): self.Ftest1() def Ftest1(self): try: self.test2.grid_forget() except AttributeError : pass self.test1 = Button(root, text='Push #1 button', bg = 'yellow', width = 25, command = self.Ftest2, height = 25) self.test1.grid(row=0, column=0) def Ftest2(self): self.test1.grid_forget() self.test2 = Button(root, text='Push #2 button', bg = 'green', width = 15, command = self.Ftest1, height = 10) self.test2.grid(row=0, column=0) if __name__== '__main__' : Ktest() mainloop() Maybe someone else has an idea about not defining a variable. My question is how does a budket of wires and screws know its a bucket of wires and screws unless someone tells it that it's a bucket of wires and screws? jim-on-linux http://.www.inqvista.com > > > > > > On Tuesday 07 November 2006 09:35, > > [EMAIL PROTECTED] wrote: > > Hi all, > > > > I'm trying to write a GUI that will put up > > multiple widgets in succession. My problem is > > that each widget also contains the previous > > widgets when they pop up. How do I > > reinitialize the widget each time so that it > > doesn't contain earlier ones? Actually, > > another question I have is, is there a way to > > set python so that it will assume any > > undefined variable is 0 or ''? That is, I > > have several statements like "If k > 0 then > > so and so" and I would like it to assume k=0 > > unless I tell it otherwise. I've just been > > defining k=0 at the start of the program but > > it seems there should be a better way. > > > > Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Tkinter problem
Greg, Run the following code to see how pack_forget() or grid_forget() works, it makes previous widgets disappear but not go away. If you call grid() or pack() again after using grid_forget() the widget returns. root = Tk() class Ktest: def __init__(self): self.Ftest1() def Ftest1(self): try: self.test2.grid_forget() except AttributeError : pass self.test1 = Button(root, text='Push #1 button', bg = 'yellow', width = 25, command = self.Ftest2, height = 25) self.test1.grid(row=0, column=0) def Ftest2(self): self.test1.grid_forget() self.test2 = Button(root, text='Push #2 button', bg = 'green', width = 15, command = self.Ftest1, height = 10) self.test2.grid(row=0, column=0) if __name__== '__main__' : Ktest() mainloop() Maybe someone else has an idea about not defining a variable. My question is how does a budket of wires and screws know its a bucket of wires and screws unless someone tells it that it's a bucket of wires and screws? On Tuesday 07 November 2006 09:35, [EMAIL PROTECTED] wrote: > Hi all, > > I'm trying to write a GUI that will put up > multiple widgets in succession. My problem is > that each widget also contains the previous > widgets when they pop up. How do I reinitialize > the widget each time so that it doesn't contain > earlier ones? Actually, another question I have > is, is there a way to set python so that it > will assume any undefined variable is 0 or ''? > That is, I have several statements like "If k > > 0 then so and so" and I would like it to assume > k=0 unless I tell it otherwise. I've just been > defining k=0 at the start of the program but it > seems there should be a better way. > > Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Tkinter problem
Here's my Tkinter class: class TwoChoice: def __init__(self, master): frame = Frame(master) frame.pack() m = Label(root, text= maentry) m.pack() n = Label(root, text= fave) n.pack() self.button = Button(frame, text=home_team, command= self.comm_1) self.button.pack(side=LEFT) self.hi_there = Button(frame, text=vis_team, command=self.comm_2) self.hi_there.pack(side=LEFT) def comm_1(self): print home_team root.quit() def comm_2(self): print vis_team root.quit() I call it by root = Tk() gui= TwoChoice(root) root.mainloop() The next time I call it I want to just run the same thing but with different values for the variables. Instead it gives me like two copies of the widget. Greg Neil Cerutti wrote: > On 2006-11-07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I'm trying to write a GUI that will put up multiple widgets in > > succession. My problem is that each widget also contains the > > previous widgets when they pop up. How do I reinitialize the > > widget each time so that it doesn't contain earlier ones? > > Show your code. > > > Actually, another question I have is, is there a way to set > > python so that it will assume any undefined variable is 0 or > > ''? That is, I have several statements like "If k > 0 then so > > and so" and I would like it to assume k=0 unless I tell it > > otherwise. I've just been defining k=0 at the start of the > > program but it seems there should be a better way. > > The best way to do it is to never use undefined names. > > -- > Neil Cerutti > If only faces could talk. --Pat Summerall -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Tkinter problem
On 2006-11-07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm trying to write a GUI that will put up multiple widgets in > succession. My problem is that each widget also contains the > previous widgets when they pop up. How do I reinitialize the > widget each time so that it doesn't contain earlier ones? Show your code. > Actually, another question I have is, is there a way to set > python so that it will assume any undefined variable is 0 or > ''? That is, I have several statements like "If k > 0 then so > and so" and I would like it to assume k=0 unless I tell it > otherwise. I've just been defining k=0 at the start of the > program but it seems there should be a better way. The best way to do it is to never use undefined names. -- Neil Cerutti If only faces could talk. --Pat Summerall -- http://mail.python.org/mailman/listinfo/python-list
Simple Tkinter problem
Hi all, I'm trying to write a GUI that will put up multiple widgets in succession. My problem is that each widget also contains the previous widgets when they pop up. How do I reinitialize the widget each time so that it doesn't contain earlier ones? Actually, another question I have is, is there a way to set python so that it will assume any undefined variable is 0 or ''? That is, I have several statements like "If k > 0 then so and so" and I would like it to assume k=0 unless I tell it otherwise. I've just been defining k=0 at the start of the program but it seems there should be a better way. Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Simon Forman <[EMAIL PROTECTED]> wrote: > Just an idea, but if you're sure that > /usr/lib/python2.4/lib-dynload/_tkinter.so exists, check it's > permissions and the permissions of /usr/lib/python2.4/lib-dynload/ Also run ldd on it - you could be missing a library eg $ ldd /usr/lib/python2.4/lib-dynload/_tkinter.so linux-gate.so.1 => (0xe000) libBLT.2.4.so.8.4 => /usr/lib/libBLT.2.4.so.8.4 (0xb7e8) libtk8.4.so.0 => /usr/lib/libtk8.4.so.0 (0xb7dab000) libtcl8.4.so.0 => /usr/lib/libtcl8.4.so.0 (0xb7cfc000) libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0xb7c31000) libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7c1e000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ae6000) libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7ac) libnsl.so.1 => /lib/tls/i686/cmov/libnsl.so.1 (0xb7aa9000) libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7aa5000) /lib/ld-linux.so.2 (0x8000) If there are any missing things then you need to re-install those packages. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Jim Anderson wrote: > I'm running Kubuntu a derivative of Debian Linux. I'm using > Python 2.4 and tcl/tk 8.4. I'm running Tkinter programs and > they were running about a month ago. When I tried them again > yesterday, I got the following message: > > > python ~/prog/python/iodef/iodef.py > > Traceback (most recent call last): > > File "/home/jja/prog/python/iodef/iodef.py", line 10, in ? > > import pkgview > > File "/home/jja/prog/python/iodef/lib/pkgview.py", line 3, in ? > > from Tkinter import * > > File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 38, in ? > > import _tkinter # If this fails your Python may not be configured > > for Tk > > ImportError: /usr/lib/python2.4/lib-dynload/_tkinter.so: cannot open > > > shared object file: No such file or directory > > My environment varibles, like PTYHONPATH and TK_LIBRIARY all look > correct and the tcl/tk and python librarys are all still in place. > There is a file '/usr/lib/python2.4/lib-dynload/_tkinter.so'. I'm > not sure if this is the file not being found, but that is what is > sounds like. > > I did a search on this on the web and got some hits, but none of them > provide a solution to my problem. > > Can anyone help with this problem? > > Jim Anderson Just an idea, but if you're sure that /usr/lib/python2.4/lib-dynload/_tkinter.so exists, check it's permissions and the permissions of /usr/lib/python2.4/lib-dynload/ HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Tkinter problem
I'm running Kubuntu a derivative of Debian Linux. I'm using Python 2.4 and tcl/tk 8.4. I'm running Tkinter programs and they were running about a month ago. When I tried them again yesterday, I got the following message: > python ~/prog/python/iodef/iodef.py > Traceback (most recent call last): > File "/home/jja/prog/python/iodef/iodef.py", line 10, in ? > import pkgview > File "/home/jja/prog/python/iodef/lib/pkgview.py", line 3, in ? > from Tkinter import * > File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 38, in ? > import _tkinter # If this fails your Python may not be configured > for Tk > ImportError: /usr/lib/python2.4/lib-dynload/_tkinter.so: cannot open > > shared object file: No such file or directory My environment varibles, like PTYHONPATH and TK_LIBRIARY all look correct and the tcl/tk and python librarys are all still in place. There is a file '/usr/lib/python2.4/lib-dynload/_tkinter.so'. I'm not sure if this is the file not being found, but that is what is sounds like. I did a search on this on the web and got some hits, but none of them provide a solution to my problem. Can anyone help with this problem? Jim Anderson -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem on Mac OS X
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Andrew Trevorrow) wrote: > Our app uses embedded Python to allow users to run arbitrary scripts. > Scripts that import Tkinter run fine on Windows, but on Mac OS X there > is a serious problem. After a script does "root = Tk()" our app's menus > are permanently changed in the following way: > > - The top item in the application menu changes to "About Tcl & Tk...". > - The Quit item is disabled. > - The File and Edit menus are completely replaced. > - All further menus (except Help) are removed. > > Is there a way to prevent Tkinter clobbering our app's menus? > Or perhaps a way to restore them after the root.mainloop() call? > > I've read Fredrik Lundh's excellent tutorial on Tkinter and done a lot > of googling but haven't been able to find a solution. > > I can probably add some Mac-specific code to detect a menu change after > a script ends and then rebuild our menus, but I'm hoping there's a > simpler Tkinter (or Tcl?) solution. I am pretty sure it's the underlying Tcl/Tk that's causing you grief. Does your application itself use Tcl/Tk anywhere? I'm guessing not, as I'd expect you'd already have gone to some trouble to get the menus right. Unfortunately, I can't offer a solution. You may want to post to the Tkinter mailing list (via news you can use gmane, group gmane.comp.python.tkinter; I'm not sure if you have to sign up for the list before posting). You could import Tcl/Tk yourself "up front" and then fix your application's menus once. But Aqua Tcl/Tk is painfully slow to start up, so this could really slow down startup of your own application. (Note that you'd have to be prepared for Tkinter to be missing (it certainly is by default on 10.3). You might also have to make users use one mainloop (see next paragraph) for this to work. James Stroud also brings up an interesting point--that it could be dangerous if there are multiple scripts each trying to run their own mainloop. But if only one runs at a time, and cleans up after itself, you're probably OK. If that's not the case, you may want to start a Tk main loop yourself and ask users to use that loop. Again, though--it'll take time, and it'll only help those users who use Tkinter in their scripts. -- Russell -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem on Mac OS X
Andrew Trevorrow wrote: > Our app uses embedded Python to allow users to run arbitrary scripts. > Scripts that import Tkinter run fine on Windows, but on Mac OS X there > is a serious problem. After a script does "root = Tk()" our app's menus > are permanently changed in the following way: > > - The top item in the application menu changes to "About Tcl & Tk...". > - The Quit item is disabled. > - The File and Edit menus are completely replaced. > - All further menus (except Help) are removed. > > Is there a way to prevent Tkinter clobbering our app's menus? > Or perhaps a way to restore them after the root.mainloop() call? > > I've read Fredrik Lundh's excellent tutorial on Tkinter and done a lot > of googling but haven't been able to find a solution. > > I can probably add some Mac-specific code to detect a menu change after > a script ends and then rebuild our menus, but I'm hoping there's a > simpler Tkinter (or Tcl?) solution. > > Andrew This menu mashing is a problem. This really has nothing to do with programing in Tcl, Tk, Python, or Tkinter. First of all, the "About Tcl & Tk" is hard-wired during the build of Aqua Tk. To fix this will require downloading the sources and building your own Aqua Tk from scratch: http://tcltkaqua.sourceforge.net/8.4.10/ Alternatively, you can res-edit the appropriate files. The "About Tcl & Tk" menu item is held in an rsrc file. I forget exactly where, but I can take a look on my ibook if you are interested in this route. To do this, you will want a working copy of resknife. I had some trouble with it, so I had to build it for my ibook with xcode--IIRC, the build I downloaded had problems saving. Getting the source and building on my computer fixed it. Its a great program. I'm guessing the best way to get around destroying your menus is to intercept calls to Tk(). I've had bad luck with multiple Tk() instances running in the same session (this is the case with EVERY implementation of Tkinter I've seen, Linux, Mac, etc.). StringVar and IntVar instances get very screwy with multiple Tk()s. You might want to re-define Tk() to return the root instance created by your program. Also, knew Toplevel()s will have their own menus, resulting in your application's menus becoming replaced while the Toplevel() is in the foreground, that's just how Aqua Tk works. This may be something you have to live with if you want your students (I'm guessing) to learn about python in your environment. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list
Tkinter problem on Mac OS X
Our app uses embedded Python to allow users to run arbitrary scripts. Scripts that import Tkinter run fine on Windows, but on Mac OS X there is a serious problem. After a script does "root = Tk()" our app's menus are permanently changed in the following way: - The top item in the application menu changes to "About Tcl & Tk...". - The Quit item is disabled. - The File and Edit menus are completely replaced. - All further menus (except Help) are removed. Is there a way to prevent Tkinter clobbering our app's menus? Or perhaps a way to restore them after the root.mainloop() call? I've read Fredrik Lundh's excellent tutorial on Tkinter and done a lot of googling but haven't been able to find a solution. I can probably add some Mac-specific code to detect a menu change after a script ends and then rebuild our menus, but I'm hoping there's a simpler Tkinter (or Tcl?) solution. Andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: TKinter problem
C D Wood wrote: > To whom this may concern, > Below is the source code, which > > demonstrates a > problem I am having making a GUI for my python project work. > 'table.txt' > is a file that is read from the same folder. > > My code writes to a text file 'table.txt', and 'table.txt' is displayed > in > the GUI. The user can generate new data at the click of a button > which re-writes 'table.txt', but I can only add the new table to the > GUI > window rather than 'update' the existing one. > > Any assistance would be much appreciated, > > Regards, > Christian Wood. > Part III Aerospace Engineering > University of Southampton, UK. > > ## > from Tkinter import * > > #Tkinter User Interface > class MoC: > def __init__(self, master): > frame = Frame(master, width=600, height=800, bd=1) > frame.pack() > > #Button frame > iframe4 = Frame(frame, bd=2, relief=SUNKEN) > #Using this button below, I want to update the text box in iframe5. > Button(iframe4, text='Display table.txt', > command=self.DisplayUpdate).pack(side=LEFT, padx=5) > Button(iframe4, text='Quit', command=self.quit).pack(side=LEFT, > padx=5) > iframe4.pack(expand=1, fill=X, pady=10, padx=5) > > #Text box frame > iframe5 = Frame(frame, bd=2, relief=SUNKEN) > text=Text(iframe5, height=10, width =70) > fd = open('table.txt') #table.txt must be in the same folder > lines = fd.read() > fd.close() > text.insert(END, lines) > text.pack(side=LEFT, fill=X, padx=5) > sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) > sb.pack(side=RIGHT, fill=Y) > text.configure(yscrollcommand=sb.set) > iframe5.pack(expand=1, fill=X, pady=10, padx=5) > > #Command definitions > def quit(self): > root.destroy() > > def DisplayUpdate(self): #The command definition used to update the > display. > #Could I insert a line here to remove the existing frame/text > box first? <= > iframe5 = Frame(root, bd=2, relief=SUNKEN) > text = Text(iframe5, height=10, width =70) > fd = open('table.txt') > lines = fd.read() > fd.close() > text.insert(END, lines) > text.pack(side=LEFT, fill=X, padx=5) > sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) > sb.pack(side=RIGHT, fill=Y) > text.configure(yscrollcommand=sb.set) > iframe5.pack(expand=1, fill=X, pady=10, padx=5) > > root = Tk() > root.option_add('*font', ('arial', 10)) > all = MoC(root) > root.title('2D Method of Characteristics') > root.update > root.mainloop() What you want probably looks like this: from Tkinter import * class MoC: def __init__(self, master): frame = Frame(master, width=600, height=800, bd=1) frame.pack() iframe4 = Frame(frame, bd=2, relief=SUNKEN) Button(iframe4, text='Display table.txt', command=self.DisplayUpdate).pack(side=LEFT, padx=5) Button(iframe4, text='Quit', command=self._quit).pack(side=LEFT, padx=5) iframe4.pack(expand=1, fill=X, pady=10, padx=5) iframe5 = Frame(frame, bd=2, relief=SUNKEN) self.text=Text(iframe5, height=10, width =70) # read the file in the update function; create Text & Scrollbar only once self.text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=self.text.yview) sb.pack(side=RIGHT, fill=Y) self.text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) self.DisplayUpdate() def _quit(self): # quit is a keyword in python 2.4 IDE root.destroy() def DisplayUpdate(self): fd = open('table.txt') lines = fd.read() fd.close() self.text.config(state=NORMAL) self.text.delete(1.0, END) self.text.insert(END, lines) self.text.config(state=DISABLED) # previous 4 lines are to make the text READONLY, see more in: # http://www.pythonware.com/library/tkinter/introduction/x8309-patterns.htm root = Tk() root.option_add('*font', ('arial', 10)) all = MoC(root) root.title('2D Method of Characteristics') root.update root.mainloop() ezd -- http://mail.python.org/mailman/listinfo/python-list
TKinter problem
To whom this may concern, Below is the source code, which demonstrates a problem I am having making a GUI for my python project work. 'table.txt' is a file that is read from the same folder. My code writes to a text file 'table.txt', and 'table.txt' is displayed in the GUI. The user can generate new data at the click of a button which re-writes 'table.txt', but I can only add the new table to the GUI window rather than 'update' the existing one. Any assistance would be much appreciated, Regards, Christian Wood. Part III Aerospace Engineering University of Southampton, UK. ## from Tkinter import * #Tkinter User Interface class MoC: def __init__(self, master): frame = Frame(master, width=600, height=800, bd=1) frame.pack() #Button frame iframe4 = Frame(frame, bd=2, relief=SUNKEN) #Using this button below, I want to update the text box in iframe5. Button(iframe4, text='Display table.txt', command=self.DisplayUpdate).pack(side=LEFT, padx=5) Button(iframe4, text='Quit', command=self.quit).pack(side=LEFT, padx=5) iframe4.pack(expand=1, fill=X, pady=10, padx=5) #Text box frame iframe5 = Frame(frame, bd=2, relief=SUNKEN) text=Text(iframe5, height=10, width =70) fd = open('table.txt') #table.txt must be in the same folder lines = fd.read() fd.close() text.insert(END, lines) text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) sb.pack(side=RIGHT, fill=Y) text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) #Command definitions def quit(self): root.destroy() def DisplayUpdate(self): #The command definition used to update the display. #Could I insert a line here to remove the existing frame/text box first? <= iframe5 = Frame(root, bd=2, relief=SUNKEN) text = Text(iframe5, height=10, width =70) fd = open('table.txt') lines = fd.read() fd.close() text.insert(END, lines) text.pack(side=LEFT, fill=X, padx=5) sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview) sb.pack(side=RIGHT, fill=Y) text.configure(yscrollcommand=sb.set) iframe5.pack(expand=1, fill=X, pady=10, padx=5) root = Tk() root.option_add('*font', ('arial', 10)) all = MoC(root) root.title('2D Method of Characteristics') root.update root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Thanks! At this moment I can see the first python generated Tk window on my screen. It's great ;-))) -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
On Mon, Oct 31, 2005 at 03:17:05PM -0800, dale cooper wrote: > Thanks, but I've got another question: > > can't find Tcl configuration script "tclConfig.sh" This file comes from the following package: $ rpm -qf /usr/lib*/tclConfig.sh tcl-devel-8.4.9-3 Fedora generally splits packages which are libraries into "foo" and "foo-devel" (and maybe others). Jeff pgpNF5sPkcOqr.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
Thanks, but I've got another question: can't find Tcl configuration script "tclConfig.sh" This is what I received trying to install TkBLT. What is tclConfig.sh? I did installed tcl/tk 8.4.9-3 as I mentioned before, I tried to find this file, but I don't have it in my filesystem. How to get it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter problem
"dale cooper" wrote: > I've recently installed python2.4.2 on Fedora 4 (from downloaded > sources), but it appeared, that I can't use Tkinter module: > import Tkinter > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 38, in ? >import _tkinter # If this fails your Python may not be configured > for Tk > ImportError: libBLT24.so: cannot open shared object file: No such file > or directory this seems to indicate that the build process picked up the Tk BLT extension [1], but that you haven't installed that extension properly. 1) http://sourceforge.net/projects/blt/ -- http://mail.python.org/mailman/listinfo/python-list
Tkinter problem
Hi everybody! I've recently installed python2.4.2 on Fedora 4 (from downloaded sources), but it appeared, that I can't use Tkinter module: >>> import Tkinter Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 38, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: libBLT24.so: cannot open shared object file: No such file or directory I tried the solution given in README file for RH9 (./configure --enable-unicode=ucs4) despite they wrote the newer wersion didn't need this hack. This is what I had after make instruction: INFO: Can't locate Tcl/Tk libs and/or headers *** WARNING: renaming "array" since importing it failed: build/lib.linux-i686-2.4/array.so: undefined symbol: PyUnicodeUCS2_FromUnicode *** WARNING: renaming "_testcapi" since importing it failed: build/lib.linux-i686-2.4/_testcapi.so: undefined symbol: PyUnicodeUCS2_Decode *** WARNING: renaming "unicodedata" since importing it failed: build/lib.linux-i686-2.4/unicodedata.so: undefined symbol: PyUnicodeUCS2_FromUnicode *** WARNING: renaming "_locale" since importing it failed: build/lib.linux-i686-2.4/_locale.so: undefined symbol: PyUnicodeUCS2_AsWideChar *** WARNING: renaming "cPickle" since importing it failed: build/lib.linux-i686-2.4/cPickle.so: undefined symbol: PyUnicodeUCS2_AsUTF8String *** WARNING: renaming "pyexpat" since importing it failed: build/lib.linux-i686-2.4/pyexpat.so: undefined symbol: PyUnicodeUCS2_DecodeUTF8 *** WARNING: renaming "_multibytecodec" since importing it failed: build/lib.linux-i686-2.4/_multibytecodec.so: undefined symbol: PyUnicodeUCS2_FromUnicode running build_scripts It seems that --enable-unicode=ucs4 wasn't the right way. I tried another hack: ./configure --enable-shared, but it still couldn't locate Tcl/Tk libs and/or headers. Then I installed RPMs: [EMAIL PROTECTED] Python-2.4.2]# rpm -q tk tk-8.4.9-3 [EMAIL PROTECTED] Python-2.4.2]# rpm -q tcl tcl-8.4.9-3 [EMAIL PROTECTED] Python-2.4.2]# rpm -q tkinter tkinter-2.4.1-2 and tried to do the hacks above, but it still could'nt find these libs. What can I do? -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tkinter] problem
These lines > if __name__ == '__main__': > OptionsWindow() mean "if this source code is the main program (not an imported module), call OptionsWindow()". So the behavior should be different when the source code is the main program ('python opt_newlogin.py') and when it's imported ('python -c "import opt_newlogin"') Jeff pgpCSdrstdRnI.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
[Tkinter] problem
when i start opt_newlogin.py directly it works fine(outputs '1 1 1 1'), but if i start it from options.py there is an error(outputs ''). opt_newlogin.py from config import * from Tkinter import * from opt_newlogin import newlogin def OptionsWindow(): """ """ root = Tk() root.title(msg_OptionsWindowTitle) b1 = Button(root, text = msgForgotPassword, width = 40).grid(padx = 5, pady = 5, column = 0, row = 0) b2 = Button(root, text = msgNewLogin, command = newlogin, width = 40).grid(padx = 5, pady = 5, column = 0, row = 1) root.mainloop() if __name__ == '__main__': OptionsWindow() options.py from config import * from Tkinter import * import tkMessageBox, os.path def create_new_account(login, password, secretq, secreta): print login, password, secretq, secreta if os.path.exists(os.path.join(data_path, login)): tkMessageBox.showerror(title = msgError, message = msgPasswordLoginExists) elif login == '': pass else: os.mkdir(os.path.join(data_path, login)) fd = file(os.path.join(data_path, login, data_info_file_name), 'wb') fd.write(password + os.linesep) fd.write(secretq + os.linesep) fd.write(secreta + os.linesep) fd.close() tkMessageBox.showinfo(title = msgInfoAccountCreated, message = msgInfoAccountCreated2) def newlogin(): """ """ root = Tk() root.title(msg_NewLoginWindowTitle) l1 = Label(root, text = msgLogin).grid(padx = 5, pady = 5, column = 0, row = 0, sticky = E) l2 = Label(root, text = msgPassword).grid(padx = 5, pady = 5, column = 0, row = 1, sticky = E) l3 = Label(root, text = msgConfirmPassword).grid(padx = 5, pady = 5, column = 0, row = 2, sticky = E) l4 = Message(root, text = msgKeyQuestion, width = 250).grid(padx = 5, pady = 5, column = 0, row = 3, sticky = E) l5 = Label(root, text = msgKeyQuestionAnswer).grid(padx = 5, pady = 5, column = 0, row = 4, sticky = E) v1 = StringVar() v2 = StringVar() v3 = StringVar() v4 = StringVar() v5 = StringVar() e1 = Entry(root, width = 50, textvariable = v1) e1.grid(padx = 5, pady = 5, column = 1, row = 0) e1.focus_force() e2 = Entry(root, width = 50, textvariable = v2, show = '*') e2.grid(padx = 5, pady = 5, column = 1, row = 1) e3 = Entry(root, width = 50, textvariable = v3, show = '*') e3.grid(padx = 5, pady = 5, column = 1, row = 2) e4 = Entry(root, width = 50, textvariable = v4) e4.grid(padx = 5, pady = 5, column = 1, row = 3) e5 = Entry(root, width = 50, textvariable = v5, show = '*') e5.grid(padx = 5, pady = 5, column = 1, row = 4) def b1_cmd(): if v2.get() <> v3.get(): tkMessageBox.showerror(title = msgError, message = msgPasswordConfirmError) print v1.get(), v2.get(), v4.get(), v5.get() create_new_account(v1.get(), v2.get(), v4.get(), v5.get()) b1 = Button(root, text = msgCreateNewLoginButton, command = b1_cmd).grid(padx = 5, pady = 5, column = 0, row = 5) b2 = Button(root, text = msgCancelButton, command = root.destroy).grid(padx = 5, pady = 5, column = 1, row = 5) root.mainloop() if __name__ == '__main__': newlogin() config.py # codepage = cp1251 # # # def u(s): return unicode(s, 'cp1251') msgMainWindowTitle = u('Менеджер сохранялок клуба B 4\\2') msgLogin= u('Логин') msgPassword = u('Пароль') msgGameNumber = u('Номер игры') msgSaveButton = u(' Сохранить ') msgLoadButton = u(' Загрузить ') msgOptionsButton= u(' Дополнительно ') msg_OptionsWindowTitle = u('Дополнительно') msgForgotPassword = u(' Забыл пароль ') msgNewLogin = u(' Новый логин ') msg_NewLoginWindowTitle = u('Создание нового логина') msgConfirmPassword = u('Еще раз пароль') msgKeyQuestion = u('Секретный вопрос - ответ на который знаете только вы - на случай, если вы забудете пароль') msgKeyQuestionAnswer= u('Ответ на секретный вопрос') msgCreateNewLoginButton = u(' Создать ') msgCancelButton = u(' Отмена ') msgError= u('Ошибка') msgPasswordConfirmError = u('Пароли не совпадают.') msgPasswordLoginExists = u('Такой логин уже существует.') msgInfoAccountCreated = u('Логин успешно зарегестрирован') msgInfoAccountCreated2 = u('Вы можете использовать этот логин и пароль для сохранения и востановления своих сохранялок.') msgInvalidGameNumber= u('Неправильный номер игры.') msgInvalidPassword = u('Неправильный пароль.') msgInvalidLogin = u('Логин не существует.') msgSave
Re: Socket and Tkinter Problem
hi, was wondering if you ever got a reply ? Did you mannage to sort this out ? I am wanting todo the same thing - just have a window that connects to a port and displays the data it receives from that port in the window? Thanks Tonino -- http://mail.python.org/mailman/listinfo/python-list