Re: Centring hyphertextctrl widgets

"Brendan Simon (eTRIX)" <[email protected]> Tue, 3 Sep 2019 10:32:23 +1000
Newsgroups gmane.comp.python.wxglade
Organization eTRIX pty ltd
Message-ID <[email protected]>
On 3/9/19 5:47 am, Dietmar Schwertberger wrote:
> On 02.09.2019 14:54, Brendan Simon (eTRIX) wrote:
>> One thing i noticed though was setting wxSHAPED clipped the underline
>> of the hyperlinkctrl.
>>
>> Is that a wxglade quirk or wxPython quirk?
>
> Maybe you can post a small file illustrating what you actually want to
> accomplish.

Here is the code that shows the issue.  There are three horizontal
sizers (with pad of 5).

  * Each horizontal sizer has 3 hyperlinkctrl widgets, set to align
    left, centre and right respectively (pad of 5).
  * The first sizer has widgets without wxSHAPED and proportion=1.
  * The second sizer has widgets with wxSHAPED and proportion=0.
  * The third sizer has widgets with wxSHAPED and proportion=1 (directly
    set in python file as wxglade wont allow it).

Interestingly, the clipping of the hypherlinkctrl happens when padding
is set and proporiton=0, but not when proportion=1.


Here is the python code.

    #!/usr/bin/env python
    # -*- coding: UTF-8 -*-
    #
    # generated by wxGlade 0.9.9pre on Tue Sep  3 10:15:07 2019
    #

    import wx
    import wx.adv

    # begin wxGlade: dependencies
    # end wxGlade

    # begin wxGlade: extracode
    # end wxGlade


    class MyFrame(wx.Frame):
        def __init__(self, *args, **kwds):
            # begin wxGlade: MyFrame.__init__
            kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
            wx.Frame.__init__(self, *args, **kwds)
            self.SetSize((436, 302))
            self.SetTitle("frame")
           
            sizer_1 = wx.BoxSizer(wx.VERTICAL)
           
            sizer_2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY,
    "without wxSHAPED"), wx.HORIZONTAL)
            sizer_1.Add(sizer_2, 0, wx.ALL | wx.EXPAND, 5)
           
            self.hyperlink_1 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_1", "")
            sizer_2.Add(self.hyperlink_1, 1, wx.ALIGN_CENTER | wx.ALL, 5)
           
            self.hyperlink_2 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_2", "", style=wx.adv.HL_ALIGN_CENTRE)
            sizer_2.Add(self.hyperlink_2, 1, wx.ALIGN_CENTER | wx.ALL, 5)
           
            self.hyperlink_3 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_3", "", style=wx.adv.HL_ALIGN_RIGHT)
            sizer_2.Add(self.hyperlink_3, 1, wx.ALIGN_CENTER | wx.ALL, 5)
           
            sizer_3 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY,
    "with wxSHAPED, proportion=0"), wx.HORIZONTAL)
            sizer_1.Add(sizer_3, 0, wx.ALL | wx.EXPAND, 5)
           
            self.hyperlink_4 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_4", "")
            sizer_3.Add(self.hyperlink_4, 0, wx.ALIGN_CENTER | wx.ALL |
    wx.SHAPED, 5)
           
            self.hyperlink_5 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_5", "", style=wx.adv.HL_ALIGN_CENTRE)
            sizer_3.Add(self.hyperlink_5, 0, wx.ALIGN_CENTER | wx.ALL |
    wx.SHAPED, 0)
           
            self.hyperlink_6 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_6", "", style=wx.adv.HL_ALIGN_RIGHT)
            sizer_3.Add(self.hyperlink_6, 0, wx.ALIGN_CENTER | wx.ALL |
    wx.SHAPED, 5)
           
            sizer_4 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY,
    "with wxSHAPED, proportion=1"), wx.HORIZONTAL)
            sizer_1.Add(sizer_4, 0, wx.ALL | wx.EXPAND, 5)
           
            #!
            #! NOTE: manually added proportion=1 as wxglade resets it to
    zero if wxSHAPED is selected !!
            #!
            proportion = 1

            self.hyperlink_7 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_7", "")
            sizer_4.Add(self.hyperlink_7, proportion, wx.ALIGN_CENTER |
    wx.ALL | wx.SHAPED, 5)
           
            self.hyperlink_8 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_8", "", style=wx.adv.HL_ALIGN_CENTRE)
            sizer_4.Add(self.hyperlink_8, proportion, wx.ALIGN_CENTER |
    wx.ALL | wx.SHAPED, 0)
           
            self.hyperlink_9 = wx.adv.HyperlinkCtrl(self, wx.ID_ANY,
    "hyperlink_9", "", style=wx.adv.HL_ALIGN_RIGHT)
            sizer_4.Add(self.hyperlink_9, proportion, wx.ALIGN_CENTER |
    wx.ALL | wx.SHAPED, 5)
           
            self.SetSizer(sizer_1)
           
            self.Layout()
            # end wxGlade

    # end of class MyFrame

    class MyApp(wx.App):
        def OnInit(self):
            self.frame = MyFrame(None, wx.ID_ANY, "")
            self.SetTopWindow(self.frame)
            self.frame.Show()
            return True

    # end of class MyApp

    if __name__ == "__main__":
        test_hypherlinkctrl = MyApp(0)
        test_hypherlinkctrl.MainLoop()


This is the wxglade project file.

    <?xml version="1.0"?>
    <!-- generated by wxGlade 0.9.9pre on Tue Sep  3 10:15:06 2019 -->

    <application class="MyApp" encoding="UTF-8" for_version="3.0"
    header_extension=".h" indent_amount="4" indent_symbol="space"
    is_template="0" language="python" mark_blocks="1"
    name="test_hypherlinkctrl" option="0" overwrite="1"
    path="test_hyperlinkctrl.py" source_extension=".cpp"
    top_window="frame" use_gettext="0" use_new_namespace="1">
        <object class="MyFrame" name="frame" base="EditFrame">
            <size>436, 302</size>
            <title>frame</title>
            <style>wxDEFAULT_FRAME_STYLE</style>
            <object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
                <orient>wxVERTICAL</orient>
                <object class="sizeritem">
                    <option>0</option>
                    <border>5</border>
                    <flag>wxALL|wxEXPAND</flag>
                    <object class="wxStaticBoxSizer" name="sizer_2"
    base="EditStaticBoxSizer">
                        <orient>wxHORIZONTAL</orient>
                        <label>without wxSHAPED</label>
                        <object class="sizeritem">
                            <option>1</option>
                            <border>5</border>
                            <flag>wxALL|wxALIGN_CENTER</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_1" base="EditHyperlinkCtrl">
                                <label>hyperlink_1</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                        <object class="sizeritem">
                            <option>1</option>
                            <border>5</border>
                            <flag>wxALL|wxALIGN_CENTER</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_2" base="EditHyperlinkCtrl">
                                <style>wxHL_ALIGN_CENTRE</style>
                                <label>hyperlink_2</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                        <object class="sizeritem">
                            <option>1</option>
                            <border>5</border>
                            <flag>wxALL|wxALIGN_CENTER</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_3" base="EditHyperlinkCtrl">
                                <style>wxHL_ALIGN_RIGHT</style>
                                <label>hyperlink_3</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                    </object>
                </object>
                <object class="sizeritem">
                    <option>0</option>
                    <border>5</border>
                    <flag>wxALL|wxEXPAND</flag>
                    <object class="wxStaticBoxSizer" name="sizer_3"
    base="EditStaticBoxSizer">
                        <orient>wxHORIZONTAL</orient>
                        <label>with wxSHAPED, proportion=0</label>
                        <object class="sizeritem">
                            <option>0</option>
                            <border>5</border>
                            <flag>wxALL|wxALIGN_CENTER|wxSHAPED</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_4" base="EditHyperlinkCtrl">
                                <label>hyperlink_4</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                        <object class="sizeritem">
                            <option>0</option>
                            <border>0</border>
                            <flag>wxALL|wxALIGN_CENTER|wxSHAPED</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_5" base="EditHyperlinkCtrl">
                                <style>wxHL_ALIGN_CENTRE</style>
                                <label>hyperlink_5</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                        <object class="sizeritem">
                            <option>0</option>
                            <border>5</border>
                            <flag>wxALL|wxALIGN_CENTER|wxSHAPED</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_6" base="EditHyperlinkCtrl">
                                <style>wxHL_ALIGN_RIGHT</style>
                                <label>hyperlink_6</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                    </object>
                </object>
                <object class="sizeritem">
                    <option>0</option>
                    <border>5</border>
                    <flag>wxALL|wxEXPAND</flag>
                    <object class="wxStaticBoxSizer" name="sizer_4"
    base="EditStaticBoxSizer">
                        <orient>wxHORIZONTAL</orient>
                        <label>with wxSHAPED, proportion=1</label>
                        <object class="sizeritem">
                            <option>0</option>
                            <border>5</border>
                            <flag>wxALL|wxALIGN_CENTER|wxSHAPED</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_7" base="EditHyperlinkCtrl">
                                <label>hyperlink_7</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                        <object class="sizeritem">
                            <option>0</option>
                            <border>0</border>
                            <flag>wxALL|wxALIGN_CENTER|wxSHAPED</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_8" base="EditHyperlinkCtrl">
                                <style>wxHL_ALIGN_CENTRE</style>
                                <label>hyperlink_8</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                        <object class="sizeritem">
                            <option>0</option>
                            <border>5</border>
                            <flag>wxALL|wxALIGN_CENTER|wxSHAPED</flag>
                            <object class="wxHyperlinkCtrl"
    name="hyperlink_9" base="EditHyperlinkCtrl">
                                <style>wxHL_ALIGN_RIGHT</style>
                                <label>hyperlink_9</label>
                                <attribute>1</attribute>
                            </object>
                        </object>
                    </object>
                </object>
            </object>
        </object>
    </application>


Hope that helps.

Brendan.



-- 
------------------------------------------------------------------------
*eTRIX Services*
PO Box 497, Inverloch, VIC 3996, AUSTRALIA.
(m) 0417-380-984
------------------------------------------------------------------------

_______________________________________________
wxGlade-general mailing list
wxGlade-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/wxglade-general