class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self, None) self._setupUi() self.model = MainWindowModel() self.nameTextBox = LineEdit(view=self.nameTextBoxView) self.helloLabel = TextHolder(view=self.helloLabelView) self.model.set_children(self.nameTextBox.model, self.helloLabel.model) self.randomNameButton.clicked.connect(self.model.select_random_name) self.sayHelloButton.clicked.connect(self.model.say_hello) def _setupUi(self): self.setWindowTitle(QCoreApplication.instance().applicationName()) self.centralwidget = QWidget(self) self.verticalLayout = QVBoxLayout(self.centralwidget) self.nameTextBoxView = QLineEdit(self.centralwidget) self.verticalLayout.addWidget(self.nameTextBoxView) self.helloLabelView = QLabel(self.centralwidget) self.verticalLayout.addWidget(self.helloLabelView) self.buttonLayout = QHBoxLayout() self.randomNameButton = QPushButton("Random Name", self.centralwidget) self.buttonLayout.addWidget(self.randomNameButton) self.sayHelloButton = QPushButton("Say Hello", self.centralwidget) self.buttonLayout.addWidget(self.sayHelloButton) self.verticalLayout.addLayout(self.buttonLayout) self.setCentralWidget(self.centralwidget)
class MainWindow(Frame): def createWidgets(self): self.nameLabel = Label(self, text="What's your name:") self.nameLabel.pack(side='top') self.nameInput = EntryTextHolder(self) self.nameInput.pack(side='top', fill='x', expand=True) self.helloLabel = LabelTextHolder(self) self.helloLabel.pack(side='top') self.sayHelloButton = Button(self, text="Say Hello") self.sayHelloButton.pack(side='right') self.sayHelloButton['command'] = self.model.say_hello self.randomNameButton = Button(self, text="Random Name") self.randomNameButton.pack(side='right') self.randomNameButton['command'] = self.model.select_random_name def __init__(self, master=None): Frame.__init__(self, master) self.model = MainWindowModel() self.pack() self.createWidgets() self.model.set_children(self.nameInput.model, self.helloLabel.model)
class MainWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="guiskel") self._setupUi() self.model = MainWindowModel() self.nameEntry = LineEdit(view=self.nameEntryView) self.helloLabel = TextHolder(view=self.helloLabelView) self.model.set_children(self.nameEntry.model, self.helloLabel.model) self.randomNameButton.connect('clicked', self.randomNameButtonClicked) self.sayHelloButton.connect('clicked', self.sayHelloButtonClicked) self.connect('delete-event', Gtk.main_quit) def _setupUi(self): self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.box) self.nameEntryView = Gtk.Entry() self.box.pack_start(self.nameEntryView, False, False, 0) self.helloLabelView = Gtk.Label() self.box.pack_start(self.helloLabelView, False, False, 0) self.buttonBox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.randomNameButton = Gtk.Button(label="Random Name") self.sayHelloButton = Gtk.Button(label="Say Hello") self.buttonBox.pack_end(self.sayHelloButton, False, False, 0) self.buttonBox.pack_end(self.randomNameButton, False, False, 0) self.box.pack_start(self.buttonBox, False, False, 0) def randomNameButtonClicked(self, widget): self.model.select_random_name() def sayHelloButtonClicked(self, widget): self.model.say_hello()
class DMainWindow(dbus.service.Object): IFACE_NAME = PROGID + '.MainWindow' def __init__(self, object_path): session_bus = dbus.SessionBus() name = dbus.service.BusName(PROGID, session_bus) dbus.service.Object.__init__(self, name, object_path) self.object_path = object_path self.model = MainWindow() self.namebox = DTextHolder(self.NameboxPath()) self.hellolabel = DTextHolder(self.HellolabelPath()) self.model.set_children(self.namebox.model, self.hellolabel.model) @dbus.service.method(IFACE_NAME, out_signature='s') def NameboxPath(self): return self.object_path + '/namebox' @dbus.service.method(IFACE_NAME, out_signature='s') def HellolabelPath(self): return self.object_path + '/hellolabel' @dbus.service.method(IFACE_NAME) def SayHello(self): self.model.say_hello() @dbus.service.method(IFACE_NAME) def SelectRandomName(self): self.model.select_random_name()
class PyMainWindow: def __init__(self): self.model = MainWindow() def setNameHolder_andMsgHolder_(self, nameHolder: pyref, msgHolder: pyref): self.model.set_children(nameHolder.model, msgHolder.model) def selectRandomName(self): self.model.select_random_name() def sayHello(self): self.model.say_hello()
class PyMainWindow(NSObject): def init(self): self = super(PyMainWindow, self).init() self.model = MainWindow() return self def setNameHolder_andMsgHolder_(self, nameHolder, msgHolder): self.model.set_children(nameHolder.model, msgHolder.model) def selectRandomName(self): self.model.select_random_name() def sayHello(self): self.model.say_hello()