Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35549 > unrolled thread

Re: running gui py script

Started byDave Angel <d@davea.name>
First post2012-12-26 18:22 -0500
Last post2012-12-26 18:22 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: running gui py script Dave Angel <d@davea.name> - 2012-12-26 18:22 -0500

#35549 — Re: running gui py script

FromDave Angel <d@davea.name>
Date2012-12-26 18:22 -0500
SubjectRe: running gui py script
Message-ID<mailman.1302.1356564168.29569.python-list@python.org>
On 12/26/2012 03:07 PM, Verde Denim wrote:
> I'm learning py in this environment -
> PyCrust 0.9.5 - The Flakiest Python Shell
> Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
> [GCC 4.4.5] on linux2
>
> When I type a tkinter program in pycrust (or pyshell), it executes as
> expected, but when I call it from a command line, it doesn't. What I'm
> getting back is this -
>
> python my_first_gui_in_py.py
> Traceback (most recent call last):
>   File "my_first_gui_in_py.py", line 2, in <module>
>     class myapp_tk(Tkinter.Tk):
>   File "my_first_gui_in_py.py", line 14, in myapp_tk
>     app = myapp_tk(None)
> NameError: name 'myapp_tk' is not defined
>
> Trying to call the file in pycrust doesn't seem to work for me either.
> If I invoke pycrust either as
> $ pycrust ./my_first_gui_in_py.py or
> $ pycrust < ./my_first_gui_in_py.py
>
> the editor opens, but with an empty buffer.
>
> What is it that I'm not understanding?
Mainly that it helps to actually show your code, or at least as much of
it as you think we might be interested in.
Good job showing us the versions & os, and the full traceback.

No idea why it works in pycrust;  I've never used it, or pyshell.  It's
not clear what you mean by "typing in the shell".  if you mean you're
entering it in the interpreter, then I'd guess you didn't indent it the
same way as in the file.

But if it doesn't work at the command line, it's broken.  And my guess
is that you're trying to use the class inside its own definition. 
That's okay inside a method, but not inside the class initialization.  
For example, if you have

class myapp_tk(Tkinter.Tk):
      app = myapp_tk(None)

it's not valid.  Instead, do the following after the class definition is
complete:

myapp.app = myapp_tk(None)

BTW, it's customary to capitalize the first letter of a class name.

-- 

DaveA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web