Little Black Box.

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))

self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if any(filename.lower().endswith(ext) for ext in (’.png’))])

img = wx.EmptyImage(680,143)

self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img), pos=(0, 0))

def loadImage(self, event):

self.image_file = self.images.next()

print(self.image_file)

image_file = os.path.join(IMAGE_DIR, self.image_file)

img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)

#img = img.Scale(680,143)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

Does anyone know what this could be? It might be the imageCtrl with the bitmap. But I am unsure.

When the image loads the black box is gone. It’s not a big problem really. Just a little annoying.

Thanks

Sion.

Hi Sion,

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))

self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if any(filename.lower().endswith(ext) for ext in (‘.png’))])

img = wx.EmptyImage(680,143)

self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img), pos=(0, 0))

If that’s the only panel in the frame, then don’t bother setting its size. It will automatically fit the frame if you don’t set its size.

def loadImage(self, event):

self.image_file = self.images.next()

print(self.image_file)

image_file = os.path.join(IMAGE_DIR, self.image_file)

img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)

#img = img.Scale(680,143)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

Does anyone know what this could be? It might be the imageCtrl with the bitmap. But I am unsure.

When the image loads the black box is gone. It’s not a big problem really. Just a little annoying.

Thanks

Sion.

You can use the Widget Inspection Tool to help you figure out which widget is which. See the wiki for usage info: http://wiki.wxpython.org/Widget%20Inspection%20Tool

  • Mike
···

On Thursday, February 21, 2013 8:11:47 PM UTC-6, Sion Jones wrote:

Hey Mike.

I have another panel on the frame. And I suspect that I need to set the Size. Otherwise, the image thats loaded won’t load properly. Well it’ll load, but not to the right size.

···

On Friday, February 22, 2013 2:36:43 PM UTC, Mike Driscoll wrote:

Hi Sion,

On Thursday, February 21, 2013 8:11:47 PM UTC-6, Sion Jones wrote:

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))

self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if any(filename.lower().endswith(ext) for ext in (‘.png’))])

img = wx.EmptyImage(680,143)

self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img), pos=(0, 0))

If that’s the only panel in the frame, then don’t bother setting its size. It will automatically fit the frame if you don’t set its size.

def loadImage(self, event):

self.image_file = self.images.next()

print(self.image_file)

image_file = os.path.join(IMAGE_DIR, self.image_file)

img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)

#img = img.Scale(680,143)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

Does anyone know what this could be? It might be the imageCtrl with the bitmap. But I am unsure.

When the image loads the black box is gone. It’s not a big problem really. Just a little annoying.

Thanks

Sion.

You can use the Widget Inspection Tool to help you figure out which widget is which. See the wiki for usage info: http://wiki.wxpython.org/Widget%20Inspection%20Tool

  • Mike

Also, I can’t seem to get the Widget inspector working. It opens then disappears suddenly!

···

On Friday, February 22, 2013 2:36:43 PM UTC, Mike Driscoll wrote:

Hi Sion,

On Thursday, February 21, 2013 8:11:47 PM UTC-6, Sion Jones wrote:

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))

self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if any(filename.lower().endswith(ext) for ext in (‘.png’))])

img = wx.EmptyImage(680,143)

self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.BitmapFromImage(img), pos=(0, 0))

If that’s the only panel in the frame, then don’t bother setting its size. It will automatically fit the frame if you don’t set its size.

def loadImage(self, event):

self.image_file = self.images.next()

print(self.image_file)

image_file = os.path.join(IMAGE_DIR, self.image_file)

img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)

#img = img.Scale(680,143)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

Does anyone know what this could be? It might be the imageCtrl with the bitmap. But I am unsure.

When the image loads the black box is gone. It’s not a big problem really. Just a little annoying.

Thanks

Sion.

You can use the Widget Inspection Tool to help you figure out which widget is which. See the wiki for usage info: http://wiki.wxpython.org/Widget%20Inspection%20Tool

  • Mike

Sion Jones wrote:

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))
self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if
any(filename.lower().endswith(ext) for ext in ('.png'))])
img = wx.EmptyImage(680,143)
self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY,
wx.BitmapFromImage(img), pos=(0, 0))
def loadImage(self, event):
self.image_file = self.images.next()
print(self.image_file)
image_file = os.path.join(IMAGE_DIR, self.image_file)
img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)
#img = img.Scale(680,143)
self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

<https://lh6.googleusercontent.com/-j3SgAle58_4/USbTVPyHp2I/AAAAAAAAAgA/NJiJoV1s67g/s1600/Untitled.png&gt;

Does anyone know what this could be? It might be the imageCtrl with the
bitmap. But I am unsure.

That is probably it. Usually when you see something like that it is some widget that is still at its default size (usually 20x20) which hasn't yet been resized to whatever its initial size will be. You can try creating your static bitmap with an explicit initial size like (0,0) or with a position that is outside of the parent's visible area, like (5000,5000). However if you are using sizers or other automatic layout mechanism then they will probably just move it back to the visual area anyway so some other workaround may be better...

···

--
Robin Dunn
Software Craftsman

Sion Jones wrote:

Also, I can't seem to get the Widget inspector working. It opens then
disappears suddenly!

How are you integrating it in to your application? What else is going on at the same time? Can you duplicate the issue in a small standalone test application? MakingSampleApps - wxPyWiki

···

--
Robin Dunn
Software Craftsman

Yes, when I just build an app just to show a frame, and open the

inspector by the hot key it’s fine. I have multiple frames. One for Main Menu, and another 4 windows then.

All open while the last frame shut down. So I have a “Basic Rhythm” window. You navigate to it from the main menu.

So it could be to do with the fact that the Main Menu shuts down. And I’m just realizing this now haha!

···

On Saturday, February 23, 2013 2:18:09 AM UTC, Robin Dunn wrote:

Sion Jones wrote:

Also, I can’t seem to get the Widget inspector working. It opens then

disappears suddenly!

How are you integrating it in to your application? What else is going
on at the same time? Can you duplicate the issue in a small standalone
test application? http://wiki.wxpython.org/MakingSampleApps


Robin Dunn

Software Craftsman

http://wxPython.org

Yeah as I thought it was something to do with the main menu closing.

Though it does appear now. It doesn’t display anything for widgets in the other window that I’m opening.

Meaning it just shows the widgets that are in the Main Menu. Odd.

Anyway, I’ll look at the first solution that you mentioned, about the bitmap.

···

On Saturday, February 23, 2013 2:18:09 AM UTC, Robin Dunn wrote:

Sion Jones wrote:

Also, I can’t seem to get the Widget inspector working. It opens then

disappears suddenly!

How are you integrating it in to your application? What else is going
on at the same time? Can you duplicate the issue in a small standalone
test application? http://wiki.wxpython.org/MakingSampleApps


Robin Dunn

Software Craftsman

http://wxPython.org

Right, it was as you thought. I didn’t have a sizer for the bitmap, causing it to be there.

But as always with programming. One problem fixed, another one occurs.

Now as I’m loading images onto a Panel, if i set the bitmap to lets say (0,0) so the black box disappears,

it doesn’t load the first image anymore like it did. If I set it to the dimensions of the image (680, 143) there’s no problem. Loads perfectly.

Luckily I just have a white background for the images. So is there any way to set the background of the bitmap, rather than the default black?

I’ve been testing this, but it doesn’t seem to work. The panel that I have has a white background. But because for some reason, the size of the

bitmap need’s to be rather big in order for the load function to work properly, the black obviously overlaps the white.

It’s not a massive problem again, but as a perfectionist it’s rather annoying.

···

On Saturday, February 23, 2013 2:18:00 AM UTC, Robin Dunn wrote:

Sion Jones wrote:

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))

self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if

any(filename.lower().endswith(ext) for ext in (‘.png’))])

img = wx.EmptyImage(680,143)

self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY,

wx.BitmapFromImage(img), pos=(0, 0))

def loadImage(self, event):

self.image_file = self.images.next()

print(self.image_file)

image_file = os.path.join(IMAGE_DIR, self.image_file)

img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)

#img = img.Scale(680,143)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

<https://lh6.googleusercontent.com/-j3SgAle58_4/USbTVPyHp2I/AAAAAAAAAgA/NJiJoV1s67g/s1600/Untitled.png>

Does anyone know what this could be? It might be the imageCtrl with the

bitmap. But I am unsure.

That is probably it. Usually when you see something like that it is
some widget that is still at its default size (usually 20x20) which
hasn’t yet been resized to whatever its initial size will be. You can
try creating your static bitmap with an explicit initial size like (0,0)
or with a position that is outside of the parent’s visible area, like
(5000,5000). However if you are using sizers or other automatic layout
mechanism then they will probably just move it back to the visual area
anyway so some other workaround may be better…


Robin Dunn

Software Craftsman

http://wxPython.org

Bump. Any way to change the background colour of the Bitmap?

···

On Saturday, February 23, 2013 2:44:29 AM UTC, Sion Jones wrote:

Right, it was as you thought. I didn’t have a sizer for the bitmap, causing it to be there.
But as always with programming. One problem fixed, another one occurs.

Now as I’m loading images onto a Panel, if i set the bitmap to lets say (0,0) so the black box disappears,

it doesn’t load the first image anymore like it did. If I set it to the dimensions of the image (680, 143) there’s no problem. Loads perfectly.

Luckily I just have a white background for the images. So is there any way to set the background of the bitmap, rather than the default black?

I’ve been testing this, but it doesn’t seem to work. The panel that I have has a white background. But because for some reason, the size of the

bitmap need’s to be rather big in order for the load function to work properly, the black obviously overlaps the white.

It’s not a massive problem again, but as a perfectionist it’s rather annoying.

On Saturday, February 23, 2013 2:18:00 AM UTC, Robin Dunn wrote:

Sion Jones wrote:

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))

self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if

any(filename.lower().endswith(ext) for ext in (‘.png’))])

img = wx.EmptyImage(680,143)

self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY,

wx.BitmapFromImage(img), pos=(0, 0))

def loadImage(self, event):

self.image_file = self.images.next()

print(self.image_file)

image_file = os.path.join(IMAGE_DIR, self.image_file)

img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)

#img = img.Scale(680,143)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

<https://lh6.googleusercontent.com/-j3SgAle58_4/USbTVPyHp2I/AAAAAAAAAgA/NJiJoV1s67g/s1600/Untitled.png>

Does anyone know what this could be? It might be the imageCtrl with the

bitmap. But I am unsure.

That is probably it. Usually when you see something like that it is
some widget that is still at its default size (usually 20x20) which
hasn’t yet been resized to whatever its initial size will be. You can
try creating your static bitmap with an explicit initial size like (0,0)
or with a position that is outside of the parent’s visible area, like
(5000,5000). However if you are using sizers or other automatic layout
mechanism then they will probably just move it back to the visual area
anyway so some other workaround may be better…


Robin Dunn

Software Craftsman

http://wxPython.org

Never mind. Just did it so that it loaded just a white image over it.

···

On Monday, February 25, 2013 1:12:03 AM UTC, Sion Jones wrote:

Bump. Any way to change the background colour of the Bitmap?

On Saturday, February 23, 2013 2:44:29 AM UTC, Sion Jones wrote:

Right, it was as you thought. I didn’t have a sizer for the bitmap, causing it to be there.
But as always with programming. One problem fixed, another one occurs.

Now as I’m loading images onto a Panel, if i set the bitmap to lets say (0,0) so the black box disappears,

it doesn’t load the first image anymore like it did. If I set it to the dimensions of the image (680, 143) there’s no problem. Loads perfectly.

Luckily I just have a white background for the images. So is there any way to set the background of the bitmap, rather than the default black?

I’ve been testing this, but it doesn’t seem to work. The panel that I have has a white background. But because for some reason, the size of the

bitmap need’s to be rather big in order for the load function to work properly, the black obviously overlaps the white.

It’s not a massive problem again, but as a perfectionist it’s rather annoying.

On Saturday, February 23, 2013 2:18:00 AM UTC, Robin Dunn wrote:

Sion Jones wrote:

So with this piece of code -

self.panel = wx.Panel(self, -1, pos=(150,80), size=(680,143))

self.images = DIter([filename for filename in os.listdir(IMAGE_DIR) if

any(filename.lower().endswith(ext) for ext in (‘.png’))])

img = wx.EmptyImage(680,143)

self.imageCtrl = wx.StaticBitmap(self.panel, wx.ID_ANY,

wx.BitmapFromImage(img), pos=(0, 0))

def loadImage(self, event):

self.image_file = self.images.next()

print(self.image_file)

image_file = os.path.join(IMAGE_DIR, self.image_file)

img = wx.Image(image_file, wx.BITMAP_TYPE_ANY)

#img = img.Scale(680,143)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

I get a little black box where the panel is, and where the image loads -

<https://lh6.googleusercontent.com/-j3SgAle58_4/USbTVPyHp2I/AAAAAAAAAgA/NJiJoV1s67g/s1600/Untitled.png>

Does anyone know what this could be? It might be the imageCtrl with the

bitmap. But I am unsure.

That is probably it. Usually when you see something like that it is
some widget that is still at its default size (usually 20x20) which
hasn’t yet been resized to whatever its initial size will be. You can
try creating your static bitmap with an explicit initial size like (0,0)
or with a position that is outside of the parent’s visible area, like
(5000,5000). However if you are using sizers or other automatic layout
mechanism then they will probably just move it back to the visual area
anyway so some other workaround may be better…


Robin Dunn

Software Craftsman

http://wxPython.org