Re: Re: WxImageButton on Linux

philippe DALET <[email protected]> Thu, 25 Apr 2019 12:59:10 +0200
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <CAPq9+MME-=NNoD2eOeAXcjWovLHpfzbJho5YY86kx5aOesy3wQ@mail.gmail.com>
--000000000000eb19f3058758b587
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Robin,

it works fine. Thanks a lot.

Philippe

Le jeu. 25 avr. 2019 =C3=A0 02:01, Robin Dunn <[email protected]> a =C3=A9c=
rit :

> This is the problem:
>
> class Image(widget.Widget, StaticBitmap):
>     ...
>
> class ImageButton(image.Image, wx.BitmapButton):
>     ...
>
> You have the ImageButton class deriving from two different widget classes=
.
> Not only can you not have a single widget be two different types of widge=
t
> at the same time, but SIP does not support multiple inheritance of wrappe=
d
> classes, which is the problem this code runs into first. (The wrong
> __init__ being called when you call wx.BitmapButton.__init__) Even if SIP
> had supported it then there likely would have been errors from wxWidgets =
or
> the platform APIs.
>
> If you change the ImageButton class to this then it will work:
>
> class ImageButton(widget.Widget, wx.BitmapButton):
>
> which is apparently what was intended since there is already a call to
> widget.Widget.__init__ in the code.
>
> --
> Robin
>
>
> On Wednesday, April 24, 2019 at 2:49:50 PM UTC-7, philippe DALET wrote:
>>
>> Hi,
>>
>> A very simple Pythoncard App to run on Windows or Ubuntu.
>> breakpoint: PythonCard\components\Imagebutton.py line57
>>                   call wx.BitmapButton.__init__
>> wheel:
>>
>> https://www.dropbox.com/s/3k6duczem056znn/PythonCard-0.9.1-py3-none-any.=
whl?dl=3D0
>>
>> Thanks a lot
>> Philippe.
>>
>> Le mer. 24 avr. 2019 =C3=A0 17:14, philippe DALET <philippe.dalet@gmail.=
com>
>> a =C3=A9crit :
>>
>>> Yes of course.
>>> I'll create a simple application.
>>>
>>> Sorry.
>>>
>>> Philippe
>>>
>>> Le mer. 24 avr. 2019 =C3=A0 00:22, Robin Dunn <[email protected]> a =C3=
=A9crit :
>>>
>>>> I'm not sure in what universe that 109,405 lines of Python code, plus
>>>> tons of data files, that uses matplotlib and scipy is considered a "sm=
all
>>>> stand-alone sample" but in this universe it isn't.
>>>>
>>>> --
>>>> Robin
>>>>
>>>>
>>>> On Tuesday, April 23, 2019 at 1:37:29 PM UTC-7, philippe DALET wrote:
>>>>>
>>>>> Robin
>>>>>
>>>>> Get this file
>>>>> https://www.dropbox.com/s/0dbsnmkrcfzgegx/avancement.tar.gz?dl=3D0
>>>>>
>>>>> untar the file, then launch run.sh.
>>>>>
>>>>> Philippe
>>>>>
>>>>> Le lun. 22 avr. 2019 =C3=A0 17:23, Robin Dunn <[email protected]> a =
=C3=A9crit :
>>>>>
>>>>>> Philippe,
>>>>>>
>>>>>> Can you duplicate the problem in a small stand-alone sample?
>>>>>>
>>>>>> --
>>>>>> Robin
>>>>>>
>>>>>>
>>>>>> On Sunday, April 21, 2019 at 2:48:31 PM UTC-7, philippe DALET wrote:
>>>>>>>
>>>>>>> Hello robin,
>>>>>>>
>>>>>>> This bug does not come necessarily from wxpython.
>>>>>>>
>>>>>>> With python 3.7.2 on Windows seven, this bug was already present. N=
o
>>>>>>> more with python 3.7.3.
>>>>>>>
>>>>>>> Philippe.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Le sam. 20 avr. 2019 =C3=A0 02:14, Robin Dunn <[email protected]> a
>>>>>>> =C3=A9crit :
>>>>>>>
>>>>>>>> On Friday, April 19, 2019 at 5:06:32 PM UTC-7, Robin Dunn wrote:
>>>>>>>>>
>>>>>>>>> On Friday, April 19, 2019 at 12:53:40 PM UTC-7, philippe DALET
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Yes, self._bitmap.getBits() is returning a wx.Bitmap.
>>>>>>>>>> It runs properly on windows. It seems that it expects another
>>>>>>>>>> parameter.
>>>>>>>>>>
>>>>>>>>>> Is it possible to debug with python, then in C with an IDE on
>>>>>>>>>> linux ?
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The C++ wrapper code where that exception is raised is identical
>>>>>>>>> on each platform and it hasn't yet gotten to any platform-depende=
nt
>>>>>>>>> wxWidgets code, it's just type-checking the parameters to  decide=
 which
>>>>>>>>> wxBitmapButton constructor to call. So if it works on one platfor=
m and not
>>>>>>>>> another then it must be differences in the inputs from the Python=
 side of
>>>>>>>>> things.
>>>>>>>>>
>>>>>>>>> Ah, I just noticed something odd:
>>>>>>>>>
>>>>>>>>> >  File
>>>>>>>>> "/usr/local/lib/python3.6/dist-packages/PythonCard/components/ima=
gebutton.py",
>>>>>>>>> line 56, in __init__
>>>>>>>>> >     wx.BitmapButton.__init__(self, parent, id,
>>>>>>>>> self._bitmap.getBits(),pos, size, style, validator, name)
>>>>>>>>> > TypeError: *Control():* arguments did not match any overloaded
>>>>>>>>> call:
>>>>>>>>>
>>>>>>>>> Somehow it is not trying to call wx.BitmapButton.__init__ but
>>>>>>>>> wx.Control's __init__. Does PythonCard do any monkey-patching or =
something
>>>>>>>>> that could be replacing wx.BitmapButton with wx.Control?
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> For example, I can duplicate the exception with code like this:
>>>>>>>>
>>>>>>>> wx.BitmapButton =3D wx.Control
>>>>>>>> class TestButton(wx.BitmapButton):
>>>>>>>>     def __init__(self, parent, id, bmp, pos=3Dwx.DefaultPosition,
>>>>>>>> size=3Dwx.DefaultSize, style=3D0:
>>>>>>>>         wx.BitmapButton.__init__(self, parent, id, bmp, pos, size,
>>>>>>>> style)
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Robin
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "wxPython-dev" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "wxPython-dev" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "wxPython-dev" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

--=20
You received this message because you are subscribed to the Google Groups "=
wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
For more options, visit https://groups.google.com/d/optout.

--000000000000eb19f3058758b587
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Robin,<div><br></div><div>it works fine. Thanks a lot.<=
/div><div><br></div><div>Philippe</div></div><br><div class=3D"gmail_quote"=
><div dir=3D"ltr" class=3D"gmail_attr">Le=C2=A0jeu. 25 avr. 2019 =C3=A0=C2=
=A002:01, Robin Dunn &lt;<a href=3D"mailto:[email protected]">robin@alldunn=
.com</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex"><div dir=3D"ltr">This is the problem:<div><br></div><div><=
div><font face=3D"courier new, monospace">class Image(widget.Widget, Static=
Bitmap):</font></div></div><div><font face=3D"courier new, monospace">=C2=
=A0 =C2=A0 ...</font></div><div><font face=3D"courier new, monospace"><br><=
/font></div><div><div><font face=3D"courier new, monospace">class ImageButt=
on(image.Image, wx.BitmapButton):</font></div></div><div><font face=3D"cour=
ier new, monospace">=C2=A0 =C2=A0 ...</font></div><div><br></div><div>You h=
ave the ImageButton class deriving from two different widget classes. Not o=
nly can you not have a single widget be two different types of widget at th=
e same time, but SIP does not support multiple inheritance of wrapped class=
es, which is the problem this code runs into first. (The wrong __init__ bei=
ng called when you call wx.BitmapButton.__init__) Even if SIP had supported=
 it then there likely would have been errors from wxWidgets or the platform=
 APIs.</div><div><br></div><div>If you change the ImageButton class to this=
 then it will work:</div><div><br></div><div><div><font face=3D"courier new=
, monospace">class ImageButton(widget.Widget, wx.BitmapButton):</font></div=
></div><div><br></div><div>which is apparently what was intended since ther=
e is already a call to widget.Widget.__init__ in the code.</div><div><br></=
div><div>--</div><div>Robin</div><div><br><br>On Wednesday, April 24, 2019 =
at 2:49:50 PM UTC-7, philippe DALET wrote:<blockquote class=3D"gmail_quote"=
 style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Hi,<div=
><br></div><div>A very simple Pythoncard App to run on Windows or Ubuntu.</=
div><div>breakpoint: PythonCard\components\Imagebutton.py line57</div><div>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 call=C2=A0wx=
.BitmapButton.__init__</div><div>wheel:=C2=A0</div><div><a href=3D"https://=
www.dropbox.com/s/3k6duczem056znn/PythonCard-0.9.1-py3-none-any.whl?dl=3D0"=
 rel=3D"nofollow" target=3D"_blank">https://www.dropbox.com/s/3k6duczem056z=
nn/PythonCard-0.9.1-py3-none-any.whl?dl=3D0</a></div><div><br></div><div>Th=
anks a lot</div><div>Philippe.</div></div></div></div><br><div class=3D"gma=
il_quote"><div dir=3D"ltr">Le=C2=A0mer. 24 avr. 2019 =C3=A0=C2=A017:14, phi=
lippe DALET &lt;<a href=3D"mailto:[email protected]" rel=3D"nofollow=
" target=3D"_blank">[email protected]</a>&gt; a =C3=A9crit=C2=A0:<br=
></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;=
border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Y=
es of course.<div>I&#39;ll create a simple application.</div><div><br></div=
><div>Sorry.</div><div><br></div><div>Philippe</div></div><br><div class=3D=
"gmail_quote"><div dir=3D"ltr">Le=C2=A0mer. 24 avr. 2019 =C3=A0=C2=A000:22,=
 Robin Dunn &lt;<a href=3D"mailto:[email protected]" rel=3D"nofollow" targe=
t=3D"_blank">[email protected]</a>&gt; a =C3=A9crit=C2=A0:<br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">I&#39;m not sur=
e in what universe that=C2=A0109,405 lines of Python code, plus tons of dat=
a files, that uses matplotlib and scipy is considered a &quot;small stand-a=
lone sample&quot; but in this universe it isn&#39;t.<div><br></div><div>--<=
/div><div>Robin</div><div><br><br>On Tuesday, April 23, 2019 at 1:37:29 PM =
UTC-7, philippe DALET wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1e=
x"><div dir=3D"ltr"><div dir=3D"ltr">Robin<div><br></div><div>Get this file=
=C2=A0</div><div><a href=3D"https://www.dropbox.com/s/0dbsnmkrcfzgegx/avanc=
ement.tar.gz?dl=3D0" rel=3D"nofollow" target=3D"_blank">https://www.dropbox=
.com/s/0dbsnmkrcfzgegx/avancement.tar.gz?dl=3D0</a><br></div><div><br></div=
><div>untar the file, then launch run.sh.</div><div><br></div><div>Philippe=
</div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">Le=C2=A0l=
un. 22 avr. 2019 =C3=A0=C2=A017:23, Robin Dunn &lt;<a href=3D"mailto:robin@=
alldunn.com" rel=3D"nofollow" target=3D"_blank">[email protected]</a>&gt; a=
 =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1e=
x"><div dir=3D"ltr"><div>Philippe,<br></div><div><br></div>Can you duplicat=
e the problem in a small stand-alone sample?<div><br></div><div>--</div><di=
v>Robin</div><div><br><br>On Sunday, April 21, 2019 at 2:48:31 PM UTC-7, ph=
ilippe DALET wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div d=
ir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Hello robin,<div><br></div><di=
v>This bug=C2=A0does not come necessarily from wxpython.=C2=A0</div><div><b=
r></div><div>With python 3.7.2 on Windows seven, this bug was=C2=A0already =
present. No more with python 3.7.3.</div><div><br></div><div>Philippe.</div=
><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div=
><div><br></div><div><br></div><div><br></div><div><br></div></div></div></=
div><br><div class=3D"gmail_quote"><div dir=3D"ltr">Le=C2=A0sam. 20 avr. 20=
19 =C3=A0=C2=A002:14, Robin Dunn &lt;<a href=3D"mailto:[email protected]" r=
el=3D"nofollow" target=3D"_blank">[email protected]</a>&gt; a =C3=A9crit=C2=
=A0:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D=
"ltr">On Friday, April 19, 2019 at 5:06:32 PM UTC-7, Robin Dunn wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">On Friday, Ap=
ril 19, 2019 at 12:53:40 PM UTC-7, philippe DALET wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"ltr">Yes, self._bitmap.getBits=
() is returning a wx.Bitmap.<div>It runs properly on windows. It seems that=
 it expects another parameter.=C2=A0</div><div><br></div><div>Is it possibl=
e to debug with python, then in C with an IDE on linux ?</div></div></block=
quote><div><br></div><div><br></div><div>The C++ wrapper code where that ex=
ception is raised is identical on each platform and it hasn&#39;t yet gotte=
n to any platform-dependent wxWidgets code, it&#39;s just type-checking the=
 parameters to=C2=A0 decide which wxBitmapButton constructor to call. So if=
 it works on one platform and not another then it must be differences in th=
e inputs from the Python side of things.</div><div><br></div><div>Ah, I jus=
t noticed something odd:</div><div><br></div><div><div>&gt;=C2=A0 File &quo=
t;/usr/local/lib/python3.6/dist-packages/PythonCard/components/imagebutton.=
py&quot;, line 56, in __init__</div><div>&gt;=C2=A0 =C2=A0 =C2=A0wx.BitmapB=
utton.__init__(self, parent, id, self._bitmap.getBits(),pos, size, style, v=
alidator, name)</div><div>&gt; TypeError: <b><font color=3D"#ff0000">Contro=
l():</font></b> arguments did not match any overloaded call:</div></div><di=
v><br></div><div>Somehow it is not trying to call wx.BitmapButton.__init__ =
but wx.Control&#39;s __init__. Does PythonCard do any monkey-patching or so=
mething that could be replacing wx.BitmapButton with wx.Control?</div></div=
></blockquote><div><br></div><div><br></div><div>For example, I can duplica=
te the exception with code like this:</div><div><br></div><div><div><font f=
ace=3D"courier new, monospace">wx.BitmapButton =3D wx.Control</font></div><=
div><font face=3D"courier new, monospace">class TestButton(wx.BitmapButton)=
:</font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 def =
__init__(self, parent, id, bmp, pos=3Dwx.DefaultPosition, size=3Dwx.Default=
Size, style=3D0:</font></div><div><span style=3D"font-family:&quot;courier =
new&quot;,monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 wx.BitmapButton.__init__(s=
elf, parent, id, bmp, pos, size, style)</span><br></div></div><div><font fa=
ce=3D"courier new, monospace"><br></font></div><div>=C2=A0</div><div>--</di=
v><div>Robin</div><div><br></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" rel=3D=
"nofollow" target=3D"_blank">[email protected]</a>.=
<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" rel=
=3D"nofollow" target=3D"_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div>
</blockquote></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" rel=3D=
"nofollow" target=3D"_blank">[email protected]</a>.=
<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" rel=
=3D"nofollow" target=3D"_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div>
</blockquote></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" rel=3D=
"nofollow" target=3D"_blank">[email protected]</a>.=
<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" rel=
=3D"nofollow" target=3D"_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" targ=
et=3D"_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-dev&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">wxPyth=
[email protected]</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />

--000000000000eb19f3058758b587--