unwanted border around GTK & bitmapbutton

I find that on GTK (Ubuntu 7.10, most recent wxPython) my bitmapbuttons
get some unwanted borders that aren't there on WinXP. GTK uses those
borders to darken the edge on hover.

How do I stop this from happening?

Paul

···

--
Paul Sijben tel: +31334566488
Eemvalley Technology BV fax: +31334557523
the Netherlands http://eemvalley.com
-----------------------------------------------------
EemValley Technology werft python & wxpython
programmeurs: http://www.eemvalley.nl/jobs

Robin Dunn wrote:

Paul Sijben wrote:

I find that on GTK (Ubuntu 7.10, most recent wxPython) my bitmapbuttons
get some unwanted borders that aren't there on WinXP. GTK uses those
borders to darken the edge on hover.

How do I stop this from happening?

Try using the wx.NO_BORDER style.

that works on WinXP but not GTK :frowning:

Depending on the active theme that may do it for you, although it will probably still try to draw something when the mouse moves over the button. If you don't want any effects from the theme then you can use the GenBitmapButton class from wx.lib.buttons with a wx.NO_BORDER style.

thanks, will try that tomorrow. Is there a convenient way to use this from XRC?

Paul

Paul Sijben wrote:

Robin Dunn wrote:

Paul Sijben wrote:

I find that on GTK (Ubuntu 7.10, most recent wxPython) my bitmapbuttons
get some unwanted borders that aren't there on WinXP. GTK uses those
borders to darken the edge on hover.

How do I stop this from happening?

Try using the wx.NO_BORDER style.

that works on WinXP but not GTK :frowning:

Depending on the active theme that may do it for you, although it will probably still try to draw something when the mouse moves over the button. If you don't want any effects from the theme then you can use the GenBitmapButton class from wx.lib.buttons with a wx.NO_BORDER style.

thanks, will try that tomorrow. Is there a convenient way to use this from XRC?

Not necessarily convenient at the moment, but doable. You'll have to write a handler for it so XRC knows how to construct it. If you use XRCed then you can also use it's new plugin facility to be able to use it from XRCed too.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Paul Sijben wrote:

Robin,

I have done it with GenBitmapButton as you suggested. After rejigging
the size of the item, it now all is in the right positions!

Now the one problem I have left is that GenBitmapButton isn't
transparent. Style wx.TRANSPARENT apparently has no effect.

I have tried setting the background through the EVT_ERASE_BACKGROUND
event to no avail.

Is there a fix for this?

Paul

Paul,

Did you try the SetTransparent() method on your GenBitmapButton instance? Something like this:

myBtn.SetTransparent(25)

You can use the values from 0 - 255 with 0 being completely transparent and 255 being completely opaque.

Mike

Mike,

thanks I'll try that one!

Paul

Mike Driscoll wrote:

···

Paul Sijben wrote:

Robin,

I have done it with GenBitmapButton as you suggested. After rejigging
the size of the item, it now all is in the right positions!

Now the one problem I have left is that GenBitmapButton isn't
transparent. Style wx.TRANSPARENT apparently has no effect.

I have tried setting the background through the EVT_ERASE_BACKGROUND
event to no avail.

Is there a fix for this?

Paul

Paul,

Did you try the SetTransparent() method on your GenBitmapButton instance? Something like this:

myBtn.SetTransparent(25)

You can use the values from 0 - 255 with 0 being completely transparent and 255 being completely opaque.

Mike
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

--
Paul Sijben tel: +31334566488
Eemvalley Technology fax: +31334557523
the Netherlands http://eemvalley.com

Indeed this is the same issue. I have addressed it as follows; I have derived my transparent buttons from GenBitMapButton and have added SetTransparent and included some code OnPaint to draw the gradient on the background. In the code below I get the data from the gradient from the skin dict I am using on my frames. YMMV

BTW: Robin, this solved my OnOver problem on WinXP as well!

class TransGenBitmapButton(wlbuttons.GenBitmapButton):
    def __init__(self,*args,**keywords):
        wlbuttons.GenBitmapButton.__init__(self,*args,**keywords)
        self._transparent=255
       def SetTransparent(self,val):
        if val==0:
            self._transparent=val
       def GetBackgroundBrush(self, dc):
        if not self._transparent:
            return None
        else:
            return wlbuttons.GenBitmapButton.GetBackgroundBrush(self,dc)
       def TransparentBackground(self,dc):
        x,y,w,h = rect = self.GetClientRect()
        posx,posy = self.GetScreenPosition()
        #first make the background
        #figure out which colors I ought to have
        panel = GetPanelParent(self)
        name2 = panel.GetName()
        col1,col2,ww,hh,direction=GetTopFrame(panel).skin['gradient'][name2]
        dc.SetBrush(wx.Brush(col2))
        dc.SetPen(wx.Pen(col2))
        dc.DrawRectangle(x,y,w,h)
        ww=int(ww)
        hh=int(hh)
        #now what is my offset on this panel?
        px,py,pw,ph=panel.GetClientRect()
        pposx,pposy=panel.GetScreenPosition()
        #for now only handle vertical gradient, TODO add in horizontal
        if posy<pposy+hh:
            #we need to draw some of the gradient
            c1r,c1g,c1b=RGB2Tuple(col1)
            c2r,c2g,c2b=RGB2Tuple(col2)
            rstep=float(c2r-c1r)/hh
            gstep=float(c2g-c1g)/hh
            bstep=float(c2b-c1b)/hh
            #we need to update col1
            c1r=c1r+(rstep*(posy-pposy))
            c1g=c1g+(gstep*(posy-pposy))
            c1b=c1b+(bstep*(posy-pposy))
            h2=min(h,pposy+hh-posy) #we need to update col2
            c2r=c1r+(rstep*h2)
            c2g=c1g+(gstep*h2)
            c2b=c1b+(bstep*h2)
            col1=(int(c1r),int(c1g),int(c1b))
            col2=(int(c2r),int(c2g),int(c2b))
            dc.GradientFillLinear((x,y,w,h2),col1,col2,int(direction))

    def OnPaint(self, event):
        (width, height) = self.GetClientSizeTuple()
        x1 = y1 = 0
        x2 = width-1
        y2 = height-1
           dc = wx.PaintDC(self)
        brush = self.GetBackgroundBrush(dc)
        if brush is not None:
            dc.SetBackground(brush)
            dc.Clear()
        else:
            self.TransparentBackground(dc)
           self.DrawBezel(dc, x1, y1, x2, y2)
        self.DrawLabel(dc, width, height)
        if self.hasFocus and self.useFocusInd:
            self.DrawFocusIndicator(dc, width, height)

Robin Dunn wrote:

···

Mike Driscoll wrote:

Did you try the SetTransparent() method on your GenBitmapButton instance? Something like this:

myBtn.SetTransparent(25)

SetTransparent is only available for top level windows, and even if it was available for other widgets it is not what he wants. SetTransparent sets the alpha transparency level for the whole widget, not just the portion that is not the foreground area of the widget.

--
Paul Sijben tel: +31334566488
Eemvalley Technology fax: +31334557523
the Netherlands http://eemvalley.com