Skip to content

Instantly share code, notes, and snippets.

@Omustardo
Omustardo / main.rs
Created August 28, 2025 03:25
egui font fallback demo
impl MyApp {
/// Called once before the first frame.
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
// This is where you can customize the look and feel of egui using
// `cc.egui_ctx.set_visuals` and `cc.egui_ctx.set_fonts`.
Self::setup_fonts(cc);
// Load previous app state (if any).
@Omustardo
Omustardo / background_width.rs
Created August 20, 2025 17:57
making a text label match the width of another
// Generated with https://claude.ai/public/artifacts/f8a4ae9b-7ad9-48bc-b867-f5e6652e9287
use eframe::egui;
use egui::{Color32, RichText};
pub struct MyApp {
text_input1: String,
text_input2: String,
text_input3: String,
}
@Omustardo
Omustardo / progress_buttons_demo.rs
Last active August 19, 2025 04:22
progress button demo
use eframe::egui;
use std::f32::consts::PI;
#[derive(Debug, Clone, PartialEq)]
pub enum ButtonState {
Order,
Processing,
Complete,
}
@Omustardo
Omustardo / dynamic_snapshots.rs
Last active August 19, 2025 08:22
egui_dock save and load DockState from a menu
// Demo of snapshotting and loading DockState.
//
// The general idea is to allow a user to save their layout and then be able to reload it later.
// For example, in an IDE it might be helpful to have one layout for UI programming (e.g. a render
// window on one side) while more space for terminal output might be preferable in other situations.
//
// Being able to save and load DockState allows quickly swapping between layouts. It also allows
// the program to provide preset layouts that users could choose between.
use eframe::NativeOptions;
@Omustardo
Omustardo / dynamic_snapshots.rs
Last active August 18, 2025 23:24
Standalone demo of saving and loading layout state in egui_dock, while it's running (v1)
// Demo of saving and loading UI layouts using egui_dock.
use eframe::NativeOptions;
use egui::containers::menu::MenuConfig;
use egui::{
CentralPanel, PopupCloseBehavior, TopBottomPanel, Ui, ViewportBuilder, WidgetText, vec2,
};
use egui_dock::tab_viewer::OnCloseResponse;
use egui_dock::{DockArea, DockState, NodeIndex, Style, SurfaceIndex, TabViewer};
use serde::{Deserialize, Serialize};
import os
import subprocess
BASE_DIR = "/home/omustardo/go/src/github.com/omustardo/omustardo.com/"
DEPLOY_DIR = BASE_DIR + "public/"
import os
from pathlib import Path
def convert_md_files_to_html(directory):
@Omustardo
Omustardo / egui_dock_stacked_tabs.rs
Last active August 24, 2025 20:24
Demo of a fraction of 1.0 causing tabs to stack weirdly
use eframe::egui;
use egui_dock::{DockState, NodeIndex, TabViewer};
fn main() -> Result<(), eframe::Error> {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([800.0, 600.0]),
..Default::default()
};
eframe::run_native(
"Dock Tab Overlap Demo",
2025-07-13 16:22:44 [INFO ]: aw-watcher-window started (aw_watcher_window.main:70)
2025-07-13 16:22:45 [INFO ]: Connection to aw-server established by aw-watcher-window (aw_client.client:447)
2025-07-13 20:39:33 [WARNING]: I don't think this case will ever happen, but not sure so leaving this message here just in case. (aw_watcher_window.xlib:82)
2025-07-13 20:39:33 [ERROR]: Exception thrown while trying to get active window (aw_watcher_window.main:133)
Traceback (most recent call last):
File "aw_watcher_window/main.py", line 115, in heartbeat_loop
File "aw_watcher_window/lib.py", line 64, in get_current_window
File "aw_watcher_window/lib.py", line 17, in get_current_window_linux
File "aw_watcher_window/xlib.py", line 85, in get_window_name
AttributeError: 'NoneType' object has no attribute 'decode'
@Omustardo
Omustardo / main.py
Last active May 22, 2025 00:36
Simple Python GUI "from scratch"
import tkinter as tk
# This program demonstrates how an application with a GUI might be created at its core.
# It creates a button by drawing a rectangle and handling mouse movement and clicks.
# It depends on tkinter (https://docs.python.org/3/library/tkinter.html) for creating a window, a drawable canvas, and getting mouse interactions.
# I generated this demo using Claude: https://claude.ai/share/62cd9df4-1ed7-40b7-a8f3-fb7e03e0146f
# Function to create and run our GUI application
def run_rectangle_demo():
# Create the main window
@Omustardo
Omustardo / layout_test.sh
Created March 19, 2025 08:27
Test tools for a Fyne Layout bug
#!/bin/bash
# Flexible Layout Test Script for Fyne applications
# Usage: ./layout_test.sh [path] [iterations]
# Examples:
# ./layout_test.sh foo/main.go 10 # Specific Go file with 10 iterations
# Parse arguments
TARGET_PATH="${1:-.}" # Default to current directory if not specified
ITERATIONS="${2:-20}" # Default to 20 iterations if not specified