robertlugg / easygui Goto Github PK
View Code? Open in Web Editor NEWeasygui for Python
Home Page: http://easygui.readthedocs.org/en/master/
License: BSD 3-Clause "New" or "Revised" License
easygui for Python
Home Page: http://easygui.readthedocs.org/en/master/
License: BSD 3-Clause "New" or "Revised" License
support dict-like objects to be passed in as images parameter.
Treat them as OrderedDicts to preserve their order if the user passes in an OrderedDict.
If the user selects a particular item, don't return the value, but instead return the key.
When I have two monitors, 1920x1080(HxW) + 1920x1080(HxW), and the Tk will get 1920x2160(HxW).
It will make the dialog window's min size become to large, due to the main monitor's width is only 1080.
It seems like the winfo_screenwidth
and winfo_screenheight
can not get only one screen's size.
https://github.com/robertlugg/easygui/blob/master/easygui/boxes/base_boxes.py#L452-L464
See sourceforge bug report:
https://sourceforge.net/p/easygui/bugs/14/
Partial text:
how can I change the defaultlocation where this box pops up? rootWindowPosition somehow does not apply???
I was thinking about adding two options to many of the dialogs:
default_button=(string)
cancel_button=(string)
So, when the dialog opens, the default is set to the Choices button that matches the default_button string.
Also, if user presses red 'x' or maybe hits , the cancel_button is "pressed"
Horst comment:
that would be fantastic. it allows gameplay without mouse
I tried compile for some distributions linux, but fail.
Traceback (most recent call last):
File "setup.py", line 3, in
import easygui
File "/home/david/Downloads/python-easygui/src/easygui/easygui/init.py", line 3, in
all = easygui.all
NameError: name 'easygui' is not defined
Original text from:
http://all-you-need-is-tech.blogspot.com/2013/01/improving-easygui-for-python.html
Andrew S08 June, 2013 23:32
Thanks Robbie this is very useful for building GUIs that look decent without much effort. One question: I have a multenterbox where one field can be left blank; if left blank, the program will autogenerate a number for the user. I would like to update the onscreen field with this number without closing the window (remain inside the callback). How can this be achieved?
Reply
Replies
Robbie Brook09 June, 2013 12:00
Hi Andrew,
What you're asking to do is actually populate the values in easygui.multenterbox after you sent them. This feature isn't supported.
I would go for a simple solution like:
import easygui_callback
import random
def get_auto_value():
# your logic here
return random.random()
choices = ["name", "address", "auto-field"]
values= ['default-name','default-address','']
input= ''
while True:
input = easygui_callback.multenterbox("auto field","generator", choices,values)
if input == None: break
if input[2] == "":
values= [input[0],input[1],get_auto_value()]
else:
# save data somewhere or whatever
pass
If you really have to work with callback, you can hack easygui_callback.multenterbox to send also 'values' list to callback and set it there. On return from callback, you'll need to set this value list into its matching widget.
a box to enter numeric float (and integer) values, with default, lowerbound and upperbound.
Ideally a list of accepted decimal point signs should be an optional parameter
def floatbox(msg="please enter float or integer",
title="",
default=0.0,
lowerbound=0.0,
upperbound=99.9999,
acceptable_decimal_signs=[".",","] ):
The floatbox shows an error message like the integerbox when the entered value is not integer nor float, or if the entered value is below lowerbound and above upperbound.
Error message is also shown if more than one single decimal sign is entered.
as per subject. The choicebox is always in 'single selection' mode.
The problem lies in the scope of the global variable __choiceboxMultipleSelect. A simple modification in the lines 472-473 and 493-494 (remove global, add bb. in front of the variable) in the file derived_boxes.py does the trick for me.
New to GitHub, so sorry if this could have been done easily in other ways.
The creator of this star already made the fixes to an older release of 0.96. Branch to learn how to do that ;)
From sourceforge bug:
https://sourceforge.net/p/easygui/bugs/9/
Janwillem included sample code:
easygui_jd.py.tar.gz
I removed all but the files necessary for a proper python package (plus documentation). Make changes needed to work with installers.
Sourceforge reference:
https://sourceforge.net/p/easygui/bugs/10/
in file https://github.com/robertlugg/easygui/blob/master/documentation/api.html
it would be fantastic to have internal links for each easygui function ( msgbox, buttonbox, yesnobox etc) and have sphinx make an table of content with hyperlinks in the upper left corner (left sidebar). this would remove the need to browse the very long api text (or use strg+f) if you already know the name of a function but want to look up it's exact parameters. Likewise, it would give the reader an fast-to-recognize overview over all easygui functions.
From sourceforge bug report #3
registration system demo does not work with Python 3.x.
Python code works only with Python 2.x.
Sourcecode of the Registration System demo needs to be updated to use Python 3.x
https://sourceforge.net/p/easygui/bugs/3/
reported by Monte Milanuk, December 1, 2011
Since all is defined, there is no reason to have all the __ ones
Consider the request from stackoverflow:
http://stackoverflow.com/questions/24621288/getting-easygui-to-self-update-info
Some code:
http://stackoverflow.com/questions/18739400/live-plotting-using-matplotlib-without-hault
When using a dual screen, side-by-side system the default way of calculating window sizes generates windows that are too wide. It would be better to restrict the aspect ration of the windows to some more reasonable one rather than purely going by the system screen height and width.
get_string has a duplicate window behind it that can be seen when the top dialog is moved.
from easygui_qt import *
from sys import exit
s = get_string('Enter a string')
print("String entered was %s" % s)
if s == "None":
exit()
input()
When the top dialog is moved to the right, the other is visible behind it.
Set up easygui to have docs autobuild.
ref:
http://read-the-docs.readthedocs.org/en/latest/faq.html
python
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.import easygui
Traceback (most recent call last):
File "", line 1, in
File "C:\python\Python34\lib\site-packages\easygui__init__.py", line 3, in
all = easygui.all
NameError: name 'easygui' is not defined
Consider internationalizing all our "hard-coded" texts using a strategy such as this:
https://docs.python.org/2/library/gettext.html
For hex_entry.py test case and others provide better control over text entry.
also asked for here:
http://stackoverflow.com/questions/18623945/python-easygui-window-size
Provide ability to only show an image (no buttons, etc) in a dialog. perhaps modify buttonbox to do that...have 'choices' argument support an empty list in which case no buttons are displayed and the image is shown in the entire window.
the (old) documenatation in
https://github.com/robertlugg/easygui/blob/master/documentation/support.html
links to https://sourceforge.net/projects/easygui
shoud it not link to Github
https://github.com/robertlugg/easygui
instead ?
Most people using this package are likely starting from a newer version of Python, so I think this would be fine. it possibly could break backwards compatibility, but I really think it should change.
Here is my code, it is supposed to produce a password box for the user to enter their password with hidden characters showing instead of letters. When I run it, the hidden characters are showing even before I've typed anything.
import easygui as eg
message="Enter Password"
title="New User"
fieldNames=["Enter Password"]
fieldVals=eg.passwordbox(message,title,fieldNames)
in https://github.com/robertlugg/easygui/blob/master/documentation/api.html, the part
"about easygui"
and
"license"
is exactly the same as in support.html and should be removed
help(easygui) doesn't return much. Write up more information (perhaps from the .rst files).
It is possible to create a single file containing all of our files. Do that to simplify the install for users. See the discussion here:
http://blog.ablepear.com/2012/10/bundling-python-files-into-stand-alone.html
(Cross posting from http://stackoverflow.com/questions/31223583/easygui-dialogs-are-not-given-focus-when-created .)
I am using Python 2.7.9, easygui 0.97.4
, and Windows 7.
I am trying to pop up a dialog box using the following:
import easygui
easygui.msgbox()
I would expect a dialog box to pop up and come to the foreground, taking focus. Sometimes, this happens. Other times, the dialog box does not come to the front, and spawns behind all other windows.
Whether the dialog box comes to the front, or hides behind other windows, seems to depend on something unpredictable. Giving different arguments to easygui.msgbox()
doesn't seem to help. Restarting the Python interpreter sometimes makes it work, and sometimes doesn't.
The issue is not so bad for simple dialogs, which at least give a flashing button in the task bar to get your attention.
It is worse for diropenbox()
which does not spawn a flashing button in the taskbar. The dialog spawns behind a window and gives no evidence it's there, until you minimise all other windows.
Is this normal and expected behaviour? I would like easygui
dialogs to always come to the front and always take focus, instead of hiding behind other windows.
My application provides a path in which the Settings file should be created. Say, it was built on Machine A, in my case (Win 7) with path D:\Trials\Trial2\filenamehere.txt.
I copied my application source to another machine, say Machine B ( in my case Win XP) and ran the python code. I supplied a valid filename and path to create the settings file, say, (E:\Temp\somefilenamehere.txt) .
As suggested in the easyGUI tutorial on the easyGUI page, I created an inherited class based on EgStore, called Settings.
However, when valid file name is provided and the store method is invoked, the Settings / EgStore class, still look for the settings file in the path in D:\ i.e. the path in the machine in which the code originally ran.
When I tried to run the code from B, from my application's folder, where the D:\ path doesn't exist, it gives an error, saying FileNotFound (Errno 2).
When I tried a minimal version of settings storage in the same folder, it didn't work.
The minimal version of settings storage in another folder worked.
davidism at stack overflow, suggested I put an additional method in my subclass called restore, that reads thus :
def restore(self):
filename = self.filename
EgStore.restore(self)
self.filename = filename
This fixed it.
An example program where I have used it is in Line No.128 of ModiBatudu.
https://github.com/whirlmind/ModiBatudu/blob/master/ModiBatudu_Python_Source/ModiBatudu.py
How the same code that uses the application path runs correctly in one folder and incorrectly in another folder is seen in this screenshot. Notice the D:\Trials.... etc in the error message. Where did that come from ? (Hint : From the path on the other machine where EgStore was used before. )
The sample file called in that screenshot, from two different locations producing two different results is here :
from easygui import *
import pprint
import os
class Settings(EgStore):
def init(self, filename): # filename is required
#-------------------------------------------------
# Specify default/initial values for variables that
# this particular application wants to remember.
#-------------------------------------------------
print("Test printing the path inside the Settings class");
pprint.pprint(settingsFile);
pprint.pprint("Exists ? " + str(os.path.isfile(settingsFile)));
self.Last_Alert_TimeStamp_Num = ""
#-------------------------------------------------
# For subclasses of EgStore, these must be
# the last two statements in __init__
#-------------------------------------------------
self.filename = filename # this is required
self.restore() # restore values from the storage file if possible
settingsFile = os.path.join(os.path.dirname(file), "ModiBatudu_LastAlertTime.txt")
print("Test printing the path before calling the Settings class");
pprint.pprint(settingsFile);
pprint.pprint("Exists ? " + str(os.path.isfile(settingsFile)));
settings = Settings(settingsFile)
settings.Last_Alert_TimeStamp_Num = "Some junk goes here";
settings.store()
Several of these methods are just wrappers for other functions with some arguments set. Rework them to just use functools.partial.
Make sure that Sphinx still documents them properly.
http://sphinx-doc.org/
When 0.97 comes out announce or update various websites:
https://wiki.python.org/moin/GuiProgramming
https://packages.debian.org/source/sid/python-easygui
so that a press of a key is like the button was cklicked with the mouse.
i suggest using the first Uppercase Char in a button string as hotkey
Integrate the work by Robbie in the main branch. Consider if any work needs to be done first.
Using easygui 0.97.4 (installed from the *.whl file on PyPI) on Python 2.7.9, in a Linux OS, a script I've used for months now has an issue where only 1 selection can be made on any multchoicebox() interface. Also, that function now returns a string containing the selected option, instead of a list of strings:
user_choices = eg.multchoicebox(choices=['choice1', 'choice2'])
In the above case, I can only choose "choice1" or "choice2" in the GUI and the value of "user_choices" is the string "choice1" or "choice2", instead of a list like ["choice1"] or ["choice2"].
I reverted to 0.97.2 and it works fine.
wished by all my underage rpg-programming students:
the possibility to display ether animated gifs instead of the image inside a button/messagebox,
or
the possibility to play an animation inside a buttonbox by providing a list of images / list of pairs (image, displaytime in seconds)
def msgbox(msg="",
title="",
ok_button="ok",
image=None,
root=None,
animation=[("image1.png", 0.1), ("image2.png",0.1), ("image3.png",0.5)],
cycle_animation=True )
The animation should stop as soon as a button in the window is clicked.
The animation should not loop if cycle_animation parameter is set to False.
animation would only work if image is set to None.
For game programming, this feature would be most needed for buttonbox and msgbox (and, if possible, for gridbox/multi-image-box)
"""
I did not find any useful link that talks about how to change the background color in easygui. Is there a way to change the background color in EASY GUI ?
"""
REF: http://stackoverflow.com/questions/27966385/changing-background-color-in-easy-gui
Modify it like the button dialogs to support cancel
a box that can display more than one image, and buttons like buttonbox
Based on this article, I'm really taking on too much when trying to allow easygui to run in both python 2 and python 3. At some point we may need to give up, but there is more I should have been doing. Review this website:
http://python-future.org/imports.html
It is acting just like the choicebox function.
from easygui import *
print multchoicebox("test", "test", [1,2,3])
Literally only allows me to select one item.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.