Zenity | full featured library to display dialogs
kandi X-RAY | Zenity Summary
kandi X-RAY | Zenity Summary
zenity is a Python library that will display GTK+ dialogs using zanity tool(this is not a Python zenity port), and return (eitherin the return code, or on standard output) the users input. This allows you to present information, and ask for infor mation from the user. For example, zenity.show(zenity.question) will return either 0, 1 or 5, depending on whether the user pressed OK, Cancel or timeout has been reached. zenity.show(zenity.entry) will output on standard output what the user typed into the text entry field.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Display a message
- Run a Zenity message
- Check if Zenity works
- Wrapper around subprocess check_output
- Show Zenity
Zenity Key Features
Zenity Examples and Code Snippets
import zenity
res,_ = zenity.show(zenity.question,text="Is it ok?")
if res:
print("it's ok")
Community Discussions
Trending Discussions on Zenity
QUESTION
Hey guys I want to set a new shortcut for my small costum script (its not optimal, but it works), Qt scripts also dont work. For that i thought to just add a new line in my xmonad.hs file and it should work, but instead nothing happens when I press the keyboard shortcut and im not really sure why..
Here is my script:
...ANSWER
Answered 2021-May-23 at 12:42OK I found the answer in the .xsession-errors file.. I have to give the full path. So in my example it was spawn "/home/flo/scripts/tablet"
QUESTION
I'm trying to exchange a string between a Python file and a Shell script. Here is how I'm doing it:
...ANSWER
Answered 2021-May-07 at 17:38TEXT=$("$SCRIPTPATH/text.txt")
means "execute the command called "$SCRIPTPATH/text.txt"
and store its stdout in TEXT
. You get the "permission denied" error because that file is not executable.
Instead you probably want TEXT=$(cat "$SCRIPTPATH/text.txt")
.
QUESTION
I wanted to make a zenity list that takes the fields for one column from one list and the fields for the other column from another list
...ANSWER
Answered 2021-Mar-30 at 09:36From man zenity
:
QUESTION
I'm using zenity --password
to get input from the user. I've tried var=${zenity --password};
, zenity var=--password
, and var=zenity --password
, but none of them work. For the last two, I got an error code.
For the second attempt, I got the error code: You must specify a dialog type. See 'zenity --help' for details
. For the last one, I got error code: -bash: --password: command not found
. I'm not that familiar with bash, and I only know basic commands. I'm using Zenity (sudo apt-get install zenity
). If someone knows how to fix this, please help.
ANSWER
Answered 2021-Feb-25 at 17:03The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
QUESTION
so im trying to do a delete function inside zenity . I managed to let the user input his desired path and then i want to display all the files that are present inside it . I found out how to do it and i know it work but no with zenity . The next window (file selection) is not poping up and my program get back to the menu. thanks here is my code.Thanks u for your help and time!
...ANSWER
Answered 2021-Mar-06 at 06:11To fix my problem, i understand the meaning behind the $? escape code . In each window $? control the ok and cancel button taking value 0 and 1 respectively. Inside my program I cleared the $? first because of the previous window , a value can be already set in, and set a variable ret to $? meaning if someone press ok or cancel it continue to the next window or goes back to the root window.
QUESTION
I have heard its a conventional practice to store program dependent files in /usr/share/application-folder
in linux. So I'm trying to do it in my c program in a function called load_interface_files()
for example. I am not sure if this is a good practice or not, I've heard about creating configuration files for this kind of issues.
Anyways, here's the the code I wrote to make a directory in /usr/share
.
ANSWER
Answered 2020-Dec-01 at 04:25use ls -ld /usr/share
to see what the permissions on the directory are (without -d
, you get the contents and their permissions).
Use code like:
QUESTION
I'm writing a Zenity-based status monitor for GNU dd(1)
in Python.
Due to the constraints of the system I'm targeting, the wrapper must run on Python 2, and cannot pull in external libraries.
Among the requirements are for Zenity's "Cancel" button to terminate dd if it's not yet finished.
I must do the following without delay (i.e. triggered/driven/immediately); if multiple of the below conditions are met/triggered simultaneously, they are to be executed in the listed order:
- when Zenity exits, terminate dd
- when dd writes to its
stderr
, munge+forward that data to Zenity'sstdin
- when dd exits, if its return code was not 0, terminate Zenity
However, the epoll object seems to only be triggering on dd's output; it never triggers on Zenity exiting, despite my registering EPOLLHUP
on Zenity's stdin
.
How should/can this be done? I understand that epoll is the only primitive that can be used to correctly trigger on dd
's output (via EPOLLIN
); I also understand that it is an unweildy primitive which may be unsuitable for triggering on Zenity's exiting. (If required, I can implement more logic into this file; doing so is infinitely preferable to pulling in any 3rd-party library, however small or "common". I reiterate that I understand that epoll is unwieldy to work with and may require a large amount of glue-logic.)
Alternatively: if epoll is not the correct primitive for monitoring a subprocess
for its exit, then what is the correct way to monitor a subprocess for exit while monitoring a subprocess for output in a Python 2 compatible way?
(I do not inherently need multithreaded capabilities; to take all actions sequentially would be fully in-spec; though, if multithreaded programming would be absolutely necessary in this case in order to avoid a busy-loop, then so be it.)
Below is my full code so far.
...ANSWER
Answered 2020-Nov-13 at 21:01It turns out the answer was as trivially simple as: Use EPOLLERR
instead of EPOLLHUP
.
I have serious doubts that this the right solution*, but it certainly seems to work:
QUESTION
I'm writing a game that uses python and webkit, and a webpage is the front-end/GUI. The PC is connected to an Arduino that controls a coin hopper and other i/o. When the Arduino sends 'coinin' over serial, I capture this in a serial-watching thread, then run some javascript on the webpage to 'add' a coin to the game.
For simplicity in troubleshooting, I set up an example that runs a test thread instead of reading serial, but the problem is the same. The thread tries to add a coin every second by running 'addcoin()' on the webpage. If you uncomment the run_javascript() line, the program core dumps.
I came up with a keyboard hack workaround. The test thread, instead of trying to run_javascript() directly, does an os.system call to xdotool to type the letters 'conn' to the program window. That window has a key-event listener, and when it gets the letters 'conn' in keybuffer[], it then runs the desired run_javascript() call to the webpage. If you copy the two files to a folder, and run the python program, you'll see the coin text count up every second (Hit BackSpace to end the program). If you try to run the javascript from the thread instead, you'll see the program core dump.
The question is, is there a better way to do this, without having to use the keyboard hack to run the javascript? Although the hack gets around the problem, it introduces a weakness in the game. You can cheat a coin in by typing 'conn' on the keyboard. I'd like to find some other way to trigger the event, without having to use the keyboard event.
Sample webpage index.htm
...ANSWER
Answered 2020-Feb-19 at 14:16Update: This answer is updated for general case, original answer below.
Although GIL allows only one python thread being run at given time, we know nothing about other thread state at the moment of context switch (it's just like executing multithreaded programm on a single-core machine.) That's why you should call any not MT-safe methods from the thread they "belong" to (that includes GTK calls, which "belong" to main event loop).
If you want to call such a function, you should schedule it's execution in the main loop. Probably the easiest approach is to use idle_add
. Also note, that idle_add
'ed function should
return True
or False
whether it should be called again later or not, respectively.
Your code shoul look like this:
QUESTION
I've made a small function that I'm using when testing a script.
However I'm not sure it displays all characters, like spaces, quote, and stuff like that.
This is the function:
...ANSWER
Answered 2020-Feb-09 at 21:06One implementation that's capable of displaying nonprintable characters unambiguously would be:
QUESTION
I'm performing an rsync process to copy files from an SD card and I want to show the progress per file in Zenity during the rsync process per file. I tried Zenity and rsync which seemed perfect for me. It should send the current file and % copied to Zenity, but I cannot get it to, output is not realtime and does not move the progress bar. And I could not figure out why its not working.
What I'm trying to do at the least is send the percentage of the file copy into Zenity to drive the progress bar. But this needs to be a number without the trailing % to drive the progress bar.
This does not output anything, but if I remove the sed and Zenity steps then I get: 0%, 1%, 2% etc. But Zenity requires non percentage values.
...ANSWER
Answered 2019-Nov-25 at 14:40One relative simple option is to capture the current file, and % of current file:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Zenity
You can use Zenity like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page