Hello @ all,
i am testing out a first Tkinter python program on different OS. On Raspbian ( Stretch ) i run this program under IDLE and IDLE3 and from Geany ( 1.29 ). The code is :
`
#from Tkinter import * # Python 2
from tkinter import * # Python 3
def upper_radio_button_pressed():
canvas.create_image(20,20, anchor=NW, image=blue_img)
def lower_radio_button_pressed():
canvas.create_image(20,20, anchor=NW, image=red_img)
class App:
def init(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame,
text="QUIT", fg="red",
command=frame.quit)
self.button.pack(side=LEFT)
self.slogan = Button(frame,
text="Hello",
command=self.write_slogan)
self.slogan.pack(side=LEFT)
def write_slogan(self): # definition of function write slogan. The text is written in the command line box only if the button Hello is pressed.
print ("Tkinter is easy to use!")
root = Tk()
root.title("First python Tkinter window")
root.geometry("500x600+30+30")
w = Label(root, text="Red Label", bg="red", fg="white")
w.pack(fill=X,pady=10)
v = IntVar()
entry1 = Entry(root)
entry2 = Entry(root)
Label(root,
text="""Choose a
programming language:""",
justify = LEFT,
padx = 20).pack()
Radiobutton(root,
text="Python",
padx = 20,
variable=v,
value=1,
command=upper_radio_button_pressed).pack(anchor=W) # call the function upper_radio_button pressed
Radiobutton(root,
text="Perl",
padx = 20,
variable=v,
value=2,
command=lower_radio_button_pressed).pack(anchor=W)# call the function upper_radio_button pressed
canvas_width = 200
canvas_height = 100
canvas = Canvas(root,
width=canvas_width,
height=canvas_height)
canvas.pack()
#definition of picture blue_img
blue_img = PhotoImage(file="/Users/holgerlech/Documents/85_Computer/Python/Quadrat_gelb_mit Smilie.PPM")
#definition of picture red_img
red_img = PhotoImage(file="/Users/holgerlech/Documents/85_Computer/Python/Rechteck_gelb_mit_Punkt_rot.gif")
app = App(root)
Label(root,text="Vorname:").pack()
vorname = entry1.pack()
Label(root,text="Nachnahme:").pack()
nachname = entry2.pack()
#start window loop
root.mainloop()
print(vorname)
print(nachname)
`
In IDLE the Tk window was opened but in Geany only a Terminal window with "geany_run_script_93XQp0.sh" appears and that's it, nothing more happens. On Mac OS a script is started too, but then the Tk windows appears. Whats wrong here ?
Thank You very much !
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.