banner



How To Create A Window In Python

Python - GUI Programming (Tkinter)


Python provides various options for developing graphical user interfaces (GUIs). Virtually of import are listed below.

  • Tkinter − Tkinter is the Python interface to the Tk GUI toolkit shipped with Python. We would wait this pick in this affiliate.

  • wxPython − This is an open-source Python interface for wxWindows http://wxpython.org.

  • JPython − JPython is a Python port for Coffee which gives Python scripts seamless admission to Java form libraries on the local automobile http://world wide web.jython.org.

There are many other interfaces available, which yous can find them on the net.

Tkinter Programming

Tkinter is the standard GUI library for Python. Python when combined with Tkinter provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.

Creating a GUI application using Tkinter is an like shooting fish in a barrel job. All y'all demand to practice is perform the following steps −

  • Import the Tkinter module.

  • Create the GUI awarding main window.

  • Add ane or more of the higher up-mentioned widgets to the GUI application.

  • Enter the chief outcome loop to have activeness confronting each effect triggered by the user.

Example

#!/usr/bin/python  import Tkinter top = Tkinter.Tk() # Code to add together widgets will go here... elevation.mainloop()        

This would create a following window −

TK Window

Tkinter Widgets

Tkinter provides various controls, such as buttons, labels and text boxes used in a GUI application. These controls are normally called widgets.

In that location are currently xv types of widgets in Tkinter. We present these widgets as well equally a brief description in the following table −

Sr.No. Operator & Clarification
1 Button

The Push button widget is used to display buttons in your application.

two Canvas

The Canvas widget is used to describe shapes, such as lines, ovals, polygons and rectangles, in your awarding.

3 Checkbutton

The Checkbutton widget is used to display a number of options as checkboxes. The user can select multiple options at a time.

four Entry

The Entry widget is used to display a unmarried-line text field for accepting values from a user.

5 Frame

The Frame widget is used equally a container widget to organize other widgets.

6 Label

The Characterization widget is used to provide a single-line explanation for other widgets. It can as well comprise images.

7 Listbox

The Listbox widget is used to provide a list of options to a user.

8 Menubutton

The Menubutton widget is used to brandish menus in your awarding.

9 Card

The Menu widget is used to provide various commands to a user. These commands are independent inside Menubutton.

10 Bulletin

The Message widget is used to display multiline text fields for accepting values from a user.

11 Radiobutton

The Radiobutton widget is used to display a number of options every bit radio buttons. The user can select merely one choice at a time.

12 Calibration

The Scale widget is used to provide a slider widget.

13 Scrollbar

The Scrollbar widget is used to add together scrolling adequacy to various widgets, such as listing boxes.

fourteen Text

The Text widget is used to brandish text in multiple lines.

15 Toplevel

The Toplevel widget is used to provide a separate window container.

sixteen Spinbox

The Spinbox widget is a variant of the standard Tkinter Entry widget, which can be used to select from a fixed number of values.

17 PanedWindow

A PanedWindow is a container widget that may contain whatsoever number of panes, bundled horizontally or vertically.

eighteen LabelFrame

A labelframe is a simple container widget. Its primary purpose is to act equally a spacer or container for complex window layouts.

19 tkMessageBox

This module is used to display bulletin boxes in your applications.

Let u.s. study these widgets in detail −

Standard attributes

Let us take a look at how some of their common attributes.such every bit sizes, colors and fonts are specified.

  • Dimensions

  • Colors

  • Fonts

  • Anchors

  • Relief styles

  • Bitmaps

  • Cursors

Let us study them briefly −

Geometry Management

All Tkinter widgets have access to specific geometry management methods, which have the purpose of organizing widgets throughout the parent widget surface area. Tkinter exposes the following geometry manager classes: pack, grid, and place.

  • The pack() Method − This geometry managing director organizes widgets in blocks before placing them in the parent widget.

  • The filigree() Method − This geometry director organizes widgets in a tabular array-like structure in the parent widget.

  • The place() Method − This geometry managing director organizes widgets by placing them in a specific position in the parent widget.

Permit us study the geometry management methods briefly −

Useful Video Courses


Python Online Training

Video

Python Essentials Online Training

Video

Learn Python Programming in 100 Easy Steps

Video

Python with Data Science

Video

Python 3 from scratch to become a developer in demand

Video

Python Data Science basics with Numpy, Pandas and Matplotlib

Video

How To Create A Window In Python,

Source: https://www.tutorialspoint.com/python/python_gui_programming.htm

Posted by: battintanderies.blogspot.com

0 Response to "How To Create A Window In Python"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel