I'm pretty new to Python, so bear with me on this. I looked at the possible duplicate of my question, and wasn't able to get it to work for me. I'm assuming I just don't understand the answer code enough, but I can't seem to get the terminal command I want, just the one used in the answer.
The answer I'm referring to can be found here: Giving a command in a embedded terminal
I've got a simple GUI that I've embedded a terminal into. The purpose of this is to run tcpdump to capture packets. I wrote a simple script that did this just fine, but I'm looking to make it easier to use on a touch screen, hence the GUI.
I set up a button that runs the following code:
os.system('sudo tcpdump')
But it doesn't execute in the embedded terminal.
Could someone explain how to make this command run in the terminal that's embedded in the GUI?
Here's all the code I have for the GUI so far:
from tkinter import *
import os
class PcapGUI:
def __init__(self, master):
self.master = master
master.title("Packet Captures")
self.start_button = Button(master, text="Start", command=self.start)
self.termf = Frame(root, height=400, width=500)
self.wid = self.termf.winfo_id()
os.system('xterm -into %d -geometry 70x20 -sb &' % self.wid)
def start(self):
os.system('sudo tcpdump')
root = Tk()
gui = PcapGUI(root)
root.mainloop()
Any help is appreciated!