You are not logged in.

#1 2009-08-17 18:11:02

B4RR13N705
Member
Registered: 2009-06-08
Posts: 87

Python ,Tk labels and variables.

Hi, im learning a bit about Tk, and im making a little script that show your architecture(i686,etc). This is my code:

mport os
from Tkinter import *
root = Tk()
frame = Frame(root, width=500, height=100)
frame.pack()
label = Label(frame, text="Press Get! to know your arch.")
label.pack()
def get():
        v = StringVar()
        v.set(os.system('arch'))
        out = Label(frame, textvariable=v, bg="black", fg="white")
        out.pack()
button = Button(frame, text="Get!", command=get)
button.pack()
root.mainloop()

But i cant get the arch command out printed in a label, i get a '0'...

Last edited by B4RR13N705 (2009-08-17 18:12:54)


OS -----> Arch Linux     DE -----> KDE4
CPU ---> 2.66GHz         RAM ---> 512 MB
SWAP -> 2 G                / -------> 10 G
/home -> 50 G             /boot ---> 64 MB

Offline

#2 2009-08-17 20:06:32

tlvb
Member
From: Sweden
Registered: 2008-10-06
Posts: 297
Website

Re: Python ,Tk labels and variables.

The zero returned is the exit value/return value from the command 'arch' not stdout.
you probably want to use os.popen() instead, possibly os.popen('arch').read().


I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.

Offline

Board footer

Powered by FluxBB