From 5bbe3a966d6c2665f7601ccbf19f092c109ef922 Mon Sep 17 00:00:00 2001 From: qu1ck Date: Fri, 24 Feb 2023 11:50:24 -0800 Subject: [PATCH] Fix link button sizing for non-windows platforms --- TransformIt/dialog_base.py | 149 ++++++++++++++++++------------------- TransformIt/link_toggle.py | 8 +- config_dialog_base.fbp | 4 +- 3 files changed, 83 insertions(+), 78 deletions(-) diff --git a/TransformIt/dialog_base.py b/TransformIt/dialog_base.py index 834a783..7433670 100644 --- a/TransformIt/dialog_base.py +++ b/TransformIt/dialog_base.py @@ -17,124 +17,123 @@ class ConfigDialogBase ( wx.Dialog ): - def __init__( self, parent ): - wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Transform It", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) + def __init__( self, parent ): + wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Transform It", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE ) - self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) + self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) - bSizer1 = wx.BoxSizer( wx.VERTICAL ) + bSizer1 = wx.BoxSizer( wx.VERTICAL ) - self.m_panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) - bSizer3 = wx.BoxSizer( wx.VERTICAL ) + self.m_panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) + bSizer3 = wx.BoxSizer( wx.VERTICAL ) - fgSizer1 = wx.FlexGridSizer( 0, 3, 0, 0 ) - fgSizer1.SetFlexibleDirection( wx.BOTH ) - fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) + fgSizer1 = wx.FlexGridSizer( 0, 3, 0, 0 ) + fgSizer1.SetFlexibleDirection( wx.BOTH ) + fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) - self.m_staticText1 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Horizontal (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText1.Wrap( -1 ) + self.m_staticText1 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Horizontal (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText1.Wrap( -1 ) - fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.m_horizontalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) - self.m_horizontalScale.SetDigits( 2 ) - fgSizer1.Add( self.m_horizontalScale, 0, wx.EXPAND|wx.ALL, 5 ) + self.m_horizontalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) + self.m_horizontalScale.SetDigits( 2 ) + fgSizer1.Add( self.m_horizontalScale, 0, wx.EXPAND|wx.ALL, 5 ) - self.m_horizontalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 ) - fgSizer1.Add( self.m_horizontalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + self.m_horizontalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 ) + fgSizer1.Add( self.m_horizontalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) + fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) - self.m_linkButton = LinkToggle(self.m_panel) - self.m_linkButton.SetToolTip( u"Preserve aspect ratio" ) - self.m_linkButton.SetMinSize( wx.Size( 28,16 ) ) + self.m_linkButton = LinkToggle(self.m_panel) + self.m_linkButton.SetToolTip( u"Preserve aspect ratio" ) - fgSizer1.Add( self.m_linkButton, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 ) + fgSizer1.Add( self.m_linkButton, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 ) - fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) + fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) - self.m_staticText2 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Vertical (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText2.Wrap( -1 ) + self.m_staticText2 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Vertical (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText2.Wrap( -1 ) - fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.m_verticalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) - self.m_verticalScale.SetDigits( 2 ) - self.m_verticalScale.Enable( False ) + self.m_verticalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) + self.m_verticalScale.SetDigits( 2 ) + self.m_verticalScale.Enable( False ) - fgSizer1.Add( self.m_verticalScale, 0, wx.EXPAND|wx.ALL, 5 ) + fgSizer1.Add( self.m_verticalScale, 0, wx.EXPAND|wx.ALL, 5 ) - self.m_verticalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_verticalMirror.Enable( False ) + self.m_verticalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_verticalMirror.Enable( False ) - fgSizer1.Add( self.m_verticalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + fgSizer1.Add( self.m_verticalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.m_staticText3 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Rotation (deg)", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText3.Wrap( -1 ) + self.m_staticText3 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Rotation (deg)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText3.Wrap( -1 ) - fgSizer1.Add( self.m_staticText3, 0, wx.ALL, 5 ) + fgSizer1.Add( self.m_staticText3, 0, wx.ALL, 5 ) - self.m_rotation = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, -360, 360, 0, 5 ) - self.m_rotation.SetDigits( 2 ) - fgSizer1.Add( self.m_rotation, 0, wx.ALL|wx.EXPAND, 5 ) + self.m_rotation = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, -360, 360, 0, 5 ) + self.m_rotation.SetDigits( 2 ) + fgSizer1.Add( self.m_rotation, 0, wx.ALL|wx.EXPAND, 5 ) - self.m_staticText4 = wx.StaticText( self.m_panel, wx.ID_ANY, u"(positive - cw)", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText4.Wrap( -1 ) + self.m_staticText4 = wx.StaticText( self.m_panel, wx.ID_ANY, u"(positive - cw)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText4.Wrap( -1 ) - fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) + fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) - self.m_staticText5 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Shape width (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText5.Wrap( -1 ) + self.m_staticText5 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Shape width (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText5.Wrap( -1 ) - fgSizer1.Add( self.m_staticText5, 0, wx.ALL, 5 ) + fgSizer1.Add( self.m_staticText5, 0, wx.ALL, 5 ) - self.m_shapeWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) - self.m_shapeWidth.SetDigits( 2 ) - fgSizer1.Add( self.m_shapeWidth, 0, wx.ALL, 5 ) + self.m_shapeWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) + self.m_shapeWidth.SetDigits( 2 ) + fgSizer1.Add( self.m_shapeWidth, 0, wx.ALL, 5 ) - fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) + fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 ) - self.m_staticText6 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Track width (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_staticText6.Wrap( -1 ) + self.m_staticText6 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Track width (%)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText6.Wrap( -1 ) - fgSizer1.Add( self.m_staticText6, 0, wx.ALL, 5 ) + fgSizer1.Add( self.m_staticText6, 0, wx.ALL, 5 ) - self.m_trackWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) - self.m_trackWidth.SetDigits( 2 ) - fgSizer1.Add( self.m_trackWidth, 0, wx.ALL, 5 ) + self.m_trackWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 ) + self.m_trackWidth.SetDigits( 2 ) + fgSizer1.Add( self.m_trackWidth, 0, wx.ALL, 5 ) - bSizer3.Add( fgSizer1, 1, wx.EXPAND, 5 ) + bSizer3.Add( fgSizer1, 1, wx.EXPAND, 5 ) - self.m_staticline1 = wx.StaticLine( self.m_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) - bSizer3.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 ) + self.m_staticline1 = wx.StaticLine( self.m_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL ) + bSizer3.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 ) - m_sdbSizer1 = wx.StdDialogButtonSizer() - self.m_sdbSizer1OK = wx.Button( self.m_panel, wx.ID_OK ) - m_sdbSizer1.AddButton( self.m_sdbSizer1OK ) - self.m_sdbSizer1Cancel = wx.Button( self.m_panel, wx.ID_CANCEL ) - m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel ) - m_sdbSizer1.Realize(); + m_sdbSizer1 = wx.StdDialogButtonSizer() + self.m_sdbSizer1OK = wx.Button( self.m_panel, wx.ID_OK ) + m_sdbSizer1.AddButton( self.m_sdbSizer1OK ) + self.m_sdbSizer1Cancel = wx.Button( self.m_panel, wx.ID_CANCEL ) + m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel ) + m_sdbSizer1.Realize(); - bSizer3.Add( m_sdbSizer1, 0, wx.BOTTOM|wx.EXPAND, 5 ) + bSizer3.Add( m_sdbSizer1, 0, wx.BOTTOM|wx.EXPAND, 5 ) - self.m_panel.SetSizer( bSizer3 ) - self.m_panel.Layout() - bSizer3.Fit( self.m_panel ) - bSizer1.Add( self.m_panel, 1, wx.EXPAND, 5 ) + self.m_panel.SetSizer( bSizer3 ) + self.m_panel.Layout() + bSizer3.Fit( self.m_panel ) + bSizer1.Add( self.m_panel, 1, wx.EXPAND, 5 ) - self.SetSizer( bSizer1 ) - self.Layout() - bSizer1.Fit( self ) + self.SetSizer( bSizer1 ) + self.Layout() + bSizer1.Fit( self ) - self.Centre( wx.BOTH ) + self.Centre( wx.BOTH ) - def __del__( self ): - pass + def __del__( self ): + pass diff --git a/TransformIt/link_toggle.py b/TransformIt/link_toggle.py index 917318e..79cfdb2 100644 --- a/TransformIt/link_toggle.py +++ b/TransformIt/link_toggle.py @@ -9,5 +9,11 @@ def __init__(self, parent): super().__init__(parent, label=wx.BitmapBundle(link_image), style=wx.BU_EXACTFIT) - self.SetSizeHints(self.Size) + sz: wx.Size = link_image.GetSize() + wxport = wx.PlatformInformation().PortIdName + if wxport == "wxMSW": + sz.IncBy(10, 8) + else: + sz.IncBy(20, 8) + self.SetMinClientSize(sz) self.SetValue(True) diff --git a/config_dialog_base.fbp b/config_dialog_base.fbp index c95785b..0a6f3f6 100644 --- a/config_dialog_base.fbp +++ b/config_dialog_base.fbp @@ -15,7 +15,7 @@ 1000 none - + 1 0 config_dialog @@ -377,7 +377,7 @@ 0 - 28,16 + -1,-1 1 m_linkButton 1