Thank you. But I have already used that.if coffee_maker.is_resource_sufficient(drink):
me method eka danna.
coffee_maker.is_resource_sufficient(drink):Thank you. But I have already used that.
else:
drink = menu.find_drink(user_choice)
if coffee_maker.is_resource_sufficient(drink):
if money_machine.make_payment(drink.cost):
coffee_maker.make_coffee(drink)
But
make_coffee(order)
and
make_payment(cost)
don't reduce the available ingredients and addition of the profit as described in the DB.
is_on = True
while is_on:
menu = Menu()
coffee_maker = CoffeeMaker()
money_machine = MoneyMachine()
user_choice = input(f"What item do you want to order? {menu.get_items()} : ")
if user_choice == 'report':
coffee_maker.report()
money_machine.report()
elif user_choice == 'off':
is_on = False
else:
drink = menu.find_drink(user_choice)
if coffee_maker.is_resource_sufficient(drink):
if money_machine.make_payment(drink.cost):
coffee_maker.make_coffee(drink)
menu = Menu()
coffee_maker = CoffeeMaker()
money_machine = MoneyMachine()
is_on = True
while is_on:
user_choice = input(f"What item do you want to order? {menu.get_items()} : ")
if user_choice == 'report':
coffee_maker.report()
money_machine.report()
elif user_choice == 'off':
is_on = False
else:
drink = menu.find_drink(user_choice)
if coffee_maker.is_resource_sufficient(drink):
if money_machine.make_payment(drink.cost):
coffee_maker.make_coffee(drink)
Yes. Qt5 designer tool එක ඕනෙ. හැබැයි python GUI ඉගෙන ගන්න ඕනෙ නෑ බන්. python වලින් UI development ඉගෙනගෙන තේරුමක් නෑ. පට්ට අමරුයි. හෙන වදයක් විදින්න ඕනෙ. ඊට වඩා ලේසියෙන් GUI හදන්න පුලුවන් වෙන ලැන්ග්වෙජ්ස් වලින්.ekata Qt danaganna one neda?
ඒ කියන්නෙ Qt වලින් GUI එක ඩිසයින් කරලා පයිතන් එකෙන් බැක් එන්ඩ් එක ගහනවා වගේ දෙයක්ද?Yes. Qt5 designer tool එක ඕනෙ. හැබැයි python GUI ඉගෙන ගන්න ඕනෙ නෑ බන්. python වලින් UI development ඉගෙනගෙන තේරුමක් නෑ. පට්ට අමරුයි. හෙන වදයක් විදින්න ඕනෙ. ඊට වඩා ලේසියෙන් GUI හදන්න පුලුවන් වෙන ලැන්ග්වෙජ්ස් වලින්.
ඔවු. වැඩේ තියෙන්නෙ එකම ide එකේ ඕක කරන්න බෑ. pyqt5 වලින් මුලින් ඩිසයින් කරල ෆයිල් එක generate කරගන්න ඕනෙ. ඊට පස්සෙ ඒකට action listener events වෙනම ලියන්න ඕනෙ. ඔය අතරෙ ui එකේ edit එකක් ගහන්න ඕනෙ උනොත් ආයිත් වෙනම qt5 open කරල ui file එක edit කරල generate කරල pycharm දාගෙන code කරන්න ඕනෙ. ඕක මල ඇනයක්.ඒ කියන්නෙ Qt වලින් GUI එක ඩිසයින් කරලා පයිතන් එකෙන් බැක් එන්ඩ් එක ගහනවා වගේ දෙයක්ද?
එහෙමනම් PyQt ඉගෙන ගන්න ඕනෙ. මුලින් පයිතන් ටික ඉවර කරලා ඒක පටන් ගන්නවා.
ඒ අතර දවස ගානෙ Qt ටිකක් කරගන්න තිබ්බා නම් හරි.
Seems like you are skipping a lot. Any reason?#Day_31 - Intermediate
Flash Card App Capstone Project (51min)
Skipped
#Day_32
Intermediate+ Send Email (smtplib) & Manage Dates (datetime) (1hr 2min)
Gmail 2 step verification enable කරල නම් app password එකක් හදා ගන්න පුලුවන් yahoo email වගේම.
manage your google account --> security --> 2 step verification settings වල තියෙනව
tkinter වැඩක් නෑ බන්. ඕව පුරුදු උනා කියල practically use කරන්න බෑ. මොකද practical projects way beyond. heavy GUI තියෙද්දි ඒව editor එකේ code කර කර හදන්න බෑ. drag and drop with properties ඕනෙ. ඉතින් කාලෙ කන එක තේරුමක් නෑ.Seems like you are skipping a lot. Any reason?
import smtplib
def send_gmail(user, password, recepient, subject, msg):
with smtplib.SMTP("smtp.gmail.com") as connection:
connection.starttls()
connection.login(user=user, password=password)
connection.sendmail(from_addr=user, to_addrs=recepient,
msg=f"Subject:{subject}\n\n{msg}")
Practical නැත්නම් කෝස් එකට දාලා තියෙන්නෙ බේසික් කියා දෙන්න හින්දා වෙන්න පුලුවන්. මම නම් ස්කිප් කරන්න අදහසක් නෑ. බලමු. කොහොමත් මෙතෙක් තිබ්බ කෝඩ් වලත් Dr. Angela ලියනවට වඩා කෙටියෙන් කෝඩ් එක ගහන්න පුලුවන් තැන් තිබුනා.tkinter වැඩක් නෑ බන්. ඕව පුරුදු උනා කියල practically use කරන්න බෑ. මොකද practical projects way beyond. heavy GUI තියෙද්දි ඒව editor එකේ code කර කර හදන්න බෑ. drag and drop with properties ඕනෙ. ඉතින් කාලෙ කන එක තේරුමක් නෑ.
උදාහරනෙකට ගත්තොත් දැන් මන් Java වලින් email දහස් ගානක් commercially යවල ඇති. හැබැයි මට java වලින් දැන් scratch වල ඉදන් code එකක් ලියල email එකක් යවන්න කිව්වොත් පටන් ගන්නවත් දන්නෙ නෑ. හිතාගන්නත් බෑ. මම කරන්නෙ modules හදාගන්න එක. ඕනෙ වෙලාවට class එක හදල method එක call කරනව. සරලයි. Dr.Angela ගෙ code exercise වල උනත් මම එකම දේ කරන්නෙ නෑ. වැඩක් නෑ බන්. අපි Java එක්ක එක මාසයක් ඔට්ටු උන ගමන් python ඔක්කොම අමතක වෙනව. ඒ නිසා පුලුවන් තරම් modules හදල method call එක තමා ලේසිම වැඩේ.
ex-- අද lesson එකෙන් මම මේ basic email module එකක් හදා ගත්ත. දැන් google කරකර මේකට attachment ගොඩක් දාන්නෙ කොහොමද, recipients ගොඩක් දාන්නෙ කොහොමද කියල බලනව. ඒව lesson එකේ නෑ. ඊට පස්සෙ ඒ ඔක්කොම method ටික හදාගෙන module එක built කරගන්නව. පස්සෙ දවසක email එකක් python වලින් යවන්න ඕනෙ උනොත් attachment එකක් කරලද, නැතුවද recipients ගොඩක්ද, එකෙක්ද එ ඔක්කොටම methods ටික තියෙනව. 1min වලින් වැඩේ ගොඩ.
Python:import smtplib def send_gmail(user, password, recepient, subject, msg): with smtplib.SMTP("smtp.gmail.com") as connection: connection.starttls() connection.login(user=user, password=password) connection.sendmail(from_addr=user, to_addrs=recepient, msg=f"Subject:{subject}\n\n{msg}")


import smtplib
import ssl
from email import encoders
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
port = 465 # For SSL
# Create a secure SSL context
context = ssl.create_default_context()
def send_gmail(user, password, recipients, subject, msg):
# with smtplib.SMTP("smtp.gmail.com") as connection:
with smtplib.SMTP_SSL("smtp.gmail.com", port=port, context=context) as connection:
# connection.starttls()
connection.login(user=user, password=password)
connection.sendmail(from_addr=user, to_addrs=recipients,
msg=f"Subject:{subject}\n\n{msg}")
def send_gmail_rich_text(user, password, recipients, subject, text="", html=""):
message = MIMEMultipart()
message["Subject"] = subject
message["From"] = user
if isinstance(recipients, str):
message["To"] = recipients
else:
message["To"] = ", ".join(recipients)
# Turn these into plain/html MIMEText objects
text_part = MIMEText(text, "plain")
html_part = MIMEText(html, "html")
# Add HTML/plain-text parts to MIMEMultipart message
# The email client will try to render the last part first
message.attach(text_part)
message.attach(html_part)
with smtplib.SMTP_SSL("smtp.gmail.com", port=port, context=context) as connection:
connection.login(user=user, password=password)
connection.sendmail(from_addr=user, to_addrs=recipients, msg=message.as_string())
def send_gmail_attachments(user, password, recipients, subject, file_name, text="", html=""):
message = MIMEMultipart()
message["Subject"] = subject
message["From"] = user
if isinstance(recipients, str):
message["To"] = recipients
message["Bcc"] = recipients # Recommended for mass emails
else:
receivers = ", ".join(recipients)
message["To"] = receivers
message["Bcc"] = receivers # Recommended for mass emails
text_part = MIMEText(text, "plain")
html_part = MIMEText(html, "html")
message.attach(text_part)
message.attach(html_part)
with open(file_name, "rb") as attachment:
# Add file as application/octet-stream
# Email client can usually download this automatically as attachment
part = MIMEBase("application", "octet-stream")
part.set_payload(attachment.read())
# Encode file in ASCII characters to send by email
encoders.encode_base64(part)
# Add header as key/value pair to attachment part
part.add_header(
"Content-Disposition",
f"attachment; filename= {file_name}",
)
# Add attachment to message
message.attach(part)
with smtplib.SMTP_SSL("smtp.gmail.com", port=port, context=context) as connection:
connection.login(user=user, password=password)
connection.sendmail(from_addr=user, to_addrs=recipients, msg=message.as_string())
me oya hadapu ekak da?
na nikan damme. wenasakatath ekka.me oya hadapu ekak da?![]()