sgzenity


Namesgzenity JSON
Version 0.1.9 PyPI version JSON
download
home_pagehttps://github.com/SoftGeekRO/sgzenity
Summarysgzentry 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.
upload_time2024-06-29 13:57:09
maintainerNone
docs_urlNone
authorZaharia Constantin
requires_python<4.0,>=3.10
licenseGPL-3.0-or-later
keywords zenity python3 poetry dialog gtk+3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![GitHub version](https://badge.fury.io/gh/SoftGeekRO%2Fsgzenity.svg)](https://badge.fury.io/gh/SoftGeekRO%2Fsgzenity)
[![PyPI version](https://badge.fury.io/py/sgzenity.svg)](https://badge.fury.io/py/sgzenity)
[![Merge2Main](https://github.com/SoftGeekRO/sgzenity/actions/workflows/push_to_main.yml/badge.svg?event=push)](https://github.com/SoftGeekRO/sgzenity/actions/workflows/push_to_main.yml)
[![Publish Python 🐍 distribution 📦 to PyPI and TestPyPI](https://github.com/SoftGeekRO/sgzenity/actions/workflows/publish_to_pypi.yml/badge.svg?event=release)](https://github.com/SoftGeekRO/sgzenity/actions/workflows/publish_to_pypi.yml)
![PyPI - Downloads](https://img.shields.io/pypi/dm/sgzenity?link=https%3A%2F%2Fpypi.org%2Fproject%2Fsgzenity%2F)
![GitHub License](https://img.shields.io/github/license/softgeekRO/sgzenity)

# 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](https://docs.gtk.org/)
* python3-gi

## Installation

Install using pip:

```bash
$ pip install sgzenity
```

Or clone the repo:

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

## Example

Simple dialog:

## API

### Simple message
```python
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

### Error

```python
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

### Warning
```python
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

### Question

![basic_dialog_01](docs/img/basic_dialog.png)

```python
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

### Progress Bar

![basic_dialog_01](docs/img/progressbar.png)

```python
progress_bar(title, text, pulse_mode, callback)
```

> Display a text input
>
>Parameters:
>* **title** (*str*) – Title of the progress window
>* **text** (*str*) – Text that will be present on top of the progress bar
>* **pulse_mode** (*bool*) – Character of the progress bar, pulse of progress based on the callback returns values from 0.0 to 1
>* **callback** (*int*) – callback function for control the progress bar. Returns a value between 0.0 and 1


### Demo

```python
import time
from sgzenity.thread import WorkerThread
from sgzenity import ProgressBar

class WorkingThread(WorkerThread):
    def payload(self):
        loading = self.data
        steps = 10
        for s in range(steps):
            if self.stop:
                break
            loading.heartbeat()
            print('Pulse {}.'.format(s))
            time.sleep(1)
        if self.stop:
            print('Working thread canceled.')
        else:
            print('Working thread ended.')
        loading.close()


def sg_progress_bar():
    loading = ProgressBar("DEMO TITLE", "DEMO TEXT", pulse_mode=True)

    workthread = WorkingThread(loading)
    loading.show(workthread)
    workthread.start()

    Gtk.main()


sg_progress_bar()
```

### Entry
```python
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

### Password
```python
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

### List of values
```python
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

### File selection
```python
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

### Calendar

```python
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

![calendar_dialog_01](docs/img/calendar_dialog.png)

And display the result :

```bash
$ python demo.py
$ (year=2017, month=6, day=4)
```

### Color selection

```python
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

### Scale

```python
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


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SoftGeekRO/sgzenity",
    "name": "sgzenity",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "zenity, python3, poetry, dialog, GTK+3",
    "author": "Zaharia Constantin",
    "author_email": "constantin.zaharia@sgsolar.ro",
    "download_url": "https://files.pythonhosted.org/packages/c6/29/737e57d9ab84747056aa854b148a2c9166eccf5ea9e30bc03666328f4dcd/sgzenity-0.1.9.tar.gz",
    "platform": null,
    "description": "[![GitHub version](https://badge.fury.io/gh/SoftGeekRO%2Fsgzenity.svg)](https://badge.fury.io/gh/SoftGeekRO%2Fsgzenity)\n[![PyPI version](https://badge.fury.io/py/sgzenity.svg)](https://badge.fury.io/py/sgzenity)\n[![Merge2Main](https://github.com/SoftGeekRO/sgzenity/actions/workflows/push_to_main.yml/badge.svg?event=push)](https://github.com/SoftGeekRO/sgzenity/actions/workflows/push_to_main.yml)\n[![Publish Python \ud83d\udc0d distribution \ud83d\udce6 to PyPI and TestPyPI](https://github.com/SoftGeekRO/sgzenity/actions/workflows/publish_to_pypi.yml/badge.svg?event=release)](https://github.com/SoftGeekRO/sgzenity/actions/workflows/publish_to_pypi.yml)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/sgzenity?link=https%3A%2F%2Fpypi.org%2Fproject%2Fsgzenity%2F)\n![GitHub License](https://img.shields.io/github/license/softgeekRO/sgzenity)\n\n# SGZenity\n\nSGZenity is a library for python which was inspired by Zenity.\n\nWhen you write scripts, you can use SGZenity to create simple dialogs that interact graphically with the user.\n\n## Requirements\n\n* Python 3\n* [GTK+4](https://docs.gtk.org/)\n* python3-gi\n\n## Installation\n\nInstall using pip:\n\n```bash\n$ pip install sgzenity\n```\n\nOr clone the repo:\n\n```bash\n$ git clone https://github.com/SoftGeekRo/sgzenity.git\n$ cd ./sgzenity\n$ python setup.py install\n```\n\n## Example\n\nSimple dialog:\n\n## API\n\n### Simple message\n```python\nmessage(title='', text='', width=330, height=120, timeout=None)\n```\n>Display a simple message\n> \n>Parameters:\n>* **text** (*str*) \u2013 text inside the window\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n\n### Error\n\n```python\nerror(title='', text='', width=330, height=120, timeout=None)\n```\n\n>Display a simple error\n>\n>Parameters:\n>* **text** (*str*) \u2013 text inside the window\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n\n### Warning\n```python\nwarning(title='', text='', width=330, height=120, timeout=None)\n```\n>Display a simple warning\n>\n>Parameters:\n>* **text** (*str*) \u2013 text inside the window\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n\n### Question\n\n![basic_dialog_01](docs/img/basic_dialog.png)\n\n```python\nquestion(title='', text='', width=330, height=120, timeout=None)\n```\n>Display a question, possible answer are yes/no.\n>\n>Parameters:\n>* **text** (*str*) \u2013 text inside the window\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>_Returns_: The answer as a boolean\n>\n>_Return type_: bool\n\n### Progress Bar\n\n![basic_dialog_01](docs/img/progressbar.png)\n\n```python\nprogress_bar(title, text, pulse_mode, callback)\n```\n\n> Display a text input\n>\n>Parameters:\n>* **title** (*str*) \u2013 Title of the progress window\n>* **text** (*str*) \u2013 Text that will be present on top of the progress bar\n>* **pulse_mode** (*bool*) \u2013 Character of the progress bar, pulse of progress based on the callback returns values from 0.0 to 1\n>* **callback** (*int*) \u2013 callback function for control the progress bar. Returns a value between 0.0 and 1\n\n\n### Demo\n\n```python\nimport time\nfrom sgzenity.thread import WorkerThread\nfrom sgzenity import ProgressBar\n\nclass WorkingThread(WorkerThread):\n    def payload(self):\n        loading = self.data\n        steps = 10\n        for s in range(steps):\n            if self.stop:\n                break\n            loading.heartbeat()\n            print('Pulse {}.'.format(s))\n            time.sleep(1)\n        if self.stop:\n            print('Working thread canceled.')\n        else:\n            print('Working thread ended.')\n        loading.close()\n\n\ndef sg_progress_bar():\n    loading = ProgressBar(\"DEMO TITLE\", \"DEMO TEXT\", pulse_mode=True)\n\n    workthread = WorkingThread(loading)\n    loading.show(workthread)\n    workthread.start()\n\n    Gtk.main()\n\n\nsg_progress_bar()\n```\n\n### Entry\n```python\nentry(text='', placeholder='', title='', width=330, height=120, timeout=None)\n```\n>Display a text input\n>\n>Parameters:\n>* **text** (*str*) \u2013 text inside the window\n>* **placeholder** (*str*) \u2013 placeholder for the input\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>_Returns_: The content of the text input\n>_Return type_: str\n\n### Password\n```python\npassword(text='', placeholder='', title='', width=330, height=120, timeout=None)\n```\n>Display a text input with hidden characters\n>\n>Parameters:\n>* **text** (*str*) \u2013 text inside the window\n>* **placeholder** (*str*) \u2013 placeholder for the input\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>Returns: The content of the text input\n>\n>Return type: str\n\n### List of values\n```python\nzlist(columns, items, print_columns=None, text='', title='', width=330, height=120, timeout=None)\n```\n>Display a list of values\n>\n>Parameters:\n>* **columns** (*list of strings*) \u2013 a list of columns name\n>* **items** (*list of strings*) \u2013 a list of values\n>* **print_columns** (*int** (**None if all the columns**)*) \u2013\n>  index of a column (return just the values from this column)\n>* **text** (*str*) \u2013 text inside the window\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>_Returns_: A row of values from the table\n>\n>_Return type_: list\n\n### File selection\n```python\nfile_selection(multiple=False, directory=False, save=False, confirm_overwrite=False, filename=None, title='', width=330, height=120, timeout=None)\n```\n>Open a file selection window\n>\n>Parameters:\n>* **multiple** (*bool*) \u2013 allow multiple file selection\n>* **directory** (*bool*) \u2013 only directory selection\n>* **save** (*bool*) \u2013 save mode\n>* **confirm_overwrite** (*bool*) \u2013 confirm when a file is overwritten\n>* **filename** (*str*) \u2013 placeholder for the filename\n>* **text** (*str*) \u2013 text inside the window\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>_Returns_: path of files selected.\n>\n>_Return type_: string or list if multiple enabled\n\n### Calendar\n\n```python\ncalendar(text='', day=None, month=None, title='', width=330, height=120, timeout=None)\n```\n>Display a calendar\n>\n>Parameters:\n>* **text** (*str*) \u2013 text inside the window\n>* **day** (*int*) \u2013 default day\n>* **month** (*int*) \u2013 default month\n>* **text** \u2013 text inside the window\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>_Returns_: (year, month, day)\n> \n>_Return type_: tuple\n\n![calendar_dialog_01](docs/img/calendar_dialog.png)\n\nAnd display the result :\n\n```bash\n$ python demo.py\n$ (year=2017, month=6, day=4)\n```\n\n### Color selection\n\n```python\ncolor_selection(show_palette=False, opacity_control=False, title='', width=330, height=120, timeout=None)\n```\n\n>Display a color selection dialog\n>\n>Parameters:\n>* **show_palette** (*bool*) \u2013 hide/show the palette with preselected colors\n>* **opacity_control** (*bool*) \u2013 allow to control opacity\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>_Returns_: the color selected by the user\n>\n>_Return type_: str\n\n### Scale\n\n```python\nscale(text='', value=0, min=0, max=100, step=1, draw_value=True, title='', width=330, height=120, timeout=None)\n```\n\n>Select a number with a range widget\n>\n>Parameters:\n>* **text** (*str*) \u2013 text inside window\n>* **value** (*int*) \u2013 current value\n>* **min** (*int*) \u2013 minimum value\n>* **max** (*int*) \u2013 maximum value\n>* **step** (*int*) \u2013 incrementation value\n>* **draw_value** (*bool*) \u2013 hide/show cursor value\n>* **title** (*str*) \u2013 title of the window\n>* **width** (*int*) \u2013 window width\n>* **height** (*int*) \u2013 window height\n>* **timeout** (*int*) \u2013 close the window after n seconds\n>\n>_Returns_: The value selected by the user\n>\n>_Return type_: float\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "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.",
    "version": "0.1.9",
    "project_urls": {
        "Discussions": "https://github.com/SoftGeekRO/sgzenity/discussions",
        "Documentation": "https://github.com/SoftGeekRO/sgzenity/",
        "Homepage": "https://github.com/SoftGeekRO/sgzenity",
        "Issues": "https://github.com/SoftGeekRO/sgzenity/issues",
        "Releases": "https://github.com/SoftGeekRO/sgzenity/releases",
        "Repository": "https://github.com/SoftGeekRO/sgzenity.git",
        "Source": "https://github.com/SoftGeekRO/sgzenity/"
    },
    "split_keywords": [
        "zenity",
        " python3",
        " poetry",
        " dialog",
        " gtk+3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4d8b2ecbb8a045ebedb6933cdc0c4d3b2802d55dbd308ea1f9870a72c388f33",
                "md5": "64092879757b03268f76598f1c84567b",
                "sha256": "11cd688a71f8fb6bd2ed543f2364ff5e3d1119249f7a0149bcab98c929803874"
            },
            "downloads": -1,
            "filename": "sgzenity-0.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "64092879757b03268f76598f1c84567b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 27846,
            "upload_time": "2024-06-29T13:57:08",
            "upload_time_iso_8601": "2024-06-29T13:57:08.342915Z",
            "url": "https://files.pythonhosted.org/packages/a4/d8/b2ecbb8a045ebedb6933cdc0c4d3b2802d55dbd308ea1f9870a72c388f33/sgzenity-0.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c629737e57d9ab84747056aa854b148a2c9166eccf5ea9e30bc03666328f4dcd",
                "md5": "b50a829ab969a8750296462f54f922d6",
                "sha256": "7f2785a1572fd3666c524f1714ff23718bb1dee67254374800f30788c1aea05e"
            },
            "downloads": -1,
            "filename": "sgzenity-0.1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "b50a829ab969a8750296462f54f922d6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 24502,
            "upload_time": "2024-06-29T13:57:09",
            "upload_time_iso_8601": "2024-06-29T13:57:09.606269Z",
            "url": "https://files.pythonhosted.org/packages/c6/29/737e57d9ab84747056aa854b148a2c9166eccf5ea9e30bc03666328f4dcd/sgzenity-0.1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-29 13:57:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SoftGeekRO",
    "github_project": "sgzenity",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "sgzenity"
}
        
Elapsed time: 0.44202s