-
Notifications
You must be signed in to change notification settings - Fork 16
allow missing vectorio #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# SPDX-FileCopyrightText: 2021 Tim C | ||
# | ||
# SPDX-License-Identifier: MIT | ||
""" | ||
Make a GridLayout with some Labels in it's cells. | ||
Displayed with Blinka_Displayio_PyGameDisplay | ||
|
||
Requires: https://github.com/FoamyGuy/Blinka_Displayio_PyGameDisplay | ||
""" | ||
import displayio | ||
import pygame | ||
from blinka_displayio_pygamedisplay import PyGameDisplay | ||
from adafruit_displayio_layout.widgets.switch_round import SwitchRound as Switch | ||
|
||
|
||
# Make the display context. Change size if you want | ||
display = PyGameDisplay(width=320, height=240) | ||
|
||
# Make the display context | ||
main_group = displayio.Group() | ||
display.show(main_group) | ||
|
||
switch_x = 30 | ||
switch_y = 30 | ||
switch_radius = 20 | ||
|
||
switch_fill_color_off = (200, 44, 200) | ||
switch_fill_color_on = (0, 100, 0) | ||
|
||
switch_outline_color_off = (30, 30, 30) | ||
switch_outline_color_on = (0, 60, 0) | ||
|
||
background_color_off = (255, 255, 255) | ||
background_color_on = (90, 255, 90) | ||
|
||
background_outline_color_off = background_color_off | ||
background_outline_color_on = background_color_on | ||
|
||
switch_width = 4 * switch_radius # This is a good aspect ratio to start with | ||
|
||
switch_stroke = 2 # Width of the outlines (in pixels) | ||
text_stroke = switch_stroke # width of text lines | ||
touch_padding = 0 # Additional boundary around widget that will accept touch input | ||
|
||
animation_time = 0.2 # time for switch to display change (in seconds). | ||
# animation_time=0.15 is a good starting point | ||
display_text = True # show the text (0/1) | ||
|
||
# initialize state variables | ||
switch_value = False | ||
switch_value = True | ||
|
||
my_switch = Switch( | ||
x=switch_x, | ||
y=switch_y, | ||
height=switch_radius * 2, | ||
fill_color_off=switch_fill_color_off, | ||
fill_color_on=switch_fill_color_on, | ||
outline_color_off=switch_outline_color_off, | ||
outline_color_on=switch_outline_color_on, | ||
background_color_off=background_color_off, | ||
background_color_on=background_color_on, | ||
background_outline_color_off=background_outline_color_off, | ||
background_outline_color_on=background_outline_color_on, | ||
switch_stroke=switch_stroke, | ||
display_button_text=display_text, | ||
touch_padding=10, | ||
animation_time=animation_time, | ||
value=False, | ||
) | ||
|
||
|
||
main_group.append(my_switch) | ||
while display.running: | ||
|
||
# get mouse up events | ||
ev = pygame.event.get(eventtype=pygame.MOUSEBUTTONUP) | ||
# proceed events | ||
for event in ev: | ||
pos = pygame.mouse.get_pos() | ||
print(pos) | ||
if my_switch.contains(pos): | ||
my_switch.selected(pos) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the docstring to match the code (SwitchRound demo for PyGameDisplay).