I have just started out with tkinter and python3 in general. I'm using pygubu to try and make a very simple that takes input from an Entry widget and displays it in a Messagebox on the press of a button. Below is the code i'm using:
# command_properties.py
import tkinter as tk
from tkinter import messagebox
import pygubu
# define the function callbacks
def on_button1_click():
tk_messageBox -message answer -type ok -icon info
class MyApplication(pygubu.TkApplication):
def _create_ui(self):
#1: Create a builder
self.builder = builder = pygubu.Builder()
#2: Load an ui file
builder.add_from_file('test.ui')
#3: Create the widget using self.master as parent
self.mainwindow = builder.get_object('Frame_1', self.master)
# Configure callbacks
callbacks = {
'on_button1_clicked': on_button1_click
}
builder.connect_callbacks(callbacks)
if __name__ == '__main__':
root = tk.Tk()
app = MyApplication(root)
app.run()
Here is the ui file code : http://pastebin.com/puRbD87m Also, please tell me where i'm wrong specifically.
Create
on_button1_click()
as method inside class and then you can createand access text using
Full example