wxPython | FindControl() function in Python (original) (raw)
Last Updated : 13 Mar, 2023
In this particular article we are going to learn about FindControl() function of wx.ToolBar class of wxPython. FindControl() function is used to returns a pointer to the control identified by id or None if no corresponding control is found. It takes only one parameter 'id'.
Syntax :
wx.ToolBar.FindControl(self, id)
Parameters :
Parameter Input Type Description id int Identifier for control. Returns Type:
wx.Control
Code Example 1:
Python3 `
import wx
class Example(wx.Frame): global count count = 0;
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
def InitUI(self):
pnl = wx.Panel(self)
self.toolbar = self.CreateToolBar()
ctrl = wx.Control(self.toolbar, 21, wx.DefaultPosition, wx.DefaultSize, style = 0, name ='control')
# Add control using AddControl() method
rtool = self.toolbar.AddControl(ctrl, 'control')
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Simple toolbar')
self.Centre()
print(self.toolbar.FindControl(21))
def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop()
if name == 'main': main()
`
Output :
<wx._core.Control object at 0x00000026931240D0>
Code Example 2:
Python3 `
import wx
class Example(wx.Frame): global count count = 0;
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
def InitUI(self):
pnl = wx.Panel(self)
self.toolbar = self.CreateToolBar()
ctrl = wx.Control(self.toolbar, 21, wx.DefaultPosition, wx.DefaultSize, style = 0, name ='control')
# Add control using AddControl() method
rtool = self.toolbar.AddControl(ctrl, 'control')
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Simple toolbar')
self.Centre()
print(self.toolbar.FindControl(21).GetName())
def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop()
if name == 'main': main()
`
Output :
control
Similar Reads
- wxPython| FindById() function in python In this article we are going to learn a simple function that is FindById() in wx.ToolBar class of wxPython. FindById is a simple function and returns a pointer to the tool identified by id or None if no corresponding tool is found. FindById() takes only single parameter that is id of a particular to 2 min read
- Python - AddCheckTool() function in wxPython In this article we are going to learn about AddCheckTool() in wx.ToolBar class of wxPython. AddCheckTool() function is used to add check tools. A checktool is a kind of toggle button. A checktool have a on and off state. Syntax : wx.ToolBar.AddCheckTool(self, toolId, label, bitmap1, bmpDisabled=Null 2 min read
- Python - Create() function in wxPython In this particular article we are going to learn about Create() function present in wx.Frame class. Create function is similar to Frame() constructor of wx.Frame class. Create function is used in two-step frame construction. Syntax : wx.Frame.Create(parent, id=ID_ANY, title="", pos=DefaultPosition, 1 min read
- wxPython | Exit() function in wxPython In this article we are going to learn about wx.Exit() which is a inbuilt parent function present in wxPython.Exit() function exits application after calling wx.App.OnExit . Should only be used in an emergency: normally the top-level frame should be deleted (after deleting all other frames) to termin 1 min read
- wxPython | FindToolForPosition() function in python In this article we are going to learn about FindToolForPosition() function of class wx.ToolBar of wxPython. FindToolForPosition() is used to find a tool for the given mouse position. It takes x and y position of the window. Syntax: wx.ToolBar.FindToolForPosition(self, x, y) Parameters : ParameterInp 2 min read
- wxPython | EnableTool() function in wxPython In this article we are going to learn about EnableTool() function of wx.ToolBar class of wxPython. It is another important function in wx.Toolbar class. EnableTool() function is used to enable or disable a particular tool in Toolbar. It takes 'enable' bool parameter which is when true enable the too 2 min read
- Python | wxPython module Introduction Python provides wxpython module which allows us to create high functional graphical user interface. It is an Open Source module, which means it is free for anyone to use and the source code is available for anyone to look and modify. It is implemented as a set of extension modules that wrap the GUI 3 min read
- Python - Move() function in wxPython In this particular article we will learn, how can we move our window to a particular point. This can be achieved using Move() function in wx.Window class of wxPython. Move() takes x and y points to move window to a particularx, y point. Syntax : wx.Move(self, x, y, flags=SIZE_USE_EXISTING) Parameter 1 min read
- wxPython - Frame() Constructor in Python In this article we will know about the frame() constructor in wxPython. frame() constructor is a constructor for the wx.Frame class of wxPython. This constructor is used to set different attributes of the frame. Syntax :  wx.Frame(parent, id=ID_ANY, title="", pos=DefaultPosition, size=DefaultSize, 1 min read
- wxPython | GetToolPacking() function in python In this article we are going to learn about GetToolPacking() function associated with wx.ToolBar class of wxPython. GetToolPacking() function simply returns the value used for packing tools.The packing is used for spacing in the vertical direction if the toolbar is horizontal, and for spacing in the 2 min read