Skip to main content

sgzentry is a library for python which was inspired by Zenity. When you write scripts, you can use sgzentry to create simple dialogs that interact graphically with the user.

Project description

GitHub version PyPI version Merge2Main Publish Python ๐Ÿ distribution ๐Ÿ“ฆ to PyPI and TestPyPI GitHub License

SGZenity

SGZenity is a library for python which was inspired by Zenity.

When you write scripts, you can use SGZenity to create simple dialogs that interact graphically with the user.

Requirements

  • Python 3
  • GTK+4
  • python3-gi

Installation

Install using pip:

$ pip install sgzenity

Or clone the repo:

$ git clone https://github.com/SoftGeekRo/sgzenity.git
$ cd ./sgzenity
$ python setup.py install

Example

Simple dialog:

from src.sgzenity import calendar

result = calendar(title="Awesome Calendar", text="Your birthday ?")
print(result)

This code show a calendar dialog :

dialog_01

And display the result :

$ python test.py
$ (year=2017, month=6, day=4)

API

sgzenity.sgzenity.message(title='', text='', width=330, height=120, timeout=None)

Display a simple message

Parameters:

  • text (str) โ€“ text inside the window
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds
sgzenity.sgzenity.error(title='', text='', width=330, height=120, timeout=None)

Display a simple error

Parameters:

  • text (str) โ€“ text inside the window
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds
sgzenity.sgzenity.warning(title='', text='', width=330, height=120, timeout=None)

Display a simple warning

Parameters:

  • text (str) โ€“ text inside the window
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds
sgzenity.sgzenity.question(title='', text='', width=330, height=120, timeout=None)

Display a question, possible answer are yes/no.

Parameters:

  • text (str) โ€“ text inside the window
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: The answer as a boolean

Return type: bool

sgzenity.sgzenity.entry(text='', placeholder='', title='', width=330, height=120, timeout=None)

Display a text input

Parameters:

  • text (str) โ€“ text inside the window
  • placeholder (str) โ€“ placeholder for the input
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: The content of the text input Return type: str

sgzenity.sgzenity.password(text='', placeholder='', title='', width=330, height=120, timeout=None)

Display a text input with hidden characters

Parameters:

  • text (str) โ€“ text inside the window
  • placeholder (str) โ€“ placeholder for the input
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: The content of the text input

Return type: str

sgzenity.sgzenity.zlist(columns, items, print_columns=None, text='', title='', width=330, height=120, timeout=None)

Display a list of values

Parameters:

  • columns (list of strings) โ€“ a list of columns name
  • items (list of strings) โ€“ a list of values
  • print_columns (int* (None if all the columns)*) โ€“ index of a column (return just the values from this column)
  • text (str) โ€“ text inside the window
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: A row of values from the table

Return type: list

sgzenity.sgzenity.file_selection(multiple=False, directory=False, save=False, confirm_overwrite=False, filename=None, title='', width=330, height=120, timeout=None)

Open a file selection window

Parameters:

  • multiple (bool) โ€“ allow multiple file selection
  • directory (bool) โ€“ only directory selection
  • save (bool) โ€“ save mode
  • confirm_overwrite (bool) โ€“ confirm when a file is overwritten
  • filename (str) โ€“ placeholder for the filename
  • text (str) โ€“ text inside the window
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: path of files selected.

Return type: string or list if multiple enabled

sgzenity.sgzenity.calendar(text='', day=None, month=None, title='', width=330, height=120, timeout=None)

Display a calendar

Parameters:

  • text (str) โ€“ text inside the window
  • day (int) โ€“ default day
  • month (int) โ€“ default month
  • text โ€“ text inside the window
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: (year, month, day)

Return type: tuple

sgzenity.sgzenity.color_selection(show_palette=False, opacity_control=False, title='', width=330, height=120, timeout=None)

Display a color selection dialog

Parameters:

  • show_palette (bool) โ€“ hide/show the palette with preselected colors
  • opacity_control (bool) โ€“ allow to control opacity
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: the color selected by the user

Return type: str

sgzenity.sgzenity.scale(text='', value=0, min=0, max=100, step=1, draw_value=True, title='', width=330, height=120, timeout=None)

Select a number with a range widget

Parameters:

  • text (str) โ€“ text inside window
  • value (int) โ€“ current value
  • min (int) โ€“ minimum value
  • max (int) โ€“ maximum value
  • step (int) โ€“ incrementation value
  • draw_value (bool) โ€“ hide/show cursor value
  • title (str) โ€“ title of the window
  • width (int) โ€“ window width
  • height (int) โ€“ window height
  • timeout (int) โ€“ close the window after n seconds

Returns: The value selected by the user

Return type: float

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

sgzenity-0.1.6.tar.gz (20.4 kB view hashes)

Uploaded Source

Built Distribution

sgzenity-0.1.6-py3-none-any.whl (20.1 kB view hashes)

Uploaded Python 3

Supported by

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