Skip to content

Commit

Permalink
Replace enabled property on implementation level with set_enabled
Browse files Browse the repository at this point in the history
…, adjust tests

Signed-off-by: obulat <[email protected]>
  • Loading branch information
obulat committed Sep 1, 2019
1 parent 88fd323 commit 32f0b66
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/core/tests/test_command.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from unittest.mock import Mock

import toga
import toga_dummy
from toga_dummy.utils import TestCase
from toga.command import cmd_sort_key


class TestCommand(unittest.TestCase):
class TestCommand(TestCase):
def test_group_init_no_order(self):
grp = toga.Group('label')
self.assertEqual(grp.label, 'label')
Expand Down Expand Up @@ -97,9 +97,9 @@ def test_command_enabler(self):
)
cmd.bind(toga_dummy.factory)
cmd.enabled = False
self.assertFalse(cmd._impl.enabled)
self.assertActionPerformedWith(cmd, 'set enabled', value=False)
cmd.enabled = True
self.assertTrue(cmd._impl.enabled)
self.assertActionPerformedWith(cmd, 'set enabled', value=True)

def test_cmd_sort_key(self):
grp = toga.Group('Test group', order=10)
Expand Down
2 changes: 1 addition & 1 deletion src/core/toga/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def enabled(self):
def enabled(self, value):
self._enabled = value
if self._impl is not None:
self._impl.enabled = value
self._impl.set_enabled(value)


GROUP_BREAK = object()
Expand Down
5 changes: 4 additions & 1 deletion src/dummy/toga_dummy/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
class Command(LoggedObject):
def __init__(self, interface):
super().__init__()
self.interface = interface
self.interface = interface

def set_enabled(self, value):
self._action('set enabled', value=value)
7 changes: 1 addition & 6 deletions src/winforms/toga_winforms/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ def __init__(self, interface):
else:
self.interface.icon = None

@property
def enabled(self):
return self.interface.enabled

@enabled.setter
def enabled(self, value):
def set_enabled(self, value):
if self.native:
for widget in self.native:
widget.Enabled = self.interface.enabled
1 change: 0 additions & 1 deletion src/winforms/toga_winforms/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def create_toolbar(self):
item = WinForms.ToolStripSeparator()
else:
cmd_impl = cmd.bind(self.interface.factory)
print("Cmd impl is ", cmd_impl)
if cmd.icon is not None:
native_icon = cmd.icon.bind(self.interface.factory).native
item = WinForms.ToolStripMenuItem(cmd.label, native_icon.ToBitmap())
Expand Down

0 comments on commit 32f0b66

Please sign in to comment.