wx.BoxSizer both VERTICAL and HORIZONTAL centered

Basj

I would like to center an element both vertically and horizontally with wx.BoxSizer. I tried this unsuccessfuly (result: the element is centered vertically but not horizontally...) :

vsizer = wx.BoxSizer(wx.VERTICAL)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
vsizer.AddStretchSpacer(1)
vsizer.Add(hsizer, 0, wx.ALL, 15)
vsizer.AddStretchSpacer(1)
self.SetSizer(vsizer)
hsizer.AddStretchSpacer(1)
hsizer.Add(wx.StaticBitmap(self, -1, myimg), 0, wx.ALL, 15)
hsizer.AddStretchSpacer(1) 

How to center an element both vertically and horizontally with wx.BoxSizer ?

Victor

Here is a simple example:

import wx

class Frame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Vertical center")
        self.text = wx.StaticText(self, label=("This should be centered both"
                                   " vertically and horizontally"))
        sizer_v = wx.BoxSizer(wx.VERTICAL)
        sizer_h = wx.BoxSizer(wx.HORIZONTAL)
        sizer_h.Add(self.text, 1, wx.CENTER)
        sizer_v.Add(sizer_h, 1, wx.CENTER)
        self.SetSizer(sizer_v)

        self.Show()

app = wx.App()
Frame()
app.MainLoop()

wx.CENTER centers an element inside wx.BoxSizer (scroll to the bottom of the page): http://wiki.wxpython.org/BoxSizerTutorial
HTH

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

wx.BoxSizer both VERTICAL and HORIZONTAL centered

From Dev

GridBagConstraints filling both VERTICAL & HORIZONTAL

From Dev

CSS, horizontal distribution + horizontal+vertical centered text

From Dev

Image <a> vertical & horizontal align center and resize with % in both

From Dev

Create a RecyclerView with both horizontal and vertical scrolling

From Dev

Margin div to center both horizontal and vertical

From Dev

Relayout of wx.BoxSizer if child resizes

From Dev

Get my login in middle of screen, both vertical and horizontal

From Dev

Plotting both horizontal and vertical point ranges simultaneously in ggplot

From Dev

Fixed table header scroll both horizontal and vertical CSS ONLY

From Dev

How to do proportionate image gallery supporting both horizontal and vertical aspects?

From Dev

How to display both horizontal and vertical grid lines in google chart

From Dev

Is it possible to plot both a horizontal line and a vertical line on an Excel chart?

From Dev

Center a both vertical and horizontal scalable div in the middle of any browser dimension

From Dev

Generating dynamic data for html table with both vertical and horizontal header

From Dev

Using jquery, How can I scroll to a particular div on a page is centered (vertical and horizontal)?

From Dev

UICollectionView Horizontal Paging not centered

From Dev

float a horizontal centered div

From Dev

How does PDF line width interact with the CTM in both horizontal and vertical dimensions?

From Dev

How do I create a robust ScrollView with both horizontal and vertical paging using autoLayout?

From Dev

jQuery horizontal aligned div is not centered

From Java

vertical & horizontal lines in matplotlib

From Dev

Labelling Vertical and Horizontal Dendrograms

From Dev

vertical to horizontal navigation

From Dev

Bootstrap Horizontal Form not vertical

From Dev

Vertical and Horizontal Group by in sql

From Dev

qlineargradient horizontal & vertical

From Dev

SQL Query; Horizontal to Vertical

From Dev

MPAndroidChart BarChart horizontal / vertical

Related Related

  1. 1

    wx.BoxSizer both VERTICAL and HORIZONTAL centered

  2. 2

    GridBagConstraints filling both VERTICAL & HORIZONTAL

  3. 3

    CSS, horizontal distribution + horizontal+vertical centered text

  4. 4

    Image <a> vertical & horizontal align center and resize with % in both

  5. 5

    Create a RecyclerView with both horizontal and vertical scrolling

  6. 6

    Margin div to center both horizontal and vertical

  7. 7

    Relayout of wx.BoxSizer if child resizes

  8. 8

    Get my login in middle of screen, both vertical and horizontal

  9. 9

    Plotting both horizontal and vertical point ranges simultaneously in ggplot

  10. 10

    Fixed table header scroll both horizontal and vertical CSS ONLY

  11. 11

    How to do proportionate image gallery supporting both horizontal and vertical aspects?

  12. 12

    How to display both horizontal and vertical grid lines in google chart

  13. 13

    Is it possible to plot both a horizontal line and a vertical line on an Excel chart?

  14. 14

    Center a both vertical and horizontal scalable div in the middle of any browser dimension

  15. 15

    Generating dynamic data for html table with both vertical and horizontal header

  16. 16

    Using jquery, How can I scroll to a particular div on a page is centered (vertical and horizontal)?

  17. 17

    UICollectionView Horizontal Paging not centered

  18. 18

    float a horizontal centered div

  19. 19

    How does PDF line width interact with the CTM in both horizontal and vertical dimensions?

  20. 20

    How do I create a robust ScrollView with both horizontal and vertical paging using autoLayout?

  21. 21

    jQuery horizontal aligned div is not centered

  22. 22

    vertical & horizontal lines in matplotlib

  23. 23

    Labelling Vertical and Horizontal Dendrograms

  24. 24

    vertical to horizontal navigation

  25. 25

    Bootstrap Horizontal Form not vertical

  26. 26

    Vertical and Horizontal Group by in sql

  27. 27

    qlineargradient horizontal & vertical

  28. 28

    SQL Query; Horizontal to Vertical

  29. 29

    MPAndroidChart BarChart horizontal / vertical

HotTag

Archive