Skip to Main Content
Python GUI Programming Cookbook
book

Python GUI Programming Cookbook

by Burkhard Meier
December 2015
Beginner to intermediate content levelBeginner to intermediate
350 pages
6h 49m
English
Packt Publishing
Content preview from Python GUI Programming Cookbook

Avoiding spaghetti code

In this recipe, we will explore a typical way to create spaghetti code and then we will see a much better way of how to avoid such code.

Note

Spaghetti code is code in which a lot of functionality is intertangled.

Getting ready

We will create a new, simple GUI written in Python using the tkinter built-in Python library.

How to do it...

Having searched online and read the documentation, we might start by writing the following code to create our GUI:

# Spaghetti Code ############################# def PRINTME(me):print(me) import tkinter x=y=z=1 PRINTME(z) from tkinter import * scrolW=30;scrolH=6 win=tkinter.Tk() if x:chVarUn=tkinter.IntVar() from tkinter import ttk WE='WE' import tkinter.scrolledtext outputFrame=tkinter.ttk.LabelFrame(win,text=' ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming - A Complete Reference Guide

Python GUI Programming - A Complete Reference Guide

Alan D. Moore, B. M. Harwani
Python Network Programming Cookbook - Second Edition

Python Network Programming Cookbook - Second Edition

Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker

Publisher Resources

ISBN: 9781785283758Supplemental Content