Question
How I can change the output size in the insert function [9:03 pm, 27/02/2023] : import tkinter as tk from tkinter import scrolledtext from MovieLens
How I can change the output size in the insert function
[9:03 pm, 27/02/2023] : import tkinter as tk from tkinter import scrolledtext from MovieLens import MovieLens from Hybrid import HybridRecommender
# Initialize MovieLens object and HybridRecommender object ml = MovieLens() ml.loadMovieLensLatestSmall() hybrid = HybridRecommender(ml)
# Define function to handle button click event def recommend_movies(): # Get user input from entry widget user_input = entry.get() # Run input through recommend_movies function recommended_movies = hybrid.recommend_movies(user_input) # Print result to GUI window output.delete(1.0, tk.END) output.insert(tk.INSERT, recommended_movies)
# Create GUI window window = tk.Tk() window.title("Movie Recommender") window.geometry("400x400")
# Create entry widget for user in [9:13 pm, 27/02/2023] : import tkinter as tk import subprocess
def run_command(command): process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, error = process.communicate() if error: return error.decode('utf-8') else: return output.decode('utf-8')
def on_click(): input_text = input_entry.get() output_text = run_command(f"python my_script.py {input_text}") here#### output_display.configure(state='normal') output_display.delete('1.0', tk.END) output_display.insert(tk.END, output_text) output_display.configure(state='disabled')
root = tk.Tk() root.title("Terminal Output in GUI")
input_label = tk.Label(root, text="Input:") input_label.pack()
input_entry = tk.Entry(root) input_entry.pack()
button = tk.Button(root, text="Run", command=on_click) button.pack()
output_label = tk.Label(root, text="Output:") output_label.pack()
output_display = tk.Text(root, state='disabled', height=10, width=50) output_display.pack()
root.mainloop()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started