Skip to main content

Rapidly create gui without any knowledge of wxpython

Project description

Rapidly create GUI without any knowledge of wxpython
=============================================
jerryzhujian9_at_gmail.com
Tested under python 2.7
To see your python version
in terminal: python -V
or in python: import sys; print (sys.version)

inspired by gui2py, easygui
=============================================
Install:
1) Requires wxPython 2.9.2.4 (tested under canopy)
2) or you can install it first manually from
http://sourceforge.net/projects/wxpython/files/wxPython/2.9.2.4/
Then https://pypi.python.org/pypi/quickgui
pip install quickgui
method 1&2 run: python myscript.py is fine
3) For anacoda python (wxPython 3.0 tested)
but remember to run: pythonw myscript.py instead of python myscript.py

Usage:
import quickgui as q

Message(msg, seconds=10), message
Displays a timed modal message box, timeout and cancel returns 0, ok returns 1
XPrinter()
Display a window to capture print output
if on, both terminal and window (updating gui will greatly increase script execution time)
if off, only terminal

Methods: on/off

Examples:
xprinter = XPrinter()
xprinter.on()
print 'will be shown on window'
xprinter.off()
print 'will be shown in terminal'
xprinter.on()
print 'on window again'

for x in range(100):
print "I am a line of " + str(x)
# time.sleep(0.01)

alert, confirm, getfile, setfile, getdir, inputs
Alert(message, title="", icon="exclamation")
# Shows a simple pop-up modal dialog.
# icon = "exclamation", "error", "question", "info"
Confirm(message="", title="", default=False, ok=False, cancel=False)
# Asks for confirmation (yes/no or ok and cancel), returns True or False or None.
# show yes/no by default
# default sets the default button
# ok shows OK; cancel shows Cancel

GetFile(directory='', filename='', multiple=False, wildcard='All Files (*.*)|*.*', title="Select file(s)")
# Shows a dialog to select files to open, return path(s) if accepted.
# wildcard format: 'BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif'
'Pictures (*.jpeg,*.png)|*.jpeg;*.png
SetFile(directory='', filename='', overwrite=False, wildcard='All Files (*.*)|*.*', title="Save"):
# Shows a dialog to select file to save, return path(s) if accepted.
# overwrite seems not work?
GetDir(path="", title='Select a directory')
# Shows a dialog to choose a directory.

values = Inputs(items=[], width=None, instruction='Click the button to read the help.', title='Ask for inputs')
# Flexible dialog for user inputs.
# Returns a value for each row in a list, e.g. [u'1001', u'female', u'', []]
# textbox accepts a string or str(default) and returns a string or eval(string)
# checkbox returns a bool
# radiobox returns a string or ''
# combobox returns a string or ''
# listbox returns a list of strings or []
# If cancels, returns None

items = [('ID:', ''),
('ID:', 'siu8505'),
('ID:', 1001),
('IDs:', [1001, 1002]), ->textbox (internally converts data types)
the first element is the label
the second is the default value (e.g. an empty string, number or a list)

('Logical Switch:', 'Checked?', False), ->checkBox (True/False)
('Gender:', ['Female', 'Male'], 0), ->radiobox (0,1; -1 does not work)
('Race:', ['Black', 'White', 'Other'], -1), ->combobox (-1 selects none)
('Majors:
(Can select more than one)',('Psychology','Math','Biology'), 0), ->listbox (multiple)
the first is the label
the second is the options:
a string makes it a checkbox
a list with two elements makes a radiobox
a list with more than two elements makes a combobox
a tuple makes a listbox with multiple choice enabled
the third is the default value (True/False, index of the list or tuple)

(''), ->blank line
just an empty string

({'Selecte Input Directory...': "GetDir()"},''),
({'Selecte Output Directory...': "GetDir()"},''),
({'Save as...': "SetFile()"},''), ->button
({'Selecte Files...': "GetFile(multiple=True)"},[]),->listbox (disabled)
({"Output File Name(*.csv):": "SetFile(directory='%s', filename='output.csv', wildcard='CSV Files (*.csv)|*.csv')" % os.getcwd()}, '')]
the general form is: ({button label: function in a string}, result from function is a str or list)
the first is a dict with the key is the label, the value is the button event function
the second is the type of the returned value from the button function
'' means the button function returns a string
[] means the button fucntion returns a list

values = Inputs(items=items) # returns a list of inputs in the order displayed on the GUI (the insertion of blank line, i.e. ('') in the above example, does not interfere the order of returned values)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quickgui-1.5.7.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file quickgui-1.5.7.tar.gz.

File metadata

  • Download URL: quickgui-1.5.7.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for quickgui-1.5.7.tar.gz
Algorithm Hash digest
SHA256 819ca8d3e6eb76975339d207f13747713711de58bd172950c812a3631735c498
MD5 97f8f8da6faaf7fac3794478ff2f25a7
BLAKE2b-256 e3f4f5f570228465ab9e9775381ac793a12af2227aaceabd6e90da2067e8ca94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page