[Tkinter] How to show text in window? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] How to show text in window? (/thread-27766.html) |
How to show text in window? - wxnerd - Jun-20-2020 Hello, I am looking for help having the text that outputs on the Command Prompt to show on the black box on this program. Any ideas on how to make this happen? import tkinter as tk from tkinter import filedialog, Text import os import time import numpy as np import urllib3 root=tk.Tk() def forecast(): print("My Forecast") def models(): print("Models selected. ") canvas = tk.Canvas(root, height=480, width=640, bg='black') canvas.pack() frame = tk.Frame(root, bg='black') frame.place(relwidth=0.6, relheight=0.6, relx=0.1, rely=0.1) forecast = tk.Button(root, text="Forecasts", padx=2, pady=3, fg='white', bg="red", command = forecast) forecast.pack() models = tk.Button(root, text="Models", padx=2, pady=3, fg='white', bg="red", command = models) models.pack() (Buttons also show as part of the GUI)
RE: TKinter: Same Window Help - Yoriz - Jun-20-2020 The code shown doesn't do anything. Lots of unused imports. RE: TKinter: Same Window Help - wxnerd - Jun-20-2020 (Jun-20-2020, 03:34 PM)Yoriz Wrote: The code shown doesn't do anything.I tested it out and it shows buttons, I forgot the root.mainloop() at the end. Does this change anything? RE: TKinter: Same Window Help - Yoriz - Jun-20-2020 import time import tkinter as tk from tkinter import Text, filedialog root = tk.Tk() def forecast(): print("My Forecast") label['text'] = "My Forecast" def models(): print("Models selected. ") label['text'] = "Models selected. " canvas = tk.Canvas(root, height=480, width=640, bg='black') canvas.pack() frame = tk.Frame(root, bg='black') frame.place(relwidth=0.6, relheight=0.6, relx=0.1, rely=0.1) label = tk.Label(frame, fg='white', bg='black') label.pack() forecast = tk.Button(root, text="Forecasts", padx=2, pady=3, fg='white', bg="red", command=forecast) forecast.pack() models = tk.Button(root, text="Models", padx=2, pady=3, fg='white', bg="red", command=models) models.pack() tk.mainloop() RE: TKinter: Same Window Help - wxnerd - Jun-20-2020 Thank you! |