问题
How can I add a outline border to a widget in wxpython? (Any widget, for example, a wx.Button
)
回答1:
For panel, you can use
p = wx.Panel(....., style=wx.SUNKEN_BORDER)
there you can choose from constants:
wx.SIMPLE_BORDER
wx.RAISED_BORDER
wx.SUNKEN_BORDER
wx.NO_BORDER
If you want to create border around wx.Button
, i would use my custom bitmap with wx.BitmapButton
:
b = wx.BitmapButton(pane, -1, wx.Bitmap('buttons/my_beautiful_button.png'))
For any widget, i think you can always create a wx.Panel
with some border and put the widget into the panel.
回答2:
There's no easy way to change how 'standard' widgets look like in wxPython ('standard' I mean wx.Button, wx.CheckBox, etc.), because they use native controls of your underlying OS window manager and you can't change that.
Your way to go is to dig into wx.lib
where you can find better generic controls and windows that don't use native controls but prefer custom rendering of those.
If you want to have better control on your buttons, use wx.lib.buttons. The same rule applies to other controls - look at wx.lib
.
来源:https://stackoverflow.com/questions/11922769/how-to-add-an-outline-border-to-a-widget