Questions tagged [tk-toolkit]

The Tk toolkit is a scripted GUI toolkit that is designed to be used from dynamic languages (initially Tcl, but also Perl and Python).

Overview

The Tk toolkit is a GUI toolkit that is designed to be used from dynamic languages. It was developed originally by John Ousterhout for use with Tcl, but has subsequently been evolved to be supported with many other languages (notably Perl, Python and Ruby).

Tk is a native toolkit on Windows and Mac OS X. On other Unix-based platforms, it is built directly on top of X11, and by default emulates the look traditionally associated with Motif (though this is configurable). It is recommended that newer applications use widgets from the Ttk set (where appropriate) as these use a theming engine that is more suitable for handling modern look-and-feels.

One of the key features of Tk is that its behaviors are defined almost entirely through scripting (plus a powerful event binding mechanism). This gives user code great flexibility to redefine what is happening without writing new low-level programs. The low-level drawing engine is written in C and takes care to postpone actual drawing activity until an appropriate moment (typically after all pending GUI events are processed) making Tk feel extremely responsive to user activity.

Examples

Tk is a remarkably simple toolkit. The following example shows how to create a window with the label "Hello, world". The example is in Tcl and designed to be run by the wish interpreter that comes with every tcl/tk installation:

label .l -text "Hello, world"
pack .l

Other languages are only slightly more verbose. Unlike with wish, other languages typically require you to import the tk library, create the root window, and start the event loop.

Here is the same example in Python 2:

import Tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="Hello, world")
label.pack()
root.mainloop()

Related tags

  • - questions related to themed tk widgets
  • - questions related to the python implementation of tk
  • - questions related to the perl implementation of tk

General reference links

2482 questions
0
votes
0 answers

Is any way the function taking the values from the imported entries from the the Tk?

So I want to run the Tk() and import there some values. Then these values will be checked from a function that will replacing the value in a particular cell in excel. This cell that matches with one imported entry. My challenge here is that the…
Zanshin
  • 25
  • 3
0
votes
1 answer

Tkinter: Text styling based on location in list

Please note I am new to Tkinter. I have also looked at text tags, but I am not sure how to apply that in this case. I would like to change the styling of text based on its location in a list (really a list of lists). The structure of "results_list"…
Steak
  • 514
  • 3
  • 15
0
votes
0 answers

Why does StringVar() not change value whenever I use it under a second mainloop() window?

I'm currently creating a login system which connects to a main application. The user uses the log in system to log in through a series of window, and after this is done, the log in window should close and the main program should open. I've created a…
amroman
  • 7
  • 2
0
votes
0 answers

How to move canvas_image top to bottom repeatedly or atleast 3 times in tkinter?

I have wrote a code that it working fine to move the image to bottom, but I am confused how to move it again to the old position of image that is on the top ? import tkinter as tk def move_object(canvas, object_id, destination, speed=50): …
sodmzs1
  • 324
  • 1
  • 12
0
votes
1 answer

How to make a GUI in Tkinter scalable

I am trying to create a GUI for a project. The code for which is below. I have a question regarding scalability. In my script I get Tkinter to display the GUI in fullscreen. However due to the nature of relx and rely in place it gets the label or…
Harry Spratt
  • 179
  • 11
0
votes
1 answer

Why does the entry widget not display text when I use state='readonly'

I'm trying to create a table to display text using entry widgets. I've written code that work,s however when I try to add state=readonly it simply does not display the text. So when I run this code, it works fine but the entry widgets are…
amroman
  • 7
  • 2
0
votes
1 answer

Are you only allowed one word with Treeview values?

I might be missing something completely obvious here as I am completely new to Treeview, but when I insert my values ("Hello there" in this case), only the "Hello" outputs - it is always only the first word that appears... As you can probably see, I…
0
votes
1 answer

Voltage calculator - Python tkinter

Anglais I would like to calculate by retrieving data in a textbox but it gives me an error: Traceback (most recent call last): File "C:/Users/#####/Desktop/Python/Calculateur_U_R_I/App_main.py", line 43, in exe_button =…
0
votes
1 answer

How to configure map for all ttk widgets except TButton?

I am creating a GUI with Tkinter and ttk, and I'm trying to create a custom map to make ttk widgets blue on hover. I could apply that to all widgets with passing "." as the first argument to ttk.Style().map(...). import tkinter as tk import…
Demian Wolf
  • 1,698
  • 2
  • 14
  • 34
0
votes
1 answer

Is it possible to provide animation on image ? - Tkinter

I'm developing a GUI in Tkinter and want to apply animation in the below GIF on the image when it appears. Here is my code, from tkinter import * from PIL import Image, ImageTk root = Tk() frame = Frame(root) frame.pack() canvas = Canvas(frame,…
sodmzs1
  • 324
  • 1
  • 12
0
votes
0 answers

Is it possible to give slideDown transition on Image in Tkinter?

Just like how we give effects on image in Jquery using the code $('.img').slideDown('fast', 'linear', function() {}); Is there any way to give slideDown effect on canvas image in tkinter ? This is my code. from tkinter import * from PIL import…
sodmzs1
  • 324
  • 1
  • 12
0
votes
0 answers

Tkinter - Create save button within a window?

Here is my code: def nameProjectWindow(): tkWindow = Tk(className = 'Export Project') tkWindow.geometry("500x500") fileNameLabel = Label(tkWindow, text="File Name").grid(row=0, column=0) fileNameVar = StringVar() fileNameEntry…
chrisHG
  • 80
  • 1
  • 2
  • 18
0
votes
3 answers

Tkinter Button does not execute command

I'm trying to create a button that opens local files from a users machine. I have my buttons set up and the function to open files is pretty simple. When clicking the actual button, nothing actually happens. The intended result should be a box that…
chrisHG
  • 80
  • 1
  • 2
  • 18
0
votes
1 answer

Tkinter images not showing up when made through thread

I have a script that is supposed to automatically change the picture on a button. When I refresh my frame manually the picture shows up normally, but when the script does it, it doesn't show up. When I hover over it, I get the error:…
0
votes
0 answers

How do I make this entry widget display text?

def create_table(self, frame): data = [['Jeremy', 'Dean', '80%', 'Asteroids', 'Jupiter'], ['Matt', 'Damon', '75%', 'Asteroids', 'Jupiter']] # sample data i = 0 try: for row in data: j = 0 for item in…