Skip to main content

easy_gui

easy_gui is a high-level Python library designed to simplify the process of creating GUI applications by wrapping tkinter. Solving problems is tricky enough... using our solutions should be EASY!

Features

  • Quickly and easily build a GUI by subclassing easy_gui.EasyGUI
  • Add easy_gui Widget objects (check out widgets.py for details on each):
    • Button, CanvasButton, Label, Entry, LabelEntry, CheckBox, DropDown, ListBox, Table, Tree, Slider, MatplotlibPlot, Canvas, ProgressBar, ScrolledText, StdOutBox, DatePicker
  • Create one or more Sections (including nested Sections) to help organize GUI elements
  • CSS Grid-style layouts
  • Simply create a popup window using EasyGUI.popup()
  • Simply create popup tooltips for widgets using Widget.add_tooltip()
  • Multithreading for GUI responsiveness (set "separate_thread=True" when creating a Button Widget)
  • Easy to install with few dependancies - just matplotlib (but you want to make plots anyway, right?!)

Quickstart

  • Installing easy_gui is easy enough. Simply use pip:
pip install easy_gui
  • To create an application with easy_gui, subclass the easy_gui.EasyGUI class and add elements in the init method.

  • Here is the most simple example:

import easy_gui

class GUI(easy_gui.EasyGUI):
    def __init__(self):
        self.add_widget(type='label', text='Example Label')
        self.add_widget(type='button', text='Button', command_func=lambda x: print('TEST'))

application = GUI()
  • Now for a more substantial example that also shows CSS-style layout capabilities. See the script examples/simple_gui.py for this code with additional explanatory comments:
import easy_gui

class GUI(easy_gui.EasyGUI):
    def __init__(self):
        self.title('Animal Diet Generator')
        self.geometry("425x170")

        section = self.add_section('example_section')
        section.configure_grid(['title             title         output',
                                'label1            entry1        output',
                                'label2            entry2        output',
                                'run_button      run_button      output'])
        section.add_widget(type='label', text='Animal Diet Generator!', grid_area='title')
        section.add_widget(type='label', text='Animal:', grid_area='label1')
        self.animal = section.add_widget(type='entry', grid_area='entry1')
        section.add_widget(type='label', text='Food:', grid_area='label2')
        self.food = section.add_widget(type='entry', grid_area='entry2')
        section.add_widget(type='stdout', grid_area='output')
        section.add_widget(type='button', text='Generate Diet!', grid_area='run_button', command_func=self.diet)

    def diet(self, event):
        print(f'The {self.animal.get()} likes to eat {self.food.get()}!')

application = GUI()

More Firepower

The toy examples above show the basics for getting started. Below is a more robust example for what a simple tool could look like. This example highlights a number of powerful features such as:

  • CSS-style grid layouts (literally make a picture of what you want to see with a list of strings)
  • Flexible, high-level Widgets that are quick to add or manipulate
  • Quick and easy popup window using with self.popup() as popup:
import easy_gui
import random
from matplotlib.figure import Figure


class GUI(easy_gui.EasyGUI):
  def __init__(self):
      self.title('Data Generator')
      self.geometry("800x550")

      self.configure_grid(['check   data_gen   info',
                                 'tree       tree        data',
                                 'tree       tree        plot'])

      self.parabolic = self.add_widget('checkbox', 'Parabolic Data', grid_area='check')
      self.add_widget('btn', 'Generate New Data', grid_area='data_gen', use_ttk=True, command_func=self.generate_data)
      self.add_key_trigger('new', self.generate_data)
      print('Also can generate new data by simply typing "new"!')

      info = self.add_section(grid_area='info')
      info.configure_grid([' .        title     . ',
                                 'mean   min  max'])
      info.add_widget('lbl', 'Data Information', underline=True, bold=True, grid_area='title')
      self.mean = info.add_widget('lbl', 'Mean:', grid_area='mean')
      self.min = info.add_widget('lbl', 'Minimum:', grid_area='min')
      self.max = info.add_widget('lbl', 'Maximum:', grid_area='max')

      self.tree = self.add_widget('tree', grid_area='tree', height=10)
      self.tree.bind_select(self.refresh_display)

      self.table = self.add_widget('table', rows=2, columns=11, border=True, grid_area='data')
      self.table[1, 1] = 'X Values'
      self.table[2, 1] = 'Y Values'

      self.plot = self.add_widget('matplotlib', grid_area='plot')

      self.add_menu(commands={}, cascades={'Data': {'Save Data to CSV': self.save_data}})

      self.data_sets = []  # store all generated datasets in this list
      self.generate_data()  # start with one initial dataset


  def current_data(self):
      name, x_vals, y_vals = [tup for tup in self.data_sets if tup[0] == self.tree.current_row['text']][0]
      return name, x_vals, y_vals

  def refresh_tree(self, *args):
      self.tree.clear()
      for name, x_vals, y_vals in self.data_sets:
          self.tree.insert_row(name)
      self.tree.select_first_row()
      self.refresh_display()

  def refresh_display(self, *args):
      name, x_vals, y_vals = self.current_data()

      # Update summary info at top
      self.mean.set(f'Mean: {round(sum(y_vals) / len(y_vals), 1)}')
      self.min.set(f'Minimum: {min(y_vals)}')
      self.max.set(f'Maximum: {max(y_vals)}')

      # Update table with current data
      for index, (x, y) in enumerate(zip(x_vals, y_vals)):
          self.table[1, index+2] = x
          self.table[2, index+2] = y

      # Update the plot
      fig = Figure(figsize=(5, 3), dpi=100)
      ax = fig.add_subplot(111)
      ax.set_title('Plot of X and Y Values')
      ax.scatter(x_vals, y_vals)
      self.plot.draw_plot(mpl_figure=fig)

  def generate_data(self, *args):
      x_vals = list(range(1, 11))
      if not self.parabolic.get():
          y_vals = [round(x + random.random() * 2, 1) for x in x_vals]
      else:
          y_vals = [round((x - 5 + random.random()) ** 2, 1) for x in x_vals]
      self.data_sets.append((f'Dataset {len(self.data_sets)+1}' + (' (Parabolic)' if self.parabolic.get() else ''), x_vals, y_vals))
      self.refresh_tree()

      with self.popup() as popup:
          popup.geometry('200x80')
          popup.add_widget('lbl', 'New data generated!', bold=True)

  def save_data(self, *args):
      with open('Moderate GUI Data.csv', 'w') as f:
          f.write('Dataset,X_Values,Y_Values\n')
          for name, x_vals, y_vals in self.data_sets:
              for x, y in zip(x_vals, y_vals):
                  f.write(f'{name},{x},{y}\n')
      print('Data saved to CSV file!')



if __name__ == '__main__':
  GUI()

License

MIT

Release files for easy-gui 0.4.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-gui 0.4.10
File Size Uploaded
easy_gui-0.4.10.tar.gz 25.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-gui 0.4.10
File Interpreter ABI Platform
easy_gui-0.4.10-py3-none-any.whl Python 3 none any Details

Total release size:50.1 kB

Release files / easy_gui-0.4.10.tar.gz

Download URL easy_gui-0.4.10.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f49d82d6e1ceb9350abfa87a58c83cd808525eca9d7bc7b22661ee0ba6d7bf73
BLAKE2b-256 checksum
How to use checksums
2cfd77097fbcaa91b861e2edc9172175d52aa12bca5191559a213727ad8a03f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / easy_gui-0.4.10-py3-none-any.whl

Download URL easy_gui-0.4.10-py3-none-any.whl
Size 24.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fd449ddf3dda8a87fa1c6fcc68ac22fa11387499f125faa406050797b977f0a
BLAKE2b-256 checksum
How to use checksums
5e0d68c33cf814dbe202bcff6b5cb5db5048e6340df844dad90e1cda888f0245
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.4.10 This release

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page