我在pygubu中使用tkinter。我想我得到Entry_1小部件的價值。 Entry_1小部件值爲藍色。和Entry_1的textvariable是'text_1' 我讀pygubu文件。但我不明白。請問誰能知道我容易。如何在pygubu中獲取tkinter入口小部件的值?
和我鏈接ask.ui文件中使用pygubu http://www.joinsland114.mireene.com/data/ask.ui
try:
import tkinter as tk # for python 3
except:
import Tkinter as tk # for python 2
import pygubu
from tkinter import *
class Application:
def __init__(self, master):
#1: Create a builder
self.builder = builder = pygubu.Builder()
#2: Load an ui file
builder.add_from_file('ask.ui')
#3: Create the widget using a master as parent
self.mainwindow = builder.get_object('Frame_1', master)
builder.connect_callbacks(self)
root = tk.Tk()
app = Application(root)
print(app.mainwindow.getvar('text_1'))
root.mainloop()
Traceback (most recent call last): File "C:\Python34\pygubu.py", line 25, in print(app.mainwindow.getvar('text_1')) File "C:\Python34\lib\tkinter__init__.py", line 454, in getvar return self.tk.getvar(name) _tkinter.TclError: can't read "text_1": no such variable