반응형
반응형

[python] chatGPT에게 TicTacToe 만들어달라고 했다. 

import tkinter as tk
from tkinter import messagebox

class TicTacToe:
    def __init__(self, root):
        self.root = root
        self.root.title("Tic-Tac-Toe")

        self.current_player = "X"
        self.board = [""] * 9

        self.buttons = []
        for i in range(9):
            button = tk.Button(root, text="", width=10, height=3, command=lambda i=i: self.make_move(i))
            button.grid(row=i // 3, column=i % 3)
            self.buttons.append(button)

    def make_move(self, position):
        if not self.board[position]:
            self.board[position] = self.current_player
            self.buttons[position].config(text=self.current_player)
            
            if self.check_winner():
                messagebox.showinfo("Game Over", f"Player {self.current_player} wins!")
                self.reset_game()
            elif all(cell != "" for cell in self.board):
                messagebox.showinfo("Game Over", "It's a draw!")
                self.reset_game()
            else:
                self.current_player = "O" if self.current_player == "X" else "X"

    def check_winner(self):
        winning_combinations = [(0, 1, 2), (3, 4, 5), (6, 7, 8),
                                (0, 3, 6), (1, 4, 7), (2, 5, 8),
                                (0, 4, 8), (2, 4, 6)]

        for combo in winning_combinations:
            if self.board[combo[0]] == self.board[combo[1]] == self.board[combo[2]] != "":
                return True
        return False

    def reset_game(self):
        self.current_player = "X"
        self.board = [""] * 9
        for button in self.buttons:
            button.config(text="")

if __name__ == "__main__":
    root = tk.Tk()
    game = TicTacToe(root)
    root.mainloop()
반응형
반응형

나에게 가난한 집 아이, 부잣집 아이 가운데 한 명을 선택해 가르쳐야 한다면,
나는 망설임 없이 부잣집 아이를 택하겠소.
가난한 집 아이들은 가난이 가르쳐준 것이 너무 많기 때문이오.
- 장 자크 루소, ‘에밀’에서


일상적 선물이 즐거움을 안겨준다면 시련이라는 선물은 인격을 닦게 해줍니다.
힘들고 어려울 때일수록 인간은 더욱 견고해지고 숙련되는 법입니다.
싫어도 할 수 밖에 없는 일을 계속해 나가면서
알게 모르게 인생의 만병통치약을 찾아냅니다.
필사적으로 일할 수밖에 없기 때문에 시련을 참고 견디는 힘도 커집니다.
가난과 역경은 나를 단련시키기 위해 신이 내게 준 선물일 가능성이 큽니다.

반응형
반응형

독일은 나치의 만행과
제2차 세계대전에서의 패배를 겪은 뒤
만신창이가 된 국가를 일으켜 세우기 위해
'시민 교육'을 실시했다. 사회 전체를 개혁하고
변화시키기 이전에, 더 중요한 것은 개인이 행복할 수
있도록, 스스로 삶을 개척할 수 있도록 사회적
기반을 마련하는 것이라 여겼다. 그러한
개개인이 모두 공동체의 일원이 될 수
있도록 하는 것이 피폐해진 독일을
재건하는 방법이었다.


- 인디고 서원의 《인디고 바칼로레아 1》 중에서 -


* 이번 'BDS 독일 캠프'를 진행하며
다녀온 독일 사회의 밑바탕에 '시민 교육'의 힘이
자리잡고 있음을 다시금 실감했습니다. 국민 한 사람
한 사람이 행복할 수 있다면 그 가정이, 그 마을이,
그 도시가, 그 나라가 행복할 것입니다. 더 나아가
온 인류가, 온 지구가 보다 더 안전하고 행복할
것입니다. 각 개인의 안녕이 전체의 질서를
이루고 국가를 바로 세우는 일입니다.

반응형

'아침편지' 카테고리의 다른 글

살아 있음에 감사하렴  (0) 2023.08.23
거울 속의 흰머리 여자  (0) 2023.08.22
희망  (0) 2023.08.20
내면의 에너지 장  (0) 2023.08.18
오래 볼수록 더 반짝이는 별  (0) 2023.08.17
반응형

반응형
반응형

길은 있다

반응형

'아침편지' 카테고리의 다른 글

거울 속의 흰머리 여자  (0) 2023.08.22
독일의 '시민 교육'  (0) 2023.08.21
내면의 에너지 장  (0) 2023.08.18
오래 볼수록 더 반짝이는 별  (0) 2023.08.17
시간이라는 약  (0) 2023.08.16
반응형

https://pypi.org/project/secure-smtplib/

 

secure-smtplib

Secure SMTP subclasses for Python 2

pypi.org

secure-smtplib 0.1.1

 

pip install secure-smtplib

 

 

.chatGPT에게 " python email sending app " 이라고 질문했다. 

# chatGPT - python email sending app 
import tkinter as tk
from tkinter import messagebox
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

def send_email():
    sender_email = sender_email_entry.get()
    sender_password = sender_password_entry.get()
    recipient_email = recipient_email_entry.get()
    subject = subject_entry.get()
    message = message_text.get("1.0", tk.END)
    
    try:
        # Set up the SMTP server
        smtp_server = smtplib.SMTP("smtp.gmail.com", 587)
        smtp_server.starttls()
        smtp_server.login(sender_email, sender_password)
        
        # Create the email
        email = MIMEMultipart()
        email["From"] = sender_email
        email["To"] = recipient_email
        email["Subject"] = subject
        email.attach(MIMEText(message, "plain"))
        
        # Send the email
        smtp_server.sendmail(sender_email, recipient_email, email.as_string())
        smtp_server.quit()
        
        messagebox.showinfo("Success", "Email sent successfully!")
    except Exception as e:
        messagebox.showerror("Error", f"An error occurred: {str(e)}")

# Create the main GUI window
root = tk.Tk()
root.title("Email Sending App")

# Create and place widgets
sender_email_label = tk.Label(root, text="Sender Email:")
sender_email_label.pack()

sender_email_entry = tk.Entry(root)
sender_email_entry.pack()

sender_password_label = tk.Label(root, text="Sender Password:")
sender_password_label.pack()

sender_password_entry = tk.Entry(root, show="*")
sender_password_entry.pack()

recipient_email_label = tk.Label(root, text="Recipient Email:")
recipient_email_label.pack()

recipient_email_entry = tk.Entry(root)
recipient_email_entry.pack()

subject_label = tk.Label(root, text="Subject:")
subject_label.pack()

subject_entry = tk.Entry(root)
subject_entry.pack()

message_label = tk.Label(root, text="Message:")
message_label.pack()

message_text = tk.Text(root, height=10, width=40)
message_text.pack()

send_button = tk.Button(root, text="Send Email", command=send_email)
send_button.pack()

root.mainloop()
반응형

+ Recent posts