GUI CheatSheet
GUI CheatSheet
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
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)
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