I am simply trying to disable the user from closing a tab in tk Pnotebook (not the window close button but the tab close button)
based on tkinter pNoteBook documentation, I can only change the state of the tab itself from normal to disable to hide and that's completely not what I am asking for
Thank you
https://docs.python.org/2/library/ttk.html#ttk.Notebook
https://wiki.tcl-lang.org/page/tkinter.Notebook
check the image here
Related
I have created a ttk Notebook with multiple tabs. Each of the tab contains data that user needs to enter. What I would like to do is to change the colour of the tabs, based on a user button click.
Say, initially all the tabs are red. I have an update button for each tab, and when the user clicks this, the tab colour should change to green. I would like the user to know which all tabs are complete, and whch are not.
Is ther any way this is possible? I tried configuring the ttk.Style(), but it affects the entire notebook.
You can simple to it by change the color of the Button
Here is a simple example that can help you
from tkinter import *
root=Tk()
def click():
btn.config(bg='green')
btn=Button(root,text='Update',bg='red',command=click)
btn.pack()
root.mainloop()
I want to make a pop up window that requires the user to interact with before using the main window, Modal Dialog. For example, the messagebox requires the user to answer the question before moving on. If the user tries to click on the original window, the messagebox flashes and plays the iconic error sound. This is what I want; I would use a messagebox but I want to add buttons, labels, widgets, etc...
How do you make a pop up window Modal Dialog?
I'm making a GUI using pyqt5 and I have two windows. In the first window, there is a button to open the second window. Now, I want to prevent windows switching from the second window to the first one. For example, when we open file dialog, we cannot switch to the main window and the main window is not clickable. (you can check it)
I have tried to set windows flag with :
setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
but it just makes the second window stay on top and I can still switch to the first window. Is there a way to prevent windows switching or make the first window to be not clickable?
Thanks in advance
You can make the window modal by:
setWindowModality(Qt.ApplicationModal)
I am trying to make a window still visible after it has lost focus. An example of what I'm trying to achieve is a window like the windows on-screen keyboard, when you click on another window, it doesn't go ontop of the on-screen keyboard window. Can anyone give me a way to do this in tkinter?
I have implemented an informational popup in a python app using a Tkinter Menu widget. I have a Text widget on a canvas in the root window. I created a Menu widget that has root as its parent. When I detect a mouse hover over the text widget I post the popup menu with menuWidget.post(). When I get a leave event from the text widget my intention was to have the popup disappear by calling menuWidget.unpost(), only the popup menu does not disappear until I click elsewhere outside the text widget.
First, is this a sane method for implementing an informational popup? And can anyone tell me why the popup menu won't disappear?
This is not the right way to do an informational popup. On the Mac and on windows machines menus are native controls. Because of this the unpost command doesn't work because tk cedes control to the system event loop in order to get platform-specific behavior.
What you want is to use instead is a toplevel window with the overrideredirect flag set. This lets you display a borderless window anywhere you want. The upside to this is that you aren't limited to simple text -- you can put anything you want in that toplevel -- another text widget, a canvas, buttons, etc.