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

tkinter window get x, y, geometry/coordinates without top of window

I am using tk in python (3), though I'd assume that this applies to any language. I am looking to get the current x, y coordinates of a tk window outside of the title bar: import tkinter root = tkinter.Tk() however, using root.winfo_y() gives me…
gnr
  • 2,324
  • 1
  • 22
  • 24
8
votes
5 answers

How can I enhance the look of the Perl/TK GUI under Perl 5.004?

I have an application that is built to work on Windows, Linux, and Solaris that uses the Perl/TK GUI. Due to constraints, we are limited to Perl/TK only. Moreover, we are limited to an old Perl/Tk version, 5.00404. I'd like to work within these…
Igor
  • 26,650
  • 27
  • 89
  • 114
8
votes
1 answer

Adding default value in simpledialog.askstring using tkinter in Python 3

I am trying to create a simple textbox using tkinter. Below is the code I am trying to use. import tkinter as tk from tkinter import simpledialog root = tk.Tk() # Create an instance of tkinter start_date = simpledialog.askstring(title = "Test…
Code_Sipra
  • 1,571
  • 4
  • 19
  • 38
8
votes
3 answers

Creating Ruby applications for Windows

I want to develop a Windows application. Honestly I care little about cross-platforms for now (but still would be good) I want to use Ruby, since it has quite a simple syntax and is so.. well, simple and easy to learn. My application is like a "game…
Saturn
  • 17,888
  • 49
  • 145
  • 271
8
votes
1 answer

BadIDChoice RENDER in python 3.3 and tk/tcl displayed on X

I have a fairly complicated GUI written through python's tkinter running on linux, and one of the components (which has a Text widget which updates frequently) causes the GUI to crash infrequently (once a day). The guis are being displayed to X…
gnr
  • 2,324
  • 1
  • 22
  • 24
8
votes
2 answers

Trying to install MinGW and Tk for Perl on Windows 7

So... I have been trying to get this working for several weeks now. I can install MinGW through the .exe, but no-matter what I do I can't seem to get make support or ppm install MinGW to work in such a way that my compilation of Tk-804.029 will…
Chris Stevens
  • 81
  • 1
  • 2
8
votes
2 answers

version conflict for package "Tk": have 8.5.2, need exactly 8.5.15

I am trying to compile a program (python2.7) but no matter what I do I keep getting this error: C:/Python27/tcl/tk8.5/tk.tcl: version conflict for package "Tk": have 8.5.2, need exactly 8.5.15 version conflict for package "Tk": have 8.5.2, need…
peech
  • 931
  • 3
  • 12
  • 23
8
votes
3 answers

PDF Viewer for Python Tkinter

I am currently looking for a possibility to display PDF Files inside a Tkinter application (displaying them e.g. in a Frame widget or similar). Is there already a solution for this problem? I already searched SO, used ddg an others but did not find…
R4PH43L
  • 2,122
  • 3
  • 18
  • 30
8
votes
4 answers

Python 3 Tkinter - Messagebox with a toplevel as master?

I've found that when a toplevel widget calls a messagebox dialog (like "showinfo"), the root window is showed up, over the toplevel. Is there a way to set the Toplevel window as the master of the messagebox dialog ? Here is a script to reproduce…
Aelys
  • 241
  • 1
  • 4
  • 19
8
votes
8 answers

Create a Fully Featured Environment For Tcl/Tk Development Under Windows

I'm now learning Tcl/Tk, but as I'm running Windows, I want to create a fully featured(professional) development environment for this language, but I need to know: Which tools I need to install(first of all)? What are the IDEs that support Tcl/Tk…
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300
8
votes
2 answers

Tkinter grid geometry manager size propagation (with sticky)

I'm missing something about how sizes propagate in Tk. Try this: from Tkinter import * root = Tk() frame1 = Frame(root, border=4, relief=RIDGE) frame1.grid(sticky=E+W) frame2 = Frame(root, border=4, relief=RIDGE) frame2.grid(sticky=E+W) label1 =…
Dan Halbert
  • 2,761
  • 3
  • 25
  • 28
8
votes
1 answer

Steps to Create A Tcl Starkit on a Windows Platform

I am trying to figure out the basic steps to creating a Tcl starkit in Windows. I've asked a similar question before, as well as purchased a book on Tcl programming, visited wiki.tcl.tk, emailed Tcl programmers directly, etc... In all, I've…
DFM
  • 473
  • 4
  • 15
7
votes
2 answers

Does Ruby offer a mechanism for responding to Apple Events on OS X?

I'm working on a desktop application for OS X using Ruby-Tk, and I would like to provide an Apple Events interface for the application. This means that the application would define a dictionary of AppleScript commands that it would respond to…
Kevin Walzer
  • 538
  • 4
  • 14
7
votes
2 answers

board-drawing code to move an oval

I am working on a python checkers game for college. I have the board drawn, using tk, but I can't seem to implement a movement function for the pieces. If anyone see any errors in my code, or can offer help, I would appreciate. Here is the complete…
7
votes
3 answers

Python TK Notebook tab change check

Newbie programmer here. I am building a tk based desktop app and ran into an issue: I have a main window with several stuff in it including two tabs: global nBook nBook = ttk.Notebook(self, name="book") nBook.place(x=300,y=400) …
Alin Iuga
  • 250
  • 4
  • 11