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

Added max lines and overflow scrollbar for gr.Code #9311

Merged
merged 10 commits into from
Sep 19, 2024

Conversation

micpst
Copy link

@micpst micpst commented Sep 10, 2024

Description

Adds max_lines parameter for gr.Code component, similar to gr.Textbox. This can be used for controlling the display size of this component.

Please run js/component-test to see it in action (go to Code tab)

pnpm i
cd js/component-test
pnpm dev

I kindly request you @abidlabs to please review this change and let me know your feedback! 🙂

Related to #9192

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Sep 10, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/73e710f188359c68b2a213cfc34cc40ab913a30f/gradio-4.44.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@73e710f188359c68b2a213cfc34cc40ab913a30f#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/73e710f188359c68b2a213cfc34cc40ab913a30f/gradio-client-1.6.0-beta.1.tgz

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Sep 10, 2024

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/code minor
@self/component-test minor
gradio minor
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Added max lines and overflow scrollbar for gr.Code

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs
Copy link
Member

Btw @micpst we are temporarily not merging PRs to main while we prepare for our 5.0 release. In the meantime, you can use the wheel generated by this PR to install Gradio from this PR:

pip install https://gradio-pypi-previews.s3.amazonaws.com/0792b5d0ed190e067d5ef438e4d2960597e7757e/gradio-4.44.0-py3-none-any.whl

but I'll probably rebase this to target 5.0-dev

@abidlabs abidlabs changed the base branch from main to 5.0-dev September 13, 2024 03:44
@abidlabs
Copy link
Member

Hi @micpst I just tested this PR and it looks like the behavior of max_lines is correct, but lines is not behaving as expected. E.g. in this example:

import gradio as gr

with gr.Blocks() as demo:
    gr.Code(lines=5)

demo.launch()

only 1 line is shown instead of 5:

image

@micpst
Copy link
Author

micpst commented Sep 18, 2024

Hi @abidlabs this is the standard behavior of the lines parameter, the current version of gradio renders the Code component in the same way.

@abidlabs
Copy link
Member

Ah you're right. Tested and confirms this PR works correct. Brilliant, thanks @micpst!

@abidlabs abidlabs merged commit c4afdcd into gradio-app:5.0-dev Sep 19, 2024
21 checks passed
@micpst micpst deleted the scrollable-code branch September 19, 2024 10:08
@hannahblair hannahblair mentioned this pull request Sep 26, 2024
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.

4 participants