Tkinter GUI Programming by Example

Total Page:16

File Type:pdf, Size:1020Kb

Tkinter GUI Programming by Example Tkinter GUI Programming by Example Learn to create modern GUIs using Tkinter by building real-world projects in Python David Love BIRMINGHAM - MUMBAI Tkinter GUI Programming by Example Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Aaron Lazar Acquisition Editor: Denim Pinto Content Development Editor: Anugraha Arunagiri Technical Editor: Subhalaxmi Nadar Copy Editor: Safis Editing Project Coordinator: Ulhas Kambali Proofreader: Safis Editing Indexer: Aishwarya Gangawane Graphics: Tania Dutta Production Coordinator: Arvindkumar Gupta First published: April 2018 Production reference: 1240418 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78862-748-1 www.packtpub.com mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Contributors About the author David Love is a web developer from Kent, England. He has worked on a multitude of different systems over his career. Programming languages in his arsenal include Python, PHP, and JavaScript. He is well-trained in Linux server management and its relevant technologies, including MySQL, PostgreSQL, NGINX, and supervisor. David has written an e-book called Tkinter By Example, which is available for free under a Creative Commons licenses and maintains an ever-growing blog post named The Tkinter Cookbook, full of small examples on how to perform some specific tasks. About the reviewer Erik S. Rapert is a programmer and a twin who loves Linux and video games. He lives in Dallas with his wife, who is also a software engineer. Erik has a wide range of experience, which includes creating blinking LEDs using Arduino, building small desktop apps using Python and Tkinter, web development with PHP or Ruby, and developing cutting-edge virtual reality using C++. He has used a very broad range of programming languages, but Python is one of his favorites. Thank you William C. Slater for teaching me how to write software. Thank you Andrew Closson for being a teacher. Thank you Ashley N. Tharp for being you. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface 1 Chapter 1: Meet Tkinter 6 Installation 7 How will the code be structured? 7 Geometry managers 8 pack 8 grid 9 place 10 To pack or to grid? 11 Getting going 12 Adding interactivity 14 Using variables 16 Our first try 16 Creating Tkinter-compatible variables 17 Using and updating 18 Fixing our application 18 Showing messages 19 Showing information with showinfo 19 Showing warnings or errors 20 Getting feedback from the user 21 Getting text input 22 Summary 24 Chapter 2: Back to the Command Line – Basic Blackjack 25 Python's class system 26 Instances 26 Inheritance 28 Blackjack's classes 30 The Card class 30 The Deck class 31 The Hand class 32 The Game class and main loop 33 Command line versus GUI 38 Interactivity 38 Familiarity 39 Ease of use 39 Size and portability 40 Summary 40 Table of Contents Chapter 3: Jack is Back in Style – the Blackjack GUI 41 Moving from the command line to a graphical interface 41 The Canvas widget 43 Creating a graphical blackjack game 46 Card, Deck, and Hand 48 The GameState class 49 The GameScreen class 53 Playing our game 62 Summary 64 Chapter 4: The Finishing Touches – Sound and Animation 65 Python's module system 66 The blackjack packages 71 The casino package 71 The casino_sounds package 74 Setting up a virtual environment 75 Creating the package 76 The blackjack.py file 77 Initializing the GameWindow class 78 The GameScreen class 80 The GameState class 90 Choosing to hit 91 Choosing to stick 95 Running out of money 96 Finishing off 97 Summary 98 Chapter 5: Creating a Highly Customizable Python Editor 99 The ttk submodule 100 Styling a tk widget 101 Styling a ttk widget 103 Ttk style inheritance 105 Beginning our text editor 109 Tkinter's event system 112 Binding an event 112 Overwriting default events 115 Generating events 116 Events in our text editor 118 A second top-level window 123 Summary 125 Chapter 6: Color Me Impressed! – Adding Syntax Highlighting 127 Tkinter's indexing system 127 Getting the cursor's position 128 Named indexes 130 [ ii ] Table of Contents Special strings 130 Line endings 130 Horizontal movement 130 Vertical movement 131 Line beginning and end 131 Word beginning and end 131 Expanding our demo 132 Using tags 134 Searching text 137 Adding syntax highlighting to our text editor 140 The Highlighter class 140 Using our Highlighter class 150 The LineNumbers class 151 Using our LineNumbers class 153 Integrating our FindWindow class 153 Using our FindWindow class 158 Summary 159 Chapter 7: Not Just for Restaurants – All About Menus 160 The Menu widget 160 A menu bar 161 A floating menu 164 Adding a menu bar to our text editor 165 Adding a context menu to our text editor 170 Handling files 172 Changing the syntax highlighting 177 Changing the editor's font 180 The Listbox widget 181 The Spinbox widget 183 Saving the user's choices 183 Changing the editor's color scheme 186 Summary 198 Chapter 8: Talk Python to Me – a Chat Application 200 Creating a scrollable frame 200 Creating our FriendsList class 206 Creating our ChatWindow class 210 Creating our SmilieSelect class 218 Summary 226 Chapter 9: Connecting – Getting Our Chat Client Online 227 Introduction to flask 227 Our first web page 228 Using JSON 230 The requests module 232 [ iii ] Table of Contents Sending a GET request 232 Sending a POST request 233 The sqlite3 module 235 Creating a database and table 235 Adding data to a SQLite database 236 Selecting data from a SQLite database 238 Linking flask and sqlite 239 Updating our FriendsList class 243 Creating the Requester class 246 Connecting our FriendsList to our web service 248 Connecting our ChatWindow 251 Updating our server to store conversations 252 Creating the Conversation class 252 Using the Conversation class in our server 254 Adding the new endpoints to our Requester 257 Updating our ChatWindow class to send requests to the server 258 Summary 260 Chapter 10: Making Friends – Finishing Our Chat Application 262 Using threads 262 Why use a thread with a GUI application? 263 Using a thread 265 Adding a Thread to our ChatWindow 266 Creating new endpoints 266 The ListeningThread class 268 Implementing the ListeningThread class in our ChatWindow 270 Allowing users to upload avatars 272 The AvatarWindow class 273 Adjusting the database 275 Adding server endpoints 276 Updating the FriendsList class 277 Manipulating images with PIL 278 Adding and blocking other users 280 New database table 280 Creating the server endpoints 282 Tying it all together 285 Summary 289 Chapter 11: Wrapping Up – Packaging Our Applications to Share 291 Unexplored widgets 291 The LabelFrame widget 292 The Checkbutton and Radiobutton widgets 293 The OptionMenu and Combobox widgets 295 The Notebook widget 296 Packaging applications 298 [ iv ] Table of Contents Adjusting our text editor for portability 298 Preparing to package with setup.py 302 Installing our text editor 303 Cross-platform using Pip 304 Windows 304 Linux 306 macOS 308 Summary 310 Other Books You May Enjoy 312 Index 315 [ v ] Preface Welcome to Tkinter GUI Programming by Example. We will be exploring how to use the Tkinter library, which is included alongside most Python installs. This framework is very simple to use, and has a powerful event-handling system and an open license, perfect for anyone who wishes to quickly write and share graphical applications.
Recommended publications
  • Gui Programming Using Tkinter
    1 GUI PROGRAMMING USING TKINTER Cuauhtémoc Carbajal ITESM CEM April 17, 2013 2 Agenda • Introduction • Tkinter and Python Programming • Tkinter Examples 3 INTRODUCTION 4 Introduction • In this lecture, we will give you a brief introduction to the subject of graphical user interface (GUI) programming. • We cannot show you everything about GUI application development in just one lecture, but we will give you a very solid introduction to it. • The primary GUI toolkit we will be using is Tk, Python’s default GUI. We’ll access Tk from its Python interface called Tkinter (short for “Tk interface”). • Tk is not the latest and greatest, nor does it have the most robust set of GUI building blocks, but it is fairly simple to use, and with it, you can build GUIs that run on most platforms. • Once you have completed this lecture, you will have the skills to build more complex applications and/or move to a more advanced toolkit. Python has bindings or adapters to most of the current major toolkits, including commercial systems. 5 What Are Tcl, Tk, and Tkinter? • Tkinter is Python’s default GUI library. It is based on the Tk toolkit, originally designed for the Tool Command Language (Tcl). Due to Tk’s popularity, it has been ported to a variety of other scripting languages, including Perl (Perl/Tk), Ruby (Ruby/Tk), and Python (Tkinter). • The combination of Tk’s GUI development portability and flexibility along with the simplicity of a scripting language integrated with the power of systems language gives you the tools to rapidly design and implement a wide variety of commercial-quality GUI applications.
    [Show full text]
  • Abstract Window Toolkit Overview
    In this chapter: • Components • Peers 1 • Layouts • Containers • And the Rest • Summary Abstract Window Toolkit Overview For years, programmers have had to go through the hassles of porting software from BSD-based UNIX to System V Release 4–based UNIX, from OpenWindows to Motif, from PC to UNIX to Macintosh (or some combination thereof), and between various other alternatives, too numerous to mention. Getting an applica- tion to work was only part of the problem; you also had to port it to all the plat- forms you supported, which often took more time than the development effort itself. In the UNIX world, standards like POSIX and X made it easier to move appli- cations between different UNIX platforms. But they only solved part of the prob- lem and didn’t provide any help with the PC world. Portability became even more important as the Internet grew. The goal was clear: wouldn’t it be great if you could just move applications between different operating environments without worr yingabout the software breaking because of a different operating system, win- dowing environment, or internal data representation? In the spring of 1995, Sun Microsystems announced Java, which claimed to solve this dilemma. What started out as a dancing penguin (or Star Trek communicator) named Duke on remote controls for interactive television has become a new paradigm for programming on the Internet. With Java, you can create a program on one platform and deliver the compilation output (byte-codes/class files) to ever yother supported environment without recompiling or worrying about the local windowing environment, word size, or byte order.
    [Show full text]
  • Drawing in GTK+
    CSci493.70 Graphical User Interface Programming Prof. Stewart Weiss Drawing in GTK+ Drawing in GTK+ Background In order to understand how to draw in GTK, you rst have to understand something about how GTK draws widgets, because how GTK draws widgets has an important role in how you design your drawing application. An understanding of how GTK draws widgets is also required if you ever plan to build your own custom widgets. Windows and Clipping Most windowing systems are designed around the idea that an application's visual display lies within a rectangular region on the screen called its window. The windowing system, e.g. Gnome or KDE or Explorer, does not automatically save the graphical content of an application's windows; instead it asks the application itself to repaint 1 its windows whenever it is needed. For example, if a window that is stacked below other windows gets raised to the top, then a client program has to repaint the area that was previously obscured. When the windowing system asks a client program to redraw part of a window, it sends an exposure event to the program that contains that window. An exposure event is simply an event sent from the underlying windowing system to a widget to notify it that it must redraw itself. In this context, a "window" means "a rectangular region with automatic clipping", not a top-level application window. Clipping is the act of removing portions of a window that do not need to be redrawn, or looked at the other way, it is determining which are the only regions of a window that must be redrawn.
    [Show full text]
  • Canvas Pocket Reference
    Canvas Pocket Reference Canvas Pocket Reference David Flanagan Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo Canvas Pocket Reference by David Flanagan Copyright © 2011 David Flanagan. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promo- tional use. Online editions are also available for most titles (http://my.safari booksonline.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Editors: Mike Loukides and Simon St. Laurent Production Editor: Teresa Elsey Proofreader: Sada Preisch Indexer: John Bickelhaupt Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano Printing History: December 2010: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. The Pocket Reference series designation, Canvas Pocket Reference, the image of a gold weaver bird, and related trade dress are trademarks of O’Reilly Media, Inc. wnload from Wow! eBook <www.wowebook.com> o D Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation
    [Show full text]
  • Quick Guide to Tkinter.Canvas
    tkinter Reference Guide Common Usage and Functions Installation on Your Local Machine.................................. 2 Canvas Initialization .......................................... 3 The Coordinate System......................................... 3 Drawing Lines.............................................. 4 Drawing Rectangles........................................... 5 Drawing Ovals.............................................. 6 Drawing Polygons ........................................... 7 Drawing Text .............................................. 8 1 Installation on Your Local Machine It is very likely that your version of Python 3 came with tkinter already installed. You can check if your local machine has a working version of tkinter by writing and executing a simple Python program consisting of the two lines of code shown below: import tkinter tkinter._test() Upon running this program, a window similar to the one pictured below should appear. If this window appears, then you have a working version of tkinter installed and available to use in your programs! If this window does not appear, then: • Make sure that the function you called is tkinter._test(), with a period followed by an underscore as well as a set of empty parenthesis. • If you are running a version of Python 2, then upgrade your version to Python 3 (this is the standard version for 15-110). • If you cannot upgrade your version of Python, then capitalize all instances of tkinter in the above program and all programs you may write to Tkinter and try again. •
    [Show full text]
  • Swingstates: Adding State Machines to the Swing Toolkit Caroline Appert, Michel Beaudouin-Lafon
    SwingStates: adding state machines to the swing toolkit Caroline Appert, Michel Beaudouin-Lafon To cite this version: Caroline Appert, Michel Beaudouin-Lafon. SwingStates: adding state machines to the swing toolkit. Symposium on User interface software and technology, 2006, Montreux, Switzerland. 10.1145/1166253.1166302. inria-00538387 HAL Id: inria-00538387 https://hal.inria.fr/inria-00538387 Submitted on 22 Nov 2010 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. SwingStates: Adding State Machines to the Swing Toolkit Caroline Appert & Michel Beaudouin-Lafon LRI (Univ. Paris-Sud & CNRS) / INRIA Futurs Bât. 490, Univ. Paris-Sud, 91405 Orsay, France [email protected], [email protected] Swing, an existing, widely used toolkit. Breaking away ABSTRACT from the traditional callback model, SwingStates uses This article describes SwingStates, a library that adds state state machines as a powerful control structure for machines to the Java Swing user interface toolkit. Unlike programming interaction. Since Newman’s seminal work traditional approaches, which use callbacks or listeners to [10], state machines have often been used to describe define interaction, state machines provide a powerful interaction but rarely to actually program it [7, 13].
    [Show full text]
  • Panorama of GUI Toolkits on Haiku
    Panorama of GUI toolkits on Haiku From ncurses to Qt5 François Revol [email protected] Haiku ● Free Software rewrite of BeOS ● An Operating System for the desktop ● A lot of POSIX – But we don't claim to be Unix® ● Some more funny things – Typed & indexable xattrs Native GUI ● InterfaceKit – C++ API (similar to Qt) – BMessage objects ● Multithreaded – 1 message loop / window + 1 app main thread ● Few bindings – yab (yabasic port) Toolkit Pros/Cons ✔ More apps, less work ✗ Never completely ✔ More potential users native ✔ More devs? ✗ No Scripting support ✗ hey Foo get Frame ✔ It can be done right of View … ✗ Screen reader… ✗ Less incentive for native apps Toolkit usage in Debian GNU/Linux ● for t in $(debtags cat | tr ' ,' '\n\n' | grep uitoolkit:: | sort | uniq); do echo -en "$t\t"; debtags search $t | wc -l; ● done Whatever TODO uitoolkit::athena 92 means uitoolkit::fltk 25 uitoolkit::glut 23 ● uitoolkit::gnustep 41 Probably not the best uitoolkit::gtk 2024 metric anyway uitoolkit::motif 53 uitoolkit::ncurses 757 uitoolkit::qt 965 uitoolkit::sdl 488 uitoolkit::tk 135 uitoolkit::TODO 52 uitoolkit::wxwidgets 117 uitoolkit::xlib 254 ncurses █████ ● So what, it's a toolkit � ● Works not too bad hdialog ████▒ ● Native implementation of [x]dialog ● Some missing features ● Shanty is a similar app (Zenity clone) SDL 1.2 █████ ● Of course! SDL 2 █████ ● What Else?™ nativefiledialog █████ ● Native file selectors for Win32, GTK+3, OSX ● Ported during GCI 2014 ● For use with SDL/SDL2/… LibreOffice (VCL) █▒▒▒▒ ● Visual Class Libraries ● LibreOffice / OpenOffice's own GUI toolkit – Is it used anywhere else? IUP █▒▒▒▒ ● Multi-platform GUI toolkit – GTK+, Motif and Windows – “Bindings for C, Lua and LED – Uses native interface elements – Simplicity of its API” ● WIP port by Adrien Destugues (PulkoMandy) wxWidget ▒▒▒▒▒ ● Is this still in use? ● Oh, I need it for KiCAD! ● Port started long ago, nothing usable yet.
    [Show full text]
  • The R-Tcl/Tk Interface
    New URL: http://www.R-project.org/conferences/DSC-2001/ DSC 2001 Proceedings of the 2nd International Workshop on Distributed Statistical Computing March 15-17, Vienna, Austria http://www.ci.tuwien.ac.at/Conferences/DSC-2001 K. Hornik & F. Leisch (eds.) ISSN 1609-395X The R-Tcl/Tk interface Peter Dalgaard∗ Abstract The tcltk package allows the use of the Tk graphical user interface ele- ments from within R by embedding Tk commands into the R language. The design considerations are discussed, and also the shortcomings of the current implementation. 1 Introduction It has been desirable for a long time to add graphical user interface (GUI) elements to R. This would be useful both to allow R programmers to write GUI-driven modules for specific purposes, and in the longer run to build a general GUI for entry-level R users. It would be advantageous to build such features on a preexisting toolkit and several possibilities exist. In choosing between them, I put high priority on the possibility for rapid prototyping and the potential for multiplatform portability. It was clear to me from the start that I would want a language embedding of the toolkit. It is not sufficient to build a predefined shell around R, it should be possible to write R1 functions that modify the GUI, and perhaps even the entire GUI could be written in R. Preferably, it should be very easily to program, whereas efficiency in terms of speed may be less important. Many cross-platform toolkits are in the form of C++ libraries or Java classes, but their object-oriented style seemed difficult to combine with the imperative pro- gramming style of R, although I have to concede that this could be attributed to shortcomings of my own.
    [Show full text]
  • Python Tkinter Canvas
    PPYYTTHHOONN TTKKIINNTTEERR CCAANNVVAASS http://www.tutorialspoint.com/python/tk_canvas.htm Copyright © tutorialspoint.com The Canvas is a rectangular area intended for drawing pictures or other complex layouts. You can place graphics, text, widgets or frames on a Canvas. Syntax Here is the simple syntax to create this widget − w = Canvas ( master, option=value, ... ) Parameters: master: This represents the parent window. options: Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas. Option Description bd Border width in pixels. Default is 2. bg Normal background color. confine If true thedefault, the canvas cannot be scrolled outside of the scrollregion. cursor Cursor used in the canvas like arrow, circle, dot etc. height Size of the canvas in the Y dimension. highlightcolor Color shown in the focus highlight. relief Relief specifies the type of the border. Some of the values are SUNKEN, RAISED, GROOVE, and RIDGE. scrollregion A tuple w, n, e, s that defines over how large an area the canvas can be scrolled, where w is the left side, n the top, e the right side, and s the bottom. width Size of the canvas in the X dimension. xscrollincrement If you set this option to some positive dimension, the canvas can be positioned only on multiples of that distance, and the value will be used for scrolling by scrolling units, such as when the user clicks on the arrows at the ends of a scrollbar. xscrollcommand If the canvas is scrollable, this attribute should be the .set method of the horizontal scrollbar.
    [Show full text]
  • A GUI Drawing Generator Based on Tkinter and Its Design Concept
    PyDraw: a GUI drawing generator based on Tkinter and its design concept Jinwei Lin1 Aimin Zhou2 Abstract The emergence of GUI is a great progress in the history of computer science and software design. GUI makes human computer interaction more simple and interesting. Python, as a popular programming language in recent years, has not been realized in GUI design. Tkinter has the advantage of native support for Python, but there are too few visual GUI generators supporting Tkinter. This article presents a GUI generator based on Tkinter framework, PyDraw. The design principle of PyDraw and the powerful design concept behind it are introduced in detail. With PyDraw's GUI design philosophy, it can easily design a visual GUI rendering generator for any GUI framework with canvas functionality or programming language with screen display control. This article is committed to conveying PyDraw's GUI free design concept. Through experiments, we have proved the practicability and efficiency of PyDrawd. In order to better convey the design concept of PyDraw, let more enthusiasts join PyDraw update and evolution, we have the source code of PyDraw. At the end of the article, we summarize our experience and express our vision for future GUI design. We believe that the future GUI will play an important role in graphical software programming, the future of less code or even no code programming software design methods must become a focus and hot, free, like drawing GUI will be worth pursuing. Keywords Python Tkinter PyDraw Canvas GUI design GUI generator By-drawn concept Jinwei Lin [email protected] Aimin Zhou [email protected] 1 Electronic science and technology major, School of physics and materials science, East China Normal University, Shanghai, China 2Department of Computer Science and Technology, East China Normal University, Shanghai, China 1 Introduction Since the onset of the screen, the graphical user interface (GUI) has been an important means of human-computer interaction between computer black boxes and the outside world.
    [Show full text]
  • Introduction to GUI Development with Tk and Python 3
    Introduction to GUI Development with Tk and Python 3 Charles Daniels 2019-09-30 Contents Introduction Background Architecture Main Window "Add New" Dialog End In Today's Talk... I Rapid GUI development with TkInter and Python 3 I Some familiarity with Python would help I Building GUIs doesn't have to be hard! I Today's demo: a simple "sound board" program In Today's Talk... Figure: The finished application Background I Tcl is one of the older embed-able scripting languages I TkInter is a package which integrates Tcl into Python I Tk is a widget toolkit (such as WPF, GTK, or qt) I Through TkInter, we can use Tk from within Python programs Why TkInter? I Python is great for rapid development I Tk is simple and mature, and so is TkInter I Not as fast/fancy as other toolkits, but very easy to work with Architecture I Main window will have "exit" and "add new sound" buttons I Main window will also have one button for each sound in the db I Database will be a directory filled with .wav files I Clicking "add new" will let us install new sounds in the db I Clicking a sound's button will play it Imports 1 import tkinter 2 import tkinter.ttk 3 import tkinter.filedialog 4 import appdirs 5 import pathlib 6 import shutil 7 import simpleaudio 8 import sys 9 10 global_root = None 11 file_dialog_root = None Controls 1 root = tkinter.Tk() 2 root.title("soundboard") 3 4 # this will let us close and restart theGUI from elsewhere 5 global global_root 6 global_root = root 7 8 #"add new" button 9 add_new_btn = tkinter.ttk.Button(root, text="Add New", 10 command=show_add_new_dialog) 11 add_new_btn.grid(row=0, column=0) 12 13 # exit button 14 exit_btn = tkinter.ttk.Button(root, text="Exit", command=sys .
    [Show full text]
  • Red Hat Linux 6.0
    Red Hat Linux 6.0 The Official Red Hat Linux Installation Guide Red Hat Software, Inc. Durham, North Carolina Copyright ­c 1995, 1996, 1997, 1998, 1999 Red Hat Software, Inc. Red Hat is a registered trademark and the Red Hat Shadow Man logo, RPM, the RPM logo, and Glint are trademarks of Red Hat Software, Inc. Linux is a registered trademark of Linus Torvalds. Motif and UNIX are registered trademarks of The Open Group. Alpha is a trademark of Digital Equipment Corporation. SPARC is a registered trademark of SPARC International, Inc. Products bearing the SPARC trade- marks are based on an architecture developed by Sun Microsystems, Inc. Netscape is a registered trademark of Netscape Communications Corporation in the United States and other countries. TrueType is a registered trademark of Apple Computer, Inc. Windows is a registered trademark of Microsoft Corporation. All other trademarks and copyrights referred to are the property of their respective owners. ISBN: 1-888172-28-2 Revision: Inst-6.0-Print-RHS (04/99) Red Hat Software, Inc. 2600 Meridian Parkway Durham, NC 27713 P. O. Box 13588 Research Triangle Park, NC 27709 (919) 547-0012 http://www.redhat.com While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein. The Official Red Hat Linux Installation Guide may be reproduced and distributed in whole or in part, in any medium, physical or electronic, so long as this copyright notice remains intact and unchanged on all copies.
    [Show full text]