import tkinter as tk
win = tk.Tk()
win.title("Python GUI")
label = tk.Label(win, text="Hello World!")
label.pack()
button = tk.Button(win, text="Click Me")
button.pack()
win.mainloop()
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
window.setWindowTitle("Python GUI")
layout = QtWidgets.QVBoxLayout()
label = QtWidgets.QLabel("Hello World!")
layout.addWidget(label)
button = QtWidgets.QPushButton("Click Me")
layout.addWidget(button)
window.setLayout(layout)
window.show()
sys.exit(app.exec_())
# Tkinter
import tkinter as tk
win = tk.Tk()
label = tk.Label(win, text="Hello World!")
label.pack()
win.mainloop()
# PyQt
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
label = QtWidgets.QLabel("Hello World!")
layout.addWidget(label)
window.setLayout(layout)
window.show()
sys.exit(app.exec_())
# Tkinter
import tkinter as tk
win = tk.Tk()
button = tk.Button(win, text="Click Me")
button.pack()
win.mainloop()
# PyQt
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
button = QtWidgets.QPushButton("Click Me")
layout.addWidget(button)
window.setLayout(layout)
window.show()
sys.exit(app.exec_())
import sys
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
window.setWindowTitle("Python GUI")
layout = QtWidgets.QHBoxLayout()
label1 = QtWidgets.QLabel("Label 1")
layout.addWidget(label1)
label2 = QtWidgets.QLabel("Label 2")
layout.addWidget(label2)
window.setLayout(layout)
window.show()
sys.exit(app.exec_())
import sys
from PyQt5 import QtWidgets, QtGui
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QWidget()
window.setWindowTitle("Python GUI")
icon = QtGui.QIcon("my_icon.png")
window.setWindowIcon(icon)
window.show()
sys.exit(app.exec_())
import sys
from PyQt5 import QtWidgets, QtGui
app = QtWidgets.QApplication(sys.argv)
result = QtWidgets.QMessageBox.question(None, "Question", "Do you like Python?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
if result == QtWidgets.QMessageBox.Yes:
print("You like Python!")
else:
print("You don't like Python!")
sys.exit(app.exec_())
标签: 智能还款