I am just starting to play with wxRuby, using the samples which come with it. However, I can't seem to add a menu item. I have tried a bunch of things, but here is what I want to do:
class MinimalFrame < Frame
def initialize(title)
...
menu_file.append(Something, "&Something\tAlt-W", "Do something")
menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
menu_bar.append(menu_file, "&File")
...
evt_menu Wx::ID_EXIT, :on_quit
evt_menu Something, :on_quit
Looking through the other samples, I don't see anything I am missing, but it refuses to work. It works when I replace Something
with Wx::ID_ANY
. I tried it with class MinimalFrame < Wx::Frame
also. I have googled bu开发者_StackOverflow社区t I haven't found my answer yet, so I thought I'd come here.
Also, I feel silly for asking, but what does the <
mean in the class def? I haven't come across it in any of the other stuff I have been working on yet.
Thanks!
Also, I feel silly for asking, but what does the < mean in the class def? I haven't come across it in any of the other stuff I have been working on yet.
This signifies inheritance. MinimalFrame is a child class of Frame.
I needed to put this earlier in the script:
Something = 1
The ID's need to be numbers, and by setting it as a constant, then I was able to use names instead of numbers.
精彩评论