1. 程式人生 > >Python GUI程式設計 文字彈窗

Python GUI程式設計 文字彈窗

        out = subprocess.getstatusoutput('adb shell pm list packages')

        top = tk.Toplevel()
        top.title('包名列表')

        top.geometry('%dx%d' % (400, 1200))  # 設定視窗大小

        t = Text(top, width=400, height=900)
        t.insert('1.0', "{}".format(out[1]))
        # 插入文字,用引號引起來“1.0” 這個是插入文字的座標,且1與0之間為點,而不是逗號,切記


        # wraplength: 指定多少單位後開始換行
        # justify:  指定多行的對齊方式
        # 例子: Label(top, text='檢視當前手機上所有包名: ',wraplength = 80,justify = 'left').grid(row=1,stick=W, pady=10)
        t.pack()
        top.mainloop()