Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Qt5 Python GUI Programming Cookbook

You're reading from   Qt5 Python GUI Programming Cookbook Building responsive and powerful cross-platform applications with PyQt

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788831000
Length 462 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
B. M. Harwani B. M. Harwani
Author Profile Icon B. M. Harwani
B. M. Harwani
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Creating a User Interface with Qt Components 2. Event Handling - Signals and Slots FREE CHAPTER 3. Working with Date and Time 4. Understanding OOP Concepts 5. Understanding Dialogs 6. Understanding Layouts 7. Networking and Managing Large Documents 8. Doing Asynchronous Programming in Python 9. Database Handling 10. Using Graphics 11. Implementing Animation 12. Using Google Maps 13. Running Python Scripts on Android and iOS 14. Other Books You May Enjoy

Prompting for a username and displaying a welcome message


This recipe will prompt the user to enter a name, and when the user clicks the OK button after entering a name, they are greeted with an alert box with the text Hello, followed by the name entered by the user.

How to do it...

In this recipe, we will be making use of the following methods:

  • dialogGetInput(): This method is used to take input from the user
  • app.dialogCreateAlert(): This method is used to greet the user
  • app.dialogSetPositiveButtonText(): This method is used to display positive button text and to keep the dialog box visible until the user presses the OK button

 

 

Let's take a look at the following steps:

  1. Type the following code in the Python script WelcomeMessage.py in the current folder:
import android
app = android.Android()
name = app.dialogGetInput("Enter Your Information", "Name: ").result
app.dialogDismiss()
app.dialogCreateAlert("Welcome", "Hello %s" % name)
app.dialogSetPositiveButtonText('OK')
app.dialogShow()
  1. Copy or push...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image