summaryrefslogtreecommitdiff
path: root/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb
blob: 8f51ab754f0982df76fdcafad58b297405a743fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env ruby
# frozen_string_literal: false
require 'tk'
require 'tkextlib/iwidgets'

mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic,
                                  :labeltext=>'Messages', :labelpos=>:n,
                                  :height=>120, :width=>550,
                                  :savedir=>'/tmp', :textbackground=>'#d9d9d9')
mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true)

mb.type_add('ERROR', :background=>'red', :foreground=>'white', :bell=>true)
mb.type_add('WARNING', :background=>'yellow', :foreground=>'black')
mb.type_add('INFO', :background=>'white', :foreground=>'black')

mb.issue('This is an error message in red with a beep', 'ERROR')
mb.issue('This warning message in yellow', 'WARNING')
mb.issue('This is an informational message', 'INFO')

Tk.mainloop