Python으로 GUI 응용 프로그램을 만드는 방법
7023 단어 programmingpython
GUI 응용 프로그램은 일상 생활의 필수적인 부분입니다. 그러나 대부분의 사람들은 프로그래밍을 배울 때 Python으로 작동하는 터미널 프로그램을 만드는 데 몇 시간을 보냅니다.
Python으로 GUI 응용 프로그램을 만드는 방법은 무엇입니까? 🐍
라이브러리로 GUI를 만들 수 있습니다. 사용할 수 있는 여러 라이브러리가 있습니다.
PyQt 🚀
PyQt는 교차 플랫폼 GUI 프레임워크인 Qt용으로 가장 많이 사용되는 Python 바인딩입니다. 그것은 많은 위젯과 함께 제공되며 현대적인 모양과 느낌을 가지고 있습니다. 그것으로 만든 것은 KDE 데스크톱 및 관련 응용 프로그램입니다.
PyQt는 Windows, Mac OS X 및 Linux를 포함한 모든 운영 체제에서 작동합니다. 또한 drag and drop designer 프로그램과 함께 제공됩니다.
PyQt를 처음 사용하는 경우 this course을 권장합니다.

PyQt의 Hello World는 다음과 같습니다.
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
출처: hello world
tkinter 😄
Tkinter를 GUI 라이브러리로 사용할 수 있습니다. Python에서 가장 일반적으로 사용되는 GUI 라이브러리입니다. 환경에 Tkinter가 없는 경우 Python의 Tkinter 패키지를 추가하거나 배포판 저장소에서 설치하여 설치할 수 있습니다.
tkinter의 한계는 사용할 수 있는 위젯이 많지 않고 꽤 구식 모양과 느낌을 가지고 있다는 것입니다.
tkinter의 Hello world는 다음과 같습니다. tkinter에 대해 자세히 알아보려면 this article을 참조하세요.
import tkinter as tk
top = tk.Tk()
top.title("Hello World")
labelHello = tk.Label(top, text = "Hello World! ")
labelHello.pack()
top.mainloop()
Tkinter는 전통적인 모양(90년대)과 느낌을 가지고 있습니다.

pysimplegui
또 다른 옵션은 PySimpleGUI입니다. 이를 통해 레이아웃을 사용하여 매우 기본적인 사용자 인터페이스를 만들 수 있습니다. 그 아래에는 PyQt, tkinter 및 remi를 사용하므로 먼저 배우는 것이 좋습니다.
import PySimpleGUI as sg # Part 1 - The import
# Define the window's contents
layout = [ [sg.Text("What's your name?")], # Part 2 - The Layout
[sg.Input()],
[sg.Button('Ok')] ]
# Create the window
window = sg.Window('Window Title', layout) # Part 3 - Window Defintion
# Display and interact with the Window
event, values = window.read() # Part 4 - Event loop or Window.read call
# Do something with the information gathered
print('Hello', values[0], "! Thanks for trying PySimpleGUI")
# Finish up by removing from the screen
window.close()
Reference
이 문제에 관하여(Python으로 GUI 응용 프로그램을 만드는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/jones268/how-to-create-gui-applications-with-python-3795텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)