A Quick Way To Build Beautiful Applications Using Python

Applications using python

applications using python

Building Applications is not easy. It takes lots of effort, how should be user interface and user experience and you must know HTML, JavaScript, CSS, and whatnot. It becomes Frustrating.

Applications Using Python:

But I have been recently introduced to an awesome python framework, where to build applications, You only need to Know Python and nothing else. This is amazing that you can build applications using python only.

In this blog, we will cover how you can build a very well-designed web application using nothing but Anvil and Python. Anvil is a Platform that lets you build beautiful applications using python only.

This blog will cover the basics of anvil so that you can also build applications using python. By the end of this blog, you will know how to:

  • Build Your User Interface
  • Write client-side Python
  • Write server-side Python
  • Store data in database
  • Publish/Deploy Your Application

First Thing First: Go to Anvil and Sign-in:

  1. Go to Anvil and Sign -in .
Anvil Login

Once you Sign Up and log in to anvil, you will be redirected to its build page.

2. Click on New blank App and choose Material – Design.

Click on Material Design.

Build Your User Interface:

What you see before yourself is your Canvas. Before Giving your application a beautiful look, We must Rename our Application.

Now that we have renamed our application, we must design our application. To design Your application, All you need to do is to Drag and drop the needed elements to our Canvas.

Let’s add a Label and a TextBox for the name of the applicant. To add any label, Textbox, or any button all you need to do is to drag and drop the specific component to your Canvas.

After Dragging and dropping all of your needed Components, Your application should look something like this:

Create Your Database Table:

We also need to create a database table, once the user submits all the information and click on submit.

First, click on ‘Services’. Then Click on Data Tables. Then Create a Table with relative columns. Your Database Table should look something like this.

Write Server-side Python code :

Create a Server Side Module :

Go to Server Code and Click on ‘+’ and click on Add Server Module, write the below code to add new rows.

@anvil.server.callable
def add_rows(name,gender,phone,course):
  app_tables.consoleflare_applicants.add_row(
    Name=name,
    Gender=gender,
    Phone = phone,
    Course = course
  )

Create Client Side Module :

Click on submit button and open code Screen and write the below code in the click event of your submit button.

  def button_1_click(self, **event_args):
    name = self.text_box_1.text
    if self.radio_button_1.selected==True:
      gender = self.radio_button_1.text
    else:
      gender = self.radio_button_2.text
    phone = self.text_box_2.text
    course = self.drop_down_1.selected_value
    anvil.server.call('add_rows', name, gender, phone,course)
    Notification('Applicant Data Submitted').show()
    

After this, your data will be stored in the database whenever you will click on submit button.

Add The Email Service :

Add a new Service and select ‘ Email ‘.Add Following Code in Server Module under add_rows Function:
  anvil.email.send(to="abhishekm@arbre.in", # Change this to your email address!
                   subject=f"Applicant : {name}",
                   text=f""" A new person has filled out the Applicant Form! Name: {name} Gender: {gender} Phone: {phone} and 
                   Course : {course}""")

Your Application is Ready.

Now that we have done everything needed, your application is ready to Publish and for others to use.

Now You can publish your app as well, by clicking on ‘Publish your app’.

This is how you build cool Web Applications Using Python.

This is how you can build applications using python framework anvil and python only. Now that you have a basic idea of building applications using python, you can explore more and build more useful applications. Do tell me how this blog helped you and leave your comments if any and for any query, reach me at ConsoleFlare.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top