So I am making a applet for my personal use . The thing is that I can’t figure out how to connect the button to close the window . It says that the function I trow for second argument takes 0 positional arguments but 1 given. Any help? Here is the code:
#!/usr/bin/env python3
import gi
import time
gi.require_version("MatePanelApplet", "4.0")
gi.require_version("Gtk","2.0")
gi.require_version("Wnck","1.0")
from gi.repository import MatePanelApplet
from gi.repository import Gtk
from gi.repository import Wnck
def GetWindow():
screen = Wnck.Screen.get_default()
screen.force_update()
window_list = screen.get_windows()
active_window = screen.get_active_window()
return active_window
def CloseAction():
action = Wnck.Window.close(GetWindow(),int(time.time()))
def ButtonsApplet(applet):
MID_LEVEL = Gtk.HBox()
close = Gtk.Button("close")
minimize = Gtk.Button("minimize")
maximize = Gtk.Button("maximize")
close.connect("clicked",CloseAction)
MID_LEVEL.add(close)
MID_LEVEL.add(minimize)
MID_LEVEL.add(maximize)
applet.add(MID_LEVEL)
applet.show_all()
def ButtonsApplet_Factory(applet,iid,data):
if iid != "WindowButtonsApplet":
return False
ButtonsApplet(applet)
return True
MatePanelApplet.Applet.factory_main("WindowButtonsAppletFactory",True,MatePanelApplet.Applet. __gtype__,ButtonsApplet_Factory,None)