[PyQt] Doubt

tanya tanyaradzwa tanyatanyaradzwa460 at gmail.com
Sat Oct 12 16:02:09 BST 2019


Hello everyone,

Referring to the assignment question l asked for your assistance, please
find my code herein, and attached is the output on my side. Thank you. Tanya

import sys
from pprint import pprint
from PyQt5.QtWidgets import QWidget, QPushButton, QInputDialog, QLineEdit,
QApplication

class TutorialWindow(QWidget):
    def __init(self):
        super().__init__()
        self.btn = QPushButton('Open', self)
        self.btn.move(0, 20)
        self.btn.clicked.connect(self.showDialog)

        self.text_name = QLineEdit(self)
        self.text_name.move(100, 22)
        self.text_name.setPlaceholderText("Enter your name:")

        self.Geometry(300, 300, 290, 140)

        def showDialog(self):
            text, result = QInputDialog.getText(self, 'Input Dialog',
'Enter your name:')
            if result ==True:
                self.text_name.setText(str(text))

if __name__ == '__main__':
    app = QApplication(sys.argv)
    pprint("input parameters  = " + str(sys.argv))
    tutorial_window = TutorialWindow()
    tutorial_window.show()
    sys.exit(app.exec_())


On Oct 4, 2019 14:33, "tanya tanyaradzwa" <tanyatanyaradzwa460 at gmail.com>
wrote:

> Hi Florian,
>
> Thank you for your response.
>
> I will send to you my code and the output on my side.
>
> On Oct 4, 2019 09:56, "Florian Bruhin" <me at the-compiler.org> wrote:
>
>> Hey Tanya,
>>
>> On Fri, Oct 04, 2019 at 08:50:50AM +0200, tanya tanyaradzwa wrote:
>> > I am struggling with a school assignment. I have researched all places
>> > online, but l am failing to bring it all together. Please assist me.
>> >
>> > Question:
>> >
>> > Create an application using PyQt. The user is prompted for the name of
>> an
>> > animal rescue service. This must be displayed in the UI in capital
>> letters.
>> > The user is then required to enter a character (letter). This must also
>> be
>> > displayed on the UI in capital letters. The application
>> > must read the name of the animal rescue service as well as the character
>> > and then count the number of occurrences of the character in the animal
>> > rescue service name. The count must be displayed.
>> >
>> > Also required:
>> >
>> > Error message for incorrect input from user (e.g. no name of animal
>> rescue
>> > service).
>> > Error message of character not found or the character is blank!
>> >
>> > May you please assist. Thank you.
>>
>> If you have some specific issues, people here would likely be happy to
>> help.
>> What do you have so far and where do you run into issues?
>>
>> This pretty much boils down to "please do my homework for me", which at
>> least
>> I'm not going to do.
>>
>> Florian
>>
>> --
>> https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
>>    GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
>>          I love long mails! | https://email.is-not-s.ms/
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20191012/1d420aed/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Output.PNG
Type: image/png
Size: 4792 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20191012/1d420aed/attachment-0001.png>


More information about the PyQt mailing list