{"id":26833393,"url":"https://github.com/mr-won/tk_time","last_synced_at":"2025-03-30T15:28:53.125Z","repository":{"id":138423053,"uuid":"453326345","full_name":"mr-won/Tk_time","owner":"mr-won","description":"tkinter 라이브러리를 사용해서 Python 언어로 현재 시각을 알려주는 버튼을 생성하는 프로그램 개발","archived":false,"fork":false,"pushed_at":"2025-03-08T00:57:14.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T02:27:15.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mr-won.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-29T07:20:07.000Z","updated_at":"2025-03-08T00:57:17.000Z","dependencies_parsed_at":"2025-03-18T02:27:19.369Z","dependency_job_id":"3bfa382e-557f-4689-8ad0-a77724ac729a","html_url":"https://github.com/mr-won/Tk_time","commit_stats":null,"previous_names":["wonttan/tk_time","wonchihyeon/tk_time","chihyunwon/tk_time","mr-won/tk_time","chihyeonwon/tk_time"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-won%2FTk_time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mr-won","download_url":"https://codeload.github.com/mr-won/Tk_time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246337851,"owners_count":20761279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-30T15:28:52.636Z","updated_at":"2025-03-30T15:28:53.114Z","avatar_url":"https://github.com/mr-won.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tk_time\ntkinter 라이브러리를 사용해서 Python 언어로 현재 시각을 알려주는 버튼을 생성하는 프로그램 개발\n\n## 25년 다시 복습\n\n## 창 생성\n\n기본적으로 tkinter 라이브러리를 불러오고 창을 만드는 함수 Tk()를 생성 한 뒤 win 변수에 저장한 후 mainloop 함수로 실행한다.\n```python\nfrom tkinter import *\nwin = Tk()\n\nwin.mainloop()\n```\n\n## 창의 기본적인 옵션으로 geometry(창크기), title(제목), option_add(세부 옵션 전체 폰트 설정을 설정한다.\n\n창을 생성하는 win = Tk()와 실행하는 win.mainloop() 사이에 창의 기본옵션(창크기, 제목, 세부옵션(전체폰트)를 설정한다.\n\n```python\nfrom tkinter import *\nwin = Tk()\nwin.geometry(\"300x100\")\nwin.title(\"What time\")\nwin.option_add(\"*Font\", \"궁서 20\")\n\n\nwin.mainloop()\n```\n\n## 버튼 생성하고 배치하기\n\n버튼을 생성하는 코드 Button()함수에 만든 창(win)을 매개변수로 넣고 btn 변수에 저장한 뒤 버튼을 배치하는 함수 pack()을 btn뒤에 붙여준다.\n\n```python\nfrom tkinter import *\nwin = Tk()\nwin.geometry(\"600x100\")\nwin.title(\"What time\")\nwin.option_add(\"*Font\", \"궁서 20\")\n\nbtn = Button(win)\n\nbtn.pack()\n\nwin.mainloop()\n```\n\n버튼생성과 배치함수 사이에 버튼의 기본옵션으로 버튼안의 텍스트(text)와 가로너비(width)를 설정한다.\n\n```python\nfrom tkinter import *\n\nwin = Tk()\nwin.geometry(\"600x100\")\nwin.title(\"What time\")\nwin.option_add(\"*Font\", \"궁서 20\")\n\nbtn = Button(win)\nbtn.config(text=\"현재 시각\")\nbtn.config(width=30)\nbtn.pack()\n```\n\nwin.mainloop()\n```\n\n시간 관련 함수들을 사용하기 위해서 파이썬에서 제공하는 datetime 라이브러리를 import 해준다.\n```python\nfrom datetime import datetime\n```\n\ncommand what_time 함수를 받고 버튼을 눌렀을 때 버튼안의 텍스트를 현재 시간으로 바꿔주는 what_time 함수를 생성한다.\n```python\ndef what_time():\n    dnow = datetime.now()\n    btn.config(text=dnow)\n\nbtn.config(command=what_time)\n```\n## 최종코드와 현재 시간을 알려주는 버튼 프로그램\n\n최종코드는 다음과 같다.\n```python\nfrom tkinter import *\nfrom datetime import datetime\n\nwin = Tk()\nwin.geometry(\"600x100\")\nwin.title(\"What time\")\nwin.option_add(\"*Font\", \"궁서 20\")\n\n\ndef what_time():\n    dnow = datetime.now()\n    btn.config(text=dnow)\n\n\nbtn = Button(win)\nbtn.config(text=\"현재 시각\")\nbtn.config(width=30)\nbtn.config(command=what_time)\nbtn.pack()\n\nwin.mainloop()\n```\n\n다음은 생성된 프로그램의 모습이다.\n\n버튼을 누르기 전\n![현재시각](https://user-images.githubusercontent.com/58906858/151652420-cbe17627-9fe7-4291-a4bc-f239fc4519a8.png)\n\n버튼을 누른 뒤\n![현재시각1](https://user-images.githubusercontent.com/58906858/151652437-ee674c3d-5ca6-4426-80f5-0439dd2e7e12.png)\n\n현재시각이 잘 나오는 것을 알 수 있다.\n\n\n\n\n    \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-won%2Ftk_time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-won%2Ftk_time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-won%2Ftk_time/lists"}