Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed divider widget on WinForms #2667

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/2667.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On WinForms, the Divider widget now behaves correctly and allows changing its background_color and dimensions.
10 changes: 5 additions & 5 deletions winforms/src/toga_winforms/widgets/divider.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from decimal import ROUND_UP

import System.Windows.Forms as WinForms
from System.Drawing import SystemColors
from travertino.size import at_least

from .base import Widget


class Divider(Widget):
def create(self):
self.native = WinForms.Label()
self.native.BorderStyle = WinForms.BorderStyle.Fixed3D
self.native = WinForms.Panel()
self.native.AutoSize = False

self._default_background = SystemColors.ControlDark
self._direction = self.interface.HORIZONTAL

def get_direction(self):
Expand All @@ -20,11 +20,11 @@ def get_direction(self):
def set_direction(self, value):
self._direction = value
if value == self.interface.HORIZONTAL:
self.native.Height = 2
self.native.Height = 1
self.native.Width = 0
else:
self.native.Height = 0
self.native.Width = 2
self.native.Width = 1

def rehint(self):
if self.get_direction() == self.interface.HORIZONTAL:
Expand Down
2 changes: 1 addition & 1 deletion winforms/tests_backend/widgets/divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@


class DividerProbe(SimpleProbe):
native_class = System.Windows.Forms.Label
native_class = System.Windows.Forms.Panel
Loading