Dear Friends,
I am working in a python based application. I need an option to go
a page with Dialog >> combobox option. But I could not close the dialog box on the onchange event of combobox. My current function is: -
def mostrar_combobox(self, titulo, texto_etiqueta, lista):
-
"""
-
MÃ © All to show a combobox on screen and get the option chosen
-
"""
-
#print texto_etiqueta
-
#dialogo = gtk.Dialog(titulo, None, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
-
dialogo = gtk.Dialog(titulo, None, 0, None)
-
etiqueta = gtk.Label(texto_etiqueta)
-
etiqueta.show()
-
dialogo.vbox.pack_start(etiqueta)
-
combobox = gtk.combo_box_new_text()
-
for x in lista:
-
combobox.append_text(x)
-
combobox.connect('changed', self.changed_cb)
-
#combobox.set_active(0)
-
combobox.show()
-
dialogo.vbox.pack_start(combobox, False)
-
dialogo.run()
-
elemento_activo = combobox.get_active()
-
dialogo.destroy()
-
-
return elemento_activo
-
-
Please advise
Thanks
Anes
4 1572
dialogo.destroy() should be in the callback function self.changed_cb (which we don't have so can't comment further).
dear dwlabs,
When I give that option in 'changed_cb' as below: -
def mostrar_combobox(self, titulo, texto_etiqueta, lista):
-
"""
-
MÃ © All to show a combobox on screen and get the option chosen
-
"""
-
#print texto_etiqueta
-
#dialogo = gtk.Dialog(titulo, None, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
-
dialogo = gtk.Dialog(titulo, None, 0, None)
-
etiqueta = gtk.Label(texto_etiqueta)
-
etiqueta.show()
-
dialogo.vbox.pack_start(etiqueta)
-
combobox = gtk.combo_box_new_text()
-
for x in lista:
-
combobox.append_text(x)
-
combobox.connect('changed', self.changed_cb)
-
#combobox.set_active(0)
-
combobox.show()
-
dialogo.vbox.pack_start(combobox, False)
-
dialogo.run()
-
#print response
-
#combobox.connect('changed', self.changed_cb)
-
elemento_activo = combobox.get_active()
-
-
#dialogo.destroy()
-
dialogo.hide()
-
return elemento_activo
-
-
def changed_cb(self, combobox):
-
model = combobox.get_model()
-
index = combobox.get_active()
-
#self.dialogo.destroy()
-
if index:
-
self.dialogo.destroy()
-
print index
-
return index
-
-
got error as
self.dialogo.destroy()
AttributeError: Controlador instance has no attribute 'dialogo'
So need an intelligent solution , waiting for it. In my opinion if I remove that 'changed_cb' def no problem in current working of program . That function is really useless ...
Thanks
Anes
Dear dwlabs and friends,
I try your code , but still have no solution :(
my code is: -
def mostrar_combobox(self, titulo, texto_etiqueta, lista):
-
"""
-
MÃ © All to show a combobox on screen and get the option chosen
-
"""
-
#print texto_etiqueta
-
#dialogo = gtk.Dialog(titulo, None, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
-
dialogo = gtk.Dialog(titulo, None, gtk.DIALOG_MODAL, None)
-
dialogo.connect('response', lambda *x: self.destroy())
-
etiqueta = gtk.Label(texto_etiqueta)
-
etiqueta.show()
-
dialogo.vbox.pack_start(etiqueta)
-
combobox = gtk.combo_box_new_text()
-
for x in lista:
-
combobox.append_text(x)
-
combobox.connect('changed', self.changed_cb)
-
combobox.show()
-
dialogo.vbox.pack_start(combobox, False)
-
response = dialogo.run()
-
combobox.connect('changed', self.changed_cb)
-
dialogo.emit("delete-event", gtk.gdk.Event(gtk.gdk.DELETE))
-
elemento_activo = combobox.get_active()
-
return elemento_activo
-
-
-
def changed_cb(self, combobox):
-
#model = combobox.get_model()
-
index = combobox.get_active()
-
#self.dialogo.destroy()
-
#response = self.dialogo.run()
-
if index > -1:
-
print index
-
-
#return index
-
-
-
Do i have use GtkWindow for this purpose ? if so please provide a sample code..
Thanks
Anes
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael |
last post by:
Hello
Currently I'm migrating an applet from Java 1.1 to 1.3.
Targetplattform:
Microsoft Internet Explorer 5.x with Sun's Java VM 1.3.1
Problem:
The attached applet works fine with the...
|
by: Christopher J. Bottaro |
last post by:
I want to get the name of the function from within the function. Something
like:
def myFunc():
print __myname__
>>> myFunc()
'myFunc'
Really what I want to do is to easily strip off the...
|
by: Nils Petter Vaskinn |
last post by:
I'm using an enum that's declared within a function (since I only need it
within that function.)
I can't find anything about this in "The C++ Programming Language" by
Stroustroup and I don't...
|
by: Yasutaka Ito |
last post by:
Hi,
Is there a way to programmatically find out the caller of your function? For
example, let's say I have a function called MyFunction(), and I want to
debug print the caller of this function...
|
by: AMT2K5 |
last post by:
Hello. I have the following function titled cleanSpace that recieves a
string and cleans it up. My program passes a string to the function via
"cleanSpace(c)". The function works the first time...
|
by: mj |
last post by:
Hi,
I recently have found it necessary to move from fortran to c++ for
scientific programming... I'm working on a program that needs to resize
a 2d vector of vectors within a function... This...
|
by: cupa |
last post by:
Hi,
is it posible to execute script from file within function (sql or pl/sql or ...)
|
by: SanPy |
last post by:
The subject of this message might be a little cryptic, so here's an
example of what I mean:
def foo():
"""doc string of foo"""
print foo.__doc__
doc string of foo
What I want to know is...
|
by: kaushalparik |
last post by:
hi all,
i am working with Desktop application, and trying to create a setup project.
i finalized my application and now creating the setup for that application.
what i need to do is, with in...
|
by: =?Utf-8?B?amZz?= |
last post by:
In the last few weeks my arrow keys have quit working in Excel 2003 only. I
have changed batteries in both my mouse and keyboard with no results. Has
anyone else experienced this problem? The...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |