我是Python的新手,所以我沒有任何嘗試或測驗的代碼。有沒有人知道如何打開一個可以用Python運行的空白視窗?我知道這可能已經被問過了,但是我找不到。謝謝你。
uj5u.com熱心網友回復:
使用tkinter你可以這樣做來打開一個空白視窗:
from tkinter import *
root = Tk()
root.title("Hello this is title")
root.geometry("500x300")
root.mainloop()
uj5u.com熱心網友回復:
試試這個,應該可以正常作業:
import tkinter as tk
class Application(tk.Frame)。
def __init__(self, master=None)。
super().__init__(master)
self.master = master
self.pack()
self.create_widgets()
def create_widgets(self)。
self.hi_there = tk.Button(self)
self.hi_there["text"] = "Hello World
(點擊我)"
self.hi_there["命令"] = self.say_hi
self.hi_there.pack(side="top")
self.quit = tk.Button(self, text="QUIT", fg="red", command=self.master.destroy)
self.quit.pack(side="bottom")
def say_hi(self)。
print("Hi there, everyone!")
root = tk.Tk()
app = Application(master=root)
app.mainloop()
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/319449.html
標籤:
