How to add an outline border to a widget?

邮差的信 提交于 2020-01-03 13:34:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!