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
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 have tried to clear some widgets (buttons) from a tkinter window in python by using button.destroy() but I have to use the button after so I have tried button.pack_forget().
After using the forget method I have tried to use the button again by doing button.pack() but it's not working.
Why?
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.
Is there a widget that shows a thread visually for Tkinter?
reason why. I want to open a Vpython window inside a Tkinter window.
I know there is a possibility to open a Vpython thread on the side while Tkinter is active, but can i show it inside Tkinter? (Like in some sort of Frame)
No, there is no widget to do that.
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)