[Python] Tkinter를 활용하여 Entry 값 계산하여 Label에 출력

이미지
  from tkinter import * from tkinter import ttk # Tkinter 인스턴스 생성 win = Tk() # Window 사이즈 지정 win.geometry( "300x200+100+100" ) win.resizable( False , False ) # get() : entry 에 텍스트를 문자열로 반환 def Cal (): label.configure( text = " 결과 값 = " + str ( eval (entry.get()))) entry = Entry(win) entry.pack() button = Button(win, text = " 계산 " , command =Cal) button.pack() label = Label(win) label.pack() win.mainloop() * 문자열을 그대로 출력하기. # get() : entry 에 텍스트를 문자열로 반환 def Cal (): label.configure( text = str (entry.get()))

[Python] Tkinter를 활용하여 Text 강조(Highlight)하기

이미지
from tkinter import * from tkinter import ttk # Tkinter 인스턴스 생성 win = Tk() # Window 사이즈 지정 win.geometry( "700x350" ) # 폰드 변경 함수 정의 def font_change (): text.tag_add( "start" , "1.0" , "1.7" ) text.tag_configure( "start" , background = "red" , foreground = "white" ) text=Text(win, width = 80 , height = 15 , font =( 'Calibri 12' )) text.insert(INSERT, "Tkinter Text background color change. \n " ) text.insert(END, "Learning Tkinter" ) text.pack() # 버튼 생성 ttk.Button(win, text = "Text Highlight" , command =font_change).pack( pady = 20 ) win.mainloop()

[Python] Tkinter를 활용한 Text Font 변경 Event

이미지
  from tkinter import * from tkinter import ttk # Tkinter 인스턴스 생성 win = Tk() # Window 사이즈 지정 win.geometry( "700x350" ) # 폰드 변경 함수 정의 def font_change (): label.config( bg = "red" , fg = "white" ) # 라벨 생성 label= Label(win, text = "Hello World" , font = ( 'italic' )) label.pack( pady = 30 ) # 버튼 생성 ttk.Button(win, text = "Font Change" , command =font_change).pack( pady = 20 ) win.mainloop()

[Python] Text Change Event

이미지
  from tkinter import * # Tkinter 인스턴스 생성 win = Tk() # Window 사이즈 지정 win.geometry( "700x350" ) # Text 변경 Function 정의 def on_click (): label[ "text" ] = "Python" b[ "state" ] = "disabled" # Label 생성 label = Label(win, text = "Text" , font =( 'Calibri 15 bold' )) label.pack( pady = 20 ) # 버튼 생성 b = Button(win, text = "Update Text" , command =on_click) b.pack( pady = 20 ) win.mainloop()

[Python] Tkinter를 활용한 Text Console 출력

이미지
  import tkinter as tk import tkinter.font as tkFont root = tk.Tk() root.geometry( "500x440" ) " 창 사이즈 지정 " def getTextInput (): result=textExample.get( "1.0" , "end" ) print (result) textExample=tk.Text(root, height = 10 ) textExample.pack() fontExample = tkFont.Font( family = "Arial" , size = 16 , weight = "bold" , slant = "italic" ) "Font 변경 " textExample.configure( font =fontExample) btnRead=tk.Button(root, height = 1 , width = 10 , text = "Read" , command =getTextInput) btnRead.pack() root.mainloop()

[Python] PyCharm(파이참) Theme(테마), Font(폰트) 변경

이미지
1.  Theme(테마) 변경 [Settings] - [Appearance & Behavior] - [Appearance] - Darcula - Windows 10 Light - IntelliJ Light - High contrast 2. Font(폰트) 변경 [Settings] - [Appearance & Behavior] - [Editor] - [Font]

[Python] tkinter를 이용하여 Hello World 만들기

이미지
import tkinter as tk root = tk.Tk() "Tkinter 를 초기화하기 위해 Tk Root 위젯을 만듬 ." "Root 위젯은 가장 먼저 만들어져야 하며 프로그램에 하나만 존재함 " root.title( 'Test' ) "Root 위젯의 타이틀 설정함 " w = tk.Label(root , text = "Hello World! \n Welcome" ) "Root 위젯의 자식으로 Label 위젯을 만듬 " w.pack() "pack() 을 호출하여 주어진 텍스트에 맞게 크기를 조절하고 , 텍스트를 업데이트함 " root.mainloop() " 윈도우를 닫을 때까지 이벤트 루프를 실행함 "