Sunteți pe pagina 1din 11

INDEX

1. INTRODUCTION

2. OBJECT-ORIENTED PROGRAMMING

3. PYTHON

4. HISTORY

5. TKINTER

6. SOURCE CODE

7. OUTPUT

8. REFERENCE
INTRODUCTION

Object-oriented
programming
Object-oriented programming (OOP) is a programming paradigm based
on the concept of "objects", which may contain data, in the form of fields,
often known as attributes; and code, in the form of procedures, often known
as methods. A feature of objects is that an object's procedures can access
and often modify the data fields of the object with which they are
associated (objects have a notion of "this" or "self"). In OOP, computer
programs are designed by making them out of objects that interact with one
another. There is significant diversity of OOP languages, but the most
popular ones are class-based, meaning that objects
are instances of classes, which typically also determine their type.
Many of the most widely used programming languages (such as C++,
Object Pascal, Java, Python etc.) are multi-paradigm programming
languages that support object-oriented programming to a greater or lesser
degree, typically in combination with imperative, procedural programming.
Significant object-oriented languages include Java, C+
+, C#,Python, PHP, JavaScript, Ruby, Perl, Object Pascal, Objective-
C, Dart, Swift, Scala, Common Lisp, and Smalltalk.
Python
Python is an interpreted, high-level, general-purpose programming
language. Created by Guido van Rossum and first released in 1991,
Python has a design philosophy that emphasizes code readability, notably
using significant whitespace. It provides constructs that enable clear
programming on both small and large scales. In July 2018, Van Rossum
stepped down as the leader in the language community.
Python features a dynamic type system and automatic memory
management. It supports multiple programming paradigms,
including object-oriented, imperative, functional and procedural, and has a
large and comprehensive standard library.
Python interpreters are available for many operating systems. CPython,
the reference implementation of Python, is open source software and has a
community-based development model, as do nearly all of Python's other
implementations. Python and CPython are managed by the non-
profit Python Software Foundation.
HISTORY
Python was conceived in the late 1980 by Guido van Rossum at Centrum
Wiskunde & Informatica (CWI) in the Netherlands as a successor to
the ABC language (itself inspired by SETL), capable of exception
handling and interfacing with the Amoeba operating system. Its
implementation began in December 1989. Van Rossum's long influence on
Python is reflected in the title given to him by the Python
community: Benevolent Dictator For Life (BDFL) – a post from which he
gave himself permanent vacation on July 12, 2018.
Python 2.0 was released on 16 October 2000 with many major new
features, including a cycle-detecting garbage collector and support
for Unicode.
Python 3.0 was released on 3 December 2008. It was a major revision of
the language that is not completely backward-compatible. Many of its major
features were backported to Python 2.6.x and 2.7.x version series.
Releases of Python 3 include the 2to3 utility, which automates (at least
partially) the translation of Python 2 code to Python 3.
Python 2.7's end-of-life date was initially set at 2015 then postponed to
2020 out of concern that a large body of existing code could not easily be
forward-ported to Python 3. In January 2017, Google announced work on a
Python 2.7 to Go transcompiler to improve performance under concurrent
workloads.
Tkinter
Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python
interface to the Tk GUI toolkit,and is Python's de
facto standard GUI. Tkinter is included with standard Linux, Microsoft
Windows and Mac OS X installs of Python.

Description
As with most other modern Tk bindings, Tkinter is implemented as a Python
wrapper around a complete Tclinterpreter embedded in the Python
interpreter. Tkinter calls are translated into Tcl commands which are fed to
this embedded interpreter, thus making it possible to mix Python and Tcl in
a single application.
Python 2.7 and Python 3.1 incorporate the "themed Tk" ("ttk") functionality
of Tk 8.5. This allows Tk widgets to be easily themed to look like the native
desktop environment in which the application is running, thereby
addressing a long-standing criticism of Tk (and hence of Tkinter).
There are several popular GUI library alternatives available, such
as wxPython, PyQt (PySide), Pygame, Pyglet, and PyGTK.
Some definition
Window

This term has different meanings in different contexts, but in general it


refers to a rectangular area somewhere on the user's display screen.

Top Level Window


A window that exists independently on the screen. It will be decorated with
the standard frame and controls for the desktop manager. It can be moved
around the desktop, and can usually be resized.
Widget

The generic term for any of the building blocks that make up an application
in a graphical user interface.

 Core widgets: The containers:frame, toplevel, paned window. The


buttons: button, radiobutton, checkbutton (checkbox), menubutton
(combobox). The text widgets: label, labelframe, message, text. The
entry widgets: scale, scroll, listbox, slider, spinbox, entry (singleline), text
(multiline), and canvas (vector and pixel graphics).

 There are the extension widgets:tk_optionMenu, tk_dialog,


tk_messageBox, tk_getOpenFile, tk_getSaveFile, tk_chooseColor,
tk_chooseDirectory.

 The ttk widgets: The ttk widgets coexist with other widgets which they
can replace. There are ttk::button, ttk::checkbutton, ttk::combobox,
ttk::entry, ttk::frame, ttk::label, ttk::labelframe, ttk::menubutton,
ttk::notebook, ttk::panedwindow, ttk::progressbar, ttk::radiobutton,
ttk::scale, ttk::scrollbar, ttk::separator, ttk::sizegrip, ttk::spinbox,
ttk::treeview.

Frame

In Tkinter, the Frame widget is the basic unit of organization for complex
layouts. A frame is a rectangular area that can contain other widgets.
Source Code
#calculator

from tkinter import*

def iCalc(source, side):

storeObj = Frame(source, borderwidth = 1, bd= 4, bg="powder blue")

storeObj.pack(side=side, expand=YES, fill=BOTH)

return storeObj

def button (source, side, text, command = None):

storeObj = Button(source, text=text, command=command)


storeObj.pack(side=side, expand=YES, fill=BOTH)

return storeObj

class app(Frame):

def __init__(self):

Frame.__init__(self)

self.option_add('*Font', 'arial 20 bold')

self.pack(expand=YES, fill=BOTH)

self.master.title("Calculator")

display = StringVar()

Entry(self, relief=GROOVE,

textvariable=display,justify='right',bd=30,bg="powder
blue").pack(side=TOP, expand=YES,fill=BOTH)

for clearBut in (["CE"],["C"]):

erase = iCalc(self, TOP)

for ichar in clearBut:

button(erase, LEFT, ichar,

lambda storeObj=display, q=ichar: storeObj.set(''))

for NumBut in ("789/", "456*", "123-", "0,+"):

FunctionNum = iCalc(self, TOP)


for char in NumBut:

button(FunctionNum, LEFT, char,

lambda storeObj=display, q=char: storeObj.set(storeObj.get()


+ q))

EqualsButton = iCalc(self, TOP)

for iEquals in '=':

if iEquals == '=':

btniEquals = button(EqualsButton, LEFT, iEquals)

btniEquals.bind('<ButtonRelease-1>',

lambda e, s=self, storeObj=display: s.calc(storeObj), '+')

else:

btniEquals = button(EqualsButton, LEFT, iEquals,

lambda storeObj=display, s=' &s '%iEquals:


storeObj.set(storeObj.get()+s))

if __name__== '__main__':

app().mainloop()
OUTPUT

S-ar putea să vă placă și