{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "source": [ "##~ WIDGET CODE | BY: ANXETY ~##\n", "\n", "import os\n", "import json\n", "import ipywidgets as widgets\n", "from ipywidgets import widgets, Layout, Label, Button, VBox, HBox\n", "from IPython.display import display, HTML, Javascript, clear_output\n", "\n", "\n", "# ================= DETECT ENV =================\n", "def detect_environment():\n", " free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n", " environments = {\n", " 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n", " 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n", " 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n", " }\n", "\n", " for env_var, (environment, path) in environments.items():\n", " if env_var in os.environ:\n", " return environment, path, free_plan\n", "\n", "env, root_path, free_plan = detect_environment()\n", "webui_path = f\"{root_path}/sdw\"\n", "\n", "!mkdir -p {root_path}\n", "# ----------------------------------------------\n", "\n", "\n", "# ==================== CSS JS ====================\n", "# custom background images (test)\n", "import argparse\n", "parser = argparse.ArgumentParser(description='This script processes an background image.')\n", "parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')\n", "parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)\n", "parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)\n", "parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)\n", "parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)\n", "parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)\n", "parser.add_argument('-m', '--mode', type=str, help='Specify \"no-repeat\" so that the image pattern is not repeated.', metavar='', default='repeat')\n", "parser.add_argument('-t', '--transparent', action='store_true', help='Flag to exclude z-index from CSS. Makes fields transparent')\n", "args = parser.parse_args()\n", "# ---\n", "url_img, opacity_img, blur_img, y_img, x_img, scale_img, mode_img = args.image, args.opacity, args.blur, args.y, args.x, args.scale, args.mode\n", "\n", "container_background = f'''\n", "\\n\"\n", "\n", "display(HTML(container_background))\n", "# ---\n", "\n", "CSS = '''\n", "\n", "\n", "\n", "\n", "'''\n", "\n", "display(HTML(CSS))\n", "# ==================== CSS JS ====================\n", "\n", "\n", "# ==================== WIDGETS ====================\n", "# --- global widgets ---\n", "style = {'description_width': 'initial'}\n", "layout = widgets.Layout(min_width='1047px')\n", "\n", "HR = widgets.HTML('