Hack Forums
[Python] How to print cli script into the tkinter gui window - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] How to print cli script into the tkinter gui window (/showthread.php?tid=5611406)



How to print cli script into the tkinter gui window - Morphine - Apr 29, 2017

Hi, i want to make in python 2.7 with Tkinter module to print the function or other script is made in cli to window (sorry for my bad english)
Im new in Tkinter module so i just want to make something like this in gui
https://imgur.com/a/L043n
Only to print my function or my script there like if user click the button the script will run in gui like in cli


* - Malicious Intent - Apr 29, 2017

pyQT is better for this and comes with designer.
in thinter simply use button widget ... here is the example i found.

Code
import Tkinter as tk

counter = 0
def counter_label(label):
  counter = 0
  def count():
    global counter
    counter += 1
    label.config(text=str(counter))
    label.after(1000, count)
  count()


root = tk.Tk()
root.title("Counting Seconds")
label = tk.Label(root, fg="dark green")
label.pack()
counter_label(label)
button = tk.Button(root, text='Stop', width=25, command=root.destroy)
button.pack()
root.mainloop()