def _get_delta_gui(phenergy):

    choices = ['Diamond, 3.525g/cm^3',
               'Beryllium, 1.848 g/cm^3',
               'Manual Input']

    menu_choices = [choices[0], choices[1], choices[2]]  # Change order here!

    choice = easyqt.get_choice(message='Select Sample Material',
                               title='Title',
                               choices=menu_choices)

    if choice is None:
        choice = menu_choices[0]

    if choice == choices[0]:
        # delta Diamond, density from wikipedia:
        # delta at 8KeV: 1.146095341e-05
        delta = 1 - xraylib.Refractive_Index_Re("C", phenergy/1e3, 3.525)
        material = 'Diamond'

    elif choice == choices[1]:
        # delta at 8KeV = 5.3265E-06
        delta = 1 - xraylib.Refractive_Index_Re("Be", phenergy/1e3,
                                                xraylib.ElementDensity(4))
        material = 'Beryllium'

    elif choice == 'Manual Input':
        # delta Diamond, density from wikipedia:
        material = easyqt.get_string('Enter symbol of material ' +
                                     '(if compounds, you need to' +
                                     ' provide the density):',
                                     title='Thickness Calculation',
                                     default_response='C')

        elementZnumber = xraylib.SymbolToAtomicNumber(material)
        density = xraylib.ElementDensity(elementZnumber)

        density = easyqt.get_float('Density [g/cm^3] ' +
                                   '(Enter for default value)',
                                   title='Thickness Calculation',
                                   default_value=density)

        delta = 1 - xraylib.Refractive_Index_Re(material,
                                                phenergy/1e3, density)

    else:
        wpu.print_red('ERROR: unknown option')

    return delta, material
Exemple #2
0
def guessing_game():
    name = eg.get_string(message="What is your name?",
                         title="Mine is Reeborg.")
    if not name:
        name = "Unknown person"

    message = """<p>The following language selection will only affect the
        default GUI elements like the text on the buttons.
        Note that <b>Default</b> is reverting back to the
        local PyQt default (likely English).</p>"""

    eg.show(message=message, title="For information")
    eg.get_language()

    eg.show(message="Hello {}. Let's play a game".format(name),
            title="Guessing game!")

    guess = min_ = 1
    max_ = 50
    answer = randint(min_, max_)
    title = "Guessing game"
    while guess != answer:
        message = "Guess a number between {} and {}".format(min_, max_)
        prev_guess = guess
        guess = eg.get_int(message=message,
                           title=title,
                           default_value=guess,
                           min_=min_,
                           max_=max_)
        if guess is None:
            quitting = eg.get_yes_or_no("Do you want to quit?")
            guess = prev_guess
            if quitting:
                break
        elif guess < answer:
            title = "Too low"
            min_ = guess
        elif guess > answer:
            title = "Too high"
            max_ = guess
    else:
        message = "Congratulations {}! {} was the answer.".format(name, guess)
        eg.show(message, title="You win!")
def guessing_game():
    name = eg.get_string(message="What is your name?",
                            title="Mine is Reeborg.")
    if not name:
        name = "Unknown person"

    message = """<p>The following language selection will only affect the
        default GUI elements like the text on the buttons.
        Note that <b>Default</b> is reverting back to the
        local PyQt default (likely English).</p>"""

    eg.show(message=message, title="For information")
    eg.get_language()

    eg.show(message="Hello {}. Let's play a game".format(name),
                      title="Guessing game!")

    guess = min_ = 1
    max_ = 50
    answer = randint(min_, max_)
    title = "Guessing game"
    while guess != answer:
        message = "Guess a number between {} and {}".format(min_, max_)
        prev_guess = guess
        guess = eg.get_int(message=message, title=title,
                              default_value=guess, min_=min_ ,max_=max_)
        if guess is None:
            quitting = eg.get_yes_or_no("Do you want to quit?")
            guess = prev_guess
            if quitting:
                break
        elif guess < answer:
            title = "Too low"
            min_ = guess
        elif guess > answer:
            title = "Too high"
            max_ = guess
    else:
        message="Congratulations {}! {} was the answer.".format(name, guess)
        eg.show(message, title="You win!")
import easygui_qt as easy

first_name = easy.get_string("Please enter your first name")
last_name = easy.get_string("Please enter your last name")

greeting = "Hello there, " + first_name + " " + last_name + "!"
easy.show_message(greeting)
    #Drawing the balloon string

    penny.penup()
    penny.goto(-250, 75)
    penny.right(90)
    draw_range_squares(penny, 2, 90, "white")

    #Final Message

    penny.write("Hello!", font=("Arial", 45, "normal"))

    #Finished

else:
    makeup = easy.get_string("What Color of Makeup do you want?", "Makeup")
    hair = easy.get_string("What Color hair do you want?", "Hair")
    balloon = easy.get_string("What Color do you want the balloon?", "Balloon")

    #Poistion to draw balloon

    penny.penup()
    penny.goto(-260, 100)
    penny.pendown()

    #Starts drawing balloon

    draw_square(penny, 20, balloon)
    penny.forward(20)
    penny.right(180)
Exemple #6
0
import turtle
import easygui_qt as easy

the_window = turtle.Screen()
the_window.bgcolor("lightgreen")

the_color = easy.get_string("What color should the shape be?")
shapes = easy.get_integer("How many shapes should there be?")

shiloh = turtle.Turtle()
shiloh.color(the_color)
shiloh.shape("turtle")
shiloh.pensize(4)
shiloh.speed(0)

for number_of_shapes in range(shapes):
    for counter in range(4):
        shiloh.forward(100)
        shiloh.left(90)
    shiloh.left(360 / shapes)
Exemple #7
0
import easygui_qt as easy

your_fav = easy.get_string("What's your favourite NBA team?")

best_teams = f"""<h1>Best NBA Teams</h1>

<p>The <em>best teams</em> in the NBA are:</p>

<ul>
    <li>Spurs</li>
    <li>Warriors</li>
    <li>Celtics</li>
    <li>Raptors</li>
    <li>{your_fav}</li>
</ul>"""

easy.show_message(best_teams)