GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — working on toolbar by clewis7 · Pull Request #195 · fastplotlib/fastplotlib

working on toolbar #195

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.

Sign up for GitHub

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
kushalkolar merged 14 commits into master from buttons
May 23, 2023

Uh oh!

There was an error while loading. Please reload this page.

Merged

working on toolbar #195

Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
7869153
working on toolbar
May 17, 2023
6a9fa9a
toolbar updates
May 18, 2023
4bab1ce
basic toolbar for plot implemented
May 19, 2023
3e916c9
base logic in notebook for gridplot toolbar
May 19, 2023
2fa309b
gp toolbar working when subplots have names & mix names/no names
May 19, 2023
b985f31
initial changes to simple plot toolbar
May 19, 2023
1702938
updates to plot toolbar, still need to refactor into separate file
May 22, 2023
20ef9dd
fixed gridplot toolbar, still need to move to separate class
May 22, 2023
47612a4
add flip button
May 22, 2023
14fda3c
adding click event handler for gp toolbar dropdown options
May 23, 2023
5bb9f00
keep new clicked plot up-to-date with toggle button values
May 23, 2023
7519116
Merge branch 'master' into buttons
clewis7 May 23, 2023
561b4eb
requested changes
May 23, 2023
0eacf45
Merge branch 'buttons' of https://github.com/kushalkolar/fastplotlib …
May 23, 2023
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

333 changes: 333 additions & 0 deletions 333 examples/buttons.ipynb
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,333 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "6725ce7d-eea7-44f7-bedc-813e8ce5bf4f",
"metadata": {},
"outputs": [],
"source": [
"from fastplotlib import Plot\n",
"from ipywidgets import HBox, Checkbox, Image, VBox, Layout, ToggleButton, Button\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "33bf59c4-14e5-43a8-8a16-69b6859864c5",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "257f4ccf14c54f1ba5a0642b2d7e82cc",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RFBOutputContext()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/clewis7/repos/fastplotlib/fastplotlib/graphics/features/_base.py:33: UserWarning: converting float64 array to float32\n",
" warn(f\"converting {array.dtype} array to float32\")\n"
]
},
{
"data": {
"text/plain": [
"<weakproxy at 0x7fe9c8a65ea0 to ImageGraphic at 0x7fe9f1a67d90>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot = Plot()\n",
"img = np.random.rand(512, 512)\n",
"plot.add_image(img)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "68ea8011-d6fd-448f-9bf6-34073164d271",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "832b884047e74f45b9e9307b0ced48cb",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(JupyterWgpuCanvas(), HBox(children=(Button(icon='expand-arrows-alt', layout=Layout(width='auto'…"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot.show()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "0bbb459c-cb49-448e-b0b8-c541e55da313",
"metadata": {},
"outputs": [],
"source": [
"from fastplotlib import GridPlot\n",
"from ipywidgets import Dropdown"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "91a31531-818b-46a2-9587-5d9ef5b59b93",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7fedb853c0c74d10bfbb900a988f6a98",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"RFBOutputContext()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"gp = GridPlot(\n",
" shape=(1,2),\n",
" names=[[\"plot1\", \"plot2\"]])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "e96bbda7-3693-42f2-bd52-f668f39134f6",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/clewis7/repos/fastplotlib/fastplotlib/graphics/features/_base.py:33: UserWarning: converting float64 array to float32\n",
" warn(f\"converting {array.dtype} array to float32\")\n"
]
}
],
"source": [
"for subplot in gp:\n",
" subplot.add_image(data=img)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "1ff67ee5-c942-4171-9058-9dd910c99d4b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['plot1', 'plot2']"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(gp.names[0])"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "95e7f25a-d936-42da-ae51-33550cf1f944",
"metadata": {},
"outputs": [],
"source": [
"names = list(gp.names[0])\n",
"\n",
"dropdown = Dropdown(options=[name for name in names], disabled=False, description='Plots:')"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "f0ec8d8c-fbc8-4e83-a764-a191b2977675",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c7eea34a49bf44e8a353c2ffbe436986",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Dropdown(description='Plots:', options=('plot1', 'plot2'), value='plot1')"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dropdown"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "84e90ac1-8e35-4cb8-b9f2-a5ea6e0e742f",
"metadata": {},
"outputs": [],
"source": [
"tools = list()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "52fbc321-0daf-49d6-bb61-cb6a16e585c3",
"metadata": {},
"outputs": [],
"source": [
"auto_tool = Button(value=False, disabled=False, icon='expand-arrows-alt', layout=Layout(width='auto'))\n",
"center_tool = Button(value=False, disabled=False, icon='compress-arrows-alt', layout=Layout(width='auto'))\n",
"panzoom_tool = ToggleButton(value=False, disabled=False, icon='hand-pointer', layout=Layout(width='auto'))\n",
"maintain_aspect_tool = ToggleButton(value=False, disabled=False, description=\"1:1\", layout=Layout(width='auto'))\n",
"maintain_aspect_tool.style.font_weight = \"bold\""
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "cf9c4930-8043-4d66-9e99-9e4b5b7c90e4",
"metadata": {},
"outputs": [],
"source": [
"tools.extend([auto_tool, center_tool, panzoom_tool, maintain_aspect_tool])\n",
"toolbar = HBox(tools)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "f3699979-ff0a-4490-9d15-b368f22fe5b8",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0e7128ecae234179812d5e784930a131",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(JupyterWgpuCanvas(frame_feedback={'index': 5018, 'timestamp': 1684520752.8116126, 'localtime': …"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VBox([gp.show(), HBox([toolbar, dropdown])])"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "cb64a77a-651e-4efd-8127-3a0e2dc87239",
"metadata": {},
"outputs": [],
"source": [
"def auto_scale(obj):\n",
" current = dropdown.value\n",
" if maintain_aspect_tool.value:\n",
" gp[current].auto_scale(maintain_aspect=True)\n",
" else:\n",
" gp[current].auto_scale()\n",
"\n",
"def center_scene(obj):\n",
" current = dropdown.value\n",
" gp[current].center_scene()\n",
"\n",
"def panzoom_control(obj):\n",
" current = dropdown.value\n",
" if panzoom_tool.value:\n",
" # toggle pan zoom controller\n",
" gp[current].controller.enabled = False\n",
" else:\n",
" gp[current].controller.enabled = True"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "52b779a2-17ad-4888-863f-da9883a2adb8",
"metadata": {},
"outputs": [],
"source": [
"panzoom_tool.observe(panzoom_control, 'value')\n",
"auto_tool.on_click(auto_scale)\n",
"center_tool.on_click(center_scene)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "36f5e040-cc58-4b0a-beb1-1f66ea02ccb9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.