Skip to content

Instantly share code, notes, and snippets.

@kojix2
Last active December 12, 2018 08:00
Show Gist options
  • Save kojix2/c5b79686211461bbb03139ab4de5bdb4 to your computer and use it in GitHub Desktop.
Save kojix2/c5b79686211461bbb03139ab4de5bdb4 to your computer and use it in GitHub Desktop.
require 'datasets-gdk-pixbuf'
require 'gtk3'
n = ARGV[0].to_i
w = Gtk::Window.new
w.set_size_request(600,600)
flowbox = Gtk::FlowBox.new
flowbox.valign = :start
flowbox.selection_mode = :none
cifar = Datasets::CIFAR.new
cifar.each.with_index do |record, i|
if i < n
pixbuf = record.to_gdk_pixbuf
img = Gtk::Image.new(pixbuf: pixbuf)
button = Gtk::Button.new
button.image = img
flowbox.add button
end
end
w.add flowbox
w.show_all
Gtk.main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment