{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b46b7109",
   "metadata": {},
   "source": [
    "# 16-32 · Отладка и качество GUI\n",
    "\n",
    "Практика к разделу [«Отладка интерфейса и качество GUI»](../../site/chapters/glava-16/16-32-debugging-i-kachestvo.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "badeccae",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Распознавать, какие действия безопасны внутри GUI-callback."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4f3052b8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T21:45:27.523765Z",
     "iopub.status.busy": "2026-08-18T21:45:27.523607Z",
     "iopub.status.idle": "2026-08-18T21:45:27.539929Z",
     "shell.execute_reply": "2026-08-18T21:45:27.539496Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False True False\n"
     ]
    }
   ],
   "source": [
    "def is_safe_for_gui_callback(action):\n",
    "    unsafe_actions = {\"time.sleep\", \"while_true_poll\", \"huge_synchronous_computation\"}\n",
    "    return action not in unsafe_actions\n",
    "\n",
    "check_sleep = is_safe_for_gui_callback(\"time.sleep\")\n",
    "check_after = is_safe_for_gui_callback(\"root.after\")\n",
    "check_while = is_safe_for_gui_callback(\"while_true_poll\")\n",
    "print(check_sleep, check_after, check_while)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
