Giter Site home page Giter Site logo

tkinter-by-example's Introduction

Learn Tkinter By Example

Learn Tkinter By Example - a free book for learning tkinter, complete with full source code.

Get the book here

Mobile formats (mobi and epub) are now available in the assets folder. However, I would recommend using FBReader with the PDF version where possible.

What's This Book About?

This book walks you through 7 full-featured applications built with Python and Tkinter. Each application will teach you different aspects of Tkinter which you can use for your own projects. Screenshots, source code and full explanations are included with each app.

The book assumes little-to-no experience with tkinter but will require some basic knowledge of the Python language.

Full source code of each application is available in the Code folder of this repository. The Latex source of the book itself is in the assets folder.

Legal Stuff

The Book

This book is licensed under Creative Commons Attribution-NoDerivs (CC BY-ND)

https://creativecommons.org/licenses/by-nd/4.0/

You are free to download this book as many times as you want and you are encouraged to share it with anyone and everyone who may benefit from it.

You are free to translate this book into another language if you wish.

If you wish to compile the Latex source into another format you may do so. If you then wish to redistribute this new format please submit it as a pull request here.

The Python Code

This source code is licensed under the MIT Licence

https://opensource.org/licenses/MIT

You are free to download, modify, use, and re-distribute this code as you see fit.

tkinter-by-example's People

Contributors

dvlv avatar dz2904 avatar xonoma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tkinter-by-example's Issues

Tablet friendly formats

Could we get a tablet-friendly PDF with narrow borders, and/or epub / mobi formats for e-readers? Eloquentjavascript.net has some good examples near the bottom of the home page, with their github page located here.

`place` coordinates confusion: 300 vs. 500

To put a widget at (100, 300) within a window, use \lstinline[columns=fixed]{widget.place(x=100, y=500)}. Alternatively, you can use \lstinline[columns=fixed]{relx} and \lstinline[columns=fixed]{rely} to \lstinline[columns=fixed]{place} a widget relative to its parent. \lstinline[columns=fixed]{relx=0.5, rely=0.5, anchor=tk.CENTER} will keep a widget completely central in its parent.

The text and the code example seem to contradict each other, with the Y coordinate being 300 and 500, respectively

Text index positioning - x.y vs line.column

To my understanding, Tkinter's Text index syntax is "line.column" - e.g. "3.2" stands for line 3, column 2.

  1. See first source - effbot:

line/column indexes are the basic index type. They are given as strings consisting of a line number and column number, separated by a period. Line numbers start at 1, while column numbers start at 0, like Python sequence indexes. You can construct indexes using the following syntax:

"%d.%d" % (line, column)
  1. See also Text widget indices:

An index is a general method of specifying a position in the content of a text widget. An index is a string with one of these forms:

'line.column'
The position just before the given column (counting from zero) on the given line (counting from one). Examples: '1.0' is the position of the beginning of the text; '2.3' is the position before the fourth character of the second line.


However, in Chapter/Para 6.13 of Tkinter by Example, you wrote:

We begin by grabbing the current index of the cursor with index(tk.INSERT) . This is returned in a string of the format "x.y". For example, the first character of the second line is "1.2" and the 14th character of line 12 is "14.12". The reason we need this is to try and grab the word which is currently being typed by the user. We need to go back one character in order to do this, which is where adjust_floating_index comes in.

The above indicates that the column/character comes first, then only line; i.e. it becomes column.line instead of line.column.

Is there an issue with the explanation, or is my understanding incorrect?

Use a real monospace font

Computer Modern is a really good font, but code listings are meant to be written in a monospace font. This thing looks bad with uneven tracking, and no way to tell some characters apart.

Also, the .pdf file is hard to discover.

Suggestion - new documentation for syntax-related issues

The code is lovely and self-documenting.

However, there are some syntax choices that may raise questions -- e.g. the difference between pack_propagate(0) and pack, the use of ntpath instead of os.path, and others.

As this is a by-example guide, I suggest the creation of a separate Markdown readme file to briefly describe why some of the code choices were made. It should not be a full-blown documentation, just a simple summary of those parts that may potentially confuse, why it was coded that way, and if necessary, some further references for more extended reading. I am happy to help out.

Visualize button is not working

import tkinter as tk
from tkinter.filedialog import askopenfilename

def browseFile1():
  global infile1
  infile1=askopenfilename()
  txt1.insert(0.0, infile1)

root = tk.Tk()
root.title("Visualization tool")
Label = tk.Label(root, text="Select a PCD file")
Label.grid(row = 1, column = 0, columnspan = 30)
browseButton1 = tk.Button(root,text="Browse", command=browseFile1)
browseButton1.grid(row = 2, column = 30)
txt1 = tk.Text(root, width = 100, height = 1)
txt1.grid(row = 2, column = 0, columnspan = 30)

def processbutton():
  global bro
  bro=processbutton()


browseButton2 = tk.Button(text="Visualize", command = processbutton)
browseButton2.grid(sticky='ew', padx=500, pady=10)


def visualize(cloud):
    global visual
    visual = visualize()
    visual = pcl.pcl_visualization.CloudViewing()

    # filtering ground points
    print(cloud.size)

    fil = cloud.make_passthrough_filter()
    fil.set_filter_field_name("z")
    fil.set_filter_limits(0, 1.5)
    cloud_filtered = fil.filter()

    print(cloud_filtered.size)

###### visualization
    visual.ShowColorCloud(cloud, b'cloud')

    flag = True
    while flag:
        flag != visual.WasStopped()
    end

root.mainloop()

Please help me in this issue. Thanks in advance

Trouble with Loading an Image in Button

I've tried running code like
self.photo = tk.PhotoImage(file="image1.gif")

and it always says it couldn't find pyimageX.gif. The code is looking for "name=" instead of "file="

Have you made a lot of changes in this area and if so, is there updated documentation? I can't get a button to load an image to save my life. I've also tried:
self.photo = tk.PhotoImage(name="image1.gif")

and it seems to succeed but then the image isn't shown in the button. Suggestions? Thx

Can I translate your Tkinter book into Chinese?

Hi dude,
Your Tkinter book is really awesome!
Can I translate it into Chinese?
I will keep your name and add this Github site on it.
And If you approve, I will start translation and share the result with you when it is finished.

BRs,
PengTian

Tk inter Mac OS Quit ()

Hello,
I've got problem, I'm under mac os (High sierra), I'm searching how to close mainloop in tkinter windows. I'v tried .quit and .destroy but it doesn't work at all and it makes the program crashing.
regards,
sr

Scrollbar Problem

Hello.After following the ToDoList V2 guide, I found something weird about the scrollbar.When the task items are too few to show the scrollbar, I can still scroll the task item because of listening the mousewheel event, which make the task frame move up and down.
I tried to find some solution on stackoverflow and the situation is similar to this question.
If I don't explain clearly, you can see the comments under the stackoverflow answer, which is the problem I meet and the solution does not work.Maybe you can figure out this problem and make the code more perfect.
Thanks a lot!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.