prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  RuntimeError in toga-demo
  **Describe the bug**
  when you run the toga-demo app and click on "Action 2" and then either Yes or No at the dialog, you get ```RuntimeError: Can't check dialog result directly; use await or an on_result handler``` printed on the console and no followup dialog.
  
  **To Reproduce**
  Steps to reproduce the behavior:
  1. Install toga-core, toga-gtk, toga and demo using `pip install -e`
  2. Run toga-demo
  3. Click on Action 2
  4. Click on either Yes or No in popup dialog
  5. Note it logs a RuntimeError in the terminal you ran it from.
  
  **Expected behavior**
  Should not throw an error and instead it should pop up an enthusiastic response dialog.
  
  **Screenshots**
  ```
  Traceback (most recent call last):
    File "/home/nick/Work/beeware/toga/src/core/toga/handlers.py", line 66, in _handler
      result = handler(interface, *args, **kwargs)
    File "/home/nick/Work/beeware/toga/src/core/toga/handlers.py", line 66, in _handler
      result = handler(interface, *args, **kwargs)
    File "/home/nick/Work/beeware/toga/demo/toga_demo/app.py", line 91, in action2
      if self.main_window.question_dialog('Toga', 'Is this cool or what?'):
    File "/home/nick/Work/beeware/toga/src/gtk/toga_gtk/dialogs.py", line 16, in __bool__
      raise RuntimeError("Can't check dialog result directly; use await or an on_result handler")
  RuntimeError: Can't check dialog result directly; use await or an on_result handler
  ```
  
  If applicable, add screenshots to help explain your problem.
  
  **Environment:**
   - Operating System: Ubuntu 20.04.4
   - Python version: 3.8.10
   - Software versions:
     - Toga: 0.3.0.dev34 400b6935c4689bedb134324b38eb1286af5b5ec6
     
  **Suggested Fix**
  It works if you make the `action2` function async, and make it await the question_dialog.
  I'll submit an extremely trivial PR for this soon :-)
  
  
  </issue>
  <code>
  [start of demo/toga_demo/app.py]
  1 import toga
  2 from toga.constants import COLUMN
  3 from toga.style import Pack
  4 
  5 
  6 class TogaDemo(toga.App):
  7 
  8     def startup(self):
  9         # Create the main window
  10         self.main_window = toga.MainWindow(self.name)
  11 
  12         left_container = toga.OptionContainer()
  13 
  14         left_table = toga.Table(
  15             headings=['Hello', 'World'],
  16             data=[
  17                 ('root1', 'value1'),
  18                 ('root2', 'value2'),
  19                 ('root3', 'value3'),
  20                 ('root4', 'value4'),
  21             ]
  22         )
  23 
  24         left_tree = toga.Tree(
  25             headings=['Navigate'],
  26             data={
  27                 ('root1',): {
  28                 },
  29                 ('root2',): {
  30                     ('root2.1',): None,
  31                     ('root2.2',): [
  32                         ('root2.2.1',),
  33                         ('root2.2.2',),
  34                         ('root2.2.3',),
  35                     ]
  36                 }
  37             }
  38         )
  39 
  40         left_container.add('Table', left_table)
  41         left_container.add('Tree', left_tree)
  42 
  43         right_content = toga.Box(style=Pack(direction=COLUMN))
  44         for b in range(0, 10):
  45             right_content.add(
  46                 toga.Button(
  47                     'Hello world %s' % b,
  48                     on_press=self.button_handler,
  49                     style=Pack(padding=20)
  50                 )
  51             )
  52 
  53         right_container = toga.ScrollContainer()
  54 
  55         right_container.content = right_content
  56 
  57         split = toga.SplitContainer()
  58 
  59         split.content = [left_container, right_container]
  60 
  61         cmd1 = toga.Command(
  62             self.action1,
  63             'Action 1',
  64             tooltip='Perform action 1',
  65             icon='resources/brutus',
  66         )
  67         cmd2 = toga.Command(
  68             self.action2,
  69             'Action 2',
  70             tooltip='Perform action 2',
  71             icon=toga.Icon.TOGA_ICON
  72         )
  73 
  74         self.main_window.toolbar.add(cmd1, cmd2)
  75 
  76         self.main_window.content = split
  77 
  78         # Show the main window
  79         self.main_window.show()
  80 
  81     def button_handler(self, widget):
  82         print("button press")
  83         for i in range(0, 10):
  84             yield 1
  85             print('still running... (iteration %s)' % i)
  86 
  87     def action1(self, widget):
  88         self.main_window.info_dialog('Toga', 'THIS! IS! TOGA!!')
  89 
  90     def action2(self, widget):
  91         if self.main_window.question_dialog('Toga', 'Is this cool or what?'):
  92             self.main_window.info_dialog('Happiness', 'I know, right! :-)')
  93         else:
  94             self.main_window.info_dialog('Shucks...', "Well aren't you a spoilsport... :-(")
  95 
  96 
  97 def main():
  98     return TogaDemo('Toga Demo', 'org.beeware.toga-demo')
  99
  [end of demo/toga_demo/app.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/demo/toga_demo/app.py b/demo/toga_demo/app.py
  --- a/demo/toga_demo/app.py
  +++ b/demo/toga_demo/app.py
  @@ -87,8 +87,8 @@
       def action1(self, widget):
           self.main_window.info_dialog('Toga', 'THIS! IS! TOGA!!')
   
  -    def action2(self, widget):
  -        if self.main_window.question_dialog('Toga', 'Is this cool or what?'):
  +    async def action2(self, widget):
  +        if await self.main_window.question_dialog('Toga', 'Is this cool or what?'):
               self.main_window.info_dialog('Happiness', 'I know, right! :-)')
           else:
               self.main_window.info_dialog('Shucks...', "Well aren't you a spoilsport... :-(")
  
verification_info: {"golden_diff": "diff --git a/demo/toga_demo/app.py b/demo/toga_demo/app.py\n--- a/demo/toga_demo/app.py\n+++ b/demo/toga_demo/app.py\n@@ -87,8 +87,8 @@\n     def action1(self, widget):\n         self.main_window.info_dialog('Toga', 'THIS! IS! TOGA!!')\n \n-    def action2(self, widget):\n-        if self.main_window.question_dialog('Toga', 'Is this cool or what?'):\n+    async def action2(self, widget):\n+        if await self.main_window.question_dialog('Toga', 'Is this cool or what?'):\n             self.main_window.info_dialog('Happiness', 'I know, right! :-)')\n         else:\n             self.main_window.info_dialog('Shucks...', \"Well aren't you a spoilsport... :-(\")\n", "issue": "RuntimeError in toga-demo\n**Describe the bug**\r\nwhen you run the toga-demo app and click on \"Action 2\" and then either Yes or No at the dialog, you get ```RuntimeError: Can't check dialog result directly; use await or an on_result handler``` printed on the console and no followup dialog.\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Install toga-core, toga-gtk, toga and demo using `pip install -e`\r\n2. Run toga-demo\r\n3. Click on Action 2\r\n4. Click on either Yes or No in popup dialog\r\n5. Note it logs a RuntimeError in the terminal you ran it from.\r\n\r\n**Expected behavior**\r\nShould not throw an error and instead it should pop up an enthusiastic response dialog.\r\n\r\n**Screenshots**\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/nick/Work/beeware/toga/src/core/toga/handlers.py\", line 66, in _handler\r\n    result = handler(interface, *args, **kwargs)\r\n  File \"/home/nick/Work/beeware/toga/src/core/toga/handlers.py\", line 66, in _handler\r\n    result = handler(interface, *args, **kwargs)\r\n  File \"/home/nick/Work/beeware/toga/demo/toga_demo/app.py\", line 91, in action2\r\n    if self.main_window.question_dialog('Toga', 'Is this cool or what?'):\r\n  File \"/home/nick/Work/beeware/toga/src/gtk/toga_gtk/dialogs.py\", line 16, in __bool__\r\n    raise RuntimeError(\"Can't check dialog result directly; use await or an on_result handler\")\r\nRuntimeError: Can't check dialog result directly; use await or an on_result handler\r\n```\r\n\r\nIf applicable, add screenshots to help explain your problem.\r\n\r\n**Environment:**\r\n - Operating System: Ubuntu 20.04.4\r\n - Python version: 3.8.10\r\n - Software versions:\r\n   - Toga: 0.3.0.dev34 400b6935c4689bedb134324b38eb1286af5b5ec6\r\n   \r\n**Suggested Fix**\r\nIt works if you make the `action2` function async, and make it await the question_dialog.\r\nI'll submit an extremely trivial PR for this soon :-)\r\n\n", "before_files": [{"content": "import toga\nfrom toga.constants import COLUMN\nfrom toga.style import Pack\n\n\nclass TogaDemo(toga.App):\n\n    def startup(self):\n        # Create the main window\n        self.main_window = toga.MainWindow(self.name)\n\n        left_container = toga.OptionContainer()\n\n        left_table = toga.Table(\n            headings=['Hello', 'World'],\n            data=[\n                ('root1', 'value1'),\n                ('root2', 'value2'),\n                ('root3', 'value3'),\n                ('root4', 'value4'),\n            ]\n        )\n\n        left_tree = toga.Tree(\n            headings=['Navigate'],\n            data={\n                ('root1',): {\n                },\n                ('root2',): {\n                    ('root2.1',): None,\n                    ('root2.2',): [\n                        ('root2.2.1',),\n                        ('root2.2.2',),\n                        ('root2.2.3',),\n                    ]\n                }\n            }\n        )\n\n        left_container.add('Table', left_table)\n        left_container.add('Tree', left_tree)\n\n        right_content = toga.Box(style=Pack(direction=COLUMN))\n        for b in range(0, 10):\n            right_content.add(\n                toga.Button(\n                    'Hello world %s' % b,\n                    on_press=self.button_handler,\n                    style=Pack(padding=20)\n                )\n            )\n\n        right_container = toga.ScrollContainer()\n\n        right_container.content = right_content\n\n        split = toga.SplitContainer()\n\n        split.content = [left_container, right_container]\n\n        cmd1 = toga.Command(\n            self.action1,\n            'Action 1',\n            tooltip='Perform action 1',\n            icon='resources/brutus',\n        )\n        cmd2 = toga.Command(\n            self.action2,\n            'Action 2',\n            tooltip='Perform action 2',\n            icon=toga.Icon.TOGA_ICON\n        )\n\n        self.main_window.toolbar.add(cmd1, cmd2)\n\n        self.main_window.content = split\n\n        # Show the main window\n        self.main_window.show()\n\n    def button_handler(self, widget):\n        print(\"button press\")\n        for i in range(0, 10):\n            yield 1\n            print('still running... (iteration %s)' % i)\n\n    def action1(self, widget):\n        self.main_window.info_dialog('Toga', 'THIS! IS! TOGA!!')\n\n    def action2(self, widget):\n        if self.main_window.question_dialog('Toga', 'Is this cool or what?'):\n            self.main_window.info_dialog('Happiness', 'I know, right! :-)')\n        else:\n            self.main_window.info_dialog('Shucks...', \"Well aren't you a spoilsport... :-(\")\n\n\ndef main():\n    return TogaDemo('Toga Demo', 'org.beeware.toga-demo')\n", "path": "demo/toga_demo/app.py"}]}