Re: [anjuta-list] How to define the entry?
- From: Sébastien Granjoux <seb sfo free fr>
- To: 前尘逐梦 <736036594 qq com>
- Cc: anjuta-list <anjuta-list gnome org>
- Subject: Re: [anjuta-list] How to define the entry?
- Date: Fri, 24 May 2013 19:48:02 +0200
Hi,
Le 24/05/2013 16:32, 前尘逐梦 a écrit :
class GUI:
def __init__(self):
self.builder = Gtk.Builder()
self.builder.add_from_file(UI_FILE)
self.builder.connect_signals(self)
window = self.builder.get_object('window')
window.show_all()
def on_button_clicked (self, button):
text =entry.get_text()
ser.write(text)
-------------------------------------------------------------------------------------------
But when I execute it, it returns this error:
NameError: global name 'entry' is not defined.
Could your tell me how to define a entry and Where I should put the
statement on?
The Gtk.Builder object will create all the widgets for you but it's up
to you to get a reference to them. You have already done it for the
window here:
window = self.builder.get_object('window')
You have to do something similar for the entry in the __init__ function.
self.entry = self.builder.get_object('entry')
'entry' is the name of your Gtk.Entry widget in your glade file, it can
be something else.
Then in your on_button_clicked handler you can use
text = self.entry.get_text()
Regards,
Sébastien
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]