[PYTHON] Change processing by user input of dialog

Display a dialog and change the process according to the input selected by the user.

dialog.py


# -*- coding: utf-8 -*-

import tkinter.messagebox as mb
import webbrowser

#If you want to open in chrome
b = webbrowser.get('"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %s')

if __name__ == '__main__':
    #Change processing according to user input
    if mb.askyesno("Title", "Open chrome browser?"):
        b.open("http://www.yahoo.co.jp")
    else:
        print("do nothing")

It's easy! The dialog uses ** Tkinter, a toolkit ** that allows you to build a GUI in Python.

Refer to this article. Try using Tkinter in Python

Recommended Posts

Change processing by user input of dialog
Error divided by 0 Processing of ZeroDivisionError 2
Grayscale by matrix-Reinventor of Python image processing-
[Language processing 100 knocks 2020] Summary of answer examples by Python
Image processing by matrix Basics & Table of Contents-Reinventor of Python image processing-
I made a threshold change box of Pepper's Dialog
Communication processing by Python
[Linux] Change user password
Various processing of Python
Basic processing of librosa