flightaware / Tcl-bounties

Bounty program for improvements to Tcl and certain Tcl packages
104 stars 8 forks source link

[Bounty Suggestion] Make CSS great again #39

Closed rubyFeedback closed 1 year ago

rubyFeedback commented 3 years ago

I have been using tk mostly indirectly, via ruby and python bindings. (I understand that tcl isn't 1:1 related to tk as such, but I always call it tcl/tk mentally, so ...)

In ruby-gtk3 we can use CSS very easily so.

For instance, the following ruby-gtk3 works:

require 'gtk3'

module Gtk

class HoverButtonExampleViaCss < ::Gtk::Box # === Gtk::HoverButtonExampleViaCss

  alias e puts

  # ========================================================================= #
  # === USE_THIS_AS_THE_CSS_STRING
  # ========================================================================= #
  USE_THIS_AS_THE_CSS_STRING = <<-EOF

button {
  font-size: 36px;
  background-image: none;
  background-color: yellow;
}

button:hover {
  transition: 4000ms linear;
  background-color: lightblue;
}

#bblack1 { border: 1px solid black; }

EOF

  # ========================================================================= #
  # === initialize
  # ========================================================================= #
  def initialize
    super(:vertical)
    enable_CSS_support
    set_border_width(25)
    button = ::Gtk::Button.new(
      label: "Test hover action and transition -\nplace the mouse cursor over this text.\nThis functionality is implemented via button:hover, and transition:"
    )
    button.set_name('bblack1')
    button.signal_connect(:clicked) { e 'Click me!' }
    add(button)
    add(::Gtk::Separator.new(:horizontal))
  end

  # ========================================================================= #
  # === enable_CSS_support
  # ========================================================================= #
  def enable_CSS_support
    provider = ::Gtk::CssProvider.new
    provider.load(data: USE_THIS_AS_THE_CSS_STRING)
    ::Gtk::StyleContext.add_provider_for_screen(
      Gdk::Screen.default,
      provider,
      Gtk::StyleProvider::PRIORITY_APPLICATION
    )
  end

end; end

if __FILE__ == $PROGRAM_NAME
  window = Gtk::Window.new
  window.add(Gtk::HoverButtonExampleViaCss.new)
  window.show_all
  window.set_size_request(880, 600)
  window.move(0, 0)
  Gtk.main  
end

CSS is useful because I, as a user, can re-use it for web-related stuff as well as for GUIs (such as gtk3).

It would be nice if Tcl/Tk also supports CSS on the same level; ideally where we could just define common layout things, and then never have to manually change buttons and other widgets to a different variant.

I do not know how the bounty program works as such, and I don't know how much tcl/tk supports CSS (I read on some wiki pages that there is some support but I don't know how up-to-date it is), but perhaps I am not the only one who thinks it may useful if Tcl/TK gets more CSS support.

I think many small donations could also help, so if someone could set this up and allow people to vote on popular feature suggestions and what not. Perhaps that may help things going?

bovine commented 1 year ago

Closing, as this is not an appropriate place to report suggestions. FlightAware has generally only funded bounties for functionality that also overlaps with its own needs and we currently make no use of Tk GUIs.