CHAPTER 4 n CREATING REPORTS ON THE DESKTOP 68
def update_display
game_id_to_analyze = @game_combobox.getItemData(@game_combobox.currentItem)
player = Player.find(@player_combobox.getItemData(@player_combobox.currentItem))
bar_chart = Gruff::Bar.new("#{@graph_picture_viewer.width}x" <<
"#{@graph_picture_viewer.height}")
. . .
bar_chart.write(chart_png_filename)
pic = FXPNGImage.new(FXApp.instance())
FXFileStream.open(chart_png_filename,
FXStreamLoad) { |stream| pic.loadPixels(stream) }
pic.create
@graph_picture_viewer.image = pic
File.unlink(chart_png_filename)
@graph_picture_viewer.image = pic
end
The first two lines of this method call the getItemData method of the two combo
boxes. ItemData is where you can store an integer for each item in the list. Here, ItemData
holds the game IDs and the player IDs. By calling the getItemData method with the currently
selected item as the parameter, you can get the appropriate player and game IDs.
After that, you create a chart, just as in Listing 3-4. The chart is written to a file, and
then loaded and displayed; however, unlike in the Chapter 3 example, you immediately
unlink??”or delete??”the file after displaying it.
Pages:
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116