当前位置: 首页>>代码示例>>Python>>正文


Python wx.ToggleButton方法代码示例

本文整理汇总了Python中wx.ToggleButton方法的典型用法代码示例。如果您正苦于以下问题:Python wx.ToggleButton方法的具体用法?Python wx.ToggleButton怎么用?Python wx.ToggleButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wx的用法示例。


在下文中一共展示了wx.ToggleButton方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_toolitem

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ToggleButton [as 别名]
def add_toolitem(
        self, name, group, position, image_file, description, toggle):

        before, group = self._add_to_group(group, name, position)
        idx = self.GetToolPos(before.Id)
        if image_file:
            bmp = _load_bitmap(image_file)
            kind = wx.ITEM_NORMAL if not toggle else wx.ITEM_CHECK
            tool = self.InsertTool(idx, -1, name, bmp, wx.NullBitmap, kind,
                                   description or "")
        else:
            size = (self.GetTextExtent(name)[0]+10, -1)
            if toggle:
                control = wx.ToggleButton(self, -1, name, size=size)
            else:
                control = wx.Button(self, -1, name, size=size)
            tool = self.InsertControl(idx, control, label=name)
        self.Realize()

        def handler(event):
            self.trigger_tool(name)

        if image_file:
            self.Bind(wx.EVT_TOOL, handler, tool)
        else:
            control.Bind(wx.EVT_LEFT_DOWN, handler)

        self._toolitems.setdefault(name, [])
        group.insert(position, tool)
        self._toolitems[name].append((tool, handler)) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:32,代码来源:backend_wx.py

示例2: add_toolitem

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ToggleButton [as 别名]
def add_toolitem(
        self, name, group, position, image_file, description, toggle):

        before, group = self._add_to_group(group, name, position)
        idx = self.GetToolPos(before.Id)
        if image_file:
            bmp = _load_bitmap(image_file)
            kind = wx.ITEM_NORMAL if not toggle else wx.ITEM_CHECK
            tool = self.InsertTool(idx, -1, name, bmp, wx.NullBitmap, kind,
                                   description or "")
        else:
            size = (self.GetTextExtent(name)[0]+10, -1)
            if toggle:
                control = wx.ToggleButton(self, -1, name, size=size)
            else:
                control = wx.Button(self, -1, name, size=size)
            tool = self.InsertControl(idx, control, label=name)
        self.Realize()

        def handler(event):
            self.trigger_tool(name)

        if image_file:
            self.Bind(wx.EVT_TOOL, handler, tool)
        else:
            control.Bind(wx.EVT_LEFT_DOWN, handler)

        self._last = tool
        self._toolitems.setdefault(name, [])
        group.insert(position, tool)
        self._toolitems[name].append((tool, handler)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:33,代码来源:backend_wx.py

示例3: __init__

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ToggleButton [as 别名]
def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        common.palette = self # for building the buttons
        self.SetBackgroundColour( compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) )

        # load the available code generators
        all_widgets = common.init_codegen()
        if not config.use_gui: return
        self.all_togglebuttons = []  # used by reset_togglebuttons

        # for keyboard navigation:
        self._id_to_coordinate = {}
        self._ids_by_row = []
        self._section_to_row = {}

        # build the palette for all_widgets
        sizer = wx.FlexGridSizer(0, 2, 0, 0)
        maxlen = max([len(all_widgets[sect]) for sect in all_widgets])  # the maximum number of buttons in a section
        for row, section in enumerate(all_widgets):
            self._section_to_row[section] = row
            self._ids_by_row.append([])
            if section:
                label = wx.StaticText(self, -1, "%s:" % section.replace('&', '&&'))
                sizer.Add( label, 1, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 2 )
            bsizer = wx.BoxSizer()
            for col, button in enumerate(all_widgets[section]):
                self._ids_by_row[-1].append(button.Id)
                self._id_to_coordinate[button.Id] = (row,col)
                bsizer.Add(button, flag=wx.ALL, border=1)
                if isinstance(button, wx.ToggleButton):
                    self.all_togglebuttons.append(button)
            sizer.Add(bsizer)
        self.SetSizer(sizer)
        # on platforms other than Windows, we'll set the ToggleButton background colour to indicate the selection
        if wx.Platform == "__WXMSW__":
            self._highlight_colour = None
        else:
            self._highlight_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
        self.Bind(wx.EVT_CHAR_HOOK, self.on_char) 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:41,代码来源:main.py

示例4: create_widget

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ToggleButton [as 别名]
def create_widget(self):
        self.widget = wx.ToggleButton(self.parent_window.widget, self.id, self.label)
        self.widget.SetValue(self.value)
        self.widget.Bind(wx.EVT_TOGGLEBUTTON, self.on_set_focus, id=self.id)
        BitmapMixin._set_preview_bitmaps(self) 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:7,代码来源:toggle_button.py

示例5: InitCtrlBool

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ToggleButton [as 别名]
def InitCtrlBool(self, info_sizer, defaultValue):
        """Add button to change value of boolean variable"""
        self.ValueCtrl = wx.ToggleButton(self, label=_("Toggle value"))
        value = GetTypeValue[self.IEC_Type](defaultValue)
        if value is not None:
            self.ValueCtrl.SetValue(value)

        info_sizer.AddWindow(self.ValueCtrl, border=10,
                             flag=wx.ALIGN_LEFT | wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT | wx.GROW) 
开发者ID:thiagoralves,项目名称:OpenPLC_Editor,代码行数:11,代码来源:ForceVariableDialog.py

示例6: make_object_button

# 需要导入模块: import wx [as 别名]
# 或者: from wx import ToggleButton [as 别名]
def make_object_button(widget, icon_path, toplevel=False, tip=None):
    """Creates a button for the widgets toolbar.

    Function used by the various widget modules to add a button to the widgets toolbar.

    Icons with a relative path will be loaded from config.icon_path.

    widget: (name of) the widget the button will add to the app 
    icon_path: Path to the icon_path used for the button
    toplevel: True if the widget is a toplevel object (frame, dialog)
    tip: Tool tip to display

    return: The newly created wxBitmapButton instance"""
    if not config.use_gui: return None
    import wx
    import misc
    from tree import WidgetTree

    if not os.path.isabs(icon_path):
        icon_path = os.path.join(config.icons_path, icon_path)
    bmp = misc.get_xpm_bitmap(icon_path)
    label = widget.replace('Edit', '')
    if compat.version < (3,0):
        # old wx version: use BitmapButton
        tmp = wx.BitmapButton(palette, -1, bmp, size=(31,31))
        if not toplevel:
            tmp.Bind(wx.EVT_BUTTON, add_object)
        else:
            tmp.Bind(wx.EVT_BUTTON, add_toplevel_object)
    else:
        # for more recent versions, we support config options to display icons and/or labels
        if not toplevel:
            if not config.preferences.show_palette_labels:
                # icons only -> set size
                tmp = wx.ToggleButton(palette, -1, size=(31,31), name=label)
            else:
                tmp = wx.ToggleButton(palette, -1, label, name=label )
            tmp.Bind(wx.EVT_TOGGLEBUTTON, add_object)
        else:
            if not config.preferences.show_palette_labels:
                tmp = wx.Button(palette, -1, size=(31,31), name=label)
            else:
                tmp = wx.Button(palette, -1, label, name=label )
            tmp.Bind(wx.EVT_BUTTON, add_toplevel_object)
        if config.preferences.show_palette_icons:
            tmp.SetBitmap( bmp )
    refs[tmp.GetId()] = widget
    if not tip:
        tip = _('Add a %s') % label
    tmp.SetToolTip(wx.ToolTip(tip))

    WidgetTree.images[widget] = icon_path

    return tmp 
开发者ID:wxGlade,项目名称:wxGlade,代码行数:56,代码来源:common.py


注:本文中的wx.ToggleButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。