User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Ruby section within the Web Development category of DaniWeb, a massive community of 332,788 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,972 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Ruby advertiser: SELL YOUR PRODUCT TODAY !
Jan 21st, 2005
Views: 2,013
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).
ruby Syntax | 4 stars
  1. require 'fox'
  2. include Fox
  3.  
  4. theApp = FXApp.new
  5.  
  6. theMainWindow = FXMainWindow.new(theApp, "Hello, World")
  7.  
  8. theButton = FXButton.new(theMainWindow, "Hello, World")
  9. theButton.tipText = "Exit!"
  10. iconFile = File.open("hwrb.png", "rb")
  11. theButton.icon = FXPNGIcon.new(theApp, iconFile.read)
  12. iconFile.close
  13. theButton.connect(SEL_COMMAND) {exit}
  14.  
  15. FXTooltip.new(theApp)
  16. theApp.create
  17. theMainWindow.show
  18. theApp.run
Comments (Newest First)
bumsfeld | Practically a Posting Shark | Aug 6th, 2005
Right from the example code! Come on, you can do better!
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 10:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC