Fedora Linux Support Community & Resources Center
  #31  
Old 19th July 2012, 04:25 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Quote:
Originally Posted by ah7013 View Post
Yup I think I'm defenitly running out of GUI toolkits with Perl bindings
There are still the Perl bindings for the Java Swing classes: http://search.cpan.org/~philcrow/Java-Swing-0.14/
It requires the Inline and Inline::Java modules. The Fedora repos have the Inline module (yum install perl-inline), but you'll have to get Inline::Java here: http://search.cpan.org/~patl/Inline-Java-0.53/
You should try it! If you're unfamiliar with the Swing API, just look at the Swing examples here so far, and use those to modify the 'calc' Perl script in the Java-Swing-0.14 example directory.

Latest update: we now have 30 examples.

Here's a summary of what we have right now, first organized by toolkit with the corresponding language bindings:
  1. GTK+: Haskell, Python, Perl, C++, Vala, Genie, C
  2. Qt: Python, C++, Java, Perl, Ruby
  3. Tk: Tcl, Perl, Python, Ruby
  4. Swing: Java, Python, Ruby
  5. XForms: C
  6. GNUstep: Objective-C
  7. Motif: C
  8. wxWidgets: Perl
  9. Icon: Icon
  10. Prima: Perl
  11. FOX: C++
  12. FLTK: C++
  13. MGUI: C
  14. EZWGL: C
  15. SWT: Java

Here's the list organized by programming language with the corresponding toolkit:
  1. Perl: Tk, wxWidgets, Prima, GTK+, Qt
  2. C: XForms, Motif, MGUI, EZWGL, GTK+
  3. C++: Qt, FOX, FLTK, GTK+
  4. Python: Tk, Qt, GTK+, Swing
  5. Java: Swing, Qt, SWT
  6. Ruby: Tk, Swing, Qt
  7. Tcl: Tk
  8. Objective-C: GNUstep
  9. Haskell: GTK+
  10. Icon: Icon
  11. Vala: GTK+
  12. Genie: GTK+

I have another C-based example that I'll post soon (which will put C in the lead over Perl unless ah7013 hurries up ), and possibly one with a language that hasn't appeared yet.
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #32  
Old 19th July 2012, 09:51 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's an example in the R programming language -- normally used for statistical computing -- using the built-in Tk bindings. R is in the Fedora repos (yum install R).

Here's the code:
Code:
#!/usr/bin/env Rscript
suppressPackageStartupMessages(library(tcltk))
sink("/dev/null", type="output")
win <- tktoplevel()
tkwm.title(win, "R/Tk Example Window")
tkwm.geometry(win, "400x150")
tkconfigure(win, bg="darkslateblue")
msg <- tklabel(win, text="Welcome!", font="Sans 32", bg="darkslateblue", fg="white")
tkpack(msg, pady=10)
ok_cb <- function()quit("yes")
.Tcl.callback(ok_cb)
ok <- tkbutton(win, text="OK", command=ok_cb)
tkpack(ok, pady=20)
tkwait.window(win)
That code can be run as a standalone executable script.

Here's the screenshot:
Attached Thumbnails
Click image for larger version

Name:	rtkwindow.png
Views:	158
Size:	7.9 KB
ID:	23471  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #33  
Old 20th July 2012, 04:16 AM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's an example in OCaml, using the Tk bindings (yum install ocaml-labltk-devel):
Code:
open Tk ;;
let top = openTk () ;;
Wm.title_set top "OCaml/Tk Example Window" ;;
Wm.geometry_set top "400x150" ;;
Toplevel.configure ~background:(`Color "#483D8B") top ;;
let msg = Label.create ~text:"Welcome!" ~font:"Sans 32"
          ~foreground:`White ~background:(`Color "#483D8B") top ;;
pack [msg] ~pady:10 ~side:`Top ;;
let ok = Button.create ~text:"OK" ~command:(fun () -> closeTk (); exit 0) top ;;
pack [ok] ~pady:20 ~side:`Bottom ;;
let _ = Printexc.print mainLoop () ;;
Save that in a file called ocamltkwindow.ml then compile and run it like this:
Code:
ocamlc -o ocamltkwindow -I +labltk labltk.cma ocamltkwindow.ml
./ocamltkwindow
Here's the screenshot:
Attached Thumbnails
Click image for larger version

Name:	ocamltkwindow.png
Views:	140
Size:	8.2 KB
ID:	23473  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #34  
Old 20th July 2012, 02:24 PM
ah7013 Offline
Registered "Cashew" User
 
Join Date: May 2010
Location: Adelaide, Australia
Age: 20
Posts: 671
linuxfirefox
Re: Programming challenge: Create a GUI window

Quote:
Originally Posted by RupertPupkin View Post
There are still the Perl bindings for the Java Swing classes: http://search.cpan.org/~philcrow/Java-Swing-0.14/
It requires the Inline and Inline::Java modules. The Fedora repos have the Inline module (yum install perl-inline), but you'll have to get Inline::Java here: http://search.cpan.org/~patl/Inline-Java-0.53/
You should try it! If you're unfamiliar with the Swing API, just look at the Swing examples here so far, and use those to modify the 'calc' Perl script in the Java-Swing-0.14 example directory.
Thanks for the links . I installed Inline (urpmi perl-Inline) and both Inline::Java and Java::Swing off CPAN and got the 'calc' example up and running. Will see if I can get something deveopled in the next couple of days.
Reply With Quote
  #35  
Old 20th July 2012, 03:53 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's an example in Pure, another functional language with Tk bindings. You can install Pure from the Fedora repos (yum install pure-devel), but you'll have to get the Tk bindings from here. All I had to do was modify the Makefile to use /usr/lib64 instead of /usr/lib, then ran make, then did "cp gnocl.pure tk.pure tk.so /usr/lib64/pure".

Here's the code:
Code:
using tk;
main = init_app $$ tk_main;
init_app = () when
   tk "wm title . \"Pure-Tk Example Window\"";
   tk "wm geometry . 400x150";
   tk ". configure -bg darkslateblue";
   tk "label .msg -font { -size 32 } -text \"Welcome!\" -bg darkslateblue -fg white";
   tk "pack .msg -pady 10";
   tk "button .ok -text OK -command exit";
   tk "pack .ok -pady 20";
end;
if compiling then () else main;
Save that in a file called puretkwindow.pure then compile it like this:
Code:
pure -c puretkwindow.pure -o puretkwindow
Alternatively, you could run the file directly with "pure puretkwindow.pure", or by putting "#!/usr/bin/pure -x" at the top of puretkwindow.pure and running it as a standalone executable script.

Here's the screenshot:
Attached Thumbnails
Click image for larger version

Name:	puretkwindow.png
Views:	129
Size:	7.9 KB
ID:	23481  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #36  
Old 21st July 2012, 04:34 AM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's an example with the ancient SNOBOL -- yes, that SNOBOL! -- using its Tk bindings. For this don't bother with the version 1.3 snobol and snobol-devel packages in the Fedora repos, their Tcl/Tk support is busted (trying the example in the snobol4tcl man page bombs out with a signal 11). Instead grab the latest 1.4.1 version here: http://www.snobol4.org/csnobol4/curr/
I ran the configure script with just the --with-tcl option and got working Tcl/Tk support.

Here's the code:
Code:
-INCLUDE 'stcl.sno'
   INTERP = STCL_CREATEINTERP()
   STCL_EVAL(INTERP, "package require Tk")   :F(END)
   STCL_EVAL(INTERP,
+      'wm title . "SNOBOL/Tk Example Window";'
+      'wm geometry . 400x150;'
+      'wm protocol . WM_DELETE_WINDOW {exit};'
+      '. configure -bg darkslateblue;'
+      'label .msg -text "Welcome!" -font {-size 32} -bg darkslateblue -fg white;'
+      'pack .msg -pady 10;'
+      'button .ok -text OK -command {exit};'
+      'pack .ok -pady 20;'
+      'vwait ok')
   OUTPUT = STCL_GETVAR(INTERP, "ok")
END
Save that in a file called snoboltkwindow.sno and run it like this:
Code:
snobol4 -b snoboltkwindow.sno
Here's the screenshot:
Attached Thumbnails
Click image for larger version

Name:	snoboltkwindow.png
Views:	144
Size:	8.4 KB
ID:	23483  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N

Last edited by RupertPupkin; 21st July 2012 at 04:38 AM.
Reply With Quote
  #37  
Old 21st July 2012, 06:37 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's another C example, this time using Tk. You'll need the the tcl-devel and tk-devel packages installed for this to work.
Code:
#include <stdlib.h>
#include <tcl.h>
#include <tk.h>

int Tk_AppInitProc(Tcl_Interp *interp) {
   if (Tcl_Init(interp) == TCL_ERROR) return TCL_ERROR;
   if (Tk_Init(interp) == TCL_ERROR) return TCL_ERROR;
   Tcl_Eval(interp, "wm title . \"C/Tk Example Window\"");
   Tcl_Eval(interp, "wm geometry . 400x150");
   Tcl_Eval(interp, ". configure -bg darkslateblue");
   Tcl_Eval(interp, "label .msg -text \"Welcome!\" -font {-size 32} -bg darkslateblue -fg white");
   Tcl_Eval(interp, "pack .msg -pady 10");
   Tcl_Eval(interp, "button .ok -text OK -command exit");
   Tcl_Eval(interp, "pack .ok -pady 20");
   Tk_MainLoop();
   exit(0);
}

void main(int argc, char *argv[]) {
   Tk_Main(argc, argv, Tk_AppInitProc);
}
Save that in a file called ctkwindow.c and compile it like this:
Code:
gcc -o ctkwindow ctkwindow.c -ltcl -ltk
Here's the screenshot:
Attached Thumbnails
Click image for larger version

Name:	ctkwindow.png
Views:	132
Size:	7.9 KB
ID:	23487  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #38  
Old 22nd July 2012, 11:49 AM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's an example in the Lua scripting language, using ltcltk, which provides Tk bindings. If you don't want to compile ltcltk from source (which takes a little tweaking of the Makefile to compile for 64-bit F17), you could install the luarocks package from the Fedora repos (yum install luarocks) then do "luarocks install ltcltk" as root.

Here's the code (to be run as an executable script):
Code:
#!/usr/bin/lua
require "ltk"
ltk.wm{'title', '.', "Lua/Tk Window Example"}
ltk.wm{'geometry', '.', "400x150"}
ltk.wcmd('.'){'configure', background="darkslateblue"}
msg = ltk.label{text="Welcome!", font={'Sans',32}, bg="darkslateblue", fg="white"}
ltk.pack{msg, pady=10}
ok = ltk.button{text="OK", command=function() ltk.exit() end}
ltk.pack{ok, pady=20}
ltk.mainloop()
Screenshot:
Attached Thumbnails
Click image for larger version

Name:	luawindow.png
Views:	141
Size:	7.3 KB
ID:	23491  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #39  
Old 23rd July 2012, 06:05 AM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's another Tcl example, this time using the GTK+ bindings available through the Gnocl package. Version 0.9.96 seems to have problems on 64-bit systems, but I did get version 0.9.95 to compile in F17 x86_64; you can get it here. I then did
Code:
mkdir /usr/lib64/tcl8.5/gnocl0.9.95; cp gnocl.so pkgIndex.tcl /usr/lib64/tcl8.5/gnocl0.9.95
from the source directory and had a working Gnotcl.

Here's the code, which can be run as a script:
Code:
#!/usr/bin/tclsh
package require Gnocl
set msg [gnocl::label -text {%<<span foreground="white">Welcome!</span>} -baseFont {Sans 32}]
set ok [gnocl::button -text "OK" -onClicked {exit}]
set okBox [gnocl::box -orientation horizontal -borderWidth 0 -expand 1 -children "$ok"]
set vbox [gnocl::box -orientation vertical -borderWidth 0 -spacing 40 -children "$msg $okBox"]
set win [gnocl::window -title "Gnocl Window Example" -defaultWidth 400 -defaultHeight 150 \
         -onDestroy {exit} -child $vbox -borderWidth 15 -backgroundColor darkslateblue]
gnocl::mainLoop
Here's the screenshot:
Attached Thumbnails
Click image for larger version

Name:	gnotclwindow.png
Views:	143
Size:	8.0 KB
ID:	23503  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #40  
Old 23rd July 2012, 12:47 PM
ah7013 Offline
Registered "Cashew" User
 
Join Date: May 2010
Location: Adelaide, Australia
Age: 20
Posts: 671
linuxfirefox
Re: Programming challenge: Create a GUI window

Quote:
Originally Posted by ah7013 View Post
Thanks for the links . I installed Inline (urpmi perl-Inline) and both Inline::Java and Java::Swing off CPAN and got the 'calc' example up and running. Will see if I can get something deveopled in the next couple of days.
Having a few issues with it so will be another few days I think.
Reply With Quote
  #41  
Old 23rd July 2012, 04:24 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's another Tcl example, this time using the Qt bindings available through the qtcl package. I had to make a couple changes to the configure script, the qtcl.pri file generated by qmake, and the lib/QTclMessageBox.cpp source file in order to compile qtcl in F17 x86_64. If anyone's interested in the details let me know.

Here's the code, which can be run as an executable script:
Code:
#!/usr/bin/env qtcl
qt create QMainWindow .win windowTitle "Qtcl Window Example" geometry "500 450 400 150"
.win setStyleSheet "QMainWindow, QLabel { background-color: #483D8B; color: white }"
qt create QLabel .win.msg text "Welcome!" geometry "85 20 230 50" font "Sans, 32" alignment AlignHCenter
qt create QPushButton .win.ok text "OK" geometry "175 100 50 30"
.win.ok connect clicked() .win close()
.win show
Screenshot:
Attached Thumbnails
Click image for larger version

Name:	qtclwindow.png
Views:	140
Size:	8.1 KB
ID:	23506  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #42  
Old 23rd July 2012, 09:03 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Another Java example, this time using plain old AWT, the default GUI in Java before Swing came along. This one required explicitly setting the background of the button since in AWT -- unlike in Swing -- the button automatically inherits the colors of its parent container.
Code:
import java.awt.*;
import java.awt.event.*;

public class awtjavawindow {
 public static void main(String[] args) {
   Frame f = new Frame("Java AWT Window Example");
   f.setSize(400,175);
   f.setLayout(new BorderLayout());
   f.setBackground(new Color(72,61,139));
   Label msg = new Label("Welcome!", Label.CENTER);
   msg.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 32));
   msg.setForeground(Color.WHITE);
   f.add(msg, BorderLayout.CENTER);
   Panel bottom = new Panel();
   Button ok = new Button("OK");
   ok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent event) {
         System.exit(0);
      }
   });
   f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent event) {
         System.exit(0);
      }
   });
   bottom.add(ok);
   ok.setBackground(new Color(222,222,222)); //Reset to default gray87
   f.add(bottom, BorderLayout.SOUTH);
   f.setVisible(true);
 }
}
Save that code in a file called awtjavawindow.java then compile and run it like this:
Code:
javac awtjavawindow.java
java awtjavawindow
Screenshot:
Attached Thumbnails
Click image for larger version

Name:	awtjavawindow.png
Views:	131
Size:	4.0 KB
ID:	23507  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #43  
Old 24th July 2012, 01:18 AM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Another C example, this time using the XView toolkit (which used to be the basis of OpenWindows, the default GUI in Solaris before CDE came along). XView has been out of the Fedora repos for a long time; the last RPMs were for Fedora 8, which you can get here (download the xview and xview-devel RPMs and use rpm -ivh to install them). It's 32-bit only, so to get it to work you'll need to install the following 32-bit packages in Fedora: glibc.i686, libXext.i686, libX11.i686, libxcb.i686, libXau.i686.

Here's the code:
Code:
#include <xview/xview.h>
#include <xview/frame.h>
#include <xview/panel.h>
#include <xview/font.h>
#include <xview/cms.h>

Frame frame;

void quit() {
   xv_destroy_safe(frame);
}

void main(int argc, char *argv[]) {
   xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
   static Xv_singlecolor cms_colors[] = {
      { 72, 61, 139 },
      { 255, 255, 255 },
      { 71, 61, 139 }
   };
   Cms cms = (Cms)xv_create(ROOT_FRAME, CMS,
             CMS_CONTROL_CMS, FALSE,
             CMS_TYPE,        XV_STATIC_CMS,
             CMS_SIZE,        3,
             CMS_COLORS,      cms_colors,
             NULL);
   frame = (Frame)xv_create(ROOT_FRAME, FRAME,
           FRAME_LABEL, "XView Example Window",
           XV_WIDTH,    400,
           XV_HEIGHT,   150,
           NULL);
   Panel panel = (Panel)xv_create(frame, PANEL,
                 WIN_CMS,              cms,
                 WIN_BACKGROUND_COLOR, 0,
                 NULL);
   Font font = (Font)xv_find(XV_NULL, FONT,
               FONT_NAME, "-adobe-helvetica-medium-r-normal--34-240-100-100-p-176-iso8859-1", NULL);
   (void) xv_create(panel, PANEL_MESSAGE,
                    XV_X,               125,
                    XV_Y,               30,
                    PANEL_LABEL_STRING, "Welcome!",
                    PANEL_LABEL_FONT,   font,
                    PANEL_ITEM_COLOR,   1,
                    NULL);
   (void) xv_create(panel, PANEL_BUTTON,
                    XV_X,               180,
                    XV_Y,               115,
                    PANEL_LABEL_STRING, "OK",
                    PANEL_NOTIFY_PROC,  quit,
                    PANEL_ITEM_COLOR,   1,
                    NULL);
   xv_main_loop(frame);
   exit(0);
}
Save that in a file called xvwindow.c and compile it like this:
Code:
gcc -m32 -o xvwindow xvwindow.c -lxview -I/usr/openwin/include -L/usr/openwin/lib
Screenshot (taken under the XView-based olvwm window manager in F17):
Attached Thumbnails
Click image for larger version

Name:	xvwindow.png
Views:	137
Size:	1.1 KB
ID:	23508  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #44  
Old 24th July 2012, 06:26 AM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Latest update: we now have 40 examples.

Here's a summary of what we have right now, first organized by programming language with the corresponding toolkit:
  1. C: XForms, Motif, MGUI, EZWGL, GTK+, Tk, XView
  2. Perl: Tk, wxWidgets, Prima, GTK+, Qt
  3. C++: Qt, FOX, FLTK, GTK+
  4. Python: Tk, Qt, GTK+, Swing
  5. Java: Swing, Qt, SWT, AWT
  6. Ruby: Tk, Swing, Qt
  7. Tcl: Tk, GTK+, Qt
  8. Objective-C: GNUstep
  9. Haskell: GTK+
  10. Icon: Icon
  11. Vala: GTK+
  12. Genie: GTK+
  13. R: Tk
  14. OCaml: Tk
  15. Pure: Tk
  16. SNOBOL: Tk
  17. Lua: Tk
So C has taken the lead over Perl since the last summary.

Here's the list organized by toolkit with the corresponding language bindings:
  1. Tk: Tcl, Perl, Python, Ruby, R, OCaml, Pure, SNOBOL, C, Lua
  2. GTK+: Haskell, Python, Perl, C++, Vala, Genie, C, Tcl
  3. Qt: Python, C++, Java, Perl, Ruby, Tcl
  4. Swing: Java, Python, Ruby
  5. XForms: C
  6. GNUstep: Objective-C
  7. Motif: C
  8. wxWidgets: Perl
  9. Icon: Icon
  10. Prima: Perl
  11. FOX: C++
  12. FLTK: C++
  13. MGUI: C
  14. EZWGL: C
  15. SWT: Java
  16. AWT: Java
  17. XView: C
So Tk has taken the lead over GTK+ since the last summary.
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #45  
Old 24th July 2012, 04:41 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 5,687
linuxfedorafirefox
Re: Programming challenge: Create a GUI window

Here's an example in the JVM-based language Scala, using its built-in Swing capabilities. The code below works with Scala 2.9.2.
Code:
import scala.swing._
import scala.swing.event._
import scala.swing.BorderPanel._

object scalawindow extends SimpleSwingApplication {
   def top = new MainFrame {
      title = "Scala Window Example"
      object msg extends Label {
         text = "Welcome!"
         foreground = new Color(255,255,255)
         font = new Font("Sans",0,32)
      }
      object ok extends Button {
         text = "OK"
      }
      object bottom extends FlowPanel {
         contents.append(ok)
         background = new Color(72,61,139)
      }
      contents = new BorderPanel {
         background = new Color(72,61,139)
         layout(msg) = Position.Center
         layout(bottom) = Position.South
         preferredSize = new Dimension(400,150)
      }
      pack
      listenTo(ok)
      reactions += {
         case ButtonClicked(ok) => quit()
      }
   }
}
Save that in a file called scalawindow.scala, then compile and run it like this:
Code:
scalac scalawindow.scala
scala -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true scalawindow
Screenshot:
Attached Thumbnails
Click image for larger version

Name:	scalawindow.png
Views:	131
Size:	6.4 KB
ID:	23520  
__________________
OS: Fedora 20 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 5GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
Reply

Tags
challenge, create, gui, programming, window

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you create your own programming language hmm? Mepoe Programming & Packaging 7 23rd April 2012 12:16 AM
How does KDE 3.7 create popup window on detection of USB drives. Brian1 Using Fedora 0 22nd November 2007 11:12 PM
Which Window Manager are you using for programming ? michaeleekk Programming & Packaging 11 29th July 2007 08:45 AM
gtk programming ~ how to link to another window after button is clicked? yan612 Programming & Packaging 2 3rd October 2006 09:10 AM
Automatic daily login script *Programming Challenge* SickFreak Programming & Packaging 4 23rd November 2005 10:45 PM


Current GMT-time: 22:55 (Thursday, 30-10-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
Wenzhou Travel Photos - Osorio - Mestre Travel Photos