Tkinter has built-in support for a few image formats — PNG, GIF, and PPM/PGM — through
tk.PhotoImage. For a PNG file, no third-party library is needed:
import tkinter as tk| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>A simple, accessible version of Bloom's taxonomy</title> | |
| <meta name="description" content="Bloom's taxonomy of cognitive levels as accessible HTML and CSS: a WCAG-conformant replacement for the common pyramid diagram, which fails contrast and is unreadable by screen readers."> | |
| <style> | |
| body { | |
| font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; |
| import tkinter as tk | |
| def main(): | |
| win = tk.Tk() | |
| win.geometry("400x200") | |
| label = tk.Label(win, text="Here is an image.") | |
| label.grid(row=0, column=0) | |
| my_tk_photoimage = tk.PhotoImage(file="your_image_here.png") |
I make reveal.js slides with markdown and convert with pandoc. Sometimes I want to post those slides so my students can access them, but I want to strip out the speaker notes because they usually aren't very useful to them.
I don't want to edit my source files; I just want the output correct. So, I could do something to the output html slides.
But: I also want to allow for the possibility that I'll want to output to other formats. So the best solution is to tell pandoc to do that filtering while it converts.
| (defun my/do-command-other-window (count command &optional return-p) | |
| "Do COMMAND in other-window. The COUNT argument is provided to | |
| `other-window'. | |
| The optional RETURN-P argument, if true, will make this return to the | |
| original window after calling COMMAND. | |
| The intended way to use this function is by calling it from an | |
| interactive function that specifies the command: |
| public enum Coffee { | |
| ESPRESSO(2.50, 2), | |
| LATTE(4.50, 8), | |
| CAPPUCCINO(4.00, 8), | |
| AMERICANO(3.00, 8); | |
| // the 'final' isn't necessary functionally, since you can't change these from outside the class/enum | |
| // but this does document our intent, and would prevent accidentally adding something inside this enum | |
| // that modified the field. | |
| private final double price; |
| # my version of Steve Reich's Clapping for Sonic Pi: | |
| # https://en.wikipedia.org/wiki/Clapping_Music | |
| # https://youtu.be/lzkOFJMI5i8?si=oaBTc4WBR_DC2SJJ | |
| # https://sonic-pi.net/ | |
| use_bpm 120 | |
| claps = [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0].ring | |
| live_loop :clapping do |
| #lang racket | |
| #| | |
| I'm trying to understand parameters in Racket. | |
| One idea: for a recursive function, | |
| have a parameter that says how much to indent a debugging print | |
| statement so that I can see the call stack more clearly. |
Inspired by this Racket discourse post I tried writing a macro that defines bindings that work like constants in Racket.
Note that the solution here handles using set!; you can't prevent shadowing or redefining these variables -- see the Discourse thread.
| #lang racket/base | |
| ;; This is lovely but Exercism doesn't let you (require math)! | |
| ;; | |
| ;; Posted this: https://gist.github.com/dandrake/d9a3e20021a68ed16bce6f5dc79e62eb | |
| (require racket/contract) |