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

Is C++/Tk compatible with Tk 8.5?

Since Tk 8.5, Tk started using Native Based UI components - buttons, scrollbars etc. I wonder if C++/Tk supports such Native GUIs approach?
Rella
  • 65,003
  • 109
  • 363
  • 636
0
votes
1 answer

Tkinter - need reiterative solution

I am making a project for school. This sign up system is working as expected, but the problem is that once an email/password is entered < 3 characters once, even entering a correct length of value causes it to throw the error. I think it is because…
Vcubbz
  • 69
  • 7
0
votes
1 answer

How to use variable defined in for-loop outside of it?

How can I use this u_name and u_pass outside this for loop? cursr.execute("SELECT rowid ,* FROM usernameandpassword") user_and_pass = (cursr.fetchall()) for users in user_and_pass: global u_name global u_pass u_name = (users[1]) …
0
votes
3 answers

TKinter syntax to creat widget

Is this written technically ok? Will it cause any problems. I cannot find any info about this way of constructing code for tkinter, however it works.. myButton = tkinter.Button(main_window) myButton['text'] = "Click Me!" myButton['state'] =…
Traper279
  • 43
  • 4
0
votes
0 answers

Entry in GUI and print in IDLE (python)

Hi, i have a problem with my code....I want the entry of variables and equations when clicking is shown in the IDLE....Help from tkinter import ttk from tkinter import scrolledtext window = tk.Tk() window.title('NAES…
0
votes
1 answer

C++/Tk: How to create slider and receive its value updates?

So I look at C++/Tk for as a GUI library. I see "lots" of examples - 6. I like its style but I do not see how to create a slider/trackbar. I want such a trackbar that on its value change to have my function called and tb value sent to it. How to do…
Rella
  • 65,003
  • 109
  • 363
  • 636
0
votes
1 answer

How do you pull out variables from a Tkinter Listbox to use elsewhere in your script?

So I have a listbox Tkinter object in python that allows me to select multiple items and it prints out the index of what items where selected. I want to use that index to match elsewhere in my script to say something like, if item 0,2,4 were…
Andrew Hicks
  • 572
  • 1
  • 6
  • 19
0
votes
1 answer

How to pass menu value to submenu

menubutton .mb -text Example -menu .mb.menu pack .mb -padx 10 -pady 10 set m [menu .mb.menu -tearoff 1] $m add cascade -label A -menu $m.sub1 $m add cascade -label B -menu $m.sub1 $m add cascade -label C -menu $m.sub1 set m2 [menu $m.sub1 -tearoff…
0
votes
2 answers

TK spinbox goes into infinite cycle of updating GUI

I cannot fix a strange behavior of spinbox. Specifically, I need to update GUI at changing the spinbox's value, by means of -command and update in it. The code a bit simplified is like: package require Tk set sv 1 ttk::spinbox .sp -from 1 -to…
Alex P
  • 96
  • 1
  • 6
0
votes
0 answers

Tkinter buttons not showing on different screen

It works on my monitor (1920x1080) perfectly but when I use my laptop (Also 1920x1080) none of the buttons or the timer shows..... I've tried using 2 different geometry managers to manage the placement of elements. At first I used .place() but that…
0
votes
1 answer

How to run two parallel scripts from tkinter?

With this code I was able to create a TK Inter pop-up with a button to run a Sample_Function. This Sample_Function destroys the tk pop-up, runs another python file, and then opens itself (the first pop-up) again. How can I run the other_python_file…
guialmachado
  • 506
  • 5
  • 17
0
votes
2 answers

Checking a particular Checkbutton also checks another checkbox in Tkinter

I ran into this problem when I tested my checkbox. When I check the show hint checkbox, Number of words also checks and vice versa. Idk how they both are related. Here is my code. import tkinter as tk COLOUR = 'grey80' WORDS = ['motor',…
Mohit
  • 31
  • 4
0
votes
1 answer

Tkinter strange on Mac

I have made a short clock program (from a lesson). On linux and Windows, it all displays as it should like this: Under OSX is looks like this with the grey box around the text: Can anyone tell me whats going on? Here is the code: from tkinter…
0
votes
1 answer

How to get the root window where a widget is placed from that widget?

I am creating a Tkinter-based GUI. I created a custom button widget, and I'd like to get access to the root (main) window from there. I know about the .master attribute, and I can use it to achieve what I want (see the code below). But because the…
Demian Wolf
  • 1,698
  • 2
  • 14
  • 34
0
votes
1 answer

Forcing TKinter button output to bottom of window?

I am very new to using TKinter. I am making a TKinter window that displays the descriptive statistics of the wine quality data sets. The problem I am having is with the positioning. Even using pack(side=BOTTOM), the button for the histogram shows up…
Illari
  • 183
  • 1
  • 12
1 2 3
99
100