Giter VIP home page Giter VIP logo

flammarion's Introduction

Flammarion GUI Toolkit

Gem Version

Overview

Flammarion is an easy-to-use library for displaying information that you might normally display to the command line in a slightly easier-to-access way.

It is not intended to be a full fledged application development toolkit. It is intended instead for small scripts where you just want to show some information or buttons without going through too much trouble.

Installation

First, you need to install electron or chrome and make sure it's in your path. (Note: On Windows, currently only chrome works, but you don't need to worry about putting it in your path.)

Then you can install the gem:

gem install flammarion

or add it to your Gemfile.

Tutorial

The easiest way to use Flammarion, is similar to how you might use STDOUT:

(Note: these examples are intended to be run from an interactive session such as IRB or pry. If you wish to use them as part of a script, you should use f.wait_until_closed at the end, in order to block termination of the script.)

require 'flammarion'
f = Flammarion::Engraving.new
f.puts "Hello World!"

It can even support standard console color codes (Thanks to ansi_up!) and emoji / icons (Thanks to tweomji and font awesome)

require 'colorized'
f.puts "This line will be red!".red
f.puts "This #{"word".colorize(:green)} will not be blue."
f.puts "This line will have cows :cow: :cow2:", escape_icons: true

However, you can also do more advanced things. Say you want to show a table. Easy!

f.table(
  [%w[Number Squared Sqrt].map{|h| h.light_magenta}] + # Make the header a different color
  10.times.collect{|x| [x, x * x, Math.sqrt(x)]})

Now, instead of a table, you decide you want a plot. No problem.

x = 10.times.to_a
f.plot([{x:x, y:x}, {x: x, y: x.map{|i| i*i}}, {x: x, y: x.map{|i| Math.sqrt(i)}}])

Or maybe you want to know where something is:

f.map("Boston, MA")

Maybe you even want to see both of those things at the same time!

f.pane("numberstuff").table([%w[Number Squared Sqrt].map{|h| h.light_magenta}] +
  10.times.collect{|x| [x, x * x, Math.sqrt(x)]})
f.pane("mapstuff").map("Big Ben")

If you need feedback, there's a simple callback mechanism for buttons and text boxes:

f.button("Click Here!!!") {f.puts "You clicked the button!"}
f.input("Placeholder > ") {|msg| f.puts "You wrote: #{msg['text'].light_magenta}"}

The api documentation is available at http://zach-capalbo.github.io/flammarion/doc/Flammarion.html.

Screenshots / Samples

Message Composer with Address Book

f = Flammarion::Engraving.new
f.orientation = :horizontal
recipient = f.subpane("number").input("Phone Number")
text = f.input("Body", multiline:true)
f.button("Send") { send_message(recipient.to_s, text.to_s); f.status("Message Sent!")}
f.pane("contacts").puts("Contacts", replace:true)
icons = %w[thumbs-up meh-o bicycle gears star-o star cow cat cactus] + [nil] * 5
30.times do |i|
  name = Faker::Name.name
  f.pane("contacts").button(name, right_icon:icons.sample, left_icon:icons.sample) do
    recipient = name
    f.subpane("number").replace(name)
  end
end

Message Sample

Rake Task Runner

f = Flammarion::Engraving.new(exit_on_disconnect:true)
f.title "frake #{Dir.pwd}"

def run(task)
  f2 = Flammarion::Engraving.new
  f2.title task
  f2.puts "Running #{task.light_magenta}"
  Open3.popen3(task) do |i,o,e,t|
    Thread.new {e.each_line{|l| f2.print l.red}}
    o.each_line {|l| f2.print l}
    f2.status t.value.success? ? "Done!".light_green : "Failed!".light_red
  end
end

f.markdown "# Rake Tasks: "
`rake -T`.each_line do |l|
  f.break
  parts = l.split("#")
  task = parts[0]
  desc = parts[1]
  f.puts desc
  f.button(task) do
    run(task)
  end
end

f.wait_until_closed

Frake

Tables

f = Flammarion::Engraving.new
f.orientation = :horizontal
f.table([["Id", "Name", "Address"].map{|h| h.light_magenta}] + 20.times.map do |i|
  [i, Faker::Name.name, Faker::Address.street_address]
end)
f.pane("sidebar").pane("side1").puts Faker::Hipster.paragraph.red
f.pane("sidebar").pane("side2").puts Faker::Hipster.paragraph.green

3.times { f.status(Faker::Hipster.sentence.light_green)}

Table Sample

f = Flammarion::Engraving.new
f.plot(5.times.map{|t| {y:100.times.map{rand * t}}})

Plot Sample

Examples

There are a number of useful examples in the examples directory.

Some of these examples can be quite handy in their own right. If you wish to install these as executables, you can install the flammarion-utils gem with the command

gem install flammarion-utils

Bundled Packages

Flammarion is distributed with a bunch of useful tools to make everyone's life easier. They are:

flammarion's People

Contributors

coezbek avatar coolzilj avatar descovi avatar ktec avatar rnadler avatar waywardmonkeys avatar zach-capalbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flammarion's Issues

Does flammarion run on a MAC?

I am running ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14] on Mac 10.10.5. In IRB, I run

  require 'flammarion'
  f = Flammarion::Engraving.new

Chrome opens with URL file:///usr/local/var/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/flammarion-0.1.5/lib/html/build/index.html and reports at the bottom that it is detached. IRB reports timeout error. Further probing shows that the javascript to run websockets is not providing the port number..

I run the same code in windows 7 and it works..

Can you help?

[Documentation] How does it work?

Right now I don't quite understand how flammarion works.

If you ever have time and motivation, could you perhaps provide
one or two paragraphs about how flammarion achieves this
live communication with a browser? I mean that is pretty
nifty - I wonder if we can use that for bidirectionaly talking.

Apps close exit after start

Just testing this out, I made a file.

# app.rb
Flammarion.about

Then I ran ruby app.rb, and a dialog opened, then closed and the whole app exited with

[23:43PM] 404app3$ ruby app.rb 
(electron) companyName is now a required option to crashReporter.start
(electron) loadUrl is deprecated. Use loadURL instead.
[23:44PM] 404app3$ 

I was able to circumvent this by adding a

Flammarion.about
while true
end

This seems to be the case for the examples in the README as well.

Callback errors

Need a better way to handle uncaught exceptions in callbacks

f.map("Boston, MA") shows nothing on Windows

Hi guys,
this does not show anything on Windows 7 64bit

f.map("Boston, MA")

Am I supposed to require something else other than flammarion?

> ruby -v
> ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]

Crash when creating Engraving

irb(main):001:0> require 'flammarion'
=> true

irb(main):002:0> f = Flammarion::Engraving.new
O sistema não pode encontrar o arquivo file://C/Ruby26-x64/lib/ruby/gems/2.6.0/gems/flammarion-0.3.0/lib/html/build/index.html?path=w1&port=46883&title=Flammarion.

When I try to create a window (Engraving), this error happens!

Use better webview

When we use browser to render the page, if I close my browser, the app will be closed。and many settings of browser will affect our app.

I have wrapped a webview, it based on zserge/webview. I think it is better.

Flammarion opens regular Chrome browser

Hi, in a ruby file I have:

require 'flammarion'
f = Flammarion::Engraving.new
f.puts "Hello World!"

when I run it, the Flammarion window correctly shows up, but the regular Chrome browser is also opened. I'm on Windows 7 64 bit.

ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32]

Thanks!

Generating .jpg .pdf files and so forth

Is it possible to generate .jpg and .pdf files, via the commandline?

This would be quite interesting, kind of a "live .pdf builder" or so,
a bit like the programming language R is used to render a plot,
which is then used in e. g. a statistics paper. Would be cool if
flammarion can also cover that use case.

Selecting another browser via flammarion directly

On my system firefox is used, oddly enough; I am using thorium most of
the time though (a chrome based browser). Could you show a code
example how to switch to thorium rather than firefox? I'd also like
to test this via opening a new tab directly. Hopefully you can understand
my issue request - I'd like to tie one tab from my KDE konsole commandline,
to one particular tab (e. g. for flammarion) if that is possible.

Input form wonkiness

  • Need to add option for auto only.
  • History should not prevent you from inputting the same thing twice

Plot outside pane

My plot covers the left margin of the subpane it's in. I've set a thick border between panes and the plot is painted right on top of it. What can I do to force my plot inside the pane?

require 'flammarion'
require 'colorize'

f = Flammarion::Engraving.new
f.orientation = :vertical

top_pane = f.subpane('main')
top_pane.orientation = :horizontal
top_pane.style('border', '1px solid white')
top_pane.style('height', '200px')

status_pane = top_pane.subpane('status')
status_pane.style('border-right', '3px solid white')
status_pane.style('width', '40%')
status_pane.puts "Status"

buffer_pane = top_pane.subpane('buffer')
buffer_pane.style('width', '60%')
buffer_pane.style('height', '180px')
plot = buffer_pane.plot(Array.new(50).map{rand(10)},  {staticPlot: true})

Screenshot 2020-04-20 at 15 43 48

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.