【问题标题】:wxPython -- How to update the border style of BitmapButton in some event say clickwxPython - 如何在某些事件中更新 BitmapButton 的边框样式说点击
【发布时间】:2014-06-28 13:59:53
【问题描述】:

我正在尝试在创建按钮后添加/删除 BitmapButton 的边框。我还没有找到任何工作示例来更新 BitmapButton 的外观。说

self.btn = wx.BitmapButton(self.panel, wx.ID_ANY, bmp, pos=(...))
self.Bind(wx.EVT_BUTTON, self.OnClick, self.btn)

然后在 OnClick 中

def OnClick(self):
    # what should be here to give / remove the border of the button being clicked

谢谢

【问题讨论】:

    标签: python button bitmap wxpython border


    【解决方案1】:

    您需要使用SetWindowStyle() 或SetWindowStyleFlag() 之类的方法,这些方法由所有wxWidgets 窗口的共同祖先wx.Window 实现,并记录在here。

    例如,对于边框,试试这个:

    btn.SetWindowStyleFlag(wx.SIMPLE_BORDER)
    # or
    btn.SetWindowStyleFlag(wx.NO_BORDER)
    

    【讨论】:

    • 要让它在 wx.Panel 上工作,我必须添加标志 wx.FULL_REPAINT_ON_RESIZE,然后将面板大小调整为 1 像素,然后再次将其调整回原始大小
    猜你喜欢
    • 2017-05-28
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 2013-04-23
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多