On Thu, 14 Feb 2019 at 17:48, J Barchan <jnbarchan at gmail.com> wrote:
>>> On Thu, 14 Feb 2019 at 14:56, Vincent Vande Vyvre <
>vincent.vande.vyvre at telenet.be> wrote:
>>> Le 14/02/19 脿 14:56, J Barchan a 茅crit :
>>>>>>>> On Thu, 14 Feb 2019 at 13:34, J Barchan <jnbarchan at gmail.com> wrote:
>>>>> This may be as much a Python question as a PyQt one. I come from a C++
>>> background. I do not understand the syntax/code I need in a class I am
>>> deriving from a PyQt class to allow a new parameter to be passed to the
>>> constructor.
>>>>>> I see that I asked this question a long time ago at
>>> https://stackoverflow.com/questions/45999732/python3-typing-overload-and-parameters
>>> but never got an answer.
>>>>>> I now want to sub-class from QListWidgetItem. That starts with these
>>> constructors:
>>>>>> QListWidgetItem(QListWidget *parent = nullptr, int type = Type)
>>> QListWidgetItem(const QString &text, QListWidget *parent = nullptr, int
>>> type = Type)
>>> QListWidgetItem(const QIcon &icon, const QString &text, QListWidget
>>> *parent = nullptr, int type = Type)
>>> QListWidgetItem(const QListWidgetItem &other)
>>>>>> My sub-class should still support these constructors. In addition to
>>> the existing text, I want my sub-class to be able to store a new
>>> optional value. At minimum/sufficient I want a new possible constructor
>>> like one of the following:
>>>>>> MyListWidgetItem(const QString &text, const QVariant &value, QListWidget
>>> *parent = nullptr, int type = Type)
>>> # or
>>> MyListWidgetItem(const QString &text, QVariant value = QVariant(), QListWidget
>>> *parent = nullptr, int type = Type)
>>>>>> So for Python I know I start with a *typing overload* definition (for
>>> my editor) like
>>>>>> @typing.overload
>>> def MyListWidgetItem(self, text: str, value: typing.Any, parent:
>>> QListWidget=None, type: int=Type)
>>> pass
>>>>>> Then I get to the *definition* bit. To cater for everything am I
>>> supposed to do:
>>>>>> def __init__(self, *__args)
>>> # Now what??
>>> super().__init__(__args)
>>>>>> Is that how we do it? Is it then my responsibility to look at __args[1]
>>> to see if it's my value argument? And remove it from __args before
>>> passing it onto super().__init__(__args)?
>>>>>> Or, am I not supposed to deal with __args, and instead have some
>>> definition with all possible parameters explicitly and deal with them like
>>> that?
>>>>>> Or what? This is pretty fundamental to sub-classing to add parameters
>>> where you don't own the code of what you're deriving from. It's easy in
>>> C-type languages; I'm finding it real to hard to understand what I
>>> can/can't/am supposed to do for this, I'd be really gratefully for a couple
>>> of lines to show me, please...! :)
>>>>>> --
>>> Kindest,
>>> Jonathan
>>>>>>> P.S.
>> I think I got my overload a bit mixed up. I meant I (think I) will have:
>>>> class MyListWidgetItem(QListWidgetItem)
>> @typing.overload
>> def __init__(self, text: str, value: typing.Any, parent:
>> QListWidget=None, type: int=Type)
>> pass
>>>> def __init__(self, *__args)
>> # Now what??
>> super().__init__(__args)
>>>>>> --
>> Kindest,
>> Jonathan
>>>> _______________________________________________
>> PyQt mailing list PyQt at riverbankcomputing.comhttps://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>> Hi,
>>>> I use just that:
>>>> class ListItem(QListWidgetItem):
>> def __init__(self, img, text, parent=None):
>> super().__init__(parent)
>> icon = QIcon()
>> icon.addPixmap(QPixmap(img), QIcon.Normal, QIcon.Off)
>> self.setIcon(icon)
>> self.setText(text)
>>>> The arguments are examples, not mandatory.
>>>> Vincent
>> _______________________________________________
>> PyQt mailing list PyQt at riverbankcomputing.com>>/mailman/listinfo/pyqt>>>> Hello Vincent,
>> Thank you for replying. I'm afraid the suggestion you give is so
> significantly different from what I am asking that I don't see how it
> addresses it. I could write a lot about the differences between what you
> show and what I am asking. Here are some:
>> - I don't see that you're adding any argument that QListWidgetItem
> does not already accept?? Please bear in mind there is already QListWidgetItem(const
> QIcon &icon, const QString &text, QListWidget *parent = nullptr, int type =
> Type). I want to add a new argument.
> - Your super().__init__() is not passing anything other than parent to
> the base constructor, yet the base constructor accepts more arguments than
> that, just like your derived class does.
> - (untested) it seems to me that your code will break the existing QListWidgetItem(const
> QIcon &icon, const QString &text, QListWidget *parent = nullptr, int type =
> Type) constructor overload (i.e. what happens when I pass a QIcon() as
> the img parameter to your ListItem constructor?)
> - how does your code allow for the existing QListWidgetItem(const
> QString &text, QListWidget *parent = nullptr, int type = Type) overload
> - you are not using any typing hints so this will lose my editor's
> context completion
>> I don't know whether one of us is misunderstanding the other, or we're on
> different planes? :)
>> --
> Kindest,
> Jonathan
>
May I politely try bumping this question? I have had one answer, which as
far as I understand does not work.
How *exactly* could/would you derive from QListWidgetItem from Python to
add a "value" parameter in a constructor? I could do it easily from C++.
It does seem to me this is at least partly a PyQt question, I've tried
asking it at
https://stackoverflow.com/questions/54746309/python-3-add-argument-when-subclassing-from-complex-arguments
,
I'm getting comments like "If PyQT makes it impossible to use common Python
idioms then I can't do much about it actually <g>" and "The OP needs to
have a re-think and accept that some compromises are inevitable when trying
to fake c++ idioms in pure python."
This is a bit above my head. I'm either getting a generic answer which is
inadequate or no answer or told it may not be doable. I don't understand
this. Can someone tell me how to add the argument I have in mind, or
something similar (you do need to read through the precise example I am
asking about), or explain why it can't be done, or something? I should be
so obliged!
--
Kindest,
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/pyqt/attachments/20190218/692f3d7b/attachment-0001.html>
More information about the PyQt
mailing list
‘She has never mentioned her father to me. Was he—well, the sort of man whom the County Club would not have blackballed?’ "We walked by the side of our teams or behind the wagons, we slept on the ground at night, we did our own cooking, we washed our knives by sticking them into the ground rapidly a few times, and we washed our plates with sand and wisps of grass. When we stopped, we arranged our wagons in a circle, and thus formed a 'corral,' or yard, where we drove our oxen to yoke them up. And the corral was often very useful as a fort, or camp, for defending ourselves against the Indians. Do you see that little hollow down there?" he asked, pointing to a depression in the ground a short distance to the right of the train. "Well, in that hollow our wagon-train was kept three days and nights by the Indians. Three days and nights they stayed around, and made several attacks. Two of our men were killed and three were wounded by their arrows, and others had narrow escapes. One arrow hit me on the throat, but I was saved by the knot of my neckerchief, and the point only tore the skin a little. Since that time I have always had a fondness for large neckties. I don't know how many of the Indians we killed, as they carried off their dead and wounded, to save them from being scalped. Next to getting the scalps of their enemies, the most important thing with the Indians is to save their own. We had several fights during our journey, but that one was the worst. Once a little party of us were surrounded in a small 'wallow,' and had a tough time to defend ourselves successfully. Luckily for us, the Indians had no fire-arms then, and their bows and arrows were no match for our rifles. Nowadays they are well armed, but there are[Pg 41] not so many of them, and they are not inclined to trouble the railway trains. They used to do a great deal of mischief in the old times, and many a poor fellow has been killed by them." As dusk came on nearly the whole population of Maastricht, with all their temporary guests, formed an endless procession and went to invoke God's mercy by the Virgin Mary's intercession. They went to Our Lady's Church, in which stands the miraculous statue of Sancta Maria Stella Maris. The procession filled all the principal streets and squares of the town. I took my stand at the corner of the Vrijthof, where all marched past me, men, women, and children, all praying aloud, with loud voices beseeching: "Our Lady, Star of the Sea, pray for us ... pray for us ... pray for us ...!" It had not occurred to her for some hours after Mrs. Campbell had told her of Landor's death that she was free now to give herself to Cairness. She had gasped, indeed, when she did remember it, and had put the thought away, angrily and self-reproachfully. But it returned now, and she felt that she might cling to it. She had been grateful, and she had been faithful, too.[Pg 286] She remembered only that Landor had been kind to her, and forgot that for the last two years she had borne with much harsh coldness, and with a sort of contempt which she felt in her unanalyzing mind to have been entirely unmerited. Gradually she raised herself until she sat quite erect by the side of the mound, the old exultation of her half-wild girlhood shining in her face as she planned the future, which only a few minutes before had seemed so hopeless. After he had gloated over Sergeant Ramsey, Shorty got his men into the road ready to start. Si placed himself in front of the squad and deliberately loaded his musket in their sight. Shorty took his place in the rear, and gave out: The groups about each gun thinned out, as the shrieking fragments of shell mowed down man after man, but the rapidity of the fire did not slacken in the least. One of the Lieutenants turned and motioned with his saber to the riders seated on their horses in the line of limbers under the cover of the slope. One rider sprang from each team and ran up to take the place of men who had fallen. "As long as there's men and women in the world, the men 'ull be top and the women bottom." Then, in the house, the little girls were useful. Mrs. Backfield was not so energetic as she used to be. She had never been a robust woman, and though her husband's care had kept her well and strong, her frame was not equal to Reuben's demands; after fourteen years' hard labour, she suffered from rheumatism, which though seldom acute, was inclined to make her stiff and slow. It was here that Caro and Tilly came in, and Reuben began to appreciate his girls. After all, girls were needed in a house—and as for young men and marriage, their father could easily see that such follies did not spoil their usefulness or take them from him. Caro and Tilly helped their grandmother in all sorts of ways—they dusted, they watched pots, they shelled peas and peeled potatoes, they darned house-linen, they could even make a bed between them. HoME一级毛片视频免费公开
ENTER NUMBET 0018rootpaper.com.cn forvert.com.cn shehua55.net.cn www.hztecai.com.cn www.cqcq02.com.cn xjqg.com.cn sun-com.com.cn www.snowpea.com.cn majime.com.cn www.ag8.org.cn