ตอนนี้มันยังไม่ค่อยเข้าใจหลักการ Class ใน python ซักเท่าไหร่ตอนนี้ผมต้องการแค่กด submit แล้วมันจะแสดงค่าที่เราเขียนไปครับ
https://www.picz.in.th/images/2018/10/28/37uFuW.png
code ใน python
from tkinter import*
#style GUI
gui=Tk()
gui.title('Profit Calculator')
'''gui.geometry('700x500')'''
Material=StringVar()
WxW=StringVar()
Income=StringVar()
#class and function
class submitbuttom:
def __init__(self,Material):
self.Material=Material.get()
def __init__(self,WxW):
self.WxW=WxW.get()
def __init__(self,Income):
self.Income=Income.get()
#Lable
Earn_Label=Label(gui,text='Earnings statement',font='times 24')
Material_Label=Label(gui,text='Material')
WxW_Label=Label(gui,text='Wage x Worker')
Income_Label=Label(gui,text='Merchantable')
#Entry
EntryMat=Entry()
EntryWW=Entry()
EntryIn=Entry()
#Button
Submit=Button(text='Submit',Command='submitbuttom')
#grid
Earn_Label.grid(columnspan=2)
Material_Label.grid(row=1,column=0)
WxW_Label.grid(row=2,column=0)
EntryMat.grid(row=1,column=1)
EntryWW.grid(row=2,column=1)
Income_Label.grid(row=3,column=0)
EntryIn.grid(row=3,column=1)
Submit.grid(row=4,column=1,sticky=E)
gui.mainloop()
ที่มันขึ้น Error
Traceback (most recent call last):
File "D:\Work\Python\Project\Program.py", line 29, in <module>
Submit=Button(text='Submit',Command='submitbuttom')
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 2366, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 2296, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: unknown option "-Command"
ขอบคุณครับ
ใครเขียน python เก่งช่วยหน่อยครับ
https://www.picz.in.th/images/2018/10/28/37uFuW.png
code ใน python
from tkinter import*
#style GUI
gui=Tk()
gui.title('Profit Calculator')
'''gui.geometry('700x500')'''
Material=StringVar()
WxW=StringVar()
Income=StringVar()
#class and function
class submitbuttom:
def __init__(self,Material):
self.Material=Material.get()
def __init__(self,WxW):
self.WxW=WxW.get()
def __init__(self,Income):
self.Income=Income.get()
#Lable
Earn_Label=Label(gui,text='Earnings statement',font='times 24')
Material_Label=Label(gui,text='Material')
WxW_Label=Label(gui,text='Wage x Worker')
Income_Label=Label(gui,text='Merchantable')
#Entry
EntryMat=Entry()
EntryWW=Entry()
EntryIn=Entry()
#Button
Submit=Button(text='Submit',Command='submitbuttom')
#grid
Earn_Label.grid(columnspan=2)
Material_Label.grid(row=1,column=0)
WxW_Label.grid(row=2,column=0)
EntryMat.grid(row=1,column=1)
EntryWW.grid(row=2,column=1)
Income_Label.grid(row=3,column=0)
EntryIn.grid(row=3,column=1)
Submit.grid(row=4,column=1,sticky=E)
gui.mainloop()
ที่มันขึ้น Error
Traceback (most recent call last):
File "D:\Work\Python\Project\Program.py", line 29, in <module>
Submit=Button(text='Submit',Command='submitbuttom')
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 2366, in __init__
Widget.__init__(self, master, 'button', cnf, kw)
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 2296, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: unknown option "-Command"
ขอบคุณครับ