I noticed that the Text widget from tkinter is not present in the ttk widgets.
I'm using the ttk instead of tkinter because its interface suits better.
And I need Text widget because it has multiple lines unlikely the Entry widget.
Does anyone have a solution for my problem?
The solution is to use the tkinter text widget. tkinter and ttk are designed to work together.
Related
Can't find this anywhere else on stack overflow.
I want to create a dialog box (on top of my main window) in tkinter that has message, a text input field and some custom buttons.
I know I can do
import tkinter as tk
from tkinter import simpledialog
master = tk.Tk()
user_input = tk.simpledialog.askstring("title", "message")
and then take the user_input from there. However, how can I make the buttons have custom text and also bind them to my own functions?
Otherwise, I was thinking of making my own dialogbox class. But that's a lot of work. Is there any way I can do this natively using any of tkinter' modules?
Regards
Hugo.
I'm using Tkinter with a GUI using a button inside the root window.
I also want to use a Button inside a MatplotLib graph that allows me to exit the graph (and potentially for other uses in the future).
The only problem is that they both use the same label Button. These two labels have different syntax so I can only either have Tkinter buttons or Matplotlib buttons.
I'm sure this is a very amateur question but is there a way to specify that this Button is a tkinter button while another Button is a matplotlib button?
Here's an example of the code:
from matplotlib.widgets import Slider, Button, RadioButtons
from tkinter import *
btn = Button(root, text="Plot", command=graph).pack()
Found the answer but this might be helpful to some people
You can instead use
import tkinter as tk
and then everytime you want to you a tkinter function you specify it by writing "tk." before it.
E.g.:
tk.Button
in this case and it will specifically use the tkinter version of the Button
Is there any way to use 'pick_event' while using Tkinter back-end? I can use tk canvas to show my plots but couldn't find any document that handles pick_evet within tkinter.
I'm curious, as making a window with Tkinter really does seem to easy. Does Python have an alert thing similar to javascript by default?
There is no graphical alert in python. Tkinter is the default python GUI interface. If all you need is an alert, that's less than a dozen lines of code. Here's a python 3 example:
import tkinter as tk
import tkinter.messagebox
def alert(message):
root = tk.Tk()
root.withdraw()
tkinter.messagebox.showwarning("Alert", message)
root.destroy()
alert("Danger Will Robinson!")
I like the warning noise that messagebox provides out of the box (no pun intended), as in the GUI below.
from tkinter import messagebox
messagebox.showinfo("my title", "my message", icon="warning", parent=None)
However, I need more customization than messagebox offers, so I've created my own window. Is there a way to include the same warning noise with a Toplevel() window?
I'm using Python3 and Tkinter 8.5.
I think you would need to manually sound it
import Tkinter
Tkinter.Tk().bell()
or maybe you can just do SomeWindow.bell() (to be honest im not overly familiar with tkinter)