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)]),
if change.checked: default_number.add_event_listener('change', value_changed) inc_number.add_event_listener('change', value_changed) float_number.add_event_listener('change', value_changed) else: default_number.remove_event_listener('change') 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)
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()
import gooeypie as gp app = gp.GooeyPieApp('Test') # License container license_container = gp.Container(app) license_box_1 = gp.Input(license_container) license_box_2 = gp.Input(license_container) license_box_3 = gp.Input(license_container) license_box_4 = gp.Input(license_container) license_box_1.width = 5 license_box_2.width = 5 license_box_3.width = 5 license_box_4.width = 5 license_container.set_grid(1, 4) license_container.add(license_box_1, 1, 1) license_container.add(license_box_2, 1, 2) 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
import gooeypie as gp app = gp.GooeyPieApp('Hello!') app.run()
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()
password_chars = string.ascii_letters + string.digits + string.punctuation 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
import gooeypie as gp def what_is_selected(event): print(genders.selected) print(genders.options) app = gp.GooeyPieApp('Testing Radios') genders = gp.Radiogroup(app, ('Female', 'Male', 'Other')) button = gp.Button(app, 'What is selected', what_is_selected) app.set_grid(2, 1) app.add(genders, 1, 1) app.add(button, 2, 1) app.run()
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()
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()
import gooeypie as gp from random import randint NUM_RANDOM_ITEMS = 15 app = gp.GooeyPieApp('Listbox Tests') def display_items(event): """Test for items getter""" items = listbox.items output.prepend(f'Regular: {len(items)} items: {items}\n') items = scroll_listbox.items output.prepend(f'Scrolled: {len(items)} items: {items}\n') def add_items(event): """Testing for items setter""" random_numbers = [randint(1, 100) for _ in range(NUM_RANDOM_ITEMS)] random_numbers = [n + 1 for n in range(NUM_RANDOM_ITEMS)] listbox.items = random_numbers scroll_listbox.items = random_numbers output.prepend(f'Set listbox to {NUM_RANDOM_ITEMS} random numbers\n') def add_item(event): """Testing for add_item """ listbox.add_item(add_what.text) scroll_listbox.add_item(add_what.text) output.prepend(f'Added {add_what.text} to end\n')
import gooeypie as gp 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
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()
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()
import gooeypie as gp presses = 0 def button_counter(event): global presses presses += 1 if presses <= 5: counter.text = f'You have pressed me {presses} times' else: counter.text = 'You have pressed me enough' counter.disabled = True app = gp.GooeyPieApp('Buttons') app.set_grid(1, 1) counter = gp.Button(app, 'You have not pressed me yet', button_counter) app.add(counter, 1, 1) app.run()
def press(event): t.append(f'{dd.selected}\n') dd.deselect() def selected(event): t.prepend(f'Selected is {dd.selected}\n') def selected_index(event): t.prepend(f'Selected is {dd.selected_index}\n') app = gp.GooeyPieApp('Dropdowns') # app.set_size(300, 200) dd = gp.Dropdown(app, ['First', 'Second', 'Third']) b = gp.Button(app, 'Test', press) t = gp.Textbox(app) actions = gp.LabelContainer(app, 'Actions') selected_button = gp.Button(actions, 'Selected', selected) selected_index_button = gp.Button(actions, 'Selected Index', selected) actions.set_grid(2, 2) actions.set_column_weights(1, 1) actions.add(selected_button, 1, 1, fill=True) actions.add(selected_index_button, 1, 2, fill=True)
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()
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()