{"id":2512,"date":"2021-10-13T04:35:05","date_gmt":"2021-10-13T04:35:05","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=2512"},"modified":"2021-10-13T04:35:50","modified_gmt":"2021-10-13T04:35:50","slug":"tkinter-validation","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-validation\/","title":{"rendered":"Tkinter Validation"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the Tkinter validation to validate user inputs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-tkinter-validation'>Introduction to the Tkinter validation <a href=\"#introduction-to-the-tkinter-validation\" class=\"anchor\" id=\"introduction-to-the-tkinter-validation\" title=\"Anchor for Introduction to the Tkinter validation\">#<\/a><\/h2>\n\n\n\n<p>Tkinter validation relies on the three options that you can use for any input widget such as <code><a href=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-entry\/\">Entry<\/a><\/code> widget:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>validate<\/code>: specifies which type of event will trigger the validation.<\/li><li><code>validatecommand<\/code>: checks if a data is valid<\/li><li><code>invalidcommand<\/code>: executes when the data is invalid. In other words, it&#8217;ll execute if the <code>validatecommand<\/code> returns <code>False<\/code>.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id='validate'>validate <a href=\"#validate\" class=\"anchor\" id=\"validate\" title=\"Anchor for validate\">#<\/a><\/h3>\n\n\n\n<p>The <code>validate<\/code> command can be one of the following string values:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><\/th><th><\/th><\/tr><\/thead><tbody><tr><td>&#8216;focus&#8217;<\/td><td>Validate whenever the widget gets or loses focus<\/td><\/tr><tr><td>&#8216;focusin&#8217;<\/td><td>Validate whenever the widget gets focus.<\/td><\/tr><tr><td>&#8216;focusout&#8217;<\/td><td>Validate whenever the widget loses focus<\/td><\/tr><tr><td>&#8216;key&#8217;<\/td><td>Validate whenever any keystroke changes the widget&#8217;s contents.<\/td><\/tr><tr><td>&#8216;all&#8217;<\/td><td>Validate in all the above situations focusing, focusout, and key<\/td><\/tr><tr><td>&#8216;none&#8217;<\/td><td>Turn the validation off. This is the default. Please note that the string <code>'none'<\/code> is not the <a href=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-none\/\"><code>None<\/code> <\/a>value in Python.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id='validatecommand'>validatecommand <a href=\"#validatecommand\" class=\"anchor\" id=\"validatecommand\" title=\"Anchor for validatecommand\">#<\/a><\/h3>\n\n\n\n<p>The <code>validatecommand<\/code> is a tuple that contains:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A reference to a Tcl\/tk function.<\/li><li>Zero or more substitution codes specify the information that triggers the event you want to pass into the function.<\/li><\/ul>\n\n\n\n<p>To get a reference to a Tck\/tk function, you pass a callable to the <code>widget.register()<\/code> method. It returns a string that you can use with the <code>validatecommand<\/code>.<\/p>\n\n\n\n<p>The following table shows the substitution codes that you can use with the tuple:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><code>%d'<\/code><\/td><td>Action code: 0 for an attempted deletion, 1 for an attempted insertion, or -1 if the callback was called for focus in, focus out, or a change to the&nbsp;<code>textvariable<\/code>.<\/td><\/tr><tr><td><code>'%i'<\/code><\/td><td>When the user attempts to insert or delete text, this argument will be the index of the beginning of the insertion or deletion. If the callback was due to focus in, focus out, or a change to the&nbsp;<code>textvariable<\/code>, the argument will be&nbsp;<code>-1<\/code>.<\/td><\/tr><tr><td><code>'%P'<\/code><\/td><td>The value that the text will have if the change is allowed.<\/td><\/tr><tr><td><code>'%s'<\/code><\/td><td>The text in the entry before the change.<\/td><\/tr><tr><td><code>'%S'<\/code><\/td><td>If the call was due to an insertion or deletion, this argument will be the text being inserted or deleted.<\/td><\/tr><tr><td><code>'%v'<\/code><\/td><td>The current value of the widget&#8217;s&nbsp;<code>validate<\/code>&nbsp;option.<\/td><\/tr><tr><td><code>'%V'<\/code><\/td><td>The reason for this callback: one of&nbsp;<code>'focusin'<\/code>,&nbsp;<code>'focusout'<\/code>,&nbsp;<code>'key'<\/code>, or&nbsp;<code>'forced'<\/code>&nbsp;if the&nbsp;<code>textvariable<\/code>&nbsp;was changed.<\/td><\/tr><tr><td><code>'%W'<\/code><\/td><td>The name of the widget.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The following example constructs a <code>validatecommand<\/code> that use the <code>self.validate()<\/code> method and <code>%P<\/code> substitution code:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">vcmd = (self.register(self.validate), <span class=\"hljs-string\">'%P'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='invalidcommand'>invalidcommand <a href=\"#invalidcommand\" class=\"anchor\" id=\"invalidcommand\" title=\"Anchor for invalidcommand\">#<\/a><\/h3>\n\n\n\n<p>Like the <code>validatecommand<\/code>, the <code>invalidcommand<\/code> also requires the use of the <code>widget.register()<\/code> method and substitution code.<\/p>\n\n\n\n<p>The following example returns a tuple that you can pass into the <code>invalidcommand<\/code> option:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">ivcmd = (self.register(self.on_invalid),)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='tkinter-validation-example'>Tkinter validation example <a href=\"#tkinter-validation-example\" class=\"anchor\" id=\"tkinter-validation-example\" title=\"Anchor for Tkinter validation example\">#<\/a><\/h2>\n\n\n\n<p>We&#8217;ll create a form that contains an email input. If you enter an invalid email address, it&#8217;ll show an error message and change the text color of the email input to red. And we&#8217;ll trigger the validation event when the focus is moving out of the entry.<\/p>\n\n\n\n<p>Here&#8217;s the complete program:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\n<span class=\"hljs-keyword\">from<\/span> tkinter <span class=\"hljs-keyword\">import<\/span> ttk\n<span class=\"hljs-keyword\">import<\/span> re\n\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">App<\/span><span class=\"hljs-params\">(tk.Tk)<\/span>:<\/span>\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">__init__<\/span><span class=\"hljs-params\">(self)<\/span>:<\/span>\n        super().__init__()\n\n        self.title(<span class=\"hljs-string\">'Tkinter Validation Demo'<\/span>)\n\n        self.create_widgets()\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">create_widgets<\/span><span class=\"hljs-params\">(self)<\/span>:<\/span>\n        self.columnconfigure(<span class=\"hljs-number\">0<\/span>, weight=<span class=\"hljs-number\">1<\/span>)\n        self.columnconfigure(<span class=\"hljs-number\">1<\/span>, weight=<span class=\"hljs-number\">3<\/span>)\n        self.columnconfigure(<span class=\"hljs-number\">2<\/span>, weight=<span class=\"hljs-number\">1<\/span>)\n\n        <span class=\"hljs-comment\"># label<\/span>\n        ttk.Label(text=<span class=\"hljs-string\">'Email:'<\/span>).grid(row=<span class=\"hljs-number\">0<\/span>, column=<span class=\"hljs-number\">0<\/span>, padx=<span class=\"hljs-number\">5<\/span>, pady=<span class=\"hljs-number\">5<\/span>)\n\n        <span class=\"hljs-comment\"># email entry<\/span>\n        vcmd = (self.register(self.validate), <span class=\"hljs-string\">'%P'<\/span>)\n        ivcmd = (self.register(self.on_invalid),)\n\n        self.email_entry = ttk.Entry(self, width=<span class=\"hljs-number\">50<\/span>)\n        self.email_entry.config(validate=<span class=\"hljs-string\">'focusout'<\/span>, validatecommand=vcmd, invalidcommand=ivcmd)\n        self.email_entry.grid(row=<span class=\"hljs-number\">0<\/span>, column=<span class=\"hljs-number\">1<\/span>, columnspan=<span class=\"hljs-number\">2<\/span>, padx=<span class=\"hljs-number\">5<\/span>)\n\n        self.label_error = ttk.Label(self, foreground=<span class=\"hljs-string\">'red'<\/span>)\n        self.label_error.grid(row=<span class=\"hljs-number\">1<\/span>, column=<span class=\"hljs-number\">1<\/span>, sticky=tk.W, padx=<span class=\"hljs-number\">5<\/span>)\n\n        <span class=\"hljs-comment\"># button<\/span>\n        self.send_button = ttk.Button(text=<span class=\"hljs-string\">'Send'<\/span>).grid(row=<span class=\"hljs-number\">0<\/span>, column=<span class=\"hljs-number\">4<\/span>, padx=<span class=\"hljs-number\">5<\/span>)\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">show_message<\/span><span class=\"hljs-params\">(self, error=<span class=\"hljs-string\">''<\/span>, color=<span class=\"hljs-string\">'black'<\/span>)<\/span>:<\/span>\n        self.label_error&#91;<span class=\"hljs-string\">'text'<\/span>] = error\n        self.email_entry&#91;<span class=\"hljs-string\">'foreground'<\/span>] = color\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">validate<\/span><span class=\"hljs-params\">(self, value)<\/span>:<\/span>\n        <span class=\"hljs-string\">\"\"\"\n        Validat the email entry\n        :param value:\n        :return:\n        \"\"\"<\/span>\n        pattern = <span class=\"hljs-string\">r'\\b&#91;A-Za-z0-9._%+-]+@&#91;A-Za-z0-9.-]+\\.&#91;A-Z|a-z]{2,}\\b'<\/span>\n        <span class=\"hljs-keyword\">if<\/span> re.fullmatch(pattern, value) <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-literal\">None<\/span>:\n            <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">False<\/span>\n\n        self.show_message()\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">True<\/span>\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">on_invalid<\/span><span class=\"hljs-params\">(self)<\/span>:<\/span>\n        <span class=\"hljs-string\">\"\"\"\n        Show the error message if the data is not valid\n        :return:\n        \"\"\"<\/span>\n        self.show_message(<span class=\"hljs-string\">'Please enter a valid email'<\/span>, <span class=\"hljs-string\">'red'<\/span>)\n\n\n<span class=\"hljs-keyword\">if<\/span> __name__ == <span class=\"hljs-string\">'__main__'<\/span>:\n    app = App()\n    app.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>First, create a validate command using the <code>self.validate()<\/code> method and <code>%P<\/code> substitution code:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">vcmd = (self.register(self.validate), <span class=\"hljs-string\">'%P'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, create the <code>invalidatecommand<\/code> that uses the <code>self.on_invalid<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">ivcmd = (self.register(self.on_invalid),)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, configure the entry widget that uses <code>validation<\/code>, <code>validatecommand<\/code> , and <code>invalidatecommand<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">self.email_entry.config(validate=<span class=\"hljs-string\">'focusout'<\/span>, validatecommand=vcmd, invalidcommand=ivcmd)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, define the <code>show_message()<\/code> method that changes the text of the <code>label_error<\/code> widget and the text color of the <code>email_entry<\/code> widget:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">show_message<\/span><span class=\"hljs-params\">(self, error=<span class=\"hljs-string\">''<\/span>, color=<span class=\"hljs-string\">'black'<\/span>)<\/span>:<\/span>\n    self.label_error&#91;<span class=\"hljs-string\">'text'<\/span>] = error\n    self.email_entry&#91;<span class=\"hljs-string\">'foreground'<\/span>] = color<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fifth, define the <code>validate()<\/code> method that validates the value of the <code>email_entry<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">validate<\/span><span class=\"hljs-params\">(self, value)<\/span>:<\/span>\n    <span class=\"hljs-string\">\"\"\"\n    Validat the email entry\n    :param value:\n    :return:\n    \"\"\"<\/span>\n    pattern = <span class=\"hljs-string\">r'\\b&#91;A-Za-z0-9._%+-]+@&#91;A-Za-z0-9.-]+\\.&#91;A-Z|a-z]{2,}\\b'<\/span>\n    <span class=\"hljs-keyword\">if<\/span> re.fullmatch(pattern, value) <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-literal\">None<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">False<\/span>\n\n    self.show_message()\n    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">True<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>validate()<\/code> method returns <code>True<\/code> if the input text is valid or <code>False<\/code> otherwise. In case the input text is a valid email address, call the <code>show_message()<\/code> to hide the error message and set the text color to black.<\/p>\n\n\n\n<p>Tkinter will execute the <code>on_invalid()<\/code> method if the input text is not a valid email address.<\/p>\n\n\n\n<p>Finally, define the <code>on_invalid()<\/code> method that shows an error message and set the text color of the <code>email_entry<\/code> widget to red.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">on_invalid<\/span><span class=\"hljs-params\">(self)<\/span>:<\/span>\n    <span class=\"hljs-string\">\"\"\"\n    Show the error message if the data is not valid\n    :return:\n    \"\"\"<\/span>\n    self.show_message(<span class=\"hljs-string\">'Please enter a valid email'<\/span>, <span class=\"hljs-string\">'red'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Tkinter uses the <code>validate<\/code>, <code>validatecommand<\/code>, and <code>invalidcommand<\/code> options on any input widget to validate data.<\/li><li>Pass a callable to the <code>widget.register()<\/code> method to create a command for the <code>validatecommand<\/code> and <code>invalidcommand<\/code> options.<\/li><li><code>validationcommand<\/code> returns <code>True<\/code> if the data is valid or <code>False<\/code> otherwise.<\/li><li><code>invalidcommand<\/code> will execute if the data is not valid, or when the <code>validatecommand<\/code> return <code>False<\/code>.<\/li><\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2512\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-validation\/\"\n\t\t\t\tdata-post-title=\"Tkinter Validation\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2512\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-validation\/\"\n\t\t\t\tdata-post-title=\"Tkinter Validation\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Summary: in this tutorial, you&#8217;ll learn how to use the Tkinter validation to validate user inputs. Introduction to the Tkinter validation # Tkinter validation relies on the three options that you can use for any input widget such as Entry widget: validate: specifies which type of event will trigger the validation. validatecommand: checks if a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1232,"menu_order":59,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2512","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/2512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=2512"}],"version-history":[{"count":0,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/2512\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/1232"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=2512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}