第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

當(dāng)我聲明大小限制時(shí),為什么我的 tkinter 頂層很大?

當(dāng)我聲明大小限制時(shí),為什么我的 tkinter 頂層很大?

Smart貓小萌 2024-01-04 10:07:00
我知道這可能是一個(gè)新問(wèn)題,但我還沒(méi)有找到答案。這是我的代碼片段,其中有一個(gè)根窗口,其中包含一個(gè)用于打開頂級(jí)的按鈕。頂層從文本文件中隨機(jī)抽取一行,作為一種想法生成器。import random, fileinputimport tkinter as tkfrom tkinter import *root = tk.Tk()root.title('Daydreamer')#fname should be the file name of the image in working directoryfname = "bg.gif"bg_image = tk.PhotoImage(file=fname)#get width and height of imagew = bg_image.width()h = bg_image.height()    #size window correctly    root.geometry("500x400")    cv = tk.Canvas(width=w, height=h)    cv.pack(side='top', fill='both', expand='yes')    cv.create_image(0,0,image=bg_image,anchor='nw')        #add a frame for text    mainframe=tk.Frame(root)        #new window for inspirations    def inspirations():        top = Toplevel(root)        top.geometry=("100x100")        top.title("Inspiration")        def idea():            textidea=None            for line in fileinput.input('textlist.txt'):                if random.randrange(fileinput.lineno())==0:                    textidea=line            entrytext=tk.Text(top)            entrytext.insert(INSERT, textidea)            entrytext.insert(END, "Or press the Inspire Me button again for another idea!")            entrytext.pack()        idea()                        top.mainloop()               #add buttons    btn1 = tk.Button(cv, text="Inspire Me", command=inspirations)    btn1.pack(side='left', padx=10, pady=5, anchor='sw')        root.mainloop()問(wèn)題是,頂級(jí)總是絕對(duì)巨大(比我的根窗口大),對(duì)于其中顯示的少量?jī)?nèi)容來(lái)說(shuō),這看起來(lái)非常愚蠢。我在這里錯(cuò)過(guò)了一些非常微小和愚蠢的事情嗎?非常感謝幫助。
查看完整描述

1 回答

?
慕森卡

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊

問(wèn)題是您沒(méi)有調(diào)用該geometry方法,而是用字符串替換它。

改變這個(gè):

top.geometry=("100x100")

對(duì)此:

top.geometry("100x100")


查看完整回答
反對(duì) 回復(fù) 2024-01-04
  • 1 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)