繁体   English   中英

将我的python脚本添加到系统托盘? 还是开始菜单,运行mu简单的GUI?

[英]Add my python script to the system tray? Or the start menu, to run mu simple GUI?

我刚刚开始使用python。 我写了一个小脚本/程序/一些代码,它是一个改变键盘亮度的GUI。

我想将我写的“程序”添加到应用程序菜单中,或者甚至更好地从系统托盘中运行它。

任何人都可以告诉我如何将我的程序变成一个独立的图标,我可以双击运行。 我在网上看过'编译','制作独立'等等。我不知道用什么词来形容我想做什么。

我正在使用KDE桌面运行Ubuntu。

我怀疑这是相关的,但我的代码是:

## GUI for adjusting keyboard back-light
## Opens the config file, writes config file, closes file.
#!/usr/bin/env python
def open_and_write():
    myfile = open("/sys/devices/platform/dell-laptop/"\
                "leds/dell::kbd_backlight/brightness", "wb")
    myfile.write(x)
    myfile.close()
def press_off():
    global x
    x = "0"
    open_and_write()
def press_medium():
    global x
    x = "1"
    open_and_write()
def press_full():
    global x
    x = "2"
    open_and_write()
from Tkinter import *
root = Tk()                 
root.title("Backlight")
root.geometry("228x122")    
app = Frame(root)           
app.grid()                  
button1 = Button(app, text = "Off", width=6, height=5, command=press_off)
button2 = Button(app, text = "Medium", width=6, height=5, command=press_medium)
button3 = Button(app, text = "Full", width=6, height=5,command=press_full)
button1.grid(row = 1, column = 0)
button2.grid(row = 1, column = 1)
button3.grid(row = 1, column = 2)
button = Button(root, text='EXIT', width=25, pady=5, command=root.destroy)
button.grid()
root.mainloop()*

这在KDE中非常容易。

右键单击您的KDE应用程序菜单,无需KDE 4或5.选择“编辑应用程序...”。 您将看到所有应用程序的列表。

选择一个类别,如“系统”,然后创建一个应用程序菜单项。

您需要提供名称并指定脚本的路径。 (可选)您可以为其选择一个图标。

然后保存它。

打开应用程序菜单,您可以找到您的应用程序图标

文件: https//docs.kde.org/stable5/en/kde-workspace/kmenuedit/quickstart.html

如果您需要桌面快捷方式,只需将应用程序菜单中的图标拖到桌面即可。

如果您想要任务栏快捷方式,请运行该应用程序并右键单击任务栏,选择“Pin”或“Show when not running”等。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM