Quantcast
Channel: Analytics India Magazine
Viewing all articles
Browse latest Browse all 21301

7 Most Popular Python Libraries And Toolkits For Desktop GUI Applications

$
0
0

The real achievement of any programming knowledge is to be able to develop an efficient graphical user interface. Python is one of the favourite picks for the programmers to carry this out. As Python is a general-purpose programming language with a lot of libraries and tools, it can be tricky to choose the best ones for GUI applications.

In this article, we recommend top libraries and toolkits. (The list is in no particular order.)

1| Camelot (Library)

Camelot, a Python command line tool library has made it easy for the analysts to draw out data tables from PDF files, which usually do not have a defined representation of a table format, making it tough to produce analytical tables. The Camelot provides a medium to send and receive documents through various machine configuration, operating systems, and network communications.

 

Key Features

  • Gives absolute control over table extraction by allowing to adjust its settings
  • Poor performing tables can be dropdown, depending upon their accuracy
  • Pandas data frame for table design
  • Various table formats like CSV, Json, Excel, and HTML can be exported to Camelot.

 

Sample Code

>>>import Camelot

>>>tables=Camelot.read_PDF(‘xyz.pdf’)

>>>tables

<Table LIst n=1>

>>>tables.export(‘xyz.csv’,f=’csv’,compress=true)

Tables[0]

<table shape=(6,6)>

>>>tables[0].parsing_report

{

‘Accuracy’:99.06,

‘Whitespace’:12.12,

‘Order’:1,

‘Page’:1

}

2| Kivy (Library)

Being an MIT-licensed open source library of Python, Kivy is used for designing mobile apps and multi-touch application software, which includes natural user interface. Kivy is specified for describing user interface and interactions.

 

Key Features

  • Comprehensive input support for mouse, keyboard, TUIO and OS-specific multimedia touch events.
  • It uses only Open GLES2, which is based on vertex Buffer object and shaders.
  • An abundant availability of widgets
  • Can be used to design custom widgets

 

Sample Code

from Kivy.app import App

from Kivy.Uix.button import Button

   class test App(App):

         def build(self):

             return Button(text=’welcome to python’)

Test App().run()

 

3| PyGTK (Graphics interface Tool Kit)

PyGTK is a free software licensed by the LGPL. It is a multi-platform toolkit which can be used to create graphical interfaces that offer a complete set of widgets suitable for projects ranging from one tool oriented to complete application collection.

 

Key Features

  • It has important sub-libraries like:
    • Glib: A low-level fundamental library which forms the building blocks of GTK to provide Data Structure handling for C
    • Pango: A layout for the rendering of text, which concentrates on classification
    • Cairo: A 2D graphics library which supports various output devices
    • ATK: A library with a set of interfaces which provides access to tools such as screen readers, magnifiers etc.

 

Sample Code

import gtk


def create_window():
   window = gtk.Window()
   window.set_default_size(400, 300)
   window.connect(‘destroy’, gtk.main_quit)

   label = gtk.Label(‘say hi to graphics’)
   window.add(label)

   label.show()
   window.show()

create_window()
gtk.main()

4| Pyjamas And Pyjamas-Desktop (Toolkit)

Pyjamas is a part of Google web toolkit which enables the development of advanced media Ajax applications using Python with no requirement of a special browser plugin. Additionally, Pyjamas also has a desktop widget set which runs as pure Python, with three available ports. This prototype makes use of web browser technology which effectively provides a secondary widget sets, such as PyQT4 and Py GTK2 and gives an advantage of providing full support for HTML, CSS, plugins and other web related functions. The Pyjamas-Desktop, which is an extended version of Pyjamas, requires additional library JSON to the already installed one.

Key Features

  • Well-developed local and remote CSS stylesheet functionality by using API manipulation
  • Provides an option of Javascript execution for complete application manipulation
  • Complete URL support for local and remote loading of HTML pages
  • Availability of plugins for multimedia
  • Complete access to XML, XSLT, AJAX

Sample Code

class VerticalDemoSlider:

 def init(auto, min_value, max_value, start_value=None):

   element = DOM.createDiv()
   FocusWidget.init(auto, element)

   auto.min_value = min_value
   auto.max_value = max_value
   if start_value is None:
     start_value = min_value
   auto.value = start_value
   auto.valuechange_listeners = []

5| Toga (Toolkit)

Joining the toolkit club of Python recently, Toga is still in its budding stage. It is a native Python OS cross-platform for GUI toolkit which consists of basic components with a shared interface.

Key Features

The biggest issue that a widget toolkit faces is to put widgets on the screen in the right manner. Various widgets toolkits follow different approaches, constraints, packing techniques, and grid-based prototypes to overcome this problem. Toga’s pack style engines are inspired by an HTML approach that is very novel for the widget toolkits but proven to be effective: cascading style Sheets (CSS)

Sample Code

import toga

def button_handler(widget):

    print(“Hi”)

def build(app)

     box_1=toga.Box()

     button=toga.Button(‘Hi’,on-press=button_handler)

     button.style.padding=60

     button.style.flex=1

     box.add(button)

     Return box_1

def main():

     return toga.App(‘opening App’,’Hi’,startup=build)

    if name==’main

    main().main_loop()

6| Tkinter (Toolkit)

Tkinter is a binding Python GUI toolkit. It is the most modern technology which is implemented to completely envelop Python and Tcl into an embedded interpreter. Tkinter calls are converted into Tcl commands which are used for the embedded interpreter, which blends Python and Tcl into a single application. The Tkinter toolkit can run on various platforms like Linux, Microsoft Windows, and Mac OS X.

Sample Code

import tkinter as tk
class Testing(tk.Frame):
 def init(auto, master=None):
       super(Testing, auto).init(master)
       auto.grid()  
       auto.createWidgets()
  def createWidgets(self):
       auto.mondialLabel = tk.Label(self, text=’welcome to TK’)
       auto.mondialLabel.config(bg=”****####”)
       auto.mondialLabel.grid()
       auto.quitButton = tk.Button(self, text=’Quit’, command=self.quit)
       auto.quitButton.grid()
app =Testing()
app.master.title(‘Testing Application’)
app.mainloop()

7| wxPython

wxPython is a binder for the cross-platform GUI toolkits and wxWidgets. The toolkit was initially written in C++ and was later implemented in the Python.

Key Features

wxPython is a complex code to maintain and does not synchronize with wxWidgets versions. This issue was addressed by launching a project called Phoenix which was launched in the year 2010. An effort was made to clean up the wxPython applications and its functionalities and made it compatible with Python. The project focused on accelerating speed, durability, and maintenance of the wxPython toolkit.

Well, known applications which used wxPython are BitTorrent, Chandler, Editra,
Google Drive, GRASS GIS, Métamorphose, Phatch, PlayOnLinux and PlayOnMac.

Sample code

import wx
app = wx.App(False)  
frame = wx.Frame(None, wx.ID_ANY, “welcome to Python”)
frame.Show(True)     
app.MainLoop()

The post 7 Most Popular Python Libraries And Toolkits For Desktop GUI Applications appeared first on Analytics India Magazine.


Viewing all articles
Browse latest Browse all 21301

Trending Articles