Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython – AddControl() method in wx.ToolBar

  • Last Updated : 15 May, 2020

In this article we are going to learn about AddControl() function in wx.ToolBar class in wxPython. AddControl() creates a control in toolbar. A Control is generally a small window which processes user input and/or displays one or more item of data.

Syntax :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

wx.ToolBar.AddControl(self, control, label="")

Parameters :

ParameterInput TypeDescription
controlwx.ControlThe control to be added.
labelstringText to be displayed near the control.

Return Type : wx.ToolBarToolBase

Code Example :

import wx
class Example(wx.Frame):
    global count
    count = 0;
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        pnl = wx.Panel(self)
        self.toolbar = self.CreateToolBar()
        ctrl = wx.Control(self.toolbar, 21
                          style = 0
                          name = 'control')
        qtool = self.toolbar.AddTool(12, 'Quit'
        # Add control using AddControl() method
        rtool = self.toolbar.AddControl(ctrl, 'control')
        self.SetSize((350, 250))
        self.SetTitle('Simple toolbar')
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output :

My Personal Notes arrow_drop_up
Recommended Articles
Page :