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

tcl/tk - how to make frameless window that open in the of cursor position invoked by button right of the mouse

The idea is how to open popup next to the event button - it's to get Onclick Mouse Cursor Position It would be like this, when clicking anywhere on the desktop, you should call the program in Tcl/Tk at the mouse pointer location. This Tcl/Tkt…
Diego Henrique
  • 255
  • 1
  • 16
0
votes
1 answer

How to implement seaborn graphs into tkinter without them losing their interactivity?

My code to put the graph onto a canvas sns.set() df = pd.DataFrame(stocks, columns=['Date', 'Close']) f = plt.Figure(figsize=(6,6)) ax = f.subplots() sns.lineplot(data=df, x='Date', y='Close', ax=ax) canvas = FigureCanvasTkAgg(f,…
Flapjack
  • 65
  • 7
0
votes
0 answers

Tkinter after() getting faster whenever my timer object is reset

I'm trying to write a timer with tkinter. And here's my class program of timer class Timer: def __init__(self, root, cv): self.sec = 0 self.stop = 0 self.label = tk.Label(root, width = 15, height = 1, text =…
0
votes
1 answer

Is there a way to change a global value from inside a function?

I am currently working an a snake game, but I first want a settings window to show up.i used tkinter for this. In smaller projekts I just wrote all of the code into the pressButton function, but I want to have non spagetti code now, so im not going…
madcoder
  • 13
  • 1
0
votes
1 answer

Unable to resize button height in tkinter python

import tkinter from tkinter import * root = Tk() root.title("Demo") class Application(Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.grid(sticky="ewns") …
0
votes
1 answer

determine how many checkbuttons are ticked that also store information

I'm making a part of my program that contains checkboxes. There are a total of 8 checkboxes and the user can set a min and max of 3 of the boxes. This would be simple enough to determine how many are ticked by setting the on-value as 1, and add the…
0
votes
1 answer

How to integrate a terminal into a text editor created with python-tk?

I took help from this website https://www.geeksforgeeks.org/make-notepad-using-tkinter/ and used the code to create a full-fledged text editor which was like the windows Notepad. Now, I want to integrate a terminal into it so that it can run the…
dev Asur
  • 44
  • 7
0
votes
1 answer

Remove tkinter window border

I've searched the web but I cant find an answer: I just want to remove the border(that contains the tk icon, and the buttons(minimise,expand and close)) from the tkinter window,
coderoftheday
  • 1,987
  • 4
  • 7
  • 21
0
votes
1 answer

Widgets inside tkinter.Text break mouse wheel

tkinter.Text widget allows other widgets, such as buttons, to be inserted along with plain text. tkinter.Text widget responds to mouse wheel by scrolling the contents. However, if the cursor happens to be over a child widget, that widget gets the…
mcu
  • 3,302
  • 8
  • 38
  • 64
0
votes
1 answer

Tkinter entry and button combined function doesn't work in other function

I created a function calling a GUI having several entries and a button. If I push the button then the values on entries will be returned on the function. def date_time_gui (): win = tk.Tk() win.title('powered by Python') # win title …
Dong-gyun Kim
  • 411
  • 5
  • 23
0
votes
0 answers

C++ calling Scilab Engine : Tcl initialisation failed

I'm building an application that will call the Scilab engine, in order to execute some functions. When I do that, the following error occurs. Warning: Localization issue: Error while binding the domain from D:\Documents\HMMF/../locale/ or…
Jason mav
  • 1
  • 1
0
votes
0 answers

How to make it so the close button on the ttk notebook tab is specific and does not appear for all tabs

I have a tkinter.ttk.notebook in my program that has close buttons for all tabs that are created in it. But I want that the first tab created shall not bear a close button acting like a welcome tab that cannot be closed by the user. I have a ttk…
typedecker
  • 1,351
  • 2
  • 13
  • 25
0
votes
1 answer

grey-out button when top level window is opened

Hey I am using Tkinter Python and I have a name entry. If an invalid name is entered it will come up with a error in a new window. I want the original window or button to be greyed out while this error is open, and then go back to normal once it is…
0
votes
3 answers

Python Tkinter grid functions ignored

I feel like I am missing something stupidly obvious here - surely the widgets should just be positioned along the top of the root window, but they completely ignore the .grid() function. When I printed the grid_size(), it returned (0,0). Why?! Any…
0
votes
1 answer

Perl Tk opens additional dialog

#!/opt/perl/bin/perl use strict; use Tk; my $response= Mainwindow->new; $response => $mw->messageBox(-title => 'Title', -message => 'Message', -type => 'YesNo', -icon => 'question', -default => 'yes');…
Steve
  • 31
  • 4
1 2 3
99
100