Skip to content

Commit

Permalink
Initial refactor and tests of the text_box class (and derived classes)
Browse files Browse the repository at this point in the history
Removes Python 2.7 compatibility!

(re)add the mouse click behaviour that the refactor had removed
(re) add docstrings for the text_box and derived methods (used by sphinx)

Move Al's test_easygui.py integration tests to the 'tests' folder for consistency

use 1x README.rst instead of (duplicate) .txt and .md README files
tweak conda meta.yaml so that bld.bat and build.sh aren't needed

rename 'test_cases' -> 'demos'
change mose_click_handlers -> MouseClickHandler class
remove test_travis.py since we now have enough *real* tests, and Travis is working nicely
remove duplicate 'parse_hotkey' method
remove 'developer information'
remove unused methods (exception_format, uniquify_list_of_strings, getFileDialogTitle, to_string)
remove unused constant definitions
remove tk 8.0+ warning since it looks like it is now bundled for all 'current' python (v3.7+)

Tests will live in the 'tests' directory
Demos will live in the 'demos' folder

Remove some 'about' files to de-clutter the project.
Aim: have more functional files, and less 'print this' type files everywhere.
In order to do this, move the 'version' information to __init__.py
* use it from the demo boxes *and* from setup.py

Moving things from easygui.boxes.__init__ to easygui.boxes.utils
... in preparation of getting rid of boxes directory entirely.
I want to keep the easygui.__init__ for import control, and move utilites to 'utils'

add more interesting things to the button_box.py default parameter values
  • Loading branch information
zadacka committed Apr 27, 2022
1 parent 1f79116 commit df92528
Show file tree
Hide file tree
Showing 79 changed files with 5,383 additions and 3,980 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- "2.7"
# - "2.7" # killed it to simplify a lot of things ... hopefully everyone is on Py3.x now
- "3.4"
- "3.5"
- "3.6"
Expand Down
31 changes: 0 additions & 31 deletions easygui/boxes/about.py → HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
"""
.. moduleauthor:: easygui developers and Stephen Raymond Ferg
.. default-domain:: py
.. highlight:: python
"""
try:
from .derived_boxes import codebox
except (SystemError, ValueError, ImportError):
from derived_boxes import codebox

eg_version = '0.98.2-RELEASED'
egversion = eg_version


def abouteasygui():
"""
Shows the EasyGUI revision history.
"""
codebox("About EasyGui\n{}".format(eg_version),
"EasyGui", EASYGUI_ABOUT_INFORMATION)
return None


EASYGUI_ABOUT_INFORMATION = '''

0.98.2
========================================================================
Expand Down Expand Up @@ -254,8 +228,3 @@ def abouteasygui():

* Fixed a bug that was preventing Linux users from copying text out of
a textbox and a codebox. This was not a problem for Windows users.
'''

if __name__ == '__main__':
abouteasygui()
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README.md
include README.rst
File renamed without changes.
122 changes: 0 additions & 122 deletions README.txt

This file was deleted.

8 changes: 0 additions & 8 deletions bld.bat

This file was deleted.

9 changes: 0 additions & 9 deletions build.sh

This file was deleted.

4 changes: 3 additions & 1 deletion test_cases/SimpleCv.py → demos/SimpleCv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
__author__ = 'Future Engineer'

import easygui.button_box

"""
from:
http://stackoverflow.com/questions/27873818/easygui-and-simplecv-typeerror-module-object-is-not-callable
Expand All @@ -22,7 +24,7 @@
# Set a breakpoint
code.interact("Code paused. Hit ctrl-D when ready to continue", local=dict(globals(), **locals()))
while True:
eg.msgbox("""Welcome to my program!""", image = "pi.jpg")
easygui.button_box.msgbox("""Welcome to my program!""", image ="pi.jpg")
msgbox("Select img ")
nam=fileopenbox(filetypes=['*'])
print(nam)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""
import sys

import easygui.button_box

sys.path.append('..')
import easygui

Expand All @@ -16,21 +18,21 @@
name = easygui.enterbox("Arrg its me Davy Jones whats your name ye scallywab")
txt = "Do you fear DEATH {}? Lets play a game if ye win ye can go if ye lose"
txt += " then you are my a sailer on my ship the flying dutchman forever AHAAAA!"
easygui.msgbox(txt.format(name))
easygui.msgbox("The game be simple ye get 15 chances to guess a number between 1 and 100. Ye be ready?")
easygui.button_box.msgbox(txt.format(name))
easygui.button_box.msgbox("The game be simple ye get 15 chances to guess a number between 1 and 100. Ye be ready?")

while guess != secret and tries < 15:
guess = easygui.integerbox("What's your guess "+name)
if not guess: break
if guess < secret:
easygui.msgbox(str(guess) + " is too low "+name)
easygui.button_box.msgbox(str(guess) + " is too low " + name)
elif guess > secret:
easygui.msgbox(str(guess) + " is too high "+name)
easygui.button_box.msgbox(str(guess) + " is too high " + name)

tries += 1

if guess == secret:
easygui.msgbox("Arrg ye got it in {}. You can go.".format(tries))
easygui.button_box.msgbox("Arrg ye got it in {}. You can go.".format(tries))
if tries == 15:
easygui.msgbox("NO more guesses for ye. You're mine forever now {} !! AHAAHAA!!!".format(name))
easygui.button_box.msgbox("NO more guesses for ye. You're mine forever now {} !! AHAAHAA!!!".format(name))

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions demos/button_box.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os

from easygui import buttonbox


def demo_buttonbox_1():
print("hello from the demo")
value = buttonbox(
title="First demo",
msg="bonjour",
choices=["Button[1]", "Button[2]", "Button[3]"],
default_choice="Button[2]")
print("Return: {}".format(value))


def demo_buttonbox_2():
package_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) ;# My parent's directory
images = list()
images.append(os.path.join(package_dir, "python_and_check_logo.gif"))
images.append(os.path.join(package_dir, "zzzzz.gif"))
images.append(os.path.join(package_dir, "python_and_check_logo.png"))
images = [images, images, images, images, ]
value = buttonbox(
title="Second demo",
msg="Now is a good time to press buttons and show images",
choices=['ok', 'cancel'],
images=images)
print("Return: {}".format(value))
61 changes: 20 additions & 41 deletions easygui/boxes/demo.py → demos/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,22 @@

import os
import sys
from tkinter import TkVersion

from easygui import ROOT_DIR, diropenbox, fileopenbox, filesavebox, buttonbox, ynbox, ccbox, boolbox, indexbox, msgbox, \
version
from easygui.text_box import textbox, codebox, exceptionbox
from easygui.multi_fillable_box import multenterbox
from easygui.multi_fillable_box import multpasswordbox

from easygui.fillable_box import integerbox
from easygui.fillable_box import enterbox
from easygui.fillable_box import passwordbox

from easygui.choice_box import choicebox
from easygui.choice_box import multchoicebox


try:
from . import utils as ut
from .button_box import buttonbox
from .text_box import textbox
from .diropen_box import diropenbox
from .fileopen_box import fileopenbox
from .filesave_box import filesavebox
from .multi_fillable_box import multenterbox
from .multi_fillable_box import multpasswordbox

from .derived_boxes import ynbox
from .derived_boxes import ccbox
from .derived_boxes import boolbox
from .derived_boxes import indexbox
from .derived_boxes import msgbox
from .derived_boxes import integerbox
from .derived_boxes import enterbox
from .derived_boxes import exceptionbox
from .derived_boxes import codebox
from .derived_boxes import passwordbox

from .choice_box import choicebox
from .choice_box import multchoicebox

from . import about
from .about import eg_version
from .about import abouteasygui
except (SystemError, ValueError, ImportError):
print("Please run demo.py from outside the package")
exit()
# --------------------------------------------------------------
#
# test/demo easygui
Expand Down Expand Up @@ -82,7 +67,6 @@ def __init__(self):
("fileopenbox", demo_fileopenbox),
("diropenbox", demo_diropenbox),
("exceptionbox", demo_exceptionbox),
("About EasyGui", demo_about),
("Help", demo_help),
]

Expand Down Expand Up @@ -115,10 +99,10 @@ def easygui_demo():
msg = []
msg.append("Pick the kind of box that you wish to demo.")
msg.append(" * Python version {}".format(sys.version))
msg.append(" * EasyGui version {}".format(eg_version))
msg.append(" * Tk version {}".format(ut.TkVersion))
msg.append(" * EasyGui version {}".format(version))
msg.append(" * Tk version {}".format(TkVersion))
intro_message = "\n".join(msg)
title = "EasyGui " + eg_version
title = "EasyGui " + version
# Table that relates keys in choicebox with functions to execute
descriptions = demos.list_descriptions()
preselected = 0
Expand Down Expand Up @@ -272,12 +256,6 @@ def demo_integerbox():
return reply


def demo_about():
reply = abouteasygui()
print("Reply was: {!r}".format(reply))
return reply


def demo_enterbox():
image = os.path.join(package_dir, "python_and_check_logo.gif")
message = ("Enter the name of your best friend."
Expand Down Expand Up @@ -379,7 +357,8 @@ def demo_passwordbox():


def demo_help():
codebox("EasyGui Help", text=about.EASYGUI_ABOUT_INFORMATION)
with open(os.path.join(ROOT_DIR, "HISTORY.rst")) as f:
codebox("EasyGui Help", text=f.read())
return None


Expand Down
Loading

0 comments on commit df92528

Please sign in to comment.