Hallo Leute,
Button ohne Rahmen bekomme ich nicht hin, meine erste Geschichte in Python, dementsprechend nahezu Null Kenntnisse. Kann nur besser werden.
Ausgehed von dem Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #! /usr/bin/python ''' switchHeadphones.py Tkinter toggle button to switch microphone On/Off using a script Modification of the solution proposed in https://www.daniweb.com/posts/jump/1909448 for the Mic On/Off script from https://gist.github.com/OndraZizka/2724d353f695dacd73a50883dfdf0fc6 ''' # Define the path for the script below, e.g., script = "./switchHeadphones.sh" try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk import os __author__ = "Weslley S Pereira" __email__ = "weslley.spereira@gmail.com" def toggle(tog=[0]): ''' a list default argument has a fixed address ''' tog[0] = not tog[0] if tog[0]: os.system(script+' speak') t_btn.config(text='Switch Mic Off') else: os.system(script+' listen') t_btn.config(text='Switch Mic On') root = tk.Tk() root.title('Headphone ') t_btn = tk.Button(text='Switch Mic On', width=15, command=toggle) t_btn.pack(pady=5) root.mainloop() |
Button geändert zu:
1 2 3 4 5 | root = tk.Tk() root.title('taste_leiser') t_btn = tk.Button(text='LS -', width=10, activebackground='cyan', background='black', command=toggle) t_btn.pack(pady=0) |
Es gibt das Rahmen Problem des Buttons. (Button nicht aktiv, wenn Maus ganz am Desktoprand). Wie lässt sich das Rahmenlos gestalten? Auch den Button in geringer Pixelhöhe habe ich nicht hinbekommen, das macht derzeit der Fenstermanager.
MKV zur Verdeutlichung im Anhang.
Bearbeitet von rklm:
Syntaxhighlighting