Ejemplo n.º 1
0
        self.title = "JythonFX"

        label = "Click Me!"
        button = control.Button(label) #crate button
        button.setOnAction(EH(self.OnButtonClicked)) #set button event on click

        self.pane = layout.StackPane() #create layout of scene
        self.pane.getChildren().add(button)#add button to scene

        self.width = 300
        self.height = 250

        stage.setTitle(self.title) #set caption for App's window

        stage.setScene(Scene(self.pane, self.width, self.height))
        #set self.pane as App's layout with self.width as App's width and self.height as App's height

        stage.show()#show App

    def OnButtonClicked(self, event):
        #handle event for clicked button
        #arg event - needed to get event data

        message = unicode("Hello World w JythonFX")#unicode to fix non English chars
        print message #display massage in console

if __name__ == "__main__": #run app
    Application.launch(HiJavaFX)

Ejemplo n.º 2
0
        self.firstText = self.Text.getText()
        self.TextScaleX = self.Text.getScaleX()
        self.TextScaleY = self.Text.getScaleY()

    def OnClick(self, event):
        if not self.clicked:
            self.Text.setScaleX(self.TextScaleX/2)
            self.Text.setScaleY(self.TextScaleY/2)
            self.Text.setText("Hello FXML!")
            self.clicked = True
        else:
            self.Text.setScaleX(self.TextScaleX)
            self.Text.setScaleY(self.TextScaleY)
            self.Text.setText(self.firstText)
            self.clicked = False


class Sample(Application):
    def __init__(self):
        self.title = "FXML Sample"

    def start(self, stage):
        stage.setTitle(self.title)

        stage.setScene(Scene(Layout()))

        stage.show()

if __name__ == "__main__":
    Application.launch(Sample)