How to create a minimize button with pysimplegui? - python

I'm creating a UI for my application and wanted to remove windows minimize and close buttons and add my own, i've added a close button but i don't know what function should I set the button to do.

The close() method is used for that. I don't what kinda button is your one, but you can call this method on your window object when button is pressed.
if event == "Button":
window.close()

Related

Is there any way to remove the click animation in Python Tkinter?

When I click a button in Tkinter, an effect shows up. Can I somehow remove it?
button
button when clicked
I tried to google the problem, but found nothing useful :(
Btw, sorry for the bad English, I hope it's not too disturbing.
You can disable the animation of a button by returning "break" in the widget's bind, which stops the propagation of bound functions.
So you can either alter the function you normally have bound to the button to return "break".
Or you can add another bind, this does however prevent any binds that are made after this one
You can use relief='sunken', however, the style of the button will always appear to be pressed.
btn = Button(frame, text='Btn', relief='sunken')

Closing an .ui file on a click of a button (pyqt5)

I need my dialog box to close when the ok button is clicked. How do I do that ?
Assuming you created the button you should be able to just set the button click event as follows:
button.clicked.connect(self.close) where button is the button name.
Although since you did not provide any code with your question it's hard to know if this is what you're asking for...

Is wait_window() required for creating a modal dialog in Python Tkinter?

I try to create a modal dialog using Python Tkinter. I found no difference between using and not using wait_window().
import tkinter as tk
def button_click():
dlg = tk.Toplevel(master=window)
tk.Button(dlg, text="Dismiss", command=dlg.destroy).pack()
dlg.transient(window) # only one window in the task bar
dlg.grab_set() # modal
#window.wait_window(dlg) # why?
window = tk.Tk()
tk.Button(window, text="Click Me", command=button_click).pack()
window.mainloop()
I've seen some examples in that use wait_window() for creating a modal dialog. So I'm not sure whether the function is required for creating a modal dialog.
I'm using Python 3.5.
Strictly speaking, no, wait_window() is not required to make a modal dialog box. What makes a dialog modal is the grab that you put on the window.
Often, however, once the window is destroyed you may need to run some other code. You can use wait_window() for this purpose, as it will wait for the window to be destroyed before continuing. You can then have code after that, such as a return statement, or some cleanup code. In your case there's nothing to do, so you don't need to call wait_window.
running your code using window.wait_window(dlg) won't change anything as dlg.grab_set() already creates a modal dialog. this does only mean that you cannot close window while dlg is still alive. you cannot close window as the modal dialog grabs all mouse events from window and redirects them to null.
If you want to create a modal dialog without grab_set(), you would need to bind all mouse events to one handler and then decide if they should be allowed or dismissed and use wait_window.
As a modal dialog is defined by "is anything outside the dialog and in my application available to be clicked" == False , you already have a modal dialog only using grab_set().
If your application shall not be able to programatically close window, you would need wait_window() as well.
Hope I made everything clear.

Manually triggering the ttk notebook tab change event

I'm talking about <<NotebookTabChanged>> event that ttk.Notebook can be bound to. Say I have:
def tabChanged(self, event):
print "tab changed"
And say I want to manually trigger this method. What I actually mean by this is, say I have a basic, tabbed GUI and there's a start button which makes plots when you click it. There are plots on each tab and when you change tabs, <<NotebookTabChanged>> is triggered, which is an automatically created event by ttk.Notebook. I already have a self.tabChanged method for this case. What I wanna do is, I wanna make my start button trigger this event so I don't have to create a new method just for the button which will do the exact same thing as self.tabChanged. So I need a way of triggering the event through a button click, but remember, that event is ttk.Notebook's own event and apparently it was designed to be used with tabs, not buttons. Is there a way to trigger <<NotebookTabChanged>> manually with a button click?
You can generate virtual events (eg: events that begin and end with << and >>) with event_generate:
self.the_notebook.event_generate("<<NotebookTabChanged>>")

Make a click event in Tkinter

I'm trying do a very simple task: Make a Button click in Tkinter.
I have an array of Buttons and, when I finish an event, I want to make a Button click event in one of my buttons.
I thought it should be as simple as buttons[2].click(), but that doesn't do anything.
Try calling .invoke() on the button

Categories

Resources