Mar-26-2022, 02:16 PM
(This post was last modified: Mar-26-2022, 04:49 PM by LinuxLife.
Edit Reason: Added prefix
)
hello all!
first time here,to ask for your support...
got this code in my attached file.it has two buttons,and two different functions.
the problem is that it does not run....!
if i remove the one block or the other,works fine,but not all together....
pls take a look,and advice.....thank you all!
here is my code:
first time here,to ask for your support...
got this code in my attached file.it has two buttons,and two different functions.
the problem is that it does not run....!
if i remove the one block or the other,works fine,but not all together....
pls take a look,and advice.....thank you all!
here is my code:
import tkinter as tk def main(): window= tk.Tk() window.title("ΕΚΑΤΟΣΤΑ to ΛΙΤΡΑ Converter") window.geometry("675x400") # block 1 - the first question # create a label with text Enter ΕΚΑΤΟΣΤΑ label1 = tk.Label(window, text="ΠΟΣΑ ΕΚΑΤΟΣΤΑ ΕΧΕΙΣ:") # create a label with text ΛΙΤΡΑ: label2 = tk.Label(window, text="ΕΧΕΙΣ ΛΙΤΡΑ:") # place label1 in window at position x,y label1.place(x=50,y=30) # create an Entry widget (text box) textbox1 = tk.Entry(window, width=12) # place textbox1 in window at position x,y textbox1.place(x=200,y=35) # create an Entry widget (text box) textbox2 = tk.Entry(window, width=12) # place label2 in window at position x,y label2.place(x=50,y=100) # create a label3 with empty text: label3 = tk.Label(window, text=" ") # place label3 in window at position x,y label3.place(x=180,y=100) def btn1_click(): ΛΙΤΡΑ = round(float(textbox1.get()) * 10) label3.configure(text = str(ΛΙΤΡΑ)+ ' ΛΙΤΡΑ') # create a button with text Button 1 btn1 = tk.Button(window, text="ΠΑΤΗΣΕ ΓΙΑ ΝΑ ΒΡΕΙΣ ΤΑ ΛΙΤΡΑ", command=btn1_click) # place this button in window at position x,y btn1.place(x=90,y=150) window.mainloop() # block 2 - LITRA SE EKATOSTA =========== # create a label with text Enter ΛΙΤΡΑ label4 = tk.Label(window, text="ΠΟΣΑ ΛΙΤΡΑ ΠΑΡΑΓΓΕΙΛΕΣ: ") # create a label with text ΛΙΤΡΑ: label5 = tk.Label(window, text="ΤΑ ΛΙΤΡΑ ΑΥΤΑ ΕΙΝΑΙ :") # place label2 in window at position x,y label5.place(x=50,y=600) # place label1 in window at position x,y label4.place(x=50,y=530) # create an Entry widget (text box) textbox2 = tk.Entry(window, width=12) # place textbox1 in window at position x,y textbox2.place(x=200,y=530) # create a label3 with empty text: label6 = tk.Label(window, text=" ") # place label3 in window at position x,y label6.place(x=180,y=600) def btn2_click(): ΛΙΤΡΑ = round(float(textbox2.get()) / 10) label6.configure(text = str(ΛΙΤΡΑ)+ ' ΕΚΑΤΟΣΤΑ') # create a button with text Button 2 btn2 = tk.Button(window, text="ΠΑΤΗΣΕ ΓΙΑ ΝΑ ΒΡΕΙΣ ΤΑ ΕΚΑΤΟΣΤΑ", command=btn2_click) # place this button in window at position x,y btn2.place(x=90,y=650) window.mainloop() # end of block 2 ===================================== main()
Attached Files
teliko.py (Size: 2.67 KB / Downloads: 188)