Git Product home page Git Product logo

zenipy's Introduction

https://badge.fury.io/py/zenipy.png Documentation Status

Zenipy

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

Requirements

  • Python 2 or 3
  • GTK+3
  • python3-gi or python-gi (for python2)

Installation

Install using pip :

$ pip install zenipy

Or clone the repo :

$ git clone https://github.com/poulp/zenipy.git
$ cd ./zenipy
$ python setup.py install

Example

Simple dialog :

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

This code show a calendar dialog :

docs/images/screen.png

And display the result :

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

API

zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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
zenipy.zenipy.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

zenipy's People

Contributors

antoniocoratelli avatar brunetton avatar colewebb avatar luk3yx avatar octomike avatar pleabargain avatar poulp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zenipy's Issues

Support --forms

For one of my scripts I'm needing the --forms command

Would it be possible to implement this ? :)

python-zenity is not in PIP

According the the readme, you can install python-zenity however attempting to do so fails:

$ sudo pip install python-zenity
Downloading/unpacking python-zenity
Could not find any downloads that satisfy the requirement python-zenity
No distributions at all found for python-zenity
Storing complete log in /home/user/.pip/pip.log

Zenity windows stay open in non-responsive state for duration of python script

On Ubuntu 15.10 zenity windows created during python scripts using the library do not close until the entire program has finished running rather than when the window is done. For example, if you run the code below the zenity message box does not dissapear until after 100 seconds (though the result and control is returned when the user presses enter):

!/usr/bin/python

import pythonzenity
import time
a = pythonzenity.Message(text="Message in the bottle")
time.sleep(100)

zlist - height not working

Linux Mint 19 with python 3.6

That's my code:
(theList is a list with 69 elements)

columns = ["Result"]
zenipy.zlist(columns, theList, title='check my memory', width=900, height=600, timeout=None)

the window height increases with the number of elements.
is zlist not scrollable?

Dialogs never go away

If I execute a method, like python.zenity.Calendar(), I get a calendar, I select a date, it is returned but the calendar window never goes away. It hangs around until I close it using the 'x' in the title bar.

Dialogs should go away after the value(s) have been returned.

File selection dialog fails

In Ipython, the first call to pythonzenity.FileSelection() fails with the following error:

In [1]: from common import pythonzenity
In [2]: pythonzenity.FileSelection()
/home/dir/prog/common/pythonzenity/python_zenity.py:452: GtkWarning: IA__gtk_file_chooser_get_files: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed
return file.dialog.get_filename()

On subsequent calls, the command silently returns and again, does not return any selected files.

Entry dialog only returns an empty string

Running the Entry dialog, regardless of text entered, the empty string is always returned rather than the value entered.

In addition to this, the dialog's strings (title, prompt) are hard coded rather than being localized.

Installation broken :/

Installation seems to be broken -

$  pip install python-zenity 
Downloading/unpacking python-zenity
  Could not find any downloads that satisfy the requirement python-zenity
Cleaning up...
No distributions at all found for python-zenity
Storing debug log for failure in /Users/janispauls/.pip/pip.log

contents of pip.log:

------------------------------------------------------------
/Users/janispauls/python/zenity_demo/virtualenv/bin/pip run on Thu Dec 25 17:07:04 2014
Downloading/unpacking python-zenity
  Getting page https://pypi.python.org/simple/python-zenity/
  URLs to search for versions for python-zenity:
  * https://pypi.python.org/simple/python-zenity/
  Analyzing links from page https://pypi.python.org/simple/python-zenity/
  Could not find any downloads that satisfy the requirement python-zenity
Cleaning up...
  Removing temporary dir /Users/janispauls/python/zenity_demo/virtualenv/build...
No distributions at all found for python-zenity
Exception information:
Traceback (most recent call last):
  File "/Users/janispauls/python/zenity_demo/virtualenv/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Users/janispauls/python/zenity_demo/virtualenv/lib/python2.7/site-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Users/janispauls/python/zenity_demo/virtualenv/lib/python2.7/site-packages/pip/req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/Users/janispauls/python/zenity_demo/virtualenv/lib/python2.7/site-packages/pip/index.py", line 277, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for python-zenity

Color selection dialog fails and crashes IPython

When running the color selection dialog, I choose a color, then click OK. The dialog hangs for a while then crashes IPython:

In [1]: from common import pythonzenity

In [2]: pythonzenity.ColorSelection()
/home/mchristensen/prog/embedded_pqa/common/pythonzenity/python_zenity.py:479: Warning: g_object_get_qdata: assertion `G_IS_OBJECT (object)' failed
return cs.dialog.get_color_selection().get_current_color().to_string()
Segmentation fault (core dumped)

home $

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.