class ApplicationConsole: def __init__(self): self._controller = ApplicationDownloader() self._controller.LoggerCreationCallbacks.append(self.loggerCreated) def main(self): self._controller.main() def loggerCreated(self, caller, logger): self._logger = LoggerConsole(logger)
class ApplicationCocoa: _controller = None _logger = None _configuration = None window = None def __init__(self): self._controller = ApplicationDownloader() self._controller.ConfigurationCreationCallbacks.append(self.configurationCreated) self._controller.LoggerCreationCallbacks.append(self.loggerCreated) def configurationCreated(self, caller, configuration): self._configuration = ConfigurationCocoa(configuration) def loggerCreated(self, caller, logger): warn("ApplicationCocoa.loggerCreated()") self._logger = LoggerCocoa(logger) def main(self): app = NSApplication.sharedApplication() self._controller.start() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) win = NSWindow.alloc() frame = ((200.0, 300.0), (250.0, 100.0)) win.initWithContentRect_styleMask_backing_defer_ (frame, 15, 2, 0) win.setTitle_ ('BinDownloader') win.setLevel_ (3) hel = NSButton.alloc().initWithFrame_ (((10.0, 10.0), (80.0, 80.0))) win.contentView().addSubview_ (hel) hel.setBezelStyle_( 4 ) hel.setTitle_( 'Hello!' ) hel.setTarget_( app.delegate() ) hel.setAction_( "sayHello:" ) win.display() win.orderFrontRegardless() AppHelper.runEventLoop()
def __init__(self): self._controller = ApplicationDownloader() self._controller.ConfigurationCreationCallbacks.append(self.configurationCreated) self._controller.LoggerCreationCallbacks.append(self.loggerCreated) #self._controller.ConfigurationCreation += self.configurationCreated #self._controller.LoggerCreation += self.loggerCreated self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) self.window.set_size_request(300, 200) self.window.set_border_width(2) self.button = gtk.Button("Hello World") self.button.connect("clicked", self.hello, None) self.button.connect_object("clicked", gtk.Widget.destroy, self.window) #self.window.add(self.button) #self.button.show() self.window.set_title("BinDownloader") self.window.show()
def __init__(self): self._controller = ApplicationDownloader() self._controller.LoggerCreationCallbacks.append(self.loggerCreated)
class ApplicationGTK: _controller = None _logger = None _configuration = None _threadtest = None def __init__(self): self._controller = ApplicationDownloader() self._controller.ConfigurationCreationCallbacks.append(self.configurationCreated) self._controller.LoggerCreationCallbacks.append(self.loggerCreated) #self._controller.ConfigurationCreation += self.configurationCreated #self._controller.LoggerCreation += self.loggerCreated self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) self.window.set_size_request(300, 200) self.window.set_border_width(2) self.button = gtk.Button("Hello World") self.button.connect("clicked", self.hello, None) self.button.connect_object("clicked", gtk.Widget.destroy, self.window) #self.window.add(self.button) #self.button.show() self.window.set_title("BinDownloader") self.window.show() def hello(self,widget, data=None): #print "hello clicked" pass def destroy(self, widget, data=None): self._controller.stop_process() #self._threadtest.stop_process() gtk.main_quit() def delete_event(self, widget, event, data=None): #print "delete event occurred" # Change FALSE to TRUE and the main window will not be destroyed # with a "delete_event". return False def configurationCreated(self, caller, configuration): self._configuration = ConfigurationGTK(configuration) def loggerCreated(self, caller, logger): #warn("ApplicationGTK.loggerCreated()") self._logger = LoggerGTK(logger) gobject.idle_add(self.window.add, self._logger._gui) def __str__(self): return "<ApplicationGTK instance>" def main(self): gobject.threads_init() self._controller.start() gtk.main()