Entri Blog
No Result
View All Result
Thursday, November 30, 2023
  • State PSC
    • Kerala PSC
      • Kerala PSC Exams
      • Kerala PSC Notification
      • Kerala PSC Exam Calender
      • Kerala PSC Previous Question papers
      • KAS Exam
      • KAS Previous Year Question papers
      • Kerala PSC VEO Notification
      • Kerala Police SI
      • Kerala PSC LDC Notification
      • Kerala PSC LP/UP Assistant
      • Kerala PSC Village Field Assistant Notification
      • Kerala PSC LD Typist Notification
      • Kerala PSC Food Safety Officer
      • Kerala PSC Excise Inspector Notification
      • Kerala PSC BDO Notification
      • Kerala PSC CPO Notification
      • Kerala PSC LGS Notification
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • Courses
    • Data Science Course
      • Data Science Malayalam
      • Data Science Training in Kochi
      • Data Science Training in Trivandrum
      • Data Science Course in Calicut
      • Data Science Training in Thrissur
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Quantity Surveying Course
    • Performance Marketing Course
    • Practical Accounting Course
      • Tally Course
      • Taxation Course
      • UAE Accounting
      • GST Course
    • Mern Stack Developer Course
      • Full Stack Developer Course in Kochi
      • Full Stack Developer Course in Trivandrum
      • Full Stack Developer Course in Calicut
      • Full Stack Developer Course in Pune
      • Full Stack Developer Course in Bangalore
      • Full Stack Developer Course in Hyderabad
      • Full Stack Developer Course in Chennai
      • Full Stack Developer Course in Indore
      • Full Stack Developer Course in Jaipur
      • Full Stack Developer Course in Coimbatore
    • Other Courses
      • Montessori Teacher Training
      • MEP Course
      • German Language Course
      • OET Coaching
      • Nurses Recruitment Abroad
      • Digital Marketing Training
      • ChatGPT Course
      • Forex Trading Course
      • Yoga Teacher Training Course
      • Oil and Gas Course
  • Others
    • Railway
    • SSC
    • GATE
    • MAT
    • KMAT
    • UPSC
    • TET
      • APTET
      • CTET
      • DSSSB
      • Karnataka TET
      • Kerala TET
      • KVS
      • MPTET
      • SUPER TET
      • TNTET
      • TSTET
      • UPTET
  • Aptitude Questions
  • Test Prep
    • PSC Coaching
      • KPSC Degree Level Exam Preparation
      • Kerala PSC 12th Level Exam Preparation
      • Kerala PSC 10th Level Exam Preparation
      • KAS Coaching
      • Kerala PSC LDC Coaching
      • Kerala PSC Fireman Coaching
      • KSFE Assistant Exam Preparation
      • Kerala PSC SI Exam Coaching
      • KTET Coaching
      • SET Coaching
      • Kerala PSC Lecturer in Diet Coaching
      • Khadi Board LDC Exam Preparation
      • LP/UP Assistant Exam Coaching
      • HSST Exam Preparation
      • HSA Exam Preparation
      • EMRS Coaching
      • University LGS Exam Preparation
      • University Assistant Exam Coaching
    • IELTS Training Online
    • Bank Exam Coaching Online
      • IBPS SO Online Coaching
      • IBPSC PO Online Coaching
      • IBPSC Clerk Online Coaching
      • SBI PO Coaching
      • SBI Clerk Online Coaching
      • RBI Grade B Coaching
      • RBI Assistant Coaching
    • UPSC Online Coaching
    • SSC Online Coaching
      • SSC JE Online Coaching
    • RRB JE Online Coaching
      • RRB Exams Coaching
    • CAT Online Coaching
    • GATE Online Coaching
Spoken English
Entri Blog
  • State PSC
    • Kerala PSC
      • Kerala PSC Exams
      • Kerala PSC Notification
      • Kerala PSC Exam Calender
      • Kerala PSC Previous Question papers
      • KAS Exam
      • KAS Previous Year Question papers
      • Kerala PSC VEO Notification
      • Kerala Police SI
      • Kerala PSC LDC Notification
      • Kerala PSC LP/UP Assistant
      • Kerala PSC Village Field Assistant Notification
      • Kerala PSC LD Typist Notification
      • Kerala PSC Food Safety Officer
      • Kerala PSC Excise Inspector Notification
      • Kerala PSC BDO Notification
      • Kerala PSC CPO Notification
      • Kerala PSC LGS Notification
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • Courses
    • Data Science Course
      • Data Science Malayalam
      • Data Science Training in Kochi
      • Data Science Training in Trivandrum
      • Data Science Course in Calicut
      • Data Science Training in Thrissur
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Quantity Surveying Course
    • Performance Marketing Course
    • Practical Accounting Course
      • Tally Course
      • Taxation Course
      • UAE Accounting
      • GST Course
    • Mern Stack Developer Course
      • Full Stack Developer Course in Kochi
      • Full Stack Developer Course in Trivandrum
      • Full Stack Developer Course in Calicut
      • Full Stack Developer Course in Pune
      • Full Stack Developer Course in Bangalore
      • Full Stack Developer Course in Hyderabad
      • Full Stack Developer Course in Chennai
      • Full Stack Developer Course in Indore
      • Full Stack Developer Course in Jaipur
      • Full Stack Developer Course in Coimbatore
    • Other Courses
      • Montessori Teacher Training
      • MEP Course
      • German Language Course
      • OET Coaching
      • Nurses Recruitment Abroad
      • Digital Marketing Training
      • ChatGPT Course
      • Forex Trading Course
      • Yoga Teacher Training Course
      • Oil and Gas Course
  • Others
    • Railway
    • SSC
    • GATE
    • MAT
    • KMAT
    • UPSC
    • TET
      • APTET
      • CTET
      • DSSSB
      • Karnataka TET
      • Kerala TET
      • KVS
      • MPTET
      • SUPER TET
      • TNTET
      • TSTET
      • UPTET
  • Aptitude Questions
  • Test Prep
    • PSC Coaching
      • KPSC Degree Level Exam Preparation
      • Kerala PSC 12th Level Exam Preparation
      • Kerala PSC 10th Level Exam Preparation
      • KAS Coaching
      • Kerala PSC LDC Coaching
      • Kerala PSC Fireman Coaching
      • KSFE Assistant Exam Preparation
      • Kerala PSC SI Exam Coaching
      • KTET Coaching
      • SET Coaching
      • Kerala PSC Lecturer in Diet Coaching
      • Khadi Board LDC Exam Preparation
      • LP/UP Assistant Exam Coaching
      • HSST Exam Preparation
      • HSA Exam Preparation
      • EMRS Coaching
      • University LGS Exam Preparation
      • University Assistant Exam Coaching
    • IELTS Training Online
    • Bank Exam Coaching Online
      • IBPS SO Online Coaching
      • IBPSC PO Online Coaching
      • IBPSC Clerk Online Coaching
      • SBI PO Coaching
      • SBI Clerk Online Coaching
      • RBI Grade B Coaching
      • RBI Assistant Coaching
    • UPSC Online Coaching
    • SSC Online Coaching
      • SSC JE Online Coaching
    • RRB JE Online Coaching
      • RRB Exams Coaching
    • CAT Online Coaching
    • GATE Online Coaching
No Result
View All Result
Entri Blog
Spoken Eng
  • HTML Tutorial
  • DSA Tutorials
  • Tutorials in Hindi
    • HTML Tutorial for Beginners in Hindi
    • Python Tutorial for Beginners in Hindi
    • GIT and GITHUB Tutorial for Beginners in Hindi
  • Tutorials in Tamil
    • JavaScript Tutorial in Tamil
  • Tutorials in Telugu
    • HTML Tutorial For Beginners in Telugu
    • CSS Tutorial for Beginners in Telugu
    • Bootstrap Tutorial for Beginner in Telugu
  • Tutorials in Kannada
    • HTML Tutorial For Beginners in Kannada
banner top article banner top article
Home Articles

Learn How to Quickly Create UIs in Python

by Feeba Mahin
May 3, 2023
in Articles
Learn How to Quickly Create UIs in Python
Share on FacebookShare on WhatsAppShare on Telegram

Table of Contents

  • Python Libraries Available for UI usage
  • Closing Thoughts

The biggest advantage of python is the ease of use and the abundance of libraries for just about anything. With a few lines of code, there is nothing you couldn’t do. As long as your python scripts are for personal use or your target audience is technical enough, you would never even have to think about a User Interface (UI).

Sometimes, however, your target audience is not technical enough. They’d love to use your python scripts but only as long as they didn’t have to look at a single line of code. In those cases, providing command line scripts will simply not cut it. You would ideally need to provide them with a UI.

Python and Machine Learning Rectangle

Python Libraries Available for UI usage

There are essentially 3 big Python UI libraries : Tkinter, wxPython and PyQT.

Much to my delight, however, I came across a fourth option that seemed to be catering to my kind of liking. The library  which is one of the best to create Python UIs is called PySimpleGUI. Funnily enough, this library is using all the 3 popular libraries, but abstracts away the super technical.

“Ready to take your python skills to the next level? Sign up for a free demo today!”

3 Quick Ways To Compare Data in Python

For anyone working in an analytical role, receiving requests to compare data will be all too familiar.

We essentially need a way to load up two files, and then choose the encryption we would like to use to do the file comparison.

Code the UI

To build that UI, we can use the following code:

import PySimpleGUI as sg
layout = [
    [sg.Text('File 1'), sg.InputText(), sg.FileBrowse(),
     sg.Checkbox('MD5'), sg.Checkbox('SHA1')
     ],
    [sg.Text('File 2'), sg.InputText(), sg.FileBrowse(),
     sg.Checkbox('SHA256')
     ],
    [sg.Output(size=(88, 20))],
    [sg.Submit(), sg.Cancel()]
]
window = sg.Window('File Compare', layout)
while True:                             # The Event Loop
    event, values = window.read()
    # print(event, values) #debug
    if event in (None, 'Exit', 'Cancel'):
        break

which results in:

Simply Python UI, generated by the above code.

“Experience the power of our web development course with a free demo – enroll now!”

Plugging in the logic

With the UI in place, it’s simple for one to see how to plug in the rest of the code. We simply need to monitor for what the user inputs and then act accordingly. We can very easily do that, with the following code.

import PySimpleGUI as sg
import re
import hashlibdef hash(fname, algo):
    if algo == 'MD5':
        hash = hashlib.md5()
    elif algo == 'SHA1':
        hash = hashlib.sha1()
    elif algo == 'SHA256':
        hash = hashlib.sha256()
    with open(fname) as handle: #opening the file one line at a time for memory considerations
        for line in handle:
            hash.update(line.encode(encoding = 'utf-8'))
    return(hash.hexdigest())layout = [
    [sg.Text('File 1'), sg.InputText(), sg.FileBrowse(),
     sg.Checkbox('MD5'), sg.Checkbox('SHA1')
     ],
    [sg.Text('File 2'), sg.InputText(), sg.FileBrowse(),
     sg.Checkbox('SHA256')
     ],
    [sg.Output(size=(88, 20))],
    [sg.Submit(), sg.Cancel()]
]window = sg.Window('File Compare', layout)while True:                             # The Event Loop
    event, values = window.read()
    # print(event, values) #debug
    if event in (None, 'Exit', 'Cancel'):
        break
    if event == 'Submit':
        file1 = file2 = isitago = None
        # print(values[0],values[3])
        if values[0] and values[3]:
            file1 = re.findall('.+:\/.+\.+.', values[0])
            file2 = re.findall('.+:\/.+\.+.', values[3])
            isitago = 1
            if not file1 and file1 is not None:
                print('Error: File 1 path not valid.')
                isitago = 0
            elif not file2 and file2 is not None:
                print('Error: File 2 path not valid.')
                isitago = 0
            elif values[1] is not True and values[2] is not True and values[4] is not True:
                print('Error: Choose at least one type of Encryption Algorithm')
            elif isitago == 1:
                print('Info: Filepaths correctly defined.')
                algos = [] #algos to compare
                if values[1] == True: algos.append('MD5')
                if values[2] == True: algos.append('SHA1')
                if values[4] == True: algos.append('SHA256')
                filepaths = [] #files
                filepaths.append(values[0])
                filepaths.append(values[3])
                print('Info: File Comparison using:', algos)
                for algo in algos:
                    print(algo, ':')
                    print(filepaths[0], ':', hash(filepaths[0], algo))
                    print(filepaths[1], ':', hash(filepaths[1], algo))
                    if hash(filepaths[0],algo) == hash(filepaths[1],algo):
                        print('Files match for ', algo)
                    else:
                        print('Files do NOT match for ', algo)
        else:
            print('Please choose 2 files.')window.close()

Running the above code will give you the following outcome:

Closing Thoughts

Although not the prettiest of UIs, this library allows you to quickly spin up simple python UIs and share them with whoever you may need to. More importantly, the code that you require to do so, is simple and very readable.

“Get hands-on with our python course – sign up for a free demo!”

Related Articles

Introduction to Data Visualization in Python Why Python Is Used For Data Science?
Guide for getting a job as a Python Developer Python Advanced Interview Questions and Answers
Best Online Python Course with Certificate What is Type Conversion in Python?
Share61SendShare

Feeba Mahin

Related Posts

Sample Transfer Letter For Nurses In OET Writing
Articles

Sample Transfer Letter For Nurses In OET Writing

November 28, 2023
Digital Marketing
Articles

What Digital Marketing Executive do? Roles & Responsibilities

November 28, 2023
Best 6 digital marketing Project Ideas & Topics For Freshers [2024]
Articles

Best 6 digital marketing Project Ideas & Topics For Freshers [2024]

November 27, 2023
Next Post
kerala psc agricultural officer answer key

Kerala PSC Agricultural Officer Answer Key 2022

Latest Posts

  • Quantity Surveyor Salaries in UAE
  • Finance and Accounting Interview Preparation for Freshers Tips to Succeed!
  • Kerala PSC ICDS Supervisor Exam Date 2023-2024
  • Kerala PSC Assistant Engineer (Civil) Shortlist 2023: Download PDF, Link
  • Top 10 Revit Interview Questions & Answers (2024 Update)

Trending Posts

  • states of india and their capitals and languages

    List of 28 States of India and their Capitals and Languages 2023 – PDF Download

    152231 shares
    Share 60890 Tweet 38056
  • List of Government Banks in India 2023: All you need to know

    65505 shares
    Share 26202 Tweet 16376
  • Kerala Bank Assistant Manager Syllabus 2023: Download Expected Syllabus PDF

    541 shares
    Share 216 Tweet 135
  • KSDA Recruitment 2023 Apply Online for 9264 FDA SDA Posts – Qualification

    9378 shares
    Share 3751 Tweet 2345
  • TNPSC Group 2 Posts and Salary Details 2022

    39986 shares
    Share 15994 Tweet 9997

Courses

  • Data Science Course
  • Full Stack Developer Course
  • Data Science Course in Malayalam
  • Full Stack Developer Course in Malayalam
  • Full Stack Developer Course in Hindi
  • Full Stack Developer Course in Tamil
  • Full Stack Developer Course in Telugu
  • Full Stack Developer Course in Kannada
  • Python Programming Course
  • Practical Accounting Course
  • Quantity Surveying Course
  • Stock Market Course
  • Stock Market Course in Malayalam
  • Stock Market Course in Tamil
  • Stock Market Course in Kannada
  • Options Trading Course

Company

  • Become a teacher
  • Login to Entri Web

Spoken English Courses

  • Spoken English Course
  • Spoken English Course in Malayalam
  • Spoken English Course in Hindi
  • Spoken English Course in Tamil
  • Spoken English Course in Telugu
  • Spoken English Course in Kannada
  • Spoken English Course for Housewives
  • Spoken English Course for Working Professionals
  • Spoken English Course for School Students
  • Spoken English Course for College Students
  • Spoken English Course for Job Seekers
  • AI Powered Spoken English Course

Quick Links

  • Aptitude Questions
  • Articles
  • Videos
  • Entri Daily Quiz Practice
  • Current Affairs & GK
  • News Capsule – eBook
  • Preparation Tips
  • Kerala PSC Gold
  • Entri Skilling
  • Kerala PSC

Other Courses

  • OET Coaching Classes
  • Nurse Recruitment Abroad
  • Forex Trading Course
  • Montessori Teachers Training
  • Performance Marketing Course
  • German Language Course
  • MEP Course
  • Oil and Gas Course Online
  • Yoga Teacher Training Course
  • Digital Marketing Course
  • German Language A1 Course
  • German Language A2 Course
  • German Language B1 Course
  • German Language B2 Course

Popular Exam

  • IBPS Exam
  • SBI Exam
  • Railway RRB Exam
  • Kerala PSC
  • Tamil Nadu PSC
  • Telangana PSC
  • Andhra Pradesh PSC
  • MPPSC
  • UPPSC
  • Karnataka PSC
  • Staff Selection Commission Exam

© 2023 Entri.app - Privacy Policy | Terms of Service

No Result
View All Result
  • State PSC
    • Kerala PSC
      • Kerala PSC Exams
      • Kerala PSC Notification
      • Kerala PSC Exam Calender
      • Kerala PSC Previous Question papers
      • KAS Exam
      • KAS Previous Year Question papers
      • Kerala PSC VEO Notification
      • Kerala Police SI
      • Kerala PSC LDC Notification
      • Kerala PSC LP/UP Assistant
      • Kerala PSC Village Field Assistant Notification
      • Kerala PSC LD Typist Notification
      • Kerala PSC Food Safety Officer
      • Kerala PSC Excise Inspector Notification
      • Kerala PSC BDO Notification
      • Kerala PSC CPO Notification
      • Kerala PSC LGS Notification
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • Courses
    • Data Science Course
      • Data Science Malayalam
      • Data Science Training in Kochi
      • Data Science Training in Trivandrum
      • Data Science Course in Calicut
      • Data Science Training in Thrissur
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Quantity Surveying Course
    • Performance Marketing Course
    • Practical Accounting Course
      • Tally Course
      • Taxation Course
      • UAE Accounting
      • GST Course
    • Mern Stack Developer Course
      • Full Stack Developer Course in Kochi
      • Full Stack Developer Course in Trivandrum
      • Full Stack Developer Course in Calicut
      • Full Stack Developer Course in Pune
      • Full Stack Developer Course in Bangalore
      • Full Stack Developer Course in Hyderabad
      • Full Stack Developer Course in Chennai
      • Full Stack Developer Course in Indore
      • Full Stack Developer Course in Jaipur
      • Full Stack Developer Course in Coimbatore
    • Other Courses
      • Montessori Teacher Training
      • MEP Course
      • German Language Course
      • OET Coaching
      • Nurses Recruitment Abroad
      • Digital Marketing Training
      • ChatGPT Course
      • Forex Trading Course
      • Yoga Teacher Training Course
      • Oil and Gas Course
  • Others
    • Railway
    • SSC
    • GATE
    • MAT
    • KMAT
    • UPSC
    • TET
      • APTET
      • CTET
      • DSSSB
      • Karnataka TET
      • Kerala TET
      • KVS
      • MPTET
      • SUPER TET
      • TNTET
      • TSTET
      • UPTET
  • Aptitude Questions
  • Test Prep
    • PSC Coaching
      • KPSC Degree Level Exam Preparation
      • Kerala PSC 12th Level Exam Preparation
      • Kerala PSC 10th Level Exam Preparation
      • KAS Coaching
      • Kerala PSC LDC Coaching
      • Kerala PSC Fireman Coaching
      • KSFE Assistant Exam Preparation
      • Kerala PSC SI Exam Coaching
      • KTET Coaching
      • SET Coaching
      • Kerala PSC Lecturer in Diet Coaching
      • Khadi Board LDC Exam Preparation
      • LP/UP Assistant Exam Coaching
      • HSST Exam Preparation
      • HSA Exam Preparation
      • EMRS Coaching
      • University LGS Exam Preparation
      • University Assistant Exam Coaching
    • IELTS Training Online
    • Bank Exam Coaching Online
      • IBPS SO Online Coaching
      • IBPSC PO Online Coaching
      • IBPSC Clerk Online Coaching
      • SBI PO Coaching
      • SBI Clerk Online Coaching
      • RBI Grade B Coaching
      • RBI Assistant Coaching
    • UPSC Online Coaching
    • SSC Online Coaching
      • SSC JE Online Coaching
    • RRB JE Online Coaching
      • RRB Exams Coaching
    • CAT Online Coaching
    • GATE Online Coaching

© 2023 Entri.app - Privacy Policy | Terms of Service