473,378 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

tkinter canvas bitmaps w/ xbm formated string data?

I'm trying to load a xbm formatted string as a bitmap and draw it to a
canvas....I don't have any trouble with loading/displaying xbm files,
it's when I've pre-created the xbm as a string I get a 'can't find
your bitmap error'

<created my canvas and I draw other objects that are displayed
correctly>

xbm_string = "#define arrow_width 1 #define arrow_height 16 static
char arrow_bits[] = {
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01
};"

a_bitmap = Tkinter.BitmapImage(data=xbm_string)

print a_bitmap.width() #prints out 1
print a_bitmap.height() #print out 16

canvas.create_bitmap(100,100, bitmap=a_bitmap) #if I used
bitmap="@line.xbm" with the exact same string as defined above, the
xbm is displayed correctly.
When the create_bitmap executes I get:
File "C:\June 5th datamaster\colorlabel.py", line 360, in
_createtext
self.canvas.create_bitmap(100,100, bitmap=a_bitmap)
File "<string>", line 1, in create_bitmap
File "C:\Python23\lib\lib-tk\Tkinter.py", line 2057, in
create_bitmap
return self._create('bitmap', args, kw)
File "C:\Python23\lib\lib-tk\Tkinter.py", line 2049, in _create
return getint(self.tk.call(
TclError: bitmap "pyimage1" not defined

....I have a feeling that I somehow lost a reference to my bitmap
object...I'm not sure what's happening.

any ideas what could be wrong?

Brett
Jul 18 '05 #1
1 3627
Brett wrote:
I'm trying to load a xbm formatted string as a bitmap and draw it to a
canvas....I don't have any trouble with loading/displaying xbm files,
it's when I've pre-created the xbm as a string I get a 'can't find
your bitmap error' ...I have a feeling that I somehow lost a reference to my bitmap
object...I'm not sure what's happening.

any ideas what could be wrong?
No, but

canvas.create_image(100, 100, image=a_bitmap)

instead of
canvas.create_bitmap(100,100, bitmap=a_bitmap) #if I used


seems to work.

Peter

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Otten | last post by:
Before I start moving them into dark corners of the canvas - is there a way to hide/show Tkinter canvas items without having to maintain their original position externally? All I've found so far is...
1
by: Elaine Jackson | last post by:
Newbie. Playing with the 'turtle' module and wondering if there's a way to save the graphics you make with it. The documentation itself has nothing to say about this, nor (as far as I can tell)...
1
by: Erik Johnson | last post by:
I want to draw some simple (dynamic) graphs and get these saved as a JPEG file to reference in a web link. I am aware of PIL (Python Image Library), but unfortunatley my system does not have it...
0
by: Shi Mu | last post by:
got confused by x, y coordinates in Tkinter canvas. from left to right, does X increase? from top to bottom, does y increase?
3
by: Tuvas | last post by:
I'm trying to display a picture on a Tkinter Canvas. It seems to work fine the first time that it is displayed. However, subsequent times running shows an error like this: TCLerror: Wrong #...
5
by: Dean Allen Provins | last post by:
I need to determine the size of a canvas while the process is running. Does anyone know of a technique that will let me do that? Thanks, Dean
0
by: fxe | last post by:
Hi, I am using tkinter and I have a canvas that with several rectangles drawn on it. The rectangles need to have bindings to move and resize them. No problem here, but I also need to display a...
0
by: WaterWalk | last post by:
Hello. When I tried to make Tkinter canvas widget respond to MouseWheel event on Windows XP, I failed. The canvas just doesn't receive MouseWheel event. I used bind_all to find out which widget...
4
by: skanemupp | last post by:
mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.