Python Forum
[XFce]i am again looking for sample menu code - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [XFce]i am again looking for sample menu code (/thread-19548.html)



[XFce]i am again looking for sample menu code - Skaperen - Jul-03-2019

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.


RE: i am again looking for sample menu code - Yoriz - Jul-03-2019

which GUI framework so the thread can be prefixed appropriately?


RE: i am again looking for sample menu code - Skaperen - Jul-03-2019

anything that works in Xfce.


RE: i am again looking for sample menu code - Yoriz - Jul-03-2019

No idea what that is ?


RE: [XFce]i am again looking for sample menu code - Axel_Erfurt - Jul-04-2019

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_())



RE: [XFce]i am again looking for sample menu code - Skaperen - Jul-04-2019

do we still need # -*- coding: utf-8 -*- in python3 since it defaults to that?


RE: [XFce]i am again looking for sample menu code - Skaperen - Jul-05-2019

i got some sample code that is in C and uses GTK. this should be translatable to Python?