{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "762c387e",
   "metadata": {},
   "source": [
    "# 16-09 · Od terminalu do GUI\n",
    "\n",
    "Praktyka do sekcji [„Od terminala do GUI: modelu zdarzeń”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a430b877",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zrozum różnicę między rejestracją callback a jej realizacją."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c0f6ca96",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T21:45:07.886226Z",
     "iopub.status.busy": "2026-08-18T21:45:07.886120Z",
     "iopub.status.idle": "2026-08-18T21:45:07.908593Z",
     "shell.execute_reply": "2026-08-18T21:45:07.908134Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[] ['clicked']\n"
     ]
    }
   ],
   "source": [
    "log = []\n",
    "\n",
    "def on_click():\n",
    "    log.append(\"clicked\")\n",
    "\n",
    "registered = on_click            # регистрация: callback запомнен, но НЕ вызван\n",
    "before_dispatch = list(log)\n",
    "\n",
    "registered()                     # диспетчеризация: callback выполняется именно сейчас\n",
    "after_dispatch = list(log)\n",
    "\n",
    "print(before_dispatch, after_dispatch)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "44e58f87",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Sprawdź, czy registered jest obiektem wywołalnym (funkcją), a nie wynikiem jego wywołania."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fddeb06b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T21:45:07.909848Z",
     "iopub.status.busy": "2026-08-18T21:45:07.909632Z",
     "iopub.status.idle": "2026-08-18T21:45:07.911785Z",
     "shell.execute_reply": "2026-08-18T21:45:07.911452Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "registered_is_callable = callable(registered)\n",
    "print(registered_is_callable)"
   ]
  }
 ],
 "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
}
