{ "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 time\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", " }\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 V1.5\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',action='store_true', help='Removes repetitive image tiles')\n", "parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')\n", "parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)\n", "args = parser.parse_args()\n", "\"\"\"---\"\"\"\n", "url_img = args.image\n", "opacity_img = args.opacity\n", "blur_img = args.blur\n", "y_img = args.y\n", "x_img = args.x\n", "scale_img = args.scale\n", "blur_fields = args.blur_fields\n", "\n", "## ---\n", "\"\"\" WTF KAGGLE - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? \"\"\"\n", "fix_heigh_img = \"-810px\" if env == \"Kaggle\" else \"-775px\"\n", "\n", "\"\"\" transperent fields \"\"\"\n", "t_bg_alpha = \"1\" if not args.transparent else \"0.65\"\n", "\n", "\"\"\" mode img - repeats \"\"\"\n", "mode_img = \"repeat\" if not args.mode else \"no-repeat\"\n", "## ---\n", "\n", "container_background = f'''\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('