logo Debian Debian Debian-France Debian-Facile Debian-fr.org Forum-Debian.fr Debian ? Communautés logo inclusivité

Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).

#1 07-12-2020 12:05:00

arpinux
CA Debian-Facile
Lieu : Montréal d'aude
Distrib. : nakeDeb
Noyau : Linux 6.1 amd64
(G)UI : sway - i3wm - fluxbox
Inscription : 30-06-2016
Site Web

[Python] un menu en systray

coucou les fans du serpent smile

alors dans l'optique de fournir un menu accessible à la souris sur une session i3wm, j'ai piqué des petits bouts de scripts python sur le net pour construire une menu disponible dans la zone de notification.

j'utilise pour cela Pygtk (j'ai vu que d'autres utilisent pytk)

comme en fait, je ne comprends absolument rien au python lol je n'ai fait qu'user de logique pour assembler ce menu qui fonctionne exactement comme je veux.

mais quand je regarde le bidule, je vois bien qu'une fabuleuse optimisation est (nécessaire) possible vu le nombre de répétition.
mais, encore une fois car je n'y capte rien, bah je demande votre avis pour optimiser le script smile

edit : version optimisée en fin de fil wink

#!/usr/bin/python3

import os
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk as gtk, AppIndicator3 as appindicator

def main():
  indicator = appindicator.Indicator.new("customtray", "debian-symbolic", appindicator.IndicatorCategory.APPLICATION_STATUS)
  indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
  indicator.set_menu(menu())
  gtk.main()

def menu():
  menu = gtk.Menu()

  command_term = gtk.ImageMenuItem('Terminal')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/apps/terminal.png')
  command_term.set_image(img)
  command_term.connect('activate', terminal)
  menu.append(command_term)

  command_clifile = gtk.ImageMenuItem('CLI Filer')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/apps/file-manager.png')
  command_clifile.set_image(img)
  command_clifile.connect('activate', clifiler)
  menu.append(command_clifile)

  command_cliweb = gtk.ImageMenuItem('CLI Browser')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/emblems/emblem-web.png')
  command_cliweb.set_image(img)
  command_cliweb.connect('activate', clibrowser)
  menu.append(command_cliweb)

  sep = gtk.SeparatorMenuItem()
  menu.append(sep)

  command_guifile = gtk.ImageMenuItem('GUI Filer')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/places/folder.png')
  command_guifile.set_image(img)
  command_guifile.connect('activate', guifiler)
  menu.append(command_guifile)

  command_torweb = gtk.ImageMenuItem('TOR Browser')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/emblems/emblem-web.png')
  command_torweb.set_image(img)
  command_torweb.connect('activate', torbrowser)
  menu.append(command_torweb)

  command_guiedit = gtk.ImageMenuItem('GUI Editor')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/places/notebook.png')
  command_guiedit.set_image(img)
  command_guiedit.connect('activate', guieditor)
  menu.append(command_guiedit)

  sep = gtk.SeparatorMenuItem()
  menu.append(sep)

  command_apps = gtk.ImageMenuItem('Apps Menu')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/actions/system-search.png')
  command_apps.set_image(img)
  command_apps.connect('activate', appsmenu)
  menu.append(command_apps)

  command_help = gtk.ImageMenuItem('naked Help')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/apps/question.png')
  command_help.set_image(img)
  command_help.connect('activate', nakedhelp)
  menu.append(command_help)

  command_nquit = gtk.ImageMenuItem('naked Quit')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/actions/gnome-session-logout.png')
  command_nquit.set_image(img)
  command_nquit.connect('activate', nakedquit)
  menu.append(command_nquit)

  sep = gtk.SeparatorMenuItem()
  menu.append(sep)

  exittray = gtk.ImageMenuItem('Close tray')
  img = gtk.Image()
  img.set_from_file('/usr/share/icons/Clarity/16x16/emblems/emblem-nowrite.png')
  exittray.set_image(img)
  exittray.connect('activate', quit)
  menu.append(exittray)
 
  menu.show_all()
  return menu
 
def terminal(_):
  os.system("urxvtcd &")

def clifiler(_):
  os.system("urxvtcd -e ranger &")

def guifiler(_):
  os.system("pcmanfm &")

def clibrowser(_):
  os.system("xterm -geometry 110x35 -e w3m /usr/share/nakedeb/nakedstart.html &")

def torbrowser(_):
  os.system("torbrowser-launcher &")

def guieditor(_):
  os.system("geany &")

def guiconfig(_):
  os.system("lxappearance &")

def appsmenu(_):
  os.system("rofi -modi drun -show drun -show-icons &")

def nakedhelp(_):
  os.system("nakedhelp &")

def nakedquit(_):
  os.system("nakedquit &")

def quit(_):
  gtk.main_quit()

if __name__ == "__main__":
  main()
 



quand je le lance, j'ai des warnings qui ne ralentissent rien et lors de mes recherches, j'ai lu que ce n'était pas grave... mais si vous voyez là encore une optimisation, je suis preneur smile

retour terminal

nakedsystray


/home/arp/bin/nakedsystray:18: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_term = gtk.ImageMenuItem('Terminal')
/home/arp/bin/nakedsystray:21: DeprecationWarning: Gtk.ImageMenuItem.set_image is deprecated
  command_term.set_image(img)
/home/arp/bin/nakedsystray:25: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_clifile = gtk.ImageMenuItem('CLI Filer')
/home/arp/bin/nakedsystray:32: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_cliweb = gtk.ImageMenuItem('CLI Browser')
/home/arp/bin/nakedsystray:42: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_guifile = gtk.ImageMenuItem('GUI Filer')
/home/arp/bin/nakedsystray:49: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_torweb = gtk.ImageMenuItem('TOR Browser')
/home/arp/bin/nakedsystray:56: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_guiedit = gtk.ImageMenuItem('GUI Editor')
/home/arp/bin/nakedsystray:66: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_apps = gtk.ImageMenuItem('Apps Menu')
/home/arp/bin/nakedsystray:73: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_help = gtk.ImageMenuItem('naked Help')
/home/arp/bin/nakedsystray:80: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  command_nquit = gtk.ImageMenuItem('naked Quit')
/home/arp/bin/nakedsystray:90: PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "label" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
  exittray = gtk.ImageMenuItem('Close tray')

(nakedsystray:27519): Gdk-CRITICAL **: 12:00:04.172: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
 



voili voilou smile un ptit kdodenowel big_smile

1607339587.jpg

Dernière modification par arpinux (10-12-2020 00:57:20)


nous sommes tous différents ... c'est notre point commun ...
Association Debian-Facile - Les cahiers du débutant - ISO Debian-Facile - 3hg - nakeDeb
GNU/Linux©2006-2024

Hors ligne

#2 07-12-2020 13:01:00

cyrille
CA Debian-Facile
Lieu : Nowhere
Distrib. : SID + FreeBSD. Stable sur serveurs.
(G)UI : Xfce/Openbox
Inscription : 21-06-2020
Site Web

Re : [Python] un menu en systray

Hello
Juste positionner un label dans le nommage wink

   command_term = gtk.ImageMenuItem(label='Terminal')



Idem pour les autres constructeurs, ça devrait dejà enlever une paire de warning

Attention dans la construction du paquet de bien mettre la dépendance gir1.2-appindicator3-0.1 en plus de python3-gi dans le control.

wink

Sinon ce n'est pas du pygtk (valable pour python2 ) mais du python avec gtk (norme python3) wink gtk offrant bien plus de possibilité que tk, comme le support des thèmes, par exemple.

Dernière modification par cyrille (07-12-2020 13:19:02)


"Ils ne me comprennent point, je ne suis pas la bouche qu’il faut à ces oreilles."

Association Debian-Facile | Les cahiers du débutant | ISO Debian-FacilePage perso. sur #df

Hors ligne

#3 07-12-2020 13:18:51

arpinux
CA Debian-Facile
Lieu : Montréal d'aude
Distrib. : nakeDeb
Noyau : Linux 6.1 amd64
(G)UI : sway - i3wm - fluxbox
Inscription : 30-06-2016
Site Web

Re : [Python] un menu en systray

^^ wow... merci cyrille.... il ne me reste qu'un seul warning ! big_smile

 $ nakedsystray


/home/arp/bin/nakedsystray:21: DeprecationWarning: Gtk.ImageMenuItem.set_image is deprecated
  command_term.set_image(img)


nous sommes tous différents ... c'est notre point commun ...
Association Debian-Facile - Les cahiers du débutant - ISO Debian-Facile - 3hg - nakeDeb
GNU/Linux©2006-2024

Hors ligne

#4 07-12-2020 13:19:44

cyrille
CA Debian-Facile
Lieu : Nowhere
Distrib. : SID + FreeBSD. Stable sur serveurs.
(G)UI : Xfce/Openbox
Inscription : 21-06-2020
Site Web

Re : [Python] un menu en systray

je regarderai ce soir (là je suis retourné au taf, sans python sur la main wink

Dernière modification par cyrille (07-12-2020 13:20:13)


"Ils ne me comprennent point, je ne suis pas la bouche qu’il faut à ces oreilles."

Association Debian-Facile | Les cahiers du débutant | ISO Debian-FacilePage perso. sur #df

Hors ligne

#5 07-12-2020 16:15:06

David5647
Membre
Distrib. : Debian Sid
Noyau : 5.15.0-2-amd64
(G)UI : i3wm + des bouts de kde
Inscription : 27-08-2017

Re : [Python] un menu en systray

#!/usr/bin/python3

import os
import gi

gi.require_version("Gtk", "3.0")
gi.require_version("AppIndicator3", "0.1")
from gi.repository import Gtk as gtk, AppIndicator3 as appindicator


def main():
  indicator = appindicator.Indicator.new(
    "customtray",
    "debian-symbolic",
    appindicator.IndicatorCategory.APPLICATION_STATUS,
  )
  indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
  indicator.set_menu(menu())
  gtk.main()

def create_menu_item(label, icon, command):

  command_term = gtk.ImageMenuItem(label=label)
  img = gtk.Image()
  img.set_from_file(icon)
  command_term.set_image(img)

  def cmd(_):
    os.system(command)

  command_term.connect("activate", cmd)

  return command_term

def menu():
  menu = gtk.Menu()

  launchers = [
    {
      'label' : "Terminal",
      'icon' : "/usr/share/icons/Clarity/16x16/apps/terminal.png",
      'command' : "urxvtcd &"
    },
    {
      'label' : "CLI Filter",
      'icon' : "/usr/share/icons/Clarity/16x16/apps/file-manager.png",
      'command' : "urxvtcd -e ranger &"
    }
  ]

  for launcher in launchers:

    label = launcher['label']
    icon = launcher['icon']
    command = launcher['command']
    menu.append(create_menu_item(label, icon, command))

  menu.show_all()
  return menu


def quit(_):
  gtk.main_quit()


if name == "main":
  main()
 



Bon pas testé, rien ne s'affiche chez moi (bullseye), pas de message d'erreur... je suis bête, j'ai pas de systray...
Donc, ce qui suit, c'est du "principe" ^^ fonctionne
Pour compacter un peu tout ça et tout en restant lisible :
- une liste de dictionnaires : launchers pour contenir les définitions
  - un fonction create_menu_item pour construire les entrées à partir de chaque dictionnaire
  - on en profite pour mettre la définition des fonctions (os.system(command))  la dedans

Dernière modification par David5647 (07-12-2020 23:53:05)

Hors ligne

#6 09-12-2020 18:51:09

David5647
Membre
Distrib. : Debian Sid
Noyau : 5.15.0-2-amd64
(G)UI : i3wm + des bouts de kde
Inscription : 27-08-2017

Re : [Python] un menu en systray

#!/usr/bin/env python3

import os
import gi

gi.require_version("Gtk", "3.0")
gi.require_version("AppIndicator3", "0.1")
from gi.repository import Gtk as gtk, AppIndicator3 as appindicator

LAUNCHERS = [
    {
        "label": "Terminal",
        "icon": "/usr/share/icons/Clarity/16x16/apps/terminal.png",
        "command": "urxvtcd &",
    },
    {
        "label": "CLI Filter",
        "icon": "/usr/share/icons/Clarity/16x16/apps/file-manager.png",
        "command": "urxvtcd -e ranger &",
    },
    {
        "label": "CLI Browser",
        "icon": "/usr/share/icons/Clarity/16x16/emblems/emblem-web.png",
        "command": "pcmanfm &",
    },
    {
        "sep": True
    },
    {
        "label": "GUI Filer",
        "icon": "/usr/share/icons/Clarity/16x16/places/folder.png",
        "command": "xterm -geometry 110x35 -e w3m /usr/share/nakedeb/nakedstart.html &",
    },
    {
        "label": "TOR Browser",
        "icon": "/usr/share/icons/Clarity/16x16/emblems/emblem-web.png",
        "command": "torbrowser-launcher &",
    },
    {
        "label": "GUI Editor",
        "icon": "/usr/share/icons/Clarity/16x16/places/notebook.png",
        "command": "kate &",
    },
    {
        "sep": True,
    },
    {
        "label": "Apps Menu",
        "icon": "/usr/share/icons/Clarity/16x16/actions/system-search.png",
        "command": "lxappearance &",
    },
    {
        "label": "naked Help",
        "icon": "/usr/share/icons/Clarity/16x16/apps/question.png",
        "command": "rofi -modi drun -show drun -show-icons &",
    },
    {
        "label": "naked Quit",
        "icon": "/usr/share/icons/Clarity/16x16/actions/gnome-session-logout.png",
        "command": "nakedhelp &",
    },
    {
        "label": "Close tray",
        "icon": "/usr/share/icons/Clarity/16x16/emblems/emblem-nowrite.png",
        "command": "nakedquit &",
    },
]


def main():
    indicator = appindicator.Indicator.new(
        "customtray",
        "debian-symbolic",
        appindicator.IndicatorCategory.APPLICATION_STATUS,
    )
    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
    indicator.set_menu(menu())
    gtk.main()


def create_menu_item(label=None, icon=None, command=None, sep=False):

    if not sep:

        img = gtk.Image().set_from_file(icon)
        cmd = gtk.ImageMenuItem(label)
        cmd.set_image(img)
        cmd.connect("activate", lambda _ : os.system(command))
        return cmd

    else:

        return gtk.SeparatorMenuItem()

def menu():
    menu = gtk.Menu()
    for launcher in LAUNCHERS:
        menu.append(create_menu_item(**launcher))
    menu.show_all()
    return menu

def quit(_):
    gtk.main_quit()

if __name__ == "__main__":
    main()
 


Hop! Un peu de fonctions avancées python! Pour se la raconter un peu... Au programme :

  - unpacking de dictionnaire : **launcher "décompresse les entrées (label, icon...) du dictionnaire directement dans les variables du même nom de la fonction create_menu_item. On ajoute un entrée sep booléenne, et une condition dans la fonction de création d'items.

  - utilisation d'un fonction "jetable" : lambda (équivalent à def ma_fonction(param), mais tiens sur une ligne)

  - et puisque j'y étais, quelques macros vim et hop!

Dernière modification par David5647 (09-12-2020 18:52:14)

Hors ligne

#7 09-12-2020 19:03:21

arpinux
CA Debian-Facile
Lieu : Montréal d'aude
Distrib. : nakeDeb
Noyau : Linux 6.1 amd64
(G)UI : sway - i3wm - fluxbox
Inscription : 30-06-2016
Site Web

Re : [Python] un menu en systray

o/ David5647 smile

merci ! voilà une belle réduction/optimisation du code smile

alors j'ai de nouveau le warning du label. j'avais transformé

  command_term = gtk.ImageMenuItem('Terminal')


par

  command_term = gtk.ImageMenuItem(label='Terminal')


pour éviter l'erreur, mais là, je ne sais plus où remplacer big_smile

et je n'ai plus les images dans le menu hmm

te prends pas la tête David, cyrille m'a déjà bien avancé wink

Dernière modification par arpinux (09-12-2020 19:14:30)


nous sommes tous différents ... c'est notre point commun ...
Association Debian-Facile - Les cahiers du débutant - ISO Debian-Facile - 3hg - nakeDeb
GNU/Linux©2006-2024

Hors ligne

#8 09-12-2020 19:25:27

David5647
Membre
Distrib. : Debian Sid
Noyau : 5.15.0-2-amd64
(G)UI : i3wm + des bouts de kde
Inscription : 27-08-2017

Re : [Python] un menu en systray

C'est sûrement ça qui ne va pas. (enfin, c'est ça à défaut d'un autre couac) J'ai été trop gourmand.

img = gtk.Image().set_from_file(icon)

Essaie de le remettre sur plusieurs lignes.

def create_menu_item(label=None, icon=None, command=None, sep=False):

    if not sep:

        cmd = gtk.ImageMenuItem(label=label)
        img = gtk.Image()
        img.set_from_file(icon)
        cmd.set_image(img)
        cmd.connect("activate", lambda _ : os.system(command))
        return cmd

    else:

        return gtk.SeparatorMenuItem()

*
Et c'est sur la ligne :

cmd = gtk.ImageMenuItem(label)


qu'il faut ajouter label=

cmd = gtk.ImageMenuItem(label=label)


(le paramètre à le même nom que la variable, c'est plus clair et moins clair en même temps tongue

Dernière modification par David5647 (09-12-2020 19:32:39)

Hors ligne

#9 09-12-2020 22:51:06

arpinux
CA Debian-Facile
Lieu : Montréal d'aude
Distrib. : nakeDeb
Noyau : Linux 6.1 amd64
(G)UI : sway - i3wm - fluxbox
Inscription : 30-06-2016
Site Web

Re : [Python] un menu en systray

merci smile

alors j'ai modifié comme tu as dit mais je n'avais plus la fonction de fermeture du menu donc j'ai recollé une section juste pour fermer le menu, supprimé le def_quit() du coup. tout fonctionne nickel, ne reste que l'avertissement pour la mise en place de l'icône, mais c'est négligeable smile

voici le code "final" pour moi, merci encore cyrille et David5647 ! big_smile

#!/usr/bin/env python3
# minimal menu in the systray
# arpinux, cyrille & David5647 @2020
# from https://debian-facile.org/viewtopic.php?id=28826
#------------------------------------------------------

import os
import gi

gi.require_version("Gtk", "3.0")
gi.require_version("AppIndicator3", "0.1")
from gi.repository import Gtk as gtk, AppIndicator3 as appindicator

LAUNCHERS = [
    {
        "label": "Terminal",
        "icon": "/usr/share/icons/Clarity/16x16/apps/terminal.png",
        "command": "urxvtcd &",
    },
    {
        "label": "CLI Filter",
        "icon": "/usr/share/icons/Clarity/16x16/apps/file-manager.png",
        "command": "urxvtcd -e ranger &",
    },
    {
        "label": "CLI Browser",
        "icon": "/usr/share/icons/Clarity/16x16/emblems/emblem-web.png",
        "command": "xterm -geometry 110x35 -e w3m /usr/share/nakedeb/nakedstart.html &",
    },
    {
        "sep": True
    },
    {
        "label": "GUI Filer",
        "icon": "/usr/share/icons/Clarity/16x16/places/folder.png",
        "command": "pcmanfm &",
    },
    {
        "label": "TOR Browser",
        "icon": "/usr/share/icons/Clarity/16x16/emblems/emblem-web.png",
        "command": "torbrowser-launcher &",
    },
    {
        "label": "GUI Editor",
        "icon": "/usr/share/icons/Clarity/16x16/places/notebook.png",
        "command": "geany &",
    },
    {
        "sep": True,
    },
    {
        "label": "Apps Menu",
        "icon": "/usr/share/icons/Clarity/16x16/actions/system-search.png",
        "command": "rofi -modi drun -show drun -show-icons &",
    },
    {
        "label": "naked Help",
        "icon": "/usr/share/icons/Clarity/16x16/apps/question.png",
        "command": "nakedhelp &",
    },
    {
        "label": "naked Quit",
        "icon": "/usr/share/icons/Clarity/16x16/actions/gnome-session-logout.png",
        "command": "nakedquit &",
    }
]

def main():
    indicator = appindicator.Indicator.new(
        "customtray",
        "debian-symbolic",
        appindicator.IndicatorCategory.APPLICATION_STATUS,
    )
    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
    indicator.set_menu(menu())
    gtk.main()

def create_menu_item(label=None, icon=None, command=None, sep=False):

    if not sep:
        img = gtk.Image()
        img.set_from_file(icon)
        cmd = gtk.ImageMenuItem(label=label)
        cmd.set_image(img)
        cmd.connect("activate", lambda _ : os.system(command))
        return cmd
    else:
        return gtk.SeparatorMenuItem()

def menu():
    menu = gtk.Menu()
    for launcher in LAUNCHERS:
        menu.append(create_menu_item(**launcher))

    exittray = gtk.ImageMenuItem(label='close tray')
    img = gtk.Image()
    img.set_from_file('/usr/share/icons/Clarity/16x16/emblems/emblem-nowrite.png')
    exittray.set_image(img)
    exittray.connect('activate', quit)
    menu.append(exittray)

    menu.show_all()
    return menu

if __name__ == "__main__":
    main()
 


nous sommes tous différents ... c'est notre point commun ...
Association Debian-Facile - Les cahiers du débutant - ISO Debian-Facile - 3hg - nakeDeb
GNU/Linux©2006-2024

Hors ligne

#10 10-12-2020 00:13:18

David5647
Membre
Distrib. : Debian Sid
Noyau : 5.15.0-2-amd64
(G)UI : i3wm + des bouts de kde
Inscription : 27-08-2017

Re : [Python] un menu en systray

Pour l'avertissement de dépréciation, je crains que cela concerne tout le module. Je n'ai jamais utilisé la lib et par conséquent, pas très familier avec la doc.
https://developer.gnome.org/gtk3/stable … -set-image

GtkImageMenuItem has been deprecated since GTK+ 3.10. If you want to display an icon in a menu item, you should use GtkMenuItem and pack a GtkBox with a GtkImage and a GtkLabel instead. You should also consider using GtkBuilder and the XML GMenu description for creating menus, by following the GMenu guide. You should consider using icons in menu items only sparingly, and for "objects" (or "nouns") elements only, like bookmarks, files, and links; "actions" (or "verbs") should not have icons.


Si la dépréciation est avérée, pas trop d'idée de jusqu'à-quand-est-ce-que-c'est-que-le-code-y-va-marcher.
Pour ce genre de menu, ça renvoie plus vers là : application. Ça parle de xml, peut être y a t'il moyen de pas trop toucher à du python avec ça...

Hors ligne

#11 10-12-2020 00:37:04

arpinux
CA Debian-Facile
Lieu : Montréal d'aude
Distrib. : nakeDeb
Noyau : Linux 6.1 amd64
(G)UI : sway - i3wm - fluxbox
Inscription : 30-06-2016
Site Web

Re : [Python] un menu en systray

merci pour les liens, je sais que ce menu fonctionnera sur Debian Buster donc j'attends Debian 11 pour la prochaine version.
merci encore les gars smile

nous sommes tous différents ... c'est notre point commun ...
Association Debian-Facile - Les cahiers du débutant - ISO Debian-Facile - 3hg - nakeDeb
GNU/Linux©2006-2024

Hors ligne

Pied de page des forums