Hi,
I want to test how I can use Bitmap. I got one question after a few
tests : is it possible to use a Bitmap in a larger Panel, or do I have
to nest a Bitmap into a Panel 'A' the samesize, Panel 'A' child of a
larger Panel 'B' ? So this way, for example, the size of B stay the
same and I can move panel A into it...
Or am I lost ?
Thanks !
Daniel D.
Your description is rather vague as to what you are attempting. The same bitmap on two panels…? sounds like you want to toggle an image panel…?
Please provide a small runnable sample app.
···
On Thursday, February 6, 2014 3:08:46 PM UTC-6, Daniel Diersant wrote:
Hi,
I want to test how I can use Bitmap. I got one question after a few
tests : is it possible to use a Bitmap in a larger Panel, or do I have
to nest a Bitmap into a Panel ‘A’ the samesize, Panel ‘A’ child of a
larger Panel ‘B’ ? So this way, for example, the size of B stay the
same and I can move panel A into it…
Or am I lost ?
Thanks !
Daniel D.
or if you are not far enough along to do that: a better description of what
you want to accomplish, rather than how you think you should accomplish
it....
But for now:
a "bitmap" is an abstract concept fora bunch of pixels, usually
representing an image. a wx.Bitmap is wx's internal class for storing and
using bitmaps. You can build a wx.Bitmap in various ways, but usually you
create one by loading a file (PNG, GIF, etc).
Once you have a wx.Bitmap, there are a number of ways to display it to the
user:
wx.StaticBitmap is a widget that does nothing but display a bitmap -- if
you that's all you need to do, it's a good option -- it can be put on a
Panel, and laced either with absolute positioning or using a Sizer
(preferred). The actual displayed bitmap can be changed programmatically if
need be.
wx.BitmapButton is a Button that displays a bitmaps rather than text for
its label -- otherwise acts like a button. You can control what which
bitmap it used normally, and when pushed, etc.
wx.DC is how you draw arbitrary stuff on a Window -- one of teh things you
can draw is a wx.Bitmap.
HTH,
-Chris
···
On Fri, Feb 7, 2014 at 11:47 AM, Metallicow <metaliobovinus@gmail.com>wrote:
On Thursday, February 6, 2014 3:08:46 PM UTC-6, Daniel Diersant wrote:
I want to test how I can use Bitmap. I got one question after a few
tests : is it possible to use a Bitmap in a larger Panel, or do I have
to nest a Bitmap into a Panel 'A' the samesize, Panel 'A' child of a
larger Panel 'B' ? So this way, for example, the size of B stay the
same and I can move panel A into it...Your description is rather vague as to what you are attempting. The same
bitmap on two panels...? sounds like you want to toggle an image panel...?
Please provide a small runnable sample app.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
Oh ok. I’m really new to the wxPython library and concepts
Basically I want to put an image in a Panel, then move the image inside this Panel. But I think, thanks to your explanation, that I put the Image in the Panel the wrong way, as when I execute my code the Panel resize to the size of the Image.
I’ll try some over way, and post some code if I get stuck again.
Thanks both of you for your help.
···
Le vendredi 7 février 2014 21:04:28 UTC+1, Chris Barker a écrit :
On Fri, Feb 7, 2014 at 11:47 AM, Metallicow metalio...@gmail.com wrote:
On Thursday, February 6, 2014 3:08:46 PM UTC-6, Daniel Diersant wrote:
I want to test how I can use Bitmap. I got one question after a few
tests : is it possible to use a Bitmap in a larger Panel, or do I have
to nest a Bitmap into a Panel ‘A’ the samesize, Panel ‘A’ child of a
larger Panel ‘B’ ? So this way, for example, the size of B stay the
same and I can move panel A into it…
Your description is rather vague as to what you are attempting. The same bitmap on two panels…? sounds like you want to toggle an image panel…?
Please provide a small runnable sample app.
or if you are not far enough along to do that: a better description of what you want to accomplish, rather than how you think you should accomplish it…
But for now:
a “bitmap” is an abstract concept fora bunch of pixels, usually representing an image. a wx.Bitmap is wx’s internal class for storing and using bitmaps. You can build a wx.Bitmap in various ways, but usually you create one by loading a file (PNG, GIF, etc).
Once you have a wx.Bitmap, there are a number of ways to display it to the user:
wx.StaticBitmap is a widget that does nothing but display a bitmap – if you that’s all you need to do, it’s a good option – it can be put on a Panel, and laced either with absolute positioning or using a Sizer (preferred). The actual displayed bitmap can be changed programmatically if need be.
wx.BitmapButton is a Button that displays a bitmaps rather than text for its label – otherwise acts like a button. You can control what which bitmap it used normally, and when pushed, etc.
wx.DC is how you draw arbitrary stuff on a Window – one of teh things you can draw is a wx.Bitmap.
HTH,
-Chris
–
Christopher Barker, Ph.D.
OceanographerEmergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 faxSeattle, WA 98115 (206) 526-6317 main reception
Have you looked at the wxPython demo for the DragImage demonstration?
Check that out--it does just what you have described. So does FloatCanvas,
also in the Demo.
Che
···
On Sat, Feb 8, 2014 at 7:18 AM, Daniel Diersant <diersant.d@gmail.com>wrote:
Oh ok. I'm really new to the wxPython library and concepts
Basically I want to put an image in a Panel, then move the image inside
this Panel.
I'm about to, but I'm trying to understand absolute positioning. As I
put a StaticBitmap into a Frame, I simply can not put it where I want
it to be, and it seems to be extended to the entire Frame.
I'm missing something here I guess I attached the code, just try to
clic anywhere you'll see.
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import wx
class MyApp(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(640, 480))
self.img = wx.Image('test.jpg',
wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
self.stb_jpg = wx.StaticBitmap(self, -1, self.img, pos=(12, 12),
size=(25, 25))
#Binding
self.stb_jpg.Bind(wx.EVT_LEFT_DOWN, self.OnKey)
#Show
self.Show(True)
def OnKey(self, event):
print 'Left Clic'
self.stb_jpg.SetPosition((64, 64))
event.Skip()
def Application():
app = wx.App(False)
frame = MyApp(None, "Test") # NOQA
app.MainLoop()
if __name__ == "__main__":
Application()
Le
Sat, 8 Feb 2014 10:27:23 -0500, C M <cmpython@gmail.com> a écrit :
···
On Sat, Feb 8, 2014 at 7:18 AM, Daniel Diersant > <diersant.d@gmail.com>wrote:
> Oh ok. I'm really new to the wxPython library and concepts
> Basically I want to put an image in a Panel, then move the image
> inside this Panel.
>Have you looked at the wxPython demo for the DragImage demonstration?
Check that out--it does just what you have described. So does
FloatCanvas, also in the Demo.Che
Yes, this a very easy point to clear up. The rule in wxPython is that
whatever is the FIRST object on a frame gets resized to be the size of the
entire frame (and dynamically updated to match the size of the frame if the
user resizes the frame).
So, what you always want to do is make the "background" of your frame a
wxPanel, and then put all your other widgets (including other panels, if
you want, or buttons, or whatever) on that panel.
For dragging images, or any widgets, around, though, that's an independent
issue, and you will need special code that does that, and that's why you
want to look at the DragImage demo.
Che
···
On Sat, Feb 8, 2014 at 10:40 AM, Daniel Diersant <diersant.d@gmail.com>wrote:
I'm about to, but I'm trying to understand absolute positioning. As I
put a StaticBitmap into a Frame, I simply can not put it where I want
it to be, and it seems to be extended to the entire Frame.
C M wrote:
I'm about to, but I'm trying to understand absolute positioning. As I
put a StaticBitmap into a Frame, I simply can not put it where I want
it to be, and it seems to be extended to the entire Frame.Yes, this a very easy point to clear up. The rule in wxPython is that
whatever is the FIRST object on a frame gets resized to be the size of
the entire frame (and dynamically updated to match the size of the frame
if the user resizes the frame).
A more accurate description would be that if the frame has only one child (besides a wx.MenuBar, wx.ToolBar, or wx.StatusBar set with a Set*Bar method) then that child is resized to fill the client area of the frame. If the frame has more than one non-Bar child then it is up to the application programmer to manage the layout of those child windows, such as with a sizer.
···
On Sat, Feb 8, 2014 at 10:40 AM, Daniel Diersant <diersant.d@gmail.com > <mailto:diersant.d@gmail.com>> wrote:
--
Robin Dunn
Software Craftsman
Nice, thank you ! Now it's working, and I understand a little bit
better how to manage my layout !
···
On Sat, 08 Feb 2014 14:38:59 -0800 Robin Dunn <robin@alldunn.com> wrote:
C M wrote:
>
>
>
> On Sat, Feb 8, 2014 at 10:40 AM, Daniel Diersant > > <diersant.d@gmail.com <mailto:diersant.d@gmail.com>> wrote:
>
> I'm about to, but I'm trying to understand absolute
> positioning. As I put a StaticBitmap into a Frame, I simply can not
> put it where I want it to be, and it seems to be extended to the
> entire Frame.
>
>
> Yes, this a very easy point to clear up. The rule in wxPython is
> that whatever is the FIRST object on a frame gets resized to be the
> size of the entire frame (and dynamically updated to match the size
> of the frame if the user resizes the frame).A more accurate description would be that if the frame has only one
child (besides a wx.MenuBar, wx.ToolBar, or wx.StatusBar set with a
Set*Bar method) then that child is resized to fill the client area of
the frame. If the frame has more than one non-Bar child then it is
up to the application programmer to manage the layout of those child
windows, such as with a sizer.