![]() For example, if your PushButton object is called button you would write button.value. Returns 1 when the button is pressed, 0 if the button is released The internal tkinter object, see Using tkinter The file path, tkinter.PhotoImage or PIL.Image you wish to display. This parameter is only required if the master object has a grid The alignment of this widget within its container You can set and get the following properties: Method Updates the function to call when the button is pressed. This is useful for scheduling a function to be regularly called, for example updating a value read from a sensor.ĭisplays the widget if it was previously hiddenĬhanges the state of the button to the opposite of its current state - if it is currently enabled, disable it and vice versa.Ĭommand (function name), args ( Optional List of arguments to be passed to command) Sets the amount of x (horizontal) and y (vertical) padding between the text/icon and the edge of the button This method will unpack the widget from the layout manager. (To repeatedly call the same command, use repeat())ĭisables the widget so that it is "greyed out" and cannot be interacted with Schedules a single call to command after time milliseconds. Time (int), command (function name), args (list of arguments) You can call the following methods on a PushButton object. ![]() Set the height of the widget in characters or pixels if its an image button or to "fill" Set the width of the widget in characters or pixels if its an image button or to "fill" If None (the default) the enabled property will be inherited from the master How much vertical padding to add between the text/icon and the edge of the button. How much horizontal padding to add between the text/icon and the edge of the button. If both an image and text are specified, the image will override the text. This parameter is only required if the master object has a grid layout. If you wish to pass any arguments to the function specified in the command parameter, you can specify them as a list Possible values: "top", "bottom", "left", "right". The name of a function to call when the button is pressed.Īlignment of this widget within its container. The container to which this widget belongs Specify parameters in the brackets, like this: button = PushButton(app) Parameter When you create a PushButton object you must specify master and you can specify any of the optional parameters. By default GIF and PNG are supported, except macOS which only supports GIF. The PushButton object displays a button with text or an image, which calls a function when pressed.Ĭreate a PushButton object like this: from guizero import App, PushButtonīutton = PushButton(app, command=do_nothing)Ĭreate a picture PushButton with an image like this: from guizero import App, PushButtonīutton = PushButton(app, image="button.gif", command=do_nothing)ĭepending on your operating system and whether you installed the guizero additional image features will determine what image types you can use for PushButton.
0 Comments
Leave a Reply. |