Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to create notification in python

import time
from plyer import notification
 
 
if __name__=="__main__":
 
        notification.notify(
            title = "HEADING HERE",
            message=" DESCRIPTION HERE" ,
           
            # displaying time
            timeout=2
)
        # waiting time
        time.sleep(7)
Comment

python - notification messages

//First add the following codes to the LOWER part of the SETTINGS 
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
    messages.ERROR: 'danger',  // only if you want to display error 
}

// Second is do the following steps 
// Open a new file inside INCLUDES folder inside templates folder 
// and call it messages.html 
// open it and paste the codes below 

{% if messages %}
  {% for message in messages %}
      <div id="message" class="container">
        <div class="alert alert-{{ message.tags }}" alert-dismissable role="alert">
            <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>
            <strong>
              {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}
                  Error:
              {% else %}
                  {{mesaage.tags|title}}
              {% endif %}
            </strong>
            {{message}}
        </div>
      </div>
  {% endfor %}
{% endif %}

// you can these code for bootstrap or django  
// Third is, go to the CLASS folder and in views.py add the codes below 

from django.contrib import messages

def register(request):
    if request.method == 'POST':
        messages.error(request, 'This is error message') // you add this line  
        return redirect('register')
    else:
        return render(request, 'pages/register.html')
 
// Forth is, go the place where you want to display the message 
// So, go to the register.html and the paste the code below 
 
 {% include 'includes/messages.html' %} 
 
// depending on where you want to display the message 
// most likely it is place above the <form> 
 
// Fith is follow the steps below 
// go to the mainControl or ( project level directory ) folder. 
// go to ( static ) folder got to ( js ) folder got to ( app.js ) 
// go to the buttom part and paste the code below 
// use to fade the message after 4 seconds 
 setTimeout(function(){
  $('#message').fadeOut('slow');
}, 4000)
 
// to to the ( terminal ) and the run the code below 
 python manage.py collectstatic 
 
// lastly --> 
// if it is not running
// go to ( view page source ) search for ( app.js ) click it 
// go to the buttom part check the code was loaded 

setTimeout(function(){
  $('#message').fadeOut('slow');
}, 2000)

// if not press ( refresh ) serveral times until you see it displayed. 
Comment

PREVIOUS NEXT
Code Example
Python :: how to plot quantity of each value of a feature in python 
Python :: sum of multiples of 5 from 1 to 100 
Python :: pdf reading shows gibberish python 
Python :: list all items in digital ocean spaces 
Python :: pandas form multiindex to column 
Python :: airflow set ui color of operator ui_color 
Python :: python specify multiple possible types 
Python :: len list python 
Python :: update python 
Python :: pandas month number to name 
Python :: select all Textinput kivy on selection 
Python :: tz convert python 
Python :: folium add a polygon to a map 
Python :: numpy create array with infinities 
Python :: treesitter python languages 
Python :: python monats liste 
Python :: print is not working in python 
Python :: sf.query_all( ) dataFrame records relation Id 
Python :: np random choice given distribution 
Python :: Summarize text using LED huggingface 
Python :: round to nearest multiple of 5 python from both end 
Python :: sum elements array with step numy 
Python :: sumif in python on a column and create new column 
Python :: resizing django embed player 
Python :: gdal user with anaconda 
Python :: creating a frequency table | generating a frequency table 
Python :: divide column in each row by last column 
Python :: copy any files from one folder to another folder in python 
Python :: drop mili sencond from datetime index 
Python :: pandas normalize rows to max value 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =