Skip to content
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

More components #23

Merged
merged 14 commits into from
Sep 15, 2022
Merged

More components #23

merged 14 commits into from
Sep 15, 2022

Conversation

CaseyHackerMan
Copy link
Collaborator

Added a switch, button, dropdown menu, and live plot component. Made tests.

  • Switch: A switch with two states
  • Button: A button that can display text and execute a callback when pressed
  • Dropdown: A dropdown menu that supports any object (in menu.py, other types of menus can be put here)
  • LivePlot: An extension of Plot. Displays a timestamped data stream and changes the y range dynamically.

Made changes to the manager and the component base class. Component._draw() should contain most of the drawing that a component needs. Components.root surface is no longer standard in components, as Switch and Button have two static surfaces. Component.update() is now responsible for readying surfaces. In a similar fashion, GUIManager.update() now updates and blits components.

Added more util functions.

  • get_default_font() gets a Font object and is cross platform
  • clip() applies a range to a value
  • float_format() converts floats to strings.

CaseyHackerMan and others added 12 commits August 31, 2022 14:24
Implemented button.py and wrote a test, moved pygame initialization stuff to guipy/__init__.py, added default font util, added optional function to textbox, changed sub_coords() to sub_vector() (and add_vector()), and added a black border to @Zjjc123's slider_test.py
Implemented switch.py and test, refactored button, added _render() to some components to contain the visual design, added TRANSPARENT color.
Implemented AutoPlot and test, fixed some range issues in Plot, slight change to translate(), commented switch.py
also added to gitignore to be sneaky
and some other stuff that I don't feel like listing
Dropdown is in menu.py
Mainly combined render() and update() for all components, and added back get_surf() method.
Plots now use float_format() from utils.py to format the numbers on the axes. Will probably change later to shorten numbers so they don't run off the screen.
also made some changes to ranging in plot.py
Copy link
Owner

@Zjjc123 Zjjc123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic

@CaseyHackerMan CaseyHackerMan merged commit f6a81da into main Sep 15, 2022
@CaseyHackerMan CaseyHackerMan deleted the more-components branch September 15, 2022 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants