python 대화 형 그래 픽 프로 그래 밍 인 스 턴 스(1)
#!/usr/bin/env python3# -*- coding: utf-8 -*-
#    
from graphics import *
 
win = GraphWin("       ", 400, 300)
win.setCoords(0.0, 0.0, 3.0, 4.0)
#     
Text(Point(1,3), "     :").draw(win)
Text(Point(1,1), "     :").draw(win)
input = Entry(Point(2,3), 5)
input.setText("0.0")
input.draw(win)
output = Text(Point(2,1),"")
output.draw(win)
button = Text(Point(1.5,2.0),"  ")
button.draw(win)
Rectangle(Point(1,1.5), Point(2,2.5)).draw(win)
#       
win.getMouse()
#     
celsius = eval(input.getText())
fahrenheit = 9.0/5.0 * celsius + 32.0
#     ,    
output.setText(fahrenheit)
button.setText("  ")
#         ,    
win.getMouse()
win.close()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#    
from tkinter import *
 
def main():  
  tk = Tk()
  canvas = Canvas(tk, width = 400, height = 400)
  canvas.pack()
 
  def moverectangle(event):
    if event.keysym == "Up":
      canvas.move(1,0,-5)
    elif event.keysym == "Down":
      canvas.move(1,0,5)
    elif event.keysym == "Left":
      canvas.move(1,-5,0)
    elif event.keysym == "Right":
      canvas.move(1,5,0)
     
  canvas.create_rectangle(180,180,220,220,fill="red")
  canvas.bind_all("<KeyPress-Up>",moverectangle)
  canvas.bind_all("<KeyPress-Down>",moverectangle)
  canvas.bind_all("<KeyPress-Left>",moverectangle)
  canvas.bind_all("<KeyPress-Right>",moverectangle)
  tk.mainloop()
 
if __name__ == '__main__':
  main()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from graphics import *
 
def convert(input):
  celsius = eval(input.getText())  #     
  fahrenheit = 9.0/5.0 * celsius + 32
  return fahrenheit 
def colorChange(win,input):
  cnum = eval(input.getText())
  weight = cnum / 100.0
  newcolor = color_rgb(int(255*weight),int(66+150*(1-weight)),int(255*(1-weight)))
  win.setBackground(newcolor)
def main():
  win = GraphWin("      ", 400, 300)
  win.setCoords(0.0, 0.0, 3.0, 4.0)
  #       
  Text(Point(1,3),
     "     :").draw(win)
  Text(Point(2,2.7),
     " (   : 0.0-100.0 )").draw(win)
  Text(Point(1,1),
     "    :").draw(win)
  input = Entry(Point(2,3), 5)
  input.setText("0.0")
  input.draw(win)
  output = Text(Point(2,1),"")
  output.draw(win)
  button = Text(Point(1.5,2.0),"  ")
  button.draw(win)
  rect = Rectangle(Point(1,1.5), Point(2,2.5))
  rect.draw(win)
  #       
  win.getMouse()
  result = convert(input)  #     
  output.setText(result)  #      
  #     
  colorChange(win,input)
  #       
  button.setText("  ")
  #       ,    
  win.getMouse()
  win.close()
 
if __name__ == '__main__':
  main()
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.