Пример #1
0
import gooeypie as gp

app = gp.GooeyPieApp('Widget Gallery')
app.set_grid(16, 1)
app.width = 200

app.add(gp.Input(app), 1, 1, fill=True)
app.add(gp.Checkbox(app, 'Checkbox'), 2, 1)
app.add(gp.Label(app, 'Label'), 3, 1)
app.add(gp.Slider(app, 1, 10), 4, 1, fill=True)

style_label = gp.StyleLabel(app, 'StyleLabel')
style_label.font_name = 'Courier'
style_label.font_size = 16
style_label.font_weight = 'bold'
style_label.colour = '#FF6702'
style_label.background_colour = 'black'
app.add(style_label, 5, 1, align='center')

app.add(gp.Hyperlink(app, 'Hyperlink', '.'), 6, 1)
app.add(gp.Secret(app), 7, 1, fill=True)
app.add(gp.Listbox(app, [f'Listbox item {n}' for n in range(1, 7)]),
        8,
        1,
        fill=True)
app.add(gp.Textbox(app), 9, 1, fill=True)
app.add(gp.ImageButton(app, 'images/favicon.ico', None, '   ImageButton'),
        10,
        1,
        fill=True)
app.add(gp.Radiogroup(app, [f'Radio item {n}' for n in range(1, 4)]),
Пример #2
0
import gooeypie as gp

app = gp.GooeyPieApp('About')
app.width = 300

logo = gp.Image(app, 'images/logo.png')
copy = gp.Label(app, 'Created with Gooey Pie\n© GooeyPie, 2020')
# copy.justify = 'center'
link = gp.Hyperlink(app, 'Visit the GooeyPie website', 'www.gooeypie.com')

app.set_grid(3, 1)
app.add(logo, 1, 1, align='center')
app.add(copy, 2, 1, align='center')
app.add(link, 3, 1, align='center')

app.run()
Пример #3
0
        inc_number.remove_event_listener('change')
        float_number.remove_event_listener('change')


def value_changed(event):
    log.prepend_line(
        f'Value of {event.widget} changed to {event.widget.value}')


app = gp.GooeyPieApp('Number widget tests')

# Widgets container
widgets = gp.LabelContainer(app, 'Widgets and tests')

# Labels
default_label = gp.Label(widgets, 'Integers 1 to 10 (default increment)')
inc_label = gp.Label(widgets, 'Integers 0 to 255 (increment 5)')
float_label = gp.Label(widgets, 'Floats 0 to 1.0 (increment 0.1)')

# Number widgets
default_number = gp.Number(widgets, 1, 10)
inc_number = gp.Number(widgets, 0, 255, 5)
float_number = gp.Number(widgets, 0, 1, 0.1)

default_get = gp.Button(widgets, 'Get value', get_value)
inc_get = gp.Button(widgets, 'Get value', get_value)
float_get = gp.Button(widgets, 'Get value', get_value)

default_set = gp.Button(widgets, 'Set value to', set_value)
inc_set = gp.Button(widgets, 'Set value to', set_value)
float_set = gp.Button(widgets, 'Set value to', set_value)
Пример #4
0
import gooeypie as gp

app = gp.GooeyPieApp('Login')

user_label = gp.Label(app, "Username")
user_input = gp.Input(app)
pass_label = gp.Label(app, "Password")
pass_input = gp.Secret(app)

app.set_grid(2, 2)
app.add(user_label, 1, 1)
app.add(user_input, 1, 2)
app.add(pass_label, 2, 1)
app.add(pass_input, 2, 2)

app.run()
Пример #5
0
def make_password(event):
    # Get the desired length of the password
    length = length_slider.value

    # Create the password by choosing 'length' random characters
    new_password = ''
    for n in range(length):
        new_password += random.choice(password_chars)

    # Display the new password in the password input field
    password.text = new_password
    app.copy_to_clipboard(new_password)

app = gp.GooeyPieApp('Make a good password... please')

instructions = gp.Label(app, 'Set your desired password length using the slider')
length_slider = gp.Slider(app, 4, 30)
password = gp.Input(app)
password.justify = 'center'

length_slider.add_event_listener('change', make_password)

app.set_grid(3, 1)
app.add(instructions, 1, 1)
app.add(length_slider, 2, 1, fill=True)
app.add(password, 3, 1, fill=True)

# Set the default password length. This will also trigger the make_password() function
length_slider.value = 12

app.run()
Пример #6
0
license_container.add(license_box_3, 1, 3)
license_container.add(license_box_4, 1, 4)

# Buttons container
buttons_container = gp.Container(app)
register = gp.Button(buttons_container, 'Register', None)
cancel = gp.Button(buttons_container, 'Cancel', None)
buttons_container.set_grid(1, 2)
buttons_container.add(register, 1, 1)
buttons_container.add(cancel, 1, 2)

# Main window
app.set_grid(4, 3)

logo = gp.Image(app, './images/leaf.gif')
name_label = gp.Label(app, 'Name')
name = gp.Input(app)

company_label = gp.Label(app, 'Company name')
company = gp.Input(app)

license_label = gp.Label(app, 'License key')

app.add(logo, 1, 1, row_span=4)
app.add(name_label, 1, 2)
app.add(company_label, 2, 2)
app.add(license_label, 3, 2)
app.add(name, 1, 3, fill=True)
app.add(company, 2, 3, fill=True)
app.add(license_container, 3, 3)
app.add(buttons_container, 4, 3, valign='top')
Пример #7
0
import gooeypie as gp

def say_hello(event):
    hello_label.text = f'Hello {name.text}!'

app = gp.GooeyPieApp('Hello!')

question = gp.Label(app, 'What is your name?')
name = gp.Input(app)
name.justify = 'center'
name.width = 30
hello_button = gp.Button(app, 'Say Hello', say_hello)
hello_label = gp.Label(app, '')

app.set_grid(4, 1)
app.add(question, 1, 1, align='center')
app.add(name, 2, 1)
app.add(hello_button, 3, 1, align='center')
app.add(hello_label, 4, 1, align='center')

app.run()
Пример #8
0
import gooeypie as gp

date_formats = [
    '28/8/20', '8/28/20', '28/08/2020', '08/28/2020', '2020-08-28',
    '28-Aug-2020', 'Friday, August 28, 2020', 'Friday, 28 August, 2020',
    'August 28, 2020', '28 August, 2020'
]

app = gp.GooeyPieApp('Time and date')
app.width = 250

label = gp.Label(app, 'Available formats:')
date_options = gp.Listbox(app, date_formats)
date_options.height = 5
ok = gp.Button(app, 'OK', None)
ok.width = 10

app.set_grid(3, 1)
app.add(label, 1, 1)
app.add(date_options, 2, 1, fill=True)
app.add(ok, 3, 1)

app.run()
Пример #9
0
def change_colour(event):
    # Convert each numbers from 0 to 255 to a 2-digit hex code
    print(type(red_value.value))
    rr = str(hex(int(red_value.value)))[2:].rjust(2, '0')
    gg = str(hex(int(green_value.value)))[2:].rjust(2, '0')
    bb = str(hex(int(blue_value.value)))[2:].rjust(2, '0')
    # Set the background colour
    colour.background_colour = f'#{rr}{gg}{bb}'
    # print(f'#{rr}{gg}{bb}')
    # colour.text = 'boooooooooooooo'


app = gp.GooeyPieApp('Colour Mixer')

red_label = gp.Label(app, 'Red')
green_label = gp.Label(app, 'Green')
blue_label = gp.Label(app, 'Blue')

red_value = gp.Number(app, 0, 255, 5)
green_value = gp.Number(app, 0, 255, 5)
blue_value = gp.Number(app, 0, 255, 5)

# loop though the Number widgets,
for number in (red_value, green_value, blue_value):
    number.add_event_listener('change', change_colour)
    number.wrap = False
    number.margin_top = 0

lines = '\n\n\n\n\n'
Пример #10
0
import gooeypie as gp

app = gp.GooeyPieApp('Tests: Label')

left = gp.Label(app, 'Left\njustified\nLabel')
center = gp.Label(app, 'Center\njustified\nlabel')
center.justify = 'center'
right = gp.Label(app, 'Right\njustified\nlabel')
right.justify = 'right'

app.set_grid(4, 1)
app.add(left, 1, 1)
app.add(center, 2, 1)
app.add(right, 3, 1)

app.run()
Пример #11
0
import gooeypie as gp

def say_hello(event):
    hello_label.text = 'Hello Gooey Pie!'

app = gp.GooeyPieApp('Hello!')
app.set_size(250, 80)
app.set_grid(2, 1)
#
hello_button = gp.Button(app, 'Say Hello', None)
hello_label = gp.Label(app, '')
#
app.add(hello_button, 1, 1, align='center')
app.add(hello_label, 2, 1, align='center')

app.run()
Пример #12
0
import gooeypie as gp

def toggle_mask(event):
    secret.toggle()

app = gp.GooeyPieApp('Secret')

question = gp.Label(app, "What's your secret?")

secret = gp.Secret(app)
secret.width = 50

check = gp.Checkbox(app, 'Show secret')
check.add_event_listener('change', toggle_mask)

app.set_grid(3, 1)
app.add(question, 1, 1)
app.add(secret, 2, 1)
app.add(check, 3, 1)

app.run()
Пример #13
0
import gooeypie as gp

age_ranges = ('Under 18', '18 - 29', '30 - 49', '50 to 64', '65 and over')

app = gp.GooeyPieApp('Age')
app.width = 200

instructions = gp.Label(app, 'Select your age')
age = gp.Radiogroup(app, age_ranges)
confirm = gp.Button(app, 'Confirm', None)

app.set_grid(3, 1)
app.add(instructions, 1, 1)
app.add(age, 2, 1)
app.add(confirm, 3, 1)

app.run()
Пример #14
0
import gooeypie as gp

app = gp.GooeyPieApp('Delivery')

delivery_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

instructions = gp.Label(app, 'Select your preferred day for delivery')
delivery_day = gp.Dropdown(app, delivery_days)
print(delivery_day)
delivery_day.selected_index = 0   # Make Monday the default
continue_button = gp.Button(app, 'Continue', None)

app.set_grid(3, 1)
app.add(instructions, 1, 1)
app.add(delivery_day, 2, 1, fill=True)
app.add(continue_button, 3, 1, align='right')

app.run()
Пример #15
0
import gooeypie as gp

meals = ('Beef burger', 'Veggie burger', 'Sausage roll', 'Tofu bowl')
sauces = ('Tomato', 'BBQ', 'Soy', 'No Sauce')

app = gp.GooeyPieApp('Food Order')
app.width = 250

name_text = gp.Label(app, 'Name')
name = gp.Input(app)
food_text = gp.Label(app, 'Food options')
meal = gp.LabelRadiogroup(app, 'Meal', meals)
sauce = gp.LabelRadiogroup(app, 'Sauce', sauces)
order = gp.Button(app, 'Place order', None)

app.set_grid(4, 2)
app.set_column_weights(0, 1)
app.add(name_text, 1, 1, align='right')
app.add(name, 1, 2)
app.add(food_text, 2, 1, align='right')
app.add(meal, 2, 2, fill=True)
app.add(sauce, 3, 2, fill=True)
app.add(order, 4, 2)

app.run()