Python Forum
How to display results from terminal window onto tkinter.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to display results from terminal window onto tkinter.
#1
Hey all.
Ive made a Tkinter frontend using the following code:
#!/usr/bin/env python3
import tkinter as tk
import subprocess
import tkinter.messagebox
import os


path = '/home/rukha/Desktop/hacker.png'

HEIGHT = 500
WIDTH = 600

root = tk.Tk()
root.title("Fake BTS")

#termf = tk.Frame(root, height=700, width=600)
#termf.place(height='37', width='120', relx='0.46', rely='0.45')
#wid = termf.winfo_id()
#os.system('xterm -into %d -geometry 400x200 -e /root/.bashrc&' % wid)


background_image = tk.PhotoImage(file = "/home/rukha/Desktop/hacker.png")
label= tk.Label(image = background_image)
label.pack()

canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH, bg= "#3498DB")
canvas.pack()

frame = tk.Frame(root, bg= "#80c1ff", bd=5)
frame.place(relx=0.5, rely=0.05, relwidth=0.45, relheight=0.1, anchor='n')

label = tk.Label(frame, text= "Welcome to Fake BTS Detector", bg= "#80c1ff")
label.config(font=("Comic Sans",20, 'bold'))
label.place(rely=0.18, relx='0.16')

lower_frame = tk.Frame(root, bg= '#80c1ff', bd='10')
lower_frame.place(relx=0.5, rely=0.17, relwidth=0.35, relheight=0.08, anchor='n')

def change_color():
    current_color = button.cget("background")
    next_color = "black" if current_color == "#5d6d7e" else "#5d6d7e"
    button.config(background=next_color)
    root.after(1000, change_color)

def run():
	subprocess.call('./grgsm.sh', shell=True)

button = tk.Button(lower_frame, text= "Start", bg= "#5d6d7e", fg= "white", command= run)
button.place(height='27', width='55', relx='0.80', rely='0.17')
change_color()



label = tk.Label(lower_frame, text= "Click here to run the scanner", bg= "#80c1ff")
label.config(font=("Comic Sans",12, 'bold'))
label.place(rely=0.22, relx='0.05')

frame_1 = tk.Frame(root, bg= '#80c1ff', bd='10')
frame_1.place(relx=0.5, rely=0.27, relwidth=0.24, relheight=0.06, anchor='n')

label = tk.Label(frame_1, text= "Choose your desired scan", bg= "#80c1ff")
label.config(font=("Comic Sans",12, 'bold'))
label.place(rely=0.03, relx='0.07')

def click():
	#tkinter.messagebox.showinfo("Quick Scan", "Your scan was initiated just now. Please wait to see results")
	#tkinter.messagebox.showinfo("Deep Scan", "Your scan was initiated just now. Please wait to see results")
	root = tk.Tk()
	root.title("Quick Scan")

	#background_image = tk.PhotoImage(file = "/home/rukha/Desktop/hacker.png")
	#label= tk.Label(image = background_image)
	#label.pack()

	canvas = tk.Canvas(root, height=350, width=280, bg= "#3498DB")
	canvas.pack()
	
	#tkinter.messagebox.showinfo("Custom Scan", "Please select the tests you want to conduct.")
	
	framez = tk.Frame(canvas, bg= '#80c1ff', bd='10')
	framez.place(relx=0.00, rely=0.00, relwidth=1.0, relheight=1.0)

	label = tk.Label(framez, text= "Scans conducted are:", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.03, relx='0.09')

	label = tk.Label(framez, text= "1. Database Comparison", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.13, relx='0.11')

	
	def clickz():
		tkinter.messagebox.showinfo("Quick Scan", "Your scan was initiated just now. Please wait to see results.")
		subprocess.call('./quickscan.sh', shell=True)
		root.destroy()

	buttonz = tk.Button(framez, text= "Okay", bg= "#DCDCDC", fg= "black", command= clickz)
	buttonz.place(height='37', width='105', relx='0.29', rely='0.73')

	root.mainloop()

button1 = tk.Button(root, text= "Quick Scan", bg= "#80c1ff", fg= "black", command= click)
button1.config(font=("Comic Sans",11,'bold'))
button1.place(height='37', width='105', relx='0.26', rely='0.40')

#btnMenu2 = tk.Menubutton(root, text='Tests Conducted', bg='#80c1ff')
#contentMenu = tk.Menu(btnMenu2)
#btnMenu2.config(menu=contentMenu)
#btnMenu2.place(height='37',width='130', relx='0.25', rely='0.47')

#btnList = ['Database Comparison']
#for btn in btnList:
	#contentMenu.add_command(label=btn)


def click1():
	#tkinter.messagebox.showinfo("Deep Scan", "Your scan was initiated just now. Please wait to see results")
	root = tk.Tk()
	root.title("Deep Scan")

	#background_image = tk.PhotoImage(file = "/home/rukha/Desktop/hacker.png")
	#label= tk.Label(image = background_image)
	#label.pack()

	canvas = tk.Canvas(root, height=350, width=280, bg= "#3498DB")
	canvas.pack()
	
	#tkinter.messagebox.showinfo("Custom Scan", "Please select the tests you want to conduct.")
	
	framey = tk.Frame(canvas, bg= '#80c1ff', bd='10')
	framey.place(relx=0.00, rely=0.00, relwidth=1.0, relheight=1.0)

	label = tk.Label(framey, text= "Scans conducted are:", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.03, relx='0.12')

	label = tk.Label(framey, text= "1. Database Comparison", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.13, relx='0.09')

	label = tk.Label(framey, text= "2. Conflicting ARFCNs", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.23, relx='0.09')

	label = tk.Label(framey, text= "3. Conflicting Cell IDs", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.33, relx='0.09')

	label = tk.Label(framey, text= "4. Lonesome Location ID", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.43, relx='0.09')

	label = tk.Label(framey, text= "5. Empty Neighbour List", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.53, relx='0.09')

	label = tk.Label(framey, text= "6. Missing IMSI", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.63, relx='0.09')

	def clicky():
		tkinter.messagebox.showinfo("Deep Scan", "Your scan was initiated just now. Please wait to see results.")
		root.destroy()

	buttony = tk.Button(framey, text= "Okay", bg= "#DCDCDC", fg= "black", command= clicky)
	buttony.place(height='37', width='105', relx='0.29', rely='0.73')

	root.mainloop()


button2 = tk.Button(root, text= "Deep Scan", bg= "#80c1ff", fg= "black", command= click1)
button2.config(font=("Comic Sans",11,'bold'))
button2.place(height='37', width='105', relx='0.66', rely='0.40')

#btnMenu1 = tk.Menubutton(root, text='Tests Conducted', bg='#80c1ff')
#contentMenu = tk.Menu(btnMenu1)
#btnMenu1.config(menu=contentMenu)
#btnMenu1.place(height='37',width='130', relx='0.65', rely='0.47')



#btnList = ['Database Comparison', 'Conflicting ARFCNs', 'Conflicting Cell IDs', 'Lonesome Location ID', 'Empty Neighbour List', 'Missing IMSI']
#for btn in btnList:
	#contentMenu.add_command(label=btn)

def click2():
	root = tk.Tk()
	root.title("Custom Scan")

	#background_image = tk.PhotoImage(file = "/home/rukha/Desktop/hacker.png")
	#label= tk.Label(image = background_image)
	#label.pack()

	canvas = tk.Canvas(root, height=350, width=280, bg= "#3498DB")
	canvas.pack()
	
	#tkinter.messagebox.showinfo("Custom Scan", "Please select the tests you want to conduct.")
	
	framex = tk.Frame(canvas, bg= '#80c1ff', bd='10')
	framex.place(relx=0.00, rely=0.00, relwidth=1.0, relheight=1.0)

	label = tk.Label(framex, text= "Select your desired scans", bg= "#80c1ff")
	label.config(font=("Comic Sans",12))
	label.place(rely=0.03, relx='0.03')

	var1 = tk.IntVar()
	self1 = tk.Checkbutton(framex, text="Test 1: Database Comparison", variable=var1, anchor='w')
	self1.place(height='27',width='250', relx='0.02', rely='0.15')

	var2 = tk.IntVar()
	self2 = tk.Checkbutton(framex, text="Test 2: Conflicting ARFCNs", variable=var2, anchor='w')
	self2.place(height='27',width='250', relx='0.02', rely='0.25')

	var3 = tk.IntVar()
	self3 = tk.Checkbutton(framex, text="Test 3: Conflicting Cell IDs", variable=var3, anchor='w')
	self3.place(height='27',width='250', relx='0.02', rely='0.35')

	var4 = tk.IntVar()
	self4 = tk.Checkbutton(framex, text="Test 4: Lonesome Location ID", variable=var4, anchor='w')
	self4.place(height='27',width='250', relx='0.02', rely='0.45')

	var5 = tk.IntVar()
	self5 = tk.Checkbutton(framex, text="Test 5: Empty Neighbour List", variable=var5, anchor='w')
	self5.place(height='27',width='250', relx='0.02', rely='0.55')

	var6 = tk.IntVar()
	self6 = tk.Checkbutton(framex, text="Test 6: Missing IMSI", variable=var6, anchor='w')
	self6.place(height='27',width='250', relx='0.02', rely='0.65')

	def clickx():
		tkinter.messagebox.showinfo("Custom Scan", "Your scan was initiated just now. Please wait to see results.")
		root.destroy()

	buttonx = tk.Button(framex, text= "Okay", bg= "#80c1ff", fg= "black", command= clickx)
	buttonx.place(height='37', width='105', relx='0.29', rely='0.80')

	root.mainloop()
	


button2 = tk.Button(root, text= "Custom Scan", bg= "#80c1ff", fg= "black", command= click2)
button2.config(font=("Comic Sans",11,'bold'))
button2.place(height='37', width='120', relx='0.46', rely='0.40')

def click3():
	tkinter.messagebox.showinfo("Details of Tests", "The details of the tests are: \n \n 1. Test 1: Scan that ARFCN (frequencies), Country Code (MCC), Network Code (MNC), Location and Cell Identity (LAI & CI).\n \n 2. Test 2: Scan that two entries have same ARFCN. \n \n 3. Test 3: Scan that two same ARFCNs have different LAI/CI. \n \n 4. Test 4: Scan that whether one LAI has only one CI. \n \n 5. Test 5: Scan whether neighbour list is empty.\n \n 6. Test 6: Scan whether the IMSI/TMSI field is empty.")

button3 = tk.Button(root, text= "Click Here for Details of Tests", bg= "#80c1ff", fg= "black", command= click3)
button3.place(height='37', width='235', relx='0.415', rely='0.55')

root.mainloop()
Now few of the codes have already been added and a few more are to be added for the operational commands for buttons. The idea is, whenever a button is pressed, it runs either a python command or a shell script on the terminal. I want an instance, where the terminal output can be displayed on the Tkinter window.
Please help.
Reply


Messages In This Thread
How to display results from terminal window onto tkinter. - by buttercup - Jul-21-2020, 04:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 343 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  Tkinter Shell Terminal Or Shell Output sweetthdevil 5 8,761 Feb-03-2024, 02:51 PM
Last Post: Gribouillis
  Tkinter multiple windows in the same window tomro91 1 786 Oct-30-2023, 02:59 PM
Last Post: Larz60+
  [PyQt] PyQt5 window closing when trying to display a graph bianca 4 1,621 Aug-12-2023, 03:25 PM
Last Post: bianca
  Centering and adding a push button to a grid window, TKinter Edward_ 15 4,380 May-25-2023, 07:37 PM
Last Post: deanhystad
  [PyQt] [Solved]Display PyQtTable results from A->Z & Z->A Extra 2 1,142 Jul-18-2022, 04:04 PM
Last Post: Extra
  [Tkinter] Open tkinter colorchooser at toplevel (so I can select/focus on either window) tabreturn 4 1,831 Jul-06-2022, 01:03 PM
Last Post: deanhystad
  [PyQt] [Solved]Display Search Results in QTable Extra 5 2,387 Jun-29-2022, 10:20 PM
Last Post: Extra
  [Tkinter] Background inactivity timer when tkinter window is not active DBox 4 2,864 Apr-16-2022, 04:04 PM
Last Post: DBox
  why my list changes to a string as I move to another window in tkinter? pymn 4 2,546 Feb-17-2022, 07:02 AM
Last Post: pymn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020