Python Forum

Full Version: import numbers into a list and print (gui python)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I import numbers into a list in Python's graphic environment (gui of python) and how to print them through a button


Thanks in advance
Which graphics toolkit?  tk?  gtk?  qt?  wx?  Something else?
(Aug-09-2017, 06:54 PM)nilamo Wrote: [ -> ]Which graphics toolkit?  tk?  gtk?  qt?  wx?  Something else?

graphics toolkit Tk
What do you have so far?  What errors are you getting?
(Aug-09-2017, 07:16 PM)nilamo Wrote: [ -> ]What do you have so far?  What errors are you getting?


I do not have any errors in code
I ask for an basic example to create it at the beginning

(Aug-09-2017, 07:48 PM)kostasalgo Wrote: [ -> ][quote='nilamo' pid='22586' dateline='1502306181']
What do you have so far?  What errors are you getting?


I do not have any errors in code
I ask for an basic example to create it at the beginning

example
Ab=[]
for i in range(3):
Ab.append(input('Give a num='))
print (Ab)
I'm not sure what importing a list of numbers means, but here's a simple example of how to have a click handler attached to a button:
import tkinter as tk


class Items:
    def __init__(self, data):
        self.data = data

    def click(self):
        print(self.data)


root = tk.Tk()
things = Items(["spam", "eggs"])
button = tk.Button(root, text="Print the things", command=things.click)
button.pack()
root.mainloop()