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| 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) |
| <!-- | |
| You want to use your phone as a flashlight, but using the camera flash | |
| is (1) too bright, and (2) is white and is jarring at night if you want | |
| just a bit of dim light. | |
| So you want, say, a dim, red light. | |
| There are apps that turn your entire screen some color, but you don't | |
| need that. Just transfer this HTML page to your phone and load it up in |