Re: Re: WxImageButton on Linux
Robin Dunn <[email protected]> Wed, 24 Apr 2019 17:01:25 -0700 (PDT)
| Newsgroups | gmane.comp.python.wxpython.devel |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_79_399911027.1556150485392
Content-Type: multipart/alternative;
boundary="----=_Part_80_1564261555.1556150485393"
------=_Part_80_1564261555.1556150485393
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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.=
=20
Not only can you not have a single widget be two different types of widget=
=20
at the same time, but SIP does not support multiple inheritance of wrapped=
=20
classes, which is the problem this code runs into first. (The wrong=20
__init__ being called when you call wx.BitmapButton.__init__) Even if SIP=
=20
had supported it then there likely would have been errors from wxWidgets or=
=20
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=20
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:=20
>
> https://www.dropbox.com/s/3k6duczem056znn/PythonCard-0.9.1-py3-none-any.w=
hl?dl=3D0
>
> Thanks a lot
> Philippe.
>
> Le mer. 24 avr. 2019 =C3=A0 17:14, philippe DALET <[email protected]=
om> a=20
> =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=
=20
>>> tons of data files, that uses matplotlib and scipy is considered a "sma=
ll=20
>>> 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=20
>>>> 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.=20
>>>>>>
>>>>>> With python 3.7.2 on Windows seven, this bug was already present. No=
=20
>>>>>> more with python 3.7.3.
>>>>>>
>>>>>> Philippe.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Le sam. 20 avr. 2019 =C3=A0 02:14, Robin Dunn <[email protected]> a=
=20
>>>>>> =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=20
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Yes, self._bitmap.getBits() is returning a wx.Bitmap.
>>>>>>>>> It runs properly on windows. It seems that it expects another=20
>>>>>>>>> parameter.=20
>>>>>>>>>
>>>>>>>>> Is it possible to debug with python, then in C with an IDE on=20
>>>>>>>>> linux ?
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> The C++ wrapper code where that exception is raised is identical o=
n=20
>>>>>>>> each platform and it hasn't yet gotten to any platform-dependent w=
xWidgets=20
>>>>>>>> code, it's just type-checking the parameters to decide which=20
>>>>>>>> wxBitmapButton constructor to call. So if it works on one platform=
and not=20
>>>>>>>> another then it must be differences in the inputs from the Python =
side of=20
>>>>>>>> things.
>>>>>>>>
>>>>>>>> Ah, I just noticed something odd:
>>>>>>>>
>>>>>>>> > File=20
>>>>>>>> "/usr/local/lib/python3.6/dist-packages/PythonCard/components/imag=
ebutton.py",=20
>>>>>>>> line 56, in __init__
>>>>>>>> > wx.BitmapButton.__init__(self, parent, id,=20
>>>>>>>> self._bitmap.getBits(),pos, size, style, validator, name)
>>>>>>>> > TypeError: *Control():* arguments did not match any overloaded=
=20
>>>>>>>> call:
>>>>>>>>
>>>>>>>> Somehow it is not trying to call wx.BitmapButton.__init__ but=20
>>>>>>>> wx.Control's __init__. Does PythonCard do any monkey-patching or s=
omething=20
>>>>>>>> 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,=
=20
>>>>>>> size=3Dwx.DefaultSize, style=3D0:
>>>>>>> wx.BitmapButton.__init__(self, parent, id, bmp, pos, size,=
=20
>>>>>>> style)
>>>>>>>
>>>>>>> =20
>>>>>>> --
>>>>>>> Robin
>>>>>>>
>>>>>>> --=20
>>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>>> Groups "wxPython-dev" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,=
=20
>>>>>>> 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=20
>>>>> Groups "wxPython-dev" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, sen=
d=20
>>>>> 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=20
>>> Groups "wxPython-dev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>> 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.
------=_Part_80_1564261555.1556150485393
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This is the problem:<div><br></div><div><div><font face=3D=
"courier new, monospace">class Image(widget.Widget, StaticBitmap):</font></=
div></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 ...</fon=
t></div><div><font face=3D"courier new, monospace"><br></font></div><div><d=
iv><font face=3D"courier new, monospace">class ImageButton(image.Image, wx.=
BitmapButton):</font></div></div><div><font face=3D"courier new, monospace"=
>=C2=A0 =C2=A0 ...</font></div><div><br></div><div>You have the ImageButton=
class deriving from two different widget classes. Not only can you not hav=
e a single widget be two different types of widget at the same time, but SI=
P does not support multiple inheritance of wrapped classes, which is the pr=
oblem this code runs into first. (The wrong __init__ being called when you =
call wx.BitmapButton.__init__) Even if SIP had supported it then there like=
ly would have been errors from wxWidgets or the platform APIs.</div><div><b=
r></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></d=
iv><div>which is apparently what was intended since there is already a call=
to widget.Widget.__init__ in the code.</div><div><br></div><div>--</div><d=
iv>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: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Hi,<div><br></div><div>A very s=
imple Pythoncard App to run on Windows or Ubuntu.</div><div>breakpoint: Pyt=
honCard\components\<wbr>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.__i=
nit__</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" target=3D"_blank=
" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.com/u=
rl?q\x3dhttps%3A%2F%2Fwww.dropbox.com%2Fs%2F3k6duczem056znn%2FPythonCard-0.=
9.1-py3-none-any.whl%3Fdl%3D0\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGnalb=
MDscV_YtjsIEqpD3jS65f6Q';return true;" onclick=3D"this.href=3D'http=
s://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.dropbox.com%2Fs%2F3k6duczem05=
6znn%2FPythonCard-0.9.1-py3-none-any.whl%3Fdl%3D0\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNGnalbMDscV_YtjsIEqpD3jS65f6Q';return true;">https://www.=
dropbox.com/s/<wbr>3k6duczem056znn/PythonCard-0.<wbr>9.1-py3-none-any.whl?d=
l=3D0</a></div><div><br></div><div>Thanks a lot</div><div>Philippe.</div></=
div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">Le=C2=A0mer=
. 24 avr. 2019 =C3=A0=C2=A017:14, philippe DALET <<a href=3D"mailto:phil=
[email protected]" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"thi=
s.href=3D'mailto:[email protected]';return true;" onclick=3D=
"this.href=3D'mailto:[email protected]';return true;">philip=
[email protected]</a>> a =C3=A9crit=C2=A0:<br></div><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 of course.<div>I'=
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 <<a hre=
f=3D"mailto:[email protected]" target=3D"_blank" rel=3D"nofollow" onmousedo=
wn=3D"this.href=3D'mailto:[email protected]';return true;" onclick=
=3D"this.href=3D'mailto:[email protected]';return true;">robin@alld=
unn.com</a>> a =C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204=
);padding-left:1ex"><div dir=3D"ltr">I'm not sure in what universe that=
=C2=A0109,405 lines of Python code, plus tons of data files, that uses matp=
lotlib and scipy is considered a "small stand-alone sample" but i=
n this universe it isn't.<div><br></div><div>--</div><div>Robin</div><d=
iv><br><br>On Tuesday, April 23, 2019 at 1:37:29 PM UTC-7, philippe DALET w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><di=
v dir=3D"ltr">Robin<div><br></div><div>Get this file=C2=A0</div><div><a hre=
f=3D"https://www.dropbox.com/s/0dbsnmkrcfzgegx/avancement.tar.gz?dl=3D0" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'https://ww=
w.google.com/url?q\x3dhttps%3A%2F%2Fwww.dropbox.com%2Fs%2F0dbsnmkrcfzgegx%2=
Favancement.tar.gz%3Fdl%3D0\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHtIgLs4=
3-YBqX_86asBx8lcin09Q';return true;" onclick=3D"this.href=3D'https:=
//www.google.com/url?q\x3dhttps%3A%2F%2Fwww.dropbox.com%2Fs%2F0dbsnmkrcfzge=
gx%2Favancement.tar.gz%3Fdl%3D0\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHtI=
gLs43-YBqX_86asBx8lcin09Q';return true;">https://www.dropbox.com/s/<wbr=
>0dbsnmkrcfzgegx/avancement.<wbr>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=A0lu=
n. 22 avr. 2019 =C3=A0=C2=A017:23, Robin Dunn <<a href=3D"mailto:robin@a=
lldunn.com" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D&=
#39;mailto:[email protected]';return true;" onclick=3D"this.href=3D'=
;mailto:[email protected]';return true;">[email protected]</a>> a =
=C3=A9crit=C2=A0:<br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex=
"><div dir=3D"ltr"><div>Philippe,<br></div><div><br></div>Can you duplicate=
the problem in a small stand-alone sample?<div><br></div><div>--</div><div=
>Robin</div><div><br><br>On Sunday, April 21, 2019 at 2:48:31 PM UTC-7, phi=
lippe DALET wrote:<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 di=
r=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Hello robin,<div><br></div><div=
>This bug=C2=A0does not come necessarily from wxpython.=C2=A0</div><div><br=
></div><div>With python 3.7.2 on Windows seven, this bug was=C2=A0already p=
resent. 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></d=
iv><br><div class=3D"gmail_quote"><div dir=3D"ltr">Le=C2=A0sam. 20 avr. 201=
9 =C3=A0=C2=A002:14, Robin Dunn <<a href=3D"mailto:[email protected]" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'mailto:rob=
[email protected]';return true;" onclick=3D"this.href=3D'mailto:robin@=
alldunn.com';return true;">[email protected]</a>> 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"lt=
r">On Friday, April 19, 2019 at 5:06:32 PM UTC-7, Robin Dunn wrote:<blockqu=
ote 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 12:53:40 PM UTC-7, philippe DALET wrote:<blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(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 e=
xpects another parameter.=C2=A0</div><div><br></div><div>Is it possible to =
debug with python, then in C with an IDE on linux ?</div></div></blockquote=
><div><br></div><div><br></div><div>The C++ wrapper code where that excepti=
on is raised is identical on each platform and it hasn't yet gotten to =
any platform-dependent wxWidgets code, it's just type-checking the para=
meters to=C2=A0 decide which wxBitmapButton constructor to call. So if it w=
orks on one platform and not another then it must be differences in the inp=
uts from the Python side of things.</div><div><br></div><div>Ah, I just not=
iced something odd:</div><div><br></div><div><div>>=C2=A0 File "/us=
r/local/lib/python3.6/<wbr>dist-packages/PythonCard/<wbr>components/imagebu=
tton.py", line 56, in __init__</div><div>>=C2=A0 =C2=A0 =C2=A0wx.Bi=
tmapButton.__init__(<wbr>self, parent, id, self._bitmap.getBits(),pos, size=
, style, validator, name)</div><div>> TypeError: <b><font color=3D"#ff00=
00">Control():</font></b> arguments did not match any overloaded call:</div=
></div><div><br></div><div>Somehow it is not trying to call wx.BitmapButton=
.__init__ but wx.Control's __init__. Does PythonCard do any monkey-patc=
hing or something that could be replacing wx.BitmapButton with wx.Control?<=
/div></div></blockquote><div><br></div><div><br></div><div>For example, I c=
an duplicate the exception with code like this:</div><div><br></div><div><d=
iv><font face=3D"courier new, monospace">wx.BitmapButton =3D wx.Control</fo=
nt></div><div><font face=3D"courier new, monospace">class TestButton(wx.Bit=
mapButton):</font></div><div><font face=3D"courier new, monospace">=C2=A0 =
=C2=A0 def __init__(self, parent, id, bmp, pos=3Dwx.DefaultPosition, size=
=3Dwx.DefaultSize, style=3D0:</font></div><div><span style=3D"font-family:&=
quot;courier new",monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 wx.BitmapButt=
on.__init__(self, parent, id, bmp, pos, size, style)</span><br></div></div>=
<div><font face=3D"courier new, monospace"><br></font></div><div>=C2=A0</di=
v><div>--</div><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" 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" onmousedown=3D"this.href=3D'mailto:wxPytho=
[email protected]';return true;" onclick=3D"this.href=
=3D'mailto:[email protected]';return true;"=
>wxPython-dev+unsubscribe@<wbr>googlegroups.com</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" rel=
=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'https://gro=
ups.google.com/d/optout';return true;" onclick=3D"this.href=3D'http=
s://groups.google.com/d/optout';return true;">https://groups.google.com=
/d/<wbr>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" 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" onmousedown=3D"this.href=3D'mailto:wxPytho=
[email protected]';return true;" onclick=3D"this.href=
=3D'mailto:[email protected]';return true;"=
>wxPython-dev+unsubscribe@<wbr>googlegroups.com</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" rel=
=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'https://gro=
ups.google.com/d/optout';return true;" onclick=3D"this.href=3D'http=
s://groups.google.com/d/optout';return true;">https://groups.google.com=
/d/<wbr>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" 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" rel=3D"nofollow" onmousedown=3D"this.href=3D'mailto:wxPytho=
[email protected]';return true;" onclick=3D"this.href=
=3D'mailto:[email protected]';return true;"=
>wxPython-dev+unsubscribe@<wbr>googlegroups.com</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" targ=
et=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://grou=
ps.google.com/d/optout';return true;" onclick=3D"this.href=3D'https=
://groups.google.com/d/optout';return true;">https://groups.google.com/=
d/<wbr>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" 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 />
------=_Part_80_1564261555.1556150485393--
------=_Part_79_399911027.1556150485392--