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
1 answer

TTK Combobox does not style properly

I have been attempting to create a combobox that fits in with the rest of my UI; however the widget still looks like the default: In my attempts, I have tried to "brute-force" the widget into adapting to the color with the following code but to no…
Geetansh G
  • 17
  • 7
0
votes
1 answer

Make a placeholder reappear when the input field is unselected without input in Tkinter

I'm trying to make a placeholder reappear in the entry widget when the user hasn't put anything in but clicked away, in Tkinter/python. Please Help. def windTurbineHeightClear(event): windTurbineHeight.delete(1, 'end') windTurbineHeight =…
0
votes
1 answer

how do I handle reading serial port data in tkinter app?

I'm trying to make a Tkinter app that connects to a selected serial port, and displays both sent and receiving data to a text widget. I am not sure how to go about handling the constant checking of data from the serial port in such an app, as my…
Bill B
  • 73
  • 3
  • 7
0
votes
2 answers

Tkinter Iterative Button Widget Bug

So I have the code below to generate a whole bunch of widgets iteratively from a list of names and other inputs. My problem now is with the button widgets, which have all their commands being the same. The problem with the code is obvious, the…
Verzus
  • 1
0
votes
1 answer

Getting Tkinter Checkbutton value from grid position

I am having trouble getting the On/OFF state of a tkinter checkbox button from its grid position. In this basic example, I want to print the text if the checkbox is on, but I keep getting the error that the checkbutton object has no attribute get,…
Lzypenguin
  • 945
  • 1
  • 7
  • 18
0
votes
1 answer

Tkinter stop similar tags from joining together

I'm working on a dynamic scrolling application that somewhat emulates a table format. Unfortunately, due to the speed of the data, the only method that is quick enough to do this is the text widget (Displaying real time stock data in a scrolling…
ACWalker
  • 11
  • 2
0
votes
1 answer

Python, Tkinter - root is not defined

I have a class - code below - which works flawlessly when called from if __name__ == '__main__': but when I call it from another .py file it spits an error. Apologies if this is a basic mistake on my part, but I tried a LOT of stuff and nothing…
user11812071
0
votes
1 answer

How do I update my stock database to reduce itself once a customer orders

Time to ask from the almighty stack overflow questions again. So my problem is that I am developing in TKINTER and have implemented and integrated 2 tables in one database on the application. I would like my table products to update once an order is…
Markkkk
  • 1
  • 1
0
votes
0 answers

Binding multiple list boxes in TK inter with pandas Dataframe

I am new to Tkinter GUI, and trying to achieve following I've dataframe df AccountName Group1 Group2 Group3 Cost Global Global Global Cost Global …
0
votes
1 answer

Is there a way to prevent a ttk OptionMenu callback from firing twice?

I have a tkinter application with a ttk.OptionMenu whose value is set to a tk.StringVar. I would like to get a callback whenever the user picks a new option in the option menu. After registering a callback on the StringVar, whenever the user changes…
ddulaney
  • 843
  • 7
  • 19
0
votes
2 answers

Basic GUI for shell commands with Python Tk threading and os.system calls

I'm doing a basic GUI to provide some user feedback after some shell commands, a little interface for a shell script really. Showing a TK window, waiting for a os.system call to complete and updating the TK window multiple times, after each…
Luke Stanley
  • 1,274
  • 1
  • 16
  • 32
0
votes
0 answers

Global variable inside Tkinter function

I want to be able to access difficulty and startingRegion inside the validateStart() function. How do I do this? I am using tkinter def startgame(): root = Tk() #storing user choice under variable difficulty difficulty =…
0
votes
1 answer

Texting being inserted into two different boxes when it should only be inserted into one

I'm making a text based adventure 'heist' game in python. I've designed a GUI for it, which is controlled using four buttons which change text and command. I also included a few text boxes to show the player's current inventory, score and money…
user14959776
0
votes
1 answer

How to Increase the Label Font Size of Tk (Python)

I want to Increase the Label Font Size of my GUI. I tried the way I attached below. But it that raises an error. What I tried so far is the code below. The error is Traceback (most recent call last): File…
0
votes
0 answers

ImageGrab.grab() not cropping screenshot correctly when given coordinates

I need to create a widget that acts like Window's snipping tool and saves the cropped image on button release. It works perfectly fine, except that the image gets cropped and saved as if it was given the wrong coordinates. I have checked a full…