Python Forum

Full Version: [XFce]i am again looking for sample menu code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am, again, looking for sample menu code. an idea case would be code that reads a config file that describes the menu layout, what to show at each item, and a command to execute if that one is selected.

something that can add itself to the Xfce panel would be extra great.

Python3 preferred, but Python2 can be OK.
which GUI framework so the thread can be prefixed appropriately?
anything that works in Xfce.
No idea what that is ?
xfce is a Window Manager in Ubuntu / Linux Mint.

(Jul-03-2019, 11:08 PM)Skaperen Wrote: [ -> ]something that can add itself to the Xfce panel would be extra great.

Here's a simple systray example

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import QApplication, QSystemTrayIcon, QDialog, QMenu, QMessageBox, QWidget
from PyQt5.QtGui import QIcon

class theTray(QWidget):
    def __init__(self, parent=None):
        super(theTray, self).__init__(parent)
        icon = QIcon.fromTheme("python")
        menu = QMenu()
        messageAction = menu.addAction(QIcon.fromTheme("help-info"), "show Message")
        messageAction.triggered.connect(self.message)
        exitAction = menu.addAction(QIcon.fromTheme("application-exit"), "exit")
        exitAction.triggered.connect(self.exitApp)
    
        self.tray = QSystemTrayIcon()
        self.tray.setIcon(icon)
        self.tray.setContextMenu(menu)
        self.tray.show()
        self.tray.setToolTip("click me (right)")
        self.tray.showMessage("SysTray", "Example")

    def message(self):
        QMessageBox.information(
                None, 'Systray', 'Hell World')

    def exitApp(self):
        sys.exit()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    myapp = theTray()
    myapp.show()
    sys.exit(app.exec_())
do we still need # -*- coding: utf-8 -*- in python3 since it defaults to that?
i got some sample code that is in C and uses GTK. this should be translatable to Python?