473,385 Members | 1,707 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,385 software developers and data experts.

bitmap problem

I'm having trouble with defining a completely transparent bitmap
for use as a stipple in a canvas
import Tkinter
Tkinter._default_root.tk.call('image','create', 'bitmap', 'gray0',
'-background', '',
'-data', '#define gray0_width 1\n#define gray0_height 1\nstatic char
gray0_bits[] = {\n0x0\n};')
print 'image names', self.tk.call('image','names')
print 'image type', self.tk.call('image','type','gray0')
self.canv.create_rectangle("10i", "10i", "13.5i", "13.5i",
fill="blue",activestipple='gray0')
the prints seem to indicate that the bitmap is defined, but the canvas
create_rectangle fails

image names gray0
image type bitmap
Traceback (most recent call last):
File "C:\Tmp\test.py", line 67, in <module>
main()
File "C:\Tmp\test.py", line 62, in main
top = PDFMU()
File "C:\Tmp\test.py", line 59, in __init__
self.createWidgets()
File "C:\Tmp\test.py", line 44, in createWidgets
self.canv.create_rectangle("10i", "10i", "13.5i", "13.5i",
fill="blue",activestipple='gray0')
File "C:\Python\lib\lib-tk\Tkinter.py", line 2166, in create_rectangle
return self._create('rectangle', args, kw)
File "C:\Python\lib\lib-tk\Tkinter.py", line 2145, in _create
*(args + self._options(cnf, kw))))
_tkinter.TclError: bitmap "gray0" not defined

if I change gray0 to one of the predefined names eg gray12 then the
create_rectangle succeeds. The tk manual seems to suggest I should be
able to do this, but it doesn't seem to work even in tk. Is there a way
to define a stipple without a file?
--
Robin Becker
Jan 20 '08 #1
1 2140
Robin Becker wrote:
I'm having trouble with defining a completely transparent bitmap
for use as a stipple in a canvas

........
after a bit of searching I find that stipples cannot be created with the
tk image command; for non-standard stipples you need to use a file.
--
Robin Becker
Jan 20 '08 #2

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

Similar topics

3
by: instruo | last post by:
I'm using the System.Drawing.Bitmap class for loading a 32-bit bmp file which includes an alpha channel. The problem is, when it gets loaded (just using the Bitmap(string filename) constructor),...
2
by: Sharon | last post by:
I encountered a strange behavior when doing ‘new Bitmap’: The following code works fine and the given bitmap file is shown on the PictureBox (the m_DrawArea) in the correct bitmap sizes: ...
4
by: vbdotnetmania | last post by:
I have the following snippet of code with bm being a succesfully stored bitmap (not including all the code just the relevant bits) Dim g As Graphics Dim g2 As Graphics Dim bm As Bitmap Dim bm2...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
15
by: Hamed | last post by:
Have I posted the message to wrong newsgroup? Or Does the question is so much strage? Would someone please kindly direct me to a true newsgroup or resource? Best Regards Hamed
2
by: =?Utf-8?B?VGhlTWFkSGF0dGVy?= | last post by:
I dont know if I missed something in documentation, but I was having a problem with "Bitmap.LockBits" and was wondering if anyone else has discovered it too. According to everyones examples...
8
by: Joergen Bech | last post by:
Suppose I have Dim bm As New Bitmap(16, 16,Imaging.PixelFormat.Format8bppIndexed) I cannot use Dim g As Graphics = Graphics.FromImage(bmdest) Dim hdc As IntPtr = g.GetHdc() as the...
6
by: \Frank\ | last post by:
I trying to learn what a Bitmap is. Not a Managed Bitmap Object but one that, for example, comes from the clipboard with CF_BITMAP. I'm guessing that a CompatableBitmap is an array of indices...
5
by: =?Utf-8?B?QVRU?= | last post by:
I have a bitmap of 100X100. On the load, the bitmap is created by a function (createimage()). On my OnPaint, I draw the image back to the screen (e.Graphics.DrawImage( bitmap, destrect)). Now,...
1
by: =?Utf-8?B?Y3JhbmtlX2JveQ==?= | last post by:
Hi Folks, I'm not sure where this post belongs since I'm using managed vc.net, but the issue is around GDI BitBlt. Here is a summary of the problem: - I am trying to copy a bitmap of my main...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.