Anda di halaman 1dari 4

Notesengine.

com

EX.NO: GUI (Graphical User Interface)
DATE:
a. GUI with Python program
1. Start
2. mkdir ex10gui
3. cd ex10gui
4. Type guiwindow1.py and guiwindow2.py programs and save the files
5. Type guiwindow1.py and guiwindow2.py to see the results
6. End of Algorithm

b. GUI with PERL Program
1. Start
2. Type guiwindow3.pl and save the program
3. Type guiwindow3.pl to see the results
4. End of Algorithm
Introduction
1. In GUI programming, a top-level root windowing object contains all of the little
windowing objects that will be part of your complete GUI application.
2. These can be text Labels, Buttons, List Boxes, etc.
3. These Individual GUI components are known as Widgets.
4. A Widget (or control) is an element of a graphical user interface (GUI) that displays an
information arrangement changeable by the user, such as window or a text box.
5. The Tkinter module (Tk interface) is the standard Python interface to the Tk GUI
toolkit from Script tics (formely developed by Sum Labs).
6. Bothe Tk and Tkinter are available on most Unix platforms, as well as on Windows and
Macintosh systems. Starting with the 8.0 release, Tk offers native look and feel on all
platforms.
7. Keeping python window on top of others.
8. Tkinter.mainloop() main loop is the heart of our programs, the repeating chunk of
code that carries out the task at hand. But Perl/Tk programs are event driven, so even if
we write we believe is our programs main loop, it must coexist with a higher order main
loop thats a fundamental part of Tk.
9. The Tk main loop is typically referred to as event loop, and its job is to invoke callbacks
in response to events such as button presses or timer expirations. Callbacks are Perl
subroutines associated with Tk events.In Perl/T.
Notesengine.com


8.a. GUI with Python program for printing Welcome Message
guiwindow1.py
#/ usr/bin/env python
import Tkinter
top =Tkinter.Tk()
label=Tkinter.Label(top, text=Hello world)
label.pack()
Tkinter.mainloop()

OUTPUT:







8.b. GUI with Python Program to print Window and Command Button
#!/usr/bin/env python
import Tkinter
top=Tkinter.Label(top,text=Hello world)
hello.pack()
quit = Tkinter.Button(top,text=QUIT,command=top.quit,bg=red,fg=white)
Notesengine.com

quit .pack(fill=Tkinter.X,expands=1)
Tkinter.mainloop()

OUTPUT:




8.c. GUI with PERL Program for creating Window.

Cgiwindow3.pl
#!/usr/local/bin/perl
use tk;
#Main Window
my $mw =new MainWindow;
my $but = $mw -=Button(-text ==Push Me, -command = =\&push_button);
$but==pack();
MainLoop;
#This is executed when the button is pressed.
sub push_button{
whatever
}

OUTPUT
Notesengine.com




Execution Steps:
1. Python guiwindow1.py
2. Python guiwindow2.py
3. Python guiwindow3.py










RESULT:
Thus the Python and Perl programs to illustrate GUI concepts are executed and the output
is verified.

Anda mungkin juga menyukai