0% found this document useful (0 votes)
213 views

GUI CheatSheet

This document provides documentation on methods for creating and customizing graphical user interfaces (GUIs) using the RWBA tools library in Python. It describes methods for adding common GUI elements like labels, buttons, text boxes, images and sounds. It also covers methods for formatting, dialog boxes, events and more. The goal is to provide developers with a concise reference for building customized GUIs programmatically.

Uploaded by

pfalencar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
213 views

GUI CheatSheet

This document provides documentation on methods for creating and customizing graphical user interfaces (GUIs) using the RWBA tools library in Python. It describes methods for adding common GUI elements like labels, buttons, text boxes, images and sounds. It also covers methods for formatting, dialog boxes, events and more. The goal is to provide developers with a concise reference for building customized GUIs programmatically.

Uploaded by

pfalencar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GUI Library

Setup
from rwbatools import gui Import the gui class from the RWBA tools library
win = gui ( “name”, “widthxheight” ) Create a GUI, with the specified name and geometry
.go ( ) .stop ( ) Start / Stop the GUI
.setGeom ( “widthxheight” ) Change the GUI’s geometry, eg. “400x200” or “fullscreen”
.exitFullscreen ( ) Take the GUI out of fullscreen, returns to previous geometry
.setResizable ( True ) Set the GUI to be resizable (True or False)
.setTitle ( title ) Set a new title for the GUI
.setIcon ( image ) Set an icon for the GUI
.setPadX ( x ) .setPady ( y ) Change the x/y padding (must be done before adding widgets)
.setTransparency ( ) Stes the transparency of the window, between 0 and 1

Labels & Message Boxes


.addLabel ( title, text, RCS ) Adds a label with the specified title and text
.addEmptyLabel ( title, RCS ) Adds an empty label
.addLabels ( titles, R, cols ) Adds a row of labels, with the specified titles as their text
.setLabel ( title, text ) Changes the text of the specified label
.getLabel ( title ) Get the contents of the specified label
.clearLabel ( title ) Clears the specified label
.addMessage ( title, text, RCS ) Adds a message box with the specified text
.addEmptyMessage (title, RCS ) Adds an empty message box
.setMessage ( title, text ) Changes the text of the specified message box
.clearMessage ( title ) Clears the specified message box

Buttons & Links


.addButton ( title, func, RCS ) Adds a button with the specified text and function
.addNamedButton ( name, title, func, RCS ) Adds a button, with a different name to the title
.addButtons ( title, funcs, RCS ) Adds a row of buttons, with the specified titles and functions
.setButton ( title, text ) Changes the text of the specified button
.setButtonImage (title, image ) Sets an image for the button, instead of text
.addWebLink ( title, page, RCS ) Adds a hyperlink to launch the specified web page
.addLink (title, func, RCS ) Adds a hyperlink to execute the specified function

Entries
.addEntry ( title, RCS ) Adds an entry box
.addSecretEntry ( title, RCS ) Adds a ‘password’ entry box
.setEntry ( title, text ) Changes the text of the specified entry box
.getEntry ( title ) Gets the text of the specified entry box
.clearEntry ( title ) Clears the specified entry box
.clearAllEntries ( ) Clears all entry boxes in the GUI
.addLabelEntry ( title, RC ) Adds an entry box with a label before it
.addSecretLabelEntry ( title, RC ) Adds a ‘password’ style entry box with a label before it
.setFocus ( title ) Gives focus to the specified entry box
.setEntryFunc ( title, func, name ) Binds the specified function to the specified entry box
GUI Library
List Boxes
.addListBox ( title, items, RCS ) Adds a single-select list box with the specified items
.addListItem ( title, item ) Adds an item to the specified list box
.getListItems ( title ) Gets the selected items from the specified list box
.clearListBox ( title ) Clears the items from the specified list box
.setListSingle ( title, True ) Sets the specified list box to be single (True) or multi (False)

Check Boxes & Radio Buttons


.addCheckBox ( title, RCS ) Adds a check box
.getCheckBox ( title ) Returns the state of the specified check box (True or False)
.setCheckBox ( title, True ) Sets the state of the specified check box (True or False)
.addRadioButton ( title, value, RCS ) Adds a radio button with the specified value to the titled set
.getRadioButton ( title ) Gets the name of the selected radio button
.setRadioButton ( title, name ) Selects the named radio button from the titled set
.setRadioTick (title, True ) Sets the radio button to be a tick box (True) or a button (False)

Scales & Meters


.addScale ( title, RCS ) Adds a horizontal scale
.orientScaleHor ( title, True ) Sets the specified scale to be horizontal (True) or vertical (False)
.setScaleRange (title, start, end, curr ) Sets a new range and selected number for the specified scale
.getScale ( title ) Gets the value of the specified scale
.setScale ( title, pos ) Sets the value for the specified scale
.showScaleValue ( title, False ) Shows the scales value, pass in False to turn it back off
.addMeter ( name, RCS ) Create a progress bar
.setMeter ( name, value, text ) Set the value of the specified progress bar
.getMeter ( name ) Get the value of the specified progress bar

OptionBoxes & SpinBoxes


.addOptionBox ( title, options, RCS ) Adds an option box, with the specified values (a list)
.addLabelOptionBox ( title, options, RCS ) Adds an option box, with a label before it
.changeOptionBox ( title, options ) Changes the options in the specified option box
.setOptionBox ( title, position ) Selects the option at the specified position in the list
.getOptionBox ( title ) Gets the currently selected option box item
.addSpinBox ( title, vals, RCS ) Adds a spin box, with the specified values (a list)
.addSpinBoxRange ( title, from, to, RCS ) Adds a spin box, with the specified range of values
.addLabelSpinBox ( title, vals, RCS ) Adds a spin box, with a label before it
.getSpinBox ( title ) Gets the currently selected spin box item

TextAreas
.addTextArea ( title, RCS ) Adds a text area
.addScrolledTextArea ( title, RCS ) Adds a text area with a vertical scroll bar
.setTextArea ( title, text ) Changes the text of the specified text area
.getTextArea ( title ) Gets the text of the specified text area
.clearTextArea ( title ) Clears the specified text area
GUI Library
Images & Sounds
.addImage ( title, file, RCS ) Displays the specified .GIF/.BMP/.PNG/(None) file
.setImage ( title, file ) Changes the specified image
.setImageSize ( title, width, height ) Sets the maximum image size, will crop bigger images
.zoomImage ( name, multiple) +ve/-ve multiple will increase/decrease image size
.setBgImage ( file ) Sets an image for the background of the GUI
.removeBgImage ( ) Removes the background image from the GUI
.playSound ( sound ) Plays (stops) the specified .WAV file (Windows only)
.stopSound ( ) Stops the sound currently playing
.loopSound ( sound ) Repeatedly play the specified .WAV file (Windows only)
.soundError ( ) .soundWarning ( ) Plays the system error/warning message (Windows only)

Extras
.addMenuList ( menu, items, funcs ) Adds a drop-down menu, with the name, items, and functions
.addMenu ( menu, func ) Adds a single menu item, with the name & function
.addToolbar ( names, funcs ) Adds a toolbar at the top, with the named buttons and functions
.addStatus ( header ) Adds a status bar at the bottom, with an optional header
.setStatus ( text ) Changes the status bar text (includes/removes header)
.clearStatus ( ) Clears the status bar

Advanced
.registerEvent ( func ) Cause the specified function to be repeatedly called
.setPollTime ( time ) Sets number of seconds to wait before firing events
.setStopFunction ( function ) Set a function to call when user closes GUI, must return True/False

Dialog Boxes
.infoBox ( title, message ) Shows an information dialog
.errorBox ( title, message ) Shows an error dialog
.warningBox ( title, message ) Shows a warning dialog
.yesNoBox ( title, message ) Asks a yes/no question
.questionBox ( title, message ) Asks a question
.okBox ( title, message ) Asks an OK question
.retryBox ( title, message ) Asks a retry question
.openBox ( ) Allows user to choose a file to open
.saveBox ( ) Allows user to choose a file to save
.directoryBox ( ) Allows user to choose a directory
.colourBox ( colour ) Allows user to choose a colour
.textBox ( title, question ) Asks a question, returns the answer
.numBox ( title, question ) Asks a question, returns the answer (must be a number)
GUI Library
Formatting
.increaseButtonFont ( ) Increases the font size of all buttons
.decreaseButtonFont ( ) Decreases the font size of all buttons
.setButtonFont ( size, family ) Sets the font size of all buttons
.increaseLabelFont ( ) Increases the font size of all text (labels, entry boxes, etc)
.decreaseLabelFont ( ) Decreases the font size of all text (labels, entry boxes, etc)
.setLabelFont ( size, family ) Sets the font size of all text (labels, entry boxes, etc)
.increaseFont ( ) Increase the font size of everything
.decreaseFont ( ) Decrease the font size of everything
.setFont ( size, family ) Set the font size of everything

.setBg ( ) Set the BG colour of everything

.setXXXBg ( title, col ) Set the BG colour of the widget


.setXXXFg ( title, col ) Set the FG colour of the widget
.setXXXDisabledFg ( title, col ) Set the disabled FG colour of the widget
.setXXXWidth ( title, width ) Set the width of the widget
.setXXXHeight ( title, height ) Set the height of the widget

.setXXXRelief ( title, relief ) Set relief of the widget (SUNKEN,RAISED,GROOVE,RIDGE,FLAT)


.setXXXAlign ( title, align ) Set alignment of the widget (N,NE,E,SE,S,SW,W,NW,CENTER)
setXXXAnchor ( title, pos )
.setXXXCommand ( title, func ) Set a new function for the widget
.setXXXCursor ( title, cursor ) Set a new cursor for the widget
.setXXXTooltip ( title, tip ) Set a tooltip for the widget
.setXXXFocus ( title )
.setXXXSticky (title, pos ) Sets the appearance in the row: left, tight, both

.enableXXX ( title ) Enable the widget


.disableXXX ( title ) Disable the widget
.hideXXX ( title ) Temporarily hide the widget
.showXXX ( title ) Reveal a hidden widget
.removeXXX ( title ) Permanently delete a widget

.removeAllWidgets ( ) Permanently delete all widgets in the GUI

.setXXXWidths (titles, width ) Sets the width of the specified widgets


.setXXXHeights (titles, height ) Sets the height of the specified widgets
.setAllXXXWidths ( width ) Sets the width of all widgets
.setAllXXXHeights ( height ) Sets the height of all widgets

You might also like