Fake LCD screen, overlaying onto bitmap, using wxglade

I’ve created a custom control that
fakes an LCD screen by creating a grid of sizers containing
StaticTextCtrl objects.

    Now I want to get funky and overlay this onto a bitmap, which

gives the appearance of a real appliance I’m trying to visualise
to the user.

    What is the best way to do that with wxPython (using wxPython

4.0.0a and Python3.6)?

    NOTE: I'm using lots of wx sizers via wxglade for the gui layout

of the app !!

              Are there any good examples of

overlaying wx widgets over bitmaps?

    Can such an overlay be accomplished with wxglade, or do I have

to create a custom control which does all the work and just
insert this custom control as any other widget?

    I'm using PNG for the bitmap image.  If I want the control/graphics

to scale with sizers, I guess I would need a scalable image
format (presumably SVG).

    What is the best way to render svg images.  It doesn't seem to

have standard support in wxPython. Is the pyWxSVG modules the
answer?

    Thanks,

    Brendan.

Hi,

  I've created a custom control that

fakes an LCD screen by creating a grid of sizers containing
StaticTextCtrl objects.

    Now I want to get funky and overlay this onto a bitmap, which

gives the appearance of a real appliance I’m trying to visualise
to the user.

    What is the best way to do that with wxPython (using wxPython

4.0.0a and Python3.6)?

    NOTE: I'm using lots of wx sizers via wxglade for the gui layout

of the app !!

              Are there any good examples of

overlaying wx widgets over bitmaps?

    Can such an overlay be accomplished with wxglade, or do I have

to create a custom control which does all the work and just
insert this custom control as any other widget?

    I'm using PNG for the bitmap image.  If I want the control/graphics

to scale with sizers, I guess I would need a scalable image
format (presumably SVG).

    What is the best way to render svg images.  It doesn't seem to

have standard support in wxPython. Is the pyWxSVG modules the
answer?

    Thanks,

    Brendan.

If your layout is not awfully complex, I would strongly suggest to abandon sizers and statictexts in favor of a fully owner-drawn custom control. This will give you freedom of putting whatever image you want as background and avoid the statictexts background color to show - as all your texts will be drawn via dc.DrawText.

I’ve never tried wxpysvg, best way to see how it works is actually download it and get your hands dirty with it :slight_smile:

Andrea.

···

On Sun, 21 May 2017 at 06:46, Brendan Simon Brendan@brendansimon.com wrote:

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Any particular reason you aren't using a gridsizer ?

Karsten

···

On Sun, May 21, 2017 at 02:46:29PM +1000, Brendan Simon wrote:

I've created a custom control that fakes an LCD screen by creating a
grid of sizers containing StaticTextCtrl objects.

I think you need to create the custom control. wxglade is more for
“standard” things.
The custom control may just be a (scrolled) panel and you would
handle the EVT_PAINT by painting the background. Scaling could be
done using PIL.
Regards,
Dietmar

···

Hi Brendan!

  On 5/21/17 6:46 AM, Brendan Simon wrote:
      Can such an overlay be

accomplished with wxglade, or do I have to create a custom
control which does all the work and just insert this custom
control as any other widget?

I’m using PNG for the bitmap
image. If I want the control/graphics to scale with sizers, I
guess I would need a scalable image format (presumably SVG).

I’m fairly sure I am using gridsizer (via the wx sized control) :slight_smile:

import wx
import wx.lib.sized_controls as wxSC

class wxLCD(wxSC.SizedPanel):
def init(self, parent, cols=COLS_DEFAULT, rows=ROWS_DEFAULT, font_size=FONT_SIZE, font_family=FONT_FAMILY, font_style=FONT_STYLE, font_weight=FONT_WEIGHT):
wxSC.SizedPanel.init(self, parent)

    self.cols = cols
    self.rows = rows

    pane = self
    pane.SetSizerType("grid", {'cols':self.cols, 'rows':self.rows})

``

Since I’m also experimenting with wxglade, I might rewrite the code to use normal sizers via wxglade :wink:

Or as others have suggested an owner drawn custom control may well be the way to go.

···

On Sunday, 21 May 2017 19:25:29 UTC+10, Karsten Hilbert wrote:

On Sun, May 21, 2017 at 02:46:29PM +1000, Brendan Simon wrote:

I’ve created a custom control that fakes an LCD screen by creating a

grid of sizers containing StaticTextCtrl objects.

Any particular reason you aren’t using a gridsizer ?

Google threw up this as a possibility, which uses EVT_ERASE_BACKGROUND to repaint a bitmap and other widgets on top (e.g. buttons).

https://www.blog.pythonlibrary.org/2010/03/18/wxpython-putting-a-background-image-on-a-panel/

This could possibly work for what I want?

I also saw wx.Overlay. Is this also a possibility? I’m thinking the bitmap on the control and the overlay would have controls. Would that work?

I tried the wx.Overlay demo (on Mac Sierra, python 3.6, wxPhoenix 4.0.0a2) but it seems broken. Every time I click the contents seem to magnify (zoom in). Anyone else experience that?