Image layering in Tkinter, Python [figured it out (smacks forehead)] - python

I am working with a graphics module called cTurtle, which builds upon TKinter. Each controllable 'Turtle' has an image assigned to it with TKinter. I am trying to add a method to the module that will allow me to change the layering position of a given 'Turtle'. Or to put it another way, i want to add a method that will allow me to put a given image on top of the displaylist. When i call the method i have made, i get this error
Traceback (most recent call last):
File "C:\Documents and Settings\login\Desktop\pYTHON EXPERIMENTS\canvastest.py", line 22, in <module>
bob.visUp()
File "C:\Documents and Settings\login\Desktop\pYTHON EXPERIMENTS\jTurtle.py", line 2017, in visUp
titem = self.turtle._item
File "C:\Documents and Settings\login\Desktop\pYTHON EXPERIMENTS\jTurtle.py", line 542, in _visUp
def _visUp(self, item):
File "<string>", line 1, in type
File "C:\Python32\lib\tkinter\__init__.py", line 2325, in type
return self.tk.call(self._w, 'type', tagOrId) or None
_tkinter.TclError: invalid command name ".16847312"
Does someone recognize why the function is rejecting what i passed to it? The number in quotes appears to be an object id, which should work.
EDIT
well, i did myself a great disservice here by not pasting everything involved. I coded these new methods several days ago, and have been trying to debug since. Turns out i coded them right the first time. The problem was in how i called them. I added the visup() test line after exitOnClick(), meaning that the widget had, in fact, already been destroyed.
But, hey, i coded it right the first time! sorta...

Related

Pyinstaller is not working with pygame, making an NotImplemented Error?

So i have a problem, whenever i try to use Pyinstaller with Pygame, it won't work, instead after a second, it says that it stopped working. I ran a test program before (consisting of a block moving up and down and a block following your cursor) and it worked just fine. However, i tried implementing some text using pygame.font.Font function and suddenly it stopped working. I tried using a try function to see if it could catch it, and nothing. I tried using no font, nothing. This also works as a regular .py file as well, just not as an executable. I'll include further info as needed if need be.
Thanks in advance!
EDIT:i was able to produce an error thanks to kaktus_car letting me know that there was an update to pygame, here it is:
Traceback (Most recent call last):
"test.py", line 20, in <module>
File "site-packages\pygame\pkgdata.py", line 50, in getResource
File "site-packages\pkg_resources\__init__.py", line 1134, in resource_exists
File "site-packages\pkg_resources\__init__.py", line 1404, in has_resource
File "site-packages\pkg_resources\__init__.py", line 1472, in _has
NotImplementedError: Can't perform this operation for unregistered loader type
[1276] Failed to execute script test
So, i managed to figure it out! What i did was i instaed used a different application than pyinstaller. Instead, i used cx_Freeze. If you are having this kind of problem as well, the link is Here the directions are rather clear and you have the option to include files, so if you have a game with made graphics, it can include them.

Spyder Trace Debugging - Python

I am having a weird situation where the trace for an AttributeError keeps referencing the exact same absolute line number in my code.
Traceback (most recent call last):
File "<ipython-input-59-513669e63f3e>", line 4, in <module>
"line of code being run"
File "modulepath", line 148, in "method that contains the line of code"
"content of the line causing the error"
AttributeError: 'list' object has no attribute 'attribute_name'
If I make line 148 empty (by putting in new lines, etc.) or if I put a comment on line 148, the trace keeps pointing to line 148 as the source of the error.
I am having trouble debugging this particular error in general since I am (to the best of my knowledge) not using that particular attribute on any list object in my code (but it seems to indicate that I'm doing so). I will figure out that issue on my own. My main question is: what causes Spyder to repeatedly reference the exact same absolute line number in a traceback? Thank you.
When in doubt, use a fresh new console - that worked for me.

LCDproc screen timeout

I am having an issue with LCDproc, using the python package here http://pydoc.net/Python/lcdproc/0.03/lcdproc.server/
Quick background - I am parsing airplay metadata from a pipe and displaying it on an lcd screen as a part of a Raspberry Pi music player project.
I'd like to display a screen when the user changes the playback volume. I thought the way to do this was to add a new screen and set a timeout. This works the first time, and subsequently causes an error:
Traceback (most recent call last):
File "./lcdtunes.py", line 194, in <module>
main()
File "./lcdtunes.py", line 147, in main
vol_screen.set_heartbeat("off")
AttributeError: 'NoneType' object has no attribute 'set_heartbeat'
The script is available here: https://github.com/john-a-harris/lcdtunes/blob/master/lcdtunes.py
I am no coder, as will be obvious, but I think that the error means that the screen I think I am adding in line 146 doesn't actually exist.
My question is why - what am I doing wrong here?
Is there another way to achieve this or am I missing something blindingly obvious?
Please be gentle with me - this is my first question!

Python: AttributeError: 'str' object has no attribute 'decompressUnknownOriginalSize'

First off, I'm not a programmer by any means. I just try to follow instructions.
So, I'm trying to use a script to decode game files. The problem is that I'm getting an error.
I've tried the script on 2 different machines wheres both give the same error. At the same time, I have friends using the exact same script w/o getting this error. Does anyone have any clue what is wrong?
Traceback (most recent call last):
File "F:\Frostbite Decoding\Decoding Files\bf4dumper.py", line 258, in <module>
if "tocRoot" in locals(): dumpRoot(tocRoot)
File "F:\Frostbite Decoding\Decoding Files\bf4dumper.py", line 249, in dumpRoot
dump(fname,targetDirectory)
File "F:\Frostbite Decoding\Decoding Files\bf4dumper.py", line 198, in dump
LZ77.decompressUnknownOriginalSize(catEntry.path,catEntry.offset,catEntry.size,targetPath)
AttributeError: 'str' object has no attribute 'decompressUnknownOriginalSize'
If you need anymore information, please let me know.
Python is saying that it is receiving a string and that there is no method for decompressUnknownOriginalSize. This sounds like the script needs to get some other data type or argument type than string. Look for where "decompressUnknownOriginalSize" is called and see what data type is being passed to that argument.

Using Ladon in Python 2.6 on windows

I have been trying to create a web service out some python scripts, and haven't seemed to have had much luck. I am new to web services in general, but would really like to get this figured out. I'm on Windows 7 and use IIS7. The service also needs to be SOAP.
I've read through most posts that have anything to do with python and SOAP and tried out pretty much all the different libraries, but most of them just seem over my head (especially ZSI/SOAPpy). The Ladon Library seems like it would be best (and simplest) for what I need, but the tutorial http://www.youtube.com/watch?v=D_JYjEBedk4&feature=feedlik loses me at 5:10 when he brings it to the server. When I type the ladon2.6ctl in the cmd, it seems like windows gets quite confused. I'm guessing it is a little different because he is running on Linux and using Apache.
With that, any tips on how to get a python web service running on Microsoft 'stuff' would be greatly appreciated, as I have been trying to figure this stuff out for way too long.
One thing to note is the reason things are so specific (and seemingly strange) is because the scripts I have do a lot of geoprocessing with ESRI's "arcpy".
--Addition--
Traceback on localhost:8080/TestService:
Traceback (most recent call last):
<br>File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\server\wsgi_application.py", line 229, in __call__
exec("import %s" % ','.join(self.service_list))
File "<string>", line 1, in <module>
File "c:\Users\r\workspace\ladon\src\testspace.py", line 3, in <module>
class TestService2(object):
File "c:\Users\r\workspace\ladon\src\testspace.py", line 4, in TestService2
#ladonize(int,int,rtype=int)
File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\decorator.py", line 87, in decorator
ladon_method_info = global_service_collection().add_service_method(f,*def_args,**def_kw)
File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\collection.py", line 119, in add_service_method
sinfo = self.source_info(src_fname)
File "c:\Python26\ArcGIS10.0\lib\site-packages\ladon-0.5.1-py2.6.egg\ladon\ladonizer\collection.py", line 79, in source_info
a = ast.parse(src)
File "c:\Python26\ArcGIS10.0\lib\ast.py", line 37, in parse
return compile(expr, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
from ladon.ladonizer import ladonize
^
SyntaxError: invalid syntax
sample code:
from ladon.ladonizer import ladonize
class TestService2(object):
#ladonize(int,int,rtype=int)
def sum(self,a,b):
'''add two numbers<br>
param a: number 1
param b: number 2
rtype: sum of result
'''
return a+b
I must admit I normally use Linux for almost everything and I haven't tried Ladon on Windows for a while. I will spin up my windows installation later today and see if there is any trouble.
You wrote that ladon2.6ctl get's confused. Do you have an exception Traceback?
To summarize the fix for anyone else interested, delete the "syslog import" from these 3 ladon modules: ladon/interfaces/jsonwsp.py - line 6
ladon/dispatcher/dispatcher.py - line 7
ladon/server/wsgi_application.py - line 37
Then, you need to change the linefeed from window's default of /r/n to /n. In Eclipse, go to Window -> Preferences -> General, then select (not drop down) the Workspace tab. On the bottom right, select "other" under New text file line delimiter and change it to Unix.

Categories

Resources