Button in wxPython - Python Last Updated : 24 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article we are going to learn how can we add buttons to a frame in wxPython. This can be done by using the Button() constructor of wx.Button class. Following styles are supported in this class: wx.BU_LEFT: Left-justifies the label. Windows and GTK+ only.wx.BU_TOP: Aligns the label to the top of the button. Windows and GTK+ only.wx.BU_RIGHT: Right-justifies the bitmap label. Windows and GTK+ only.wx.BU_BOTTOM: Aligns the label to the bottom of the button. Windows and GTK+ only.wx.BU_EXACTFIT: By default, all buttons are made of at least the standard button size, even if their contents is small enough to fit into a smaller size. This is done for consistency as most platforms use buttons of the same size in the native dialogs, but can be overridden by specifying this flag. If it is given, the button will be made just big enough for its contents. Notice that under MSW the button will still have at least the standard height, even with this style, if it has a non-empty label.wx.BU_NOTEXT: Disables the display of the text label in the button even if it has one or its id is one of the standard stock ids with an associated label: without using this style a button which is only supposed to show a bitmap but uses a standard id would display a label too.wx.BORDER_NONE: Creates a button without border. This is currently implemented in MSW, GTK2 and OSX/Cocoa. Syntax : wx.StaticText(self, parent, id=ID_ANY, label=””, pos=DefaultPosition, size=DefaultSize, style=0, validator= DefaultValidator, name=StaticTextNameStr) Parameters : ParameterInput TypeDescriptionparentwx.WindowParent window. Should not be None.idwx.WindowIDControl identifier. A value of -1 denotes a default value.labelstringText Label.poswx.PointWindow position.sizewx.WindowWindow size.stylelongWindow style.validatorwx.ValidatorWindow validator.namestringWindow name. Example #1: Python3 # import wxPython def onButton(event): print( "Button pressed.") app = wx.App() frame = wx.Frame(None, -1, 'win.py') frame.SetDimensions(200, 0, 200, 50) panel = wx.Panel(frame, wx.ID_ANY) button = wx.Button(panel, wx.ID_ANY, 'Test', (10, 10)) button.Bind(wx.EVT_BUTTON, onButton) frame.Show() app.MainLoop() Output : Comment More infoAdvertise with us Next Article wxPython - Image on button in Python R RahulSabharwal Follow Improve Article Tags : Python Python-gui Python-wxPython Practice Tags : python Similar Reads wxPython - Image on button in Python In this particular article we will learn how can we add image to a button in GUI using wxPython. This can be achieved using BitmapButton() constructor of wx.BitmapButton class in wx. Following Window Styles are supported : wx.BU_LEFT: Left-justifies the bitmap label.wx.BU_TOP: Aligns the bitmap labe 1 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| 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 - 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 Python - CreateToolBar() in wxPython In this article we will learn how can we add a toolbar in a frame. A toolbar in a gui application provides quick access to various important tools. We can create toolbar using CreateToolBar() function in wx.Frame class of wxPython. Syntax : wx.Frame.CreateToolBar(self, style=TB_DEFAULT_STYLE, id=ID_ 1 min read Like