본문 바로가기
[파이썬 python] tkinter - listbox 리스트박스 참고사이트: 유튜브 나도코딩 code - 창, 크기 조절하기 code 설명 import tkinter as tk root = tk.Tk() # tkinter root창 생성 root.title("계산기") #창 이름 root.geometry("500x500+200+200") # 창 크기, 가로 x 세로 + 창 출력 위치 좌표 ''' height=0 : list숫자만큼 자동으로 생성 height=3 : list 3개만 보이게 생성 ''' listbox = tk.Listbox(root, selectmode="extend", height=0) listbox.insert(0, "구글") listbox.insert(1, "애플") listbox.insert(2, "삼성") listbox.insert(tk.END,.. 2021. 9. 5.
[파이썬 python] tkinter - 텍스트 text, 엔트리 entry, 글자입력받는 빈칸만들기 참고사이트: 유튜브 나도코딩 code - 창, 크기 조절하기 code 설명 import tkinter as tk root = tk.Tk() # tkinter root창 생성 root.title("계산기") #창 이름 root.geometry("500x500+200+200") # 창 크기, 가로 x 세로 + 창 출력 위치 좌표 ''' text 입력할 수 있는 네모창 만들기 ''' text = tk.Text(root, width=30, height=5) text.pack() ''' text창에 기본값으로 미리 입력해두기 ''' text.insert(tk.END, "글자를 입력하세요") ''' 엔트리: 엔터가 불가능한 한줄짜리 text창 만들기 ''' e = tk.Entry(root, width=30) e.p.. 2021. 9. 5.
[파이썬 python] tkinter - label 레이블 기능(글자 입력 / 클릭시 사진 바꾸기) 참고사이트: 유튜브 나도코딩 code - label 기능 code 설명 import tkinter as tk root = tk.Tk() # tkinter root창 생성 root.title("계산기") #창 이름 root.geometry("500x500+200+200") # 창 크기, 가로 x 세로 + 창 출력 위치 좌표 ''' 글자 입력하기 ''' label1 = tk.Label(root, text="누굴까") label1.pack() ''' 사진 입력하기 ''' photo = tk.PhotoImage(file="iu.png") label2= tk.Label(root, image=photo) label2.pack() ''' 버튼 클릭시 label1의 내용 변경시키기 ''' def change_a(): .. 2021. 9. 5.
[파이썬 python] tkinter - 버튼 기능 참고사이트: 유튜브 나도코딩 code - 버튼 기능 code 설명 import tkinter as tk root = tk.Tk() # tkinter root창 생성 root.title("계산기") #창 이름 ################################################# ''' 창 크기, 가로 x 세로 + 창 출력 위치 좌표 ''' root.geometry("300x500+200+200") ################################################# ''' 기본 버튼 기능 ''' button1 = tk.Button(root, text="버튼1") button1.pack() ############################################.. 2021. 8. 25.
[파이썬 python] tkinter - 창, 크기 조절 참고사이트: 유튜브 나도코딩 창, 크기 조절하기 소스 코드 설명 import tkinter as tk root = tk.Tk() # tkinter root창 생성 root.title("계산기") #창 이름 #root.geometry("500x500") # 창 크기, 가로 x 세로 root.geometry("500x500+200+200") # 창 크기, 가로 x 세로 + 창 출력 위치 좌표 root.resizable(True,False) # 가로축, 세로축 크기 마우스로 조절 불가 root.mainloop() #mainloop 선언해야 root창이 종료되지 않고 계속 실행됨 결과 화면 2021. 8. 24.
[파이썬 python] 전화번호부 만들기 - 미니 프로젝트 목표 기능 1. 로그인 기능 2. 연락처 추가 3. 연락처 삭제 4. 연락처 검색 5. module, class 사용하기 소스 코드 import getpass import os import phonebook_extra ''' 로그인 기능 ID/비밀번호 확인하기 ''' get_id = input("ID 입력: ") ''' pycharm 에서 실행하기 getpass 실행하기 위해서는 'edit configuration'에서 emulate terminal in output console 선택 필수 ''' get_password = getpass.getpass("비밀번호 입력: ") print(get_password) if get_id == "master" and get_password == "1234": pr.. 2021. 8. 15.
[파이썬 python] 바탕화면 경로 설정하는 법 바탕화면 경로 설정하는 법 import os save_file_name = "test.txt" windows_user_name = os.path.expanduser('~') print(windows_user_name) try: os.makedirs(f'{windows_user_name}//Desktop//PhoneBook') except FileExistsError: pass phonebook_file = f'{windows_user_name}//Desktop//PhoneBook//{save_file_name}' with open(phonebook_file, 'w') as f: f.write(f'이름:철수\n') f.write(f'번호:010-9999-9999\n') f.write(f'생일:2002040.. 2021. 5. 29.
[파이썬 python] 메뉴 선택하는 기능 구현하기 python으로 메뉴 선택하는 기능 함수로 구현하기 def print_menu(): print("----------------") print("1. 연락처 추가") print("2. 연락처 삭제") print("3. 연락처 검색") print("4. 연락처 삭제") print("5. 나가기") inputed_number = int(input("번호를 입력하세요:")) if inputed_number == 1: print("저장할 연락처를 입력하세요") elif inputed_number == 2: print("삭제할 연락처를 입력하세요") elif inputed_number == 3: print("검색할 연락처를 입력하세요") elif inputed_number == 4: print("삭제할 연락처를 입.. 2021. 5. 29.
[파이썬 python] 클래스 상속 이해하기 클래스 상속 class # 클래스 상속 # Parent Class, Super Class : 물려주는 클래스 # Child Class, Sub class : 물려받는 클래스 # 클래스 상속을 이용하면 Super(parent) Class의 속성을 Sub(child) Class에서 사용이 가능 class Animal: # Super class 생성 name = "동물" age = "나이" living = "산" def print(self): print(f'여기는 super class 의 print 메서드 입니다.') def print_2(self): print(f'여기는 super class 의 print_2 메서드 입니다.') class Cat(Animal): # Sub class 생성 def __init.. 2021. 1. 14.
[파이썬 python] 클래스 class 이해하기 클래스 class class StudentInformation: # 생성자란? # 메서드 이름으로 __init__을 사용하면 메서드는 생성자가됨 # 메서드(method): 클래스 안에 구현됨 함수 # 객체에 초기값을 설정할 때 사용 def __init__(self, name, hobby, age): self.name = name self.age = age self.hobby = hobby # 메서드(method): 클래스 안에 구현됨 함수 def say_introduce(self): print(f'제 이름은{self.name}이고 취미는 {self.hobby}이며 나이는 {self.age}입니다.') # 클래스 변수는 클래스 내에서 동일하게 공유 grade = "A" print("\n1----------.. 2021. 1. 12.
[파이썬 python] 함수 function 이해하기 함수 function ''' 함수 function 란? - 자주 사용하는 기능은 함수를 활용하여 저장해두고 필요할 경우마다 호출해서 사용 매개변수(parameter) : 매개변수는 함수에 입력으로 전달된 값을 받는 변수 인수(arguments): 인수는 함수를 호출할 때 전달하는 입력값 def add(a, b): # a, b는 매개변수 return a+b print(add(3, 4)) # 3, 4는 인수 ''' print("1-----------") print("매개변수, 인수가 있는 함수 #1") def add(a,b): result = a + b print(f'{a} + {b} = {result}') add(3,4) print("\n2-----------") print("매개변수, 인수가 있는 함수 .. 2021. 1. 8.
반응형

loading