Skip to main content

A very simple tkinter prompt window with an animated gradient background, By: Fibo Metavinci

Project description

gradient message box

gradientmessagebox_img.png

A very simple tkinter prompt window with an animated gradient background.

Installation:

pip install gradientmessagebox

Several Presets that require basic configuration:

from gradientmessagebox import ColorConfig, PresetPromptWindow, PresetLoadingMessage, PresetImageBgMessage, PresetChoiceWindow, PresetChoiceEntryWindow, PresetChoiceMultilineEntryWindow, PresetCopyTextWindow, PresetUserPasswordWindow

PresetLoadingMessage:
loading.png

'''
Basic loading indicator that can create a custom Loading message, plays a simple text animation.
shows without a frame, must be closed in code.
'''

loading = PresetLoadingMessage('LOADING')

loading.Play()

time.sleep(10)

loading.Close()

PresetImageBgMessage:

loading.png
'''
Basic text pop up with a background image.
shows without a frame, must be closed in code.
'''

splash = PresetImageBgMessage(msg='THE TITLE', bg_img='./bg_image.png', logo_img='./logo.png')

splash.Show()

time.sleep(10)

splash.Close()

PresetPromptWindow:

'''
Basic choice window with an accept and a reject button.
returns the text of the clicked button
'''

prompt = PresetPromptWindow('You are kinda cool!', 'OK')
prompt.Prompt()

##no return

PresetChoiceWindow:

'''
Basic choice window with an accept and a reject button.
returns the text of the clicked button
'''

choice = PresetChoiceWindow('Cool?', 'Yup', 'Nope')

answer = choice.Ask()
print(answer.response)

#~"Yup"

PresetChoiceEntryWindow:

'''
Basic choice window with a text entry, an accept button, and a reject button.
returns the text of the entry, or reject button
'''

prompt = PresetChoiceEntryWindow('Why so Cool?', 'Enter', 'Nope')

prompt.Ask()

answer = prompt.Ask()
print(answer.response))

#Returns text entered into field
#~"None of your business..."

 

PresetDropDownWindow:

'''
Basic choice window with a drop down, an accept button, and a reject button.
returns the drop down value, or reject button
'''

prompt = PresetDropDownWindow('How Cool?', 'Enter')

answer = prompt.DropDown(['Pretty cool', 'Cool', 'Huh?'])

print(answer.response)

#Returns text entered into field
#~"None of your business..."

 

PresetChoiceMultilineEntryWindow:

'''
Basic choice window with a multi line text entry, and an accept and a reject button.
returns the text of the entry, or reject button
'''

prompt = PresetChoiceMultilineEntryWindow('Coolness details:', 'Enter', 'Nope')

answer = prompt.Ask()

print(answer.response)

#Returns text entered into field
#~"None of your business..."

 

All window objects  text and color attributes can be configured, here are some examples:

popup = PresetChoiceWindow('Cool?', 'Yup', 'Nope')

'''
Add a header text to the popup
'''
win.set_title_text('QUIZ')

'''After creating various attributes can be configured
Here we lighten the foreground, and darken the background
By Default, foreground is the text color, and background is the widget surface color.'''
popup.fg_luminance(0.65)
popup.bg_luminance(0.35)

'''
add a bg image & logo to the window
'''

window.imagery('./hvym_3d_logo.png', './logo.png')

'''If you want to invert the foreground and background colors:'''
popup.invert()

'''On instantiation a midground color is created, based on the
the color that is halfway between the foreground and background.
To swap the midground for the foreground or background:'''
popup.swap_mg_for_fg()
##or
popup.swap_mg_for_bg()

'''Here we reduce the saturation of the gradient used on the pop up background
We could also lighten or darken it with config.gradient_luminance'''
popup.gradient_saturation(0.5)

'''Set the text to a custom color with'''

popup.custom_txt_color('red')#use web color codes

 

Pop ups can also be configured with a config object, for more customization:

from gradientmessagebox import ColorConfig, ChoiceWindow, MultiTextChoice, CopyText, UserPasswordWindow

'''Create the color configuration for the dialog:'''
config = ColorConfig(width=450, height=300, color1="#00ffff", color2="#ffa500", alpha=1.0, saturation=1.0, direct='+x', hasframe=True)

Color colors can be manipulated per element:

'''Here we lighten the foreground, and darken the background
By Default, foreground is the text color, and background is the widget surface color.'''
config.fg_luminance(0.65)
config.bg_luminance(0.35)

'''If you want to invert the foreground and background colors:'''
config.invert()

'''On instantiation a midground color is created, based on the
the color that is halfway between the foreground and background.
To swap the midground for the foreground or background:'''
config.swap_mg_for_fg()
##or
config.swap_mg_for_bg()

'''Here we reduce the saturation of the gradient used on the pop up background
We could also lighten or darken it with config.gradient_luminance'''
config.gradient_saturation(0.5)

'''This call will add an image to the pop up background on
top of the gradient.  If logo is set, a logo for the window
is applied. If useImgSize is True, the pop up size is based on
the image size passed.'''
config.imagery(path='./test-bg.png', icon_path='./logo.png', useImgSize=False)

animation can be applied to the gradient background of the pop up:

'''Speed is in ms, so lower is faster
Stretch, lengthens the gradient, generally makes it look
better if it's a little longer in length.'''
config.animation(speed=10, stretch=2)

Example1 ~ Choice Window:

'''Create the window:'''
choice = ChoiceWindow(config)

'''Create a simple pop up, with option to add a text entry field,
Without the field, the popup returns the text of the button pressed
With an entry field, the accept button returns the text from the entry field.'''
answer = choice.Ask(msg='What's up?', b_accept='Chillin', b_decline='Nah', entry=False, horizontal=True)

print(answer.response)

'''Returns: "Chillin"'''

There are currently 4 window types:
ChoiceWindow, MultiTextChoice, CopyText, UserPasswordWindow

Each Window has an Ask('your prompt') method which will pop the window.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gradientmessagebox-1.3.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

gradientmessagebox-1.3-py2.py3-none-any.whl (9.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file gradientmessagebox-1.3.tar.gz.

File metadata

  • Download URL: gradientmessagebox-1.3.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for gradientmessagebox-1.3.tar.gz
Algorithm Hash digest
SHA256 c443aab66d81b61d1ceb31be8362409ba53eb88fd8fc8bb5c32c78d134df2c3f
MD5 cdd7c493ed9f47563e0322ec329abaf6
BLAKE2b-256 e5ebe2f0d4f7bef952d171571abb176cef784cabfde9bcd5ae3a247e4ff82bf5

See more details on using hashes here.

File details

Details for the file gradientmessagebox-1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for gradientmessagebox-1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 80df3d52117b2ec5131a2662948de75f73fc9b1dc7aee629b8d92e3c71855c8c
MD5 a122d2d8c637f368b1a1ab59c2564d2b
BLAKE2b-256 734c1e07c5292352b6bfb0e96eb7e272fbf244031e789b58c4a0355ff3574ba7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page