Python Forum
[Tkinter] output to canvas widget
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] output to canvas widget
#1
First post here on this new forum.

I'm trying to get a windows 'dir' command output to display in a canvas widget. Ultimately I want to built an interactive program than will display the output in the canvas widget; this is the first step to get it working.

from Tkinter import *
import subprocess

class window:


   def __init__(self, parent):
       self.frame=Frame(parent)
       self.frame.pack()
       self.gobutton = Button(self.frame, text="Go", command=self.dircall)
       self.gobutton.grid(row=0, column=1)
       self.canvas = Canvas(root, width = 100, height = 100, bg = "white")
       self.canvas.pack()
   def dircall(self):
       output=subprocess.call(["dir", "c:"], shell=True)
       self.canvas.create_text(25, 25, text=output, tags="text")


root = Tk()
root.geometry("200x200")
runit=window(root)
root.mainloop()
When started the GUI opens and then when the button is clicked the output is a 0 and the output from the dir command goes to the run output part of my IDE. I don't get and error, it just doesn't quite do what I want it to.

Any help pointing me to the solution would be appreciated.
Reply


Messages In This Thread
output to canvas widget - by freakbot - Dec-01-2016, 06:18 AM
RE: output to canvas widget - by heiner55 - Dec-01-2016, 07:00 AM
RE: output to canvas widget - by Larz60+ - Dec-01-2016, 12:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] canvas widget scroll issue chrisdb 2 3,898 Apr-07-2021, 05:48 AM
Last Post: chrisdb
  [Tkinter] How to erase previous output from the canvas? Pedroski55 4 4,549 Jul-05-2020, 10:25 PM
Last Post: Pedroski55
  How to place global tk text widget in class or on canvas puje 1 2,345 Jul-04-2020, 09:25 AM
Last Post: deanhystad
  The coordinates of the Entry widget (canvas) when moving berckut72 8 5,968 Jan-07-2020, 09:26 AM
Last Post: berckut72
  [Tkinter] Resizing image inside Canvas (with Canvas' resize) Gupi 2 25,127 Jun-04-2019, 05:05 AM
Last Post: Gupi

Forum Jump:

User Panel Messages

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