Window creation: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
==[[ |
==[[C]]== |
||
[[Category:C]] |
|||
'''Standard:''' [[ANSI C]] (AKA [[C89]]): |
|||
Using SDL: |
Using SDL: |
||
Line 35: | Line 38: | ||
Submitted by Calvin Arndt 2007-01-21 2:49pm CST |
Submitted by Calvin Arndt 2007-01-21 2:49pm CST |
||
==[[C++]]== |
==[[C plus plus|C++]]== |
||
[[Category:C plus plus]] |
|||
Using QT4: |
Using QT4: |
||
Line 81: | Line 85: | ||
==[[mIRC]]== |
==[[mIRC]]== |
||
[[Category:mIRC]] |
|||
'''Compiler:''' [[mIRC]] |
'''Compiler:''' [[mIRC]] |
||
Line 94: | Line 99: | ||
==[[Perl]]== |
==[[Perl]]== |
||
[[Category:Perl]] |
|||
'''Interpreter:''' [[Perl]] 5.8.8 |
'''Interpreter:''' [[Perl]] 5.8.8 |
||
Line 105: | Line 111: | ||
==[[Python]]== |
==[[Python]]== |
||
[[Category:Python]] |
|||
'''Interpreter:''' [[Python]] 2.4, 2.5 |
'''Interpreter:''' [[Python]] 2.4, 2.5 |
||
Line 146: | Line 153: | ||
==[[Ruby]]== |
==[[Ruby]]== |
||
[[Category:Ruby]] |
|||
'''Interpreter:''' [[Ruby]] 1.8.5 |
'''Interpreter:''' [[Ruby]] 1.8.5 |
||
Line 161: | Line 170: | ||
==[[RapidQ]]== |
==[[RapidQ]]== |
||
[[Category:RapidQ]] |
|||
create form as qform |
create form as qform |
||
Line 170: | Line 180: | ||
==[[VB.NET]]== |
==[[VB.NET]]== |
||
[[Category:VB.NET]] |
|||
Using .Net Framework: |
Using .Net Framework: |
||
Line 179: | Line 190: | ||
==[[Java]]== |
==[[Java]]== |
||
[[Category:Java]] |
|||
Using Swing |
Using Swing |
||
Line 199: | Line 211: | ||
==[[JavaScript]]== |
==[[JavaScript]]== |
||
[[Category:JavaScript]] |
|||
Easy |
Easy |
Revision as of 18:44, 23 January 2007
Window creation
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
C
Using SDL:
/* * Opens an 800x600 16bit color window. * Done here with ANSI C. */ #include <stdio.h> #include <stdlib.h> #include "SDL/SDL.h" main(){ SDL_Surface *screen; if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError()); return(1); } atexit(SDL_Quit); screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE ); }
Compiled with: gcc (GCC) 4.0.3 (Ubuntu 4.0.3-1ubuntu5) Compiler command: gcc -lSDL SDL_Window.c -o window Notes: Submitted by Calvin Arndt 2007-01-21 2:49pm CST
C++
Using QT4:
#include <QApplication> #include <QMainWindow> int main(int argc, char *argv[]) { QApplication app(argc, argv); QMainWindow window; window.show(); return app.exec(); }
Compiler command: qmake -pro qmake
Using Gtkmm:
#include <iostream> #include <gtkmm.h> int main( int argc, char* argv[] ) { try { Gtk::Main m( argc, argv ) ; Gtk::Window win ; m.run( win ) ; } catch( std::exception& exc ) { std::out << exc.what() << std::endl ; exit( -1 ) ; } exit( 0 ) ; }
Compiler command: g++ filename.cc -o test `pkg-config --cflags --libs gtkmm-2.4`
mIRC
Compiler: mIRC
Switches: C = Center Window p = Picture Window d = Desktop Window
alias CreateMyWindow { .window -Cp +d @WindowName 600 480 }
Perl
Interpreter: Perl 5.8.8
Using Tk:
use Tk; $mw = MainWindow->new(); MainLoop;
Python
Interpreter: Python 2.4, 2.5
Using Tkinter:
import tkinter w = tkinter.Tk() w.mainloop()
Using wxPython:
from wxPython.wx import * class MyApp(wxApp): def OnInit(self): frame = wxFrame(NULL, -1, "Hello from wxPython") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop()
Using Pythonwin:
import win32ui from pywin.mfc.dialog import Dialog d = Dialog(win32ui.IDD_SIMPLE_INPUT) d.CreateWindow()
Using PyGTK:
import gtk window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.show() gtk.main()
Ruby
Interpreter: Ruby 1.8.5
Using Tk:
require 'tk' window = TkRoot::new() window::mainloop()
Using GTK:
require 'gtk2' window = Gtk::Window.new.show Gtk.main
RapidQ
create form as qform center width=500 height=400 end create form.showModal
VB.NET
Using .Net Framework:
Dim newForm as new Form newForm.Text = "It's a new windows" newForm.Show()
Java
Using Swing
import javax.swing.JFrame; import javax.swing.WindowConstants; public class SimpleWindow { public static void main(String[] args) { JFrame window = new JFrame("This is a title!"); window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); window.setSize(800, 600); window.setVisible(true); } }
JavaScript
Easy
window.open(null, null, "width=800,height=600");