9 Feb 00:03
How to dispose of a GUI
Dear all,
A main GUI (GUI #1) is displayed with a single button. When the user
pushes the button,
another GUI (GUI #2) appears with a Save button on it. When the user
presses the Save button,
a dialog box appears and prompt the user to select a file to be save.
When the user presses Save on
the dialog box, the dialog box disappears of the screen as it should. Is
there a way that GUI #2 disappears as well?
I include below an example. I would appreciate if someone can help me to
complete this piece of code.
from enthought.traits.api import HasTraits, Button
from enthought.pyface.api import FileDialog, OK
from enthought.traits.ui.api import View, Item, Handler
from enthought.traits.ui.menu import Action
class UI_Handler(Handler):
def save(self, info):
info.object.save()
class MainClass(HasTraits):
myButton = Button(label = 'My Button',
height_padding = 30,
orientation = 'horizontal')
traits_view = View(Item('myButton', show_label=False, style='custom'))
def __init__(self, **traits):
super(MainClass, self).__init__(**traits)
def _myButton_fired(self):
SubClass()
class SubClass(HasTraits):
saveButton = Action(name='Save',action='save')
traits_view = View(
handler = UI_Handler(),
buttons=[saveButton],
resizable = True,
kind = 'modal')
def __init__(self, **traits):
super(SubClass, self).__init__(**traits)
self.configure_traits()
def save(self):
dialog = FileDialog(title='Save File',
action='save as')
if dialog.open() == OK:
print 'Hello World'
if __name__ == "__main__":
main_object = MainClass()
main_object.configure_traits()
RSS Feed