More using the FXRuby

Dark_Omen 0 Tallied Votes 141 Views Share

Okay, this introduces two new things into the widget. The first thing you need is a picture file (.jpg, .png, .bmp etc...). The new code makes the picture into the button with the text "Hello, World" on the side. In the parentheses next to File.open you would put the file name with its appropriate extension. On the next line you would say FX"filetype"Icon. This code snippet also includes another part called tipText. When you go ontot the button with the mouse it will say "exit". I saved the file I was using with the .rb file (I don't know if it has any effect on the program, you can try and post it in the coments if it does have any effect).

require 'fox'
include Fox

theApp = FXApp.new

theMainWindow = FXMainWindow.new(theApp, "Hello, World")

theButton = FXButton.new(theMainWindow, "Hello, World")
theButton.tipText = "Exit!"
iconFile = File.open("hwrb.png", "rb")
theButton.icon = FXPNGIcon.new(theApp, iconFile.read)
iconFile.close
theButton.connect(SEL_COMMAND) {exit}

FXTooltip.new(theApp)
theApp.create
theMainWindow.show
theApp.run
bumsfeld 413 Nearly a Posting Virtuoso

Right from the example code! Come on, you can do better!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.